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 |
---|---|---|---|---|---|---|
PUT /top_menus/1 PUT /top_menus/1.xml | def update
@top_menu = TopMenu.find(params[:id])
respond_to do |format|
if @top_menu.update_attributes(params[:top_menu])
flash[:notice] = 'TopMenu was successfully updated.'
format.html { redirect_to(@top_menu) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @top_menu.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @menu_item = MenuItem.find(params[:id])\n\n respond_to do |format|\n if uhook_update_menu_item(@menu_item)\n flash[:notice] = t('ubiquo.menus.sitemap_updated')\n format.html { redirect_to(ubiquo_menu_items_path) }\n format.xml { head :ok }\n else\n flash[:error] = t('ubiquo.menus.sitemap_update_error')\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @menu = Menu.find(params[:id])\n\n respond_to do |format|\n if uhook_update_menu(@menu)\n flash[:notice] = t(\"ubiquo.menu.edited\")\n return if check_redirects(@menu)\n format.html { redirect_to(ubiquo.menus_url) }\n format.xml { head :ok }\n else\n flash[:error] = t(\"ubiquo.menu.edit_error\")\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @current_admin_user = current_admin_user\n @menu = Menu.find(params[:id])\n @title = @menu.name\n respond_to do |format|\n if @menu.update_attributes(params[:menu])\n format.html { redirect_to @menu, notice: 'Menu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def update\n @menu = Menu.find(params[:id])\n \n respond_to do |format|\n if @menu.update_attributes(params[:menu])\n format.html { redirect_to(@menu, :notice => 'Menu was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @menu = Menu.find(params[:id])\n\n respond_to do |format|\n if @menu.update_attributes(params[:menu])\n flash[:notice] = 'Menu was successfully updated.'\n format.html { redirect_to(@menu) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @menu = Menu.find(params[:id])\n\n respond_to do |format|\n if @menu.update_attributes(params[:menu])\n flash[:notice] = 'Menu was successfully updated.'\n format.html { redirect_to(@menu) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @menu = Menu.find(params[:id])\n\n respond_to do |format|\n if @menu.update_attributes(params[:menu])\n flash[:notice] = 'Menu was successfully updated.'\n format.html { redirect_to(@menu) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @menu = Menu.find(params[:id])\n\n respond_to do |format|\n if @menu.update_attributes(params[:menu])\n flash[:notice] = 'Menu was successfully updated.'\n format.html { redirect_to(@menu) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n if @api_v1_menu.update(api_v1_menu_params)\n render json: @api_v1_menu\n else\n render json: @api_v1_menu.errors\n end\n\n end",
"def update\n @menu = @menus.find(params[:id])\n\n respond_to do |format|\n if @menu.update_attributes(params[:menu])\n format.html { redirect_to @shop, notice: t(\"menus.update.notice_success\") }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n @store = Store.find(params[:store_id])\n @menu = @store.menus.find(params[:id])\n\n respond_to do |format|\n if @menu.update_attributes(params[:menu])\n format.html { redirect_to store_menus_url(@store), notice: 'Menu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_menu\n @api_v1_menu = Menu.find(params[:id])\n end",
"def update\n @table_menu = Table::Menu.find(params[:id])\n\n respond_to do |format|\n if @table_menu.update_attributes(params[:table_menu])\n format.html { redirect_to table_menus_path(:site_id => @table_menu.site_id) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @table_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @menu = Menu.find(params[:id])\n\n respond_to do |format|\n if @menu.update_attributes(params[:menu])\n format.html { redirect_to @menu, notice: 'Menu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_api_menu\n @api_menu = Menu.find(params[:id])\n end",
"def update\n @menu_item = MenuItem.find(params[:id])\n respond_to do |format|\n if uhook_update_menu_item(@menu_item)\n flash[:notice] = t('ubiquo.menu_item.updated')\n format.html { redirect_to(ubiquo.edit_menu_path(@menu_item.menu)) }\n format.xml { head :ok }\n else\n flash[:error] = t('ubiquo.menu_item.update_error')\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n menu = Menu.find params[:id]\n menu.update menu_params\n redirect_to new_menu_path\n end",
"def update\n @original_menu = OriginalMenu.find(params[:id])\n\n respond_to do |format|\n if @original_menu.update_attributes(params[:original_menu])\n format.html { redirect_to(@original_menu, :notice => 'Original menu was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @original_menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @top_menu = TopMenu.new(params[:top_menu])\n\n respond_to do |format|\n if @top_menu.save\n flash[:notice] = 'TopMenu was successfully created.'\n format.html { redirect_to(@top_menu) }\n format.xml { render :xml => @top_menu, :status => :created, :location => @top_menu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @top_menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @menu.update(menu_params)\n\t\t\t\tformat.html { redirect_to @menu, notice: 'Menuen blev opdateret.' }\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: @menu.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @menu_item = current_site.menu_items.find(params[:id])\n\n respond_to do |format|\n if @menu_item.update_attributes(params[:menu_item])\n format.html { redirect_to([:admin, @menu_item], :notice => t('menu_items.notices.updated', :default=>'Menu item was successfully updated.')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu.update(menu_params)\n format.html { redirect_to @menu.canteen, notice: 'Menu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @menutree = Menutree.find(params[:id])\n\n respond_to do |format|\n if @menutree.update_attributes(params[:menutree])\n flash[:notice] = 'Menutree was successfully updated.'\n format.html { redirect_to(@menutree) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menutree.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu.update(menu_params)\n format.html { redirect_to @menu, notice: \"Menu was successfully updated.\" }\n format.json { render :show, status: :ok, location: @menu }\n else\n format.html { render :edit }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu.update(menu_params)\n format.html { redirect_to @menu, notice: 'Menu was successfully updated.' }\n format.json { render :show, status: :ok, location: @menu }\n else\n format.html { render :edit }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu.update(menu_params)\n format.html { redirect_to @menu, notice: 'Menu was successfully updated.' }\n format.json { render :show, status: :ok, location: @menu }\n else\n format.html { render :edit }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu.update(menu_params)\n format.html { redirect_to @menu, notice: 'Menu was successfully updated.' }\n format.json { render :show, status: :ok, location: @menu }\n else\n format.html { render :edit }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu.update(menu_params)\n format.html { redirect_to @menu, notice: 'Menu was successfully updated.' }\n format.json { render :show, status: :ok, location: @menu }\n else\n format.html { render :edit }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu.update(menu_params)\n format.html { redirect_to cafeteria_url(@cafeteria), notice: 'El menú se ha actualizado.' }\n format.json { render :show, status: :ok, location: @menu }\n else\n format.html { render :edit }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if menu.update(menu_params)\n format.html { redirect_to [place, menu], notice: 'Menu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: menu.errors, status: ':unprocessable_entity' }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu.update(menu_params)\n format.html { redirect_to @menu, notice: 'Menu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_side_menu = Admin::SideMenu.find(params[:id])\n\n respond_to do |format|\n if @admin_side_menu.update_attributes(params[:admin_side_menu])\n format.html { redirect_to @admin_side_menu, notice: 'Side menu was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_side_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_menu.update(admin_menu_params)\n format.html { redirect_to admin_menus_path, notice: 'Запис успішно редаговано.' }\n format.json { render :show, status: :ok, location: @admin_menu }\n else\n format.html { render :edit }\n format.json { render json: @admin_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu.update(menu_params)\n format.html { redirect_to menus_url, notice: 'Menu was successfully updated.' }\n format.json { render :show, status: :ok, location: @menu }\n else\n format.html { render :edit }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @menu_item_default = MenuItemDefault.find(params[:id])\n\n respond_to do |format|\n if @menu_item_default.update_attributes(params[:menu_item_default])\n format.html { redirect_to(@menu_item_default, :notice => 'Menu item default was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu_item_default.errors, :status => :unprocessable_entity }\n format.json { render :json => @menu_item_default.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n @site = Site.find_by_name(params[:site])\n if @site.nil?\n return render_404\n end\n @menu = @site.menus.by_menu_type(params[:menu_type]).first\n if @menu.nil?\n return render_404\n end\n @menu_item = @menu.menu_items.by_id(params[:id]).first\n if @menu_item.nil?\n return render_404\n end\n \n if params[:parent_id]\n parent = @menu.menu_items.by_id(params[:parent_id]).first\n if parent.nil?\n return render_404\n end\n @menu_item.parent = parent\n end\n \n generate_selections!(@menu_item)\n respond_to do |format|\n format.html \n end\n end",
"def update\n material = @current_shop.materials.find(menu_params[:material_id]) rescue nil\n if material\n @menu.material = material\n @menu.keyword = nil\n elsif Menu.reply_message(@system_config).map{|key| key[1]}.include? menu_params[:material_id]\n @menu.keyword = menu_params[:material_id].gsub(Event::KEY_PREFIX, \"\")\n @menu.material = nil\n end\n respond_to do |format|\n if @menu.update(menu_params.except(:event_id))\n format.html { redirect_to backend_shop_system_config_menu_path(@current_shop.slug,@system_config, @menu), notice: t('Menu was successfully updated.') }\n format.json { head :no_content }\n else\n @parent_menus_array = get_other_top_menu\n format.html { render action: 'edit' }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @top_menu = TopMenu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @top_menu }\n end\n end",
"def update\n @menuitem = Menuitem.find(params[:id])\n\n respond_to do |format|\n if @menuitem.update_attributes(params[:menuitem])\n format.html { redirect_to @menuitem, notice: 'Menuitem was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @menuitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @main_menu.update(main_menu_params)\n format.html { redirect_to @main_menu, notice: \"Main menu was successfully updated.\" }\n format.json { render :show, status: :ok, location: @main_menu }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @main_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @menu_item = MenuItem.find(params[:id])\n\n respond_to do |format|\n if @menu_item.update_attributes(params[:menu_item])\n format.html { redirect_to @menu_item, notice: 'Menu item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @menu_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_menu\n set_system_config\n @menu = @system_config.menus.find(params[:id])\n end",
"def update\n @menu_item.update(menu_item_params)\n @menu_items = @menu.menu_items.all\n end",
"def update\n respond_to do |format|\n if @admin_menu.update(admin_menu_params)\n format.html { redirect_to admin_menus_url, notice: \"#{ t 'activerecord.successful.messages.menu_updated'}\" }\n format.json { render :show, status: :ok, location: @admin_menu }\n else\n format.html { render :edit }\n format.json { render json: @admin_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_menu_params\n params.fetch(:menu).permit(:items)\n end",
"def update\n all_routes = Rails.application.routes.routes\n respond_to do |format|\n if @menu_item.update(menu_item_params)\n format.html { redirect_to menu_path, notice: 'Menu item was successfully updated.' }\n format.json { render :show, status: :ok, location: @menu_item }\n else\n format.html { render :edit }\n format.json { render json: @menu_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @top_menu = TopMenu.find(params[:id])\n @top_menu.destroy\n\n respond_to do |format|\n format.html { redirect_to(top_menus_url) }\n format.xml { head :ok }\n end\n end",
"def update\n @forms_selfmenu = FormsSelfmenu.find(params[:id])\n\n respond_to do |format|\n if @forms_selfmenu.update_attributes(params[:forms_selfmenu])\n flash[:notice] = 'FormsSelfmenu was successfully updated.'\n format.html { redirect_to(@forms_selfmenu) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @forms_selfmenu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @normal_menu.update(normal_menu_params)\n @normal_menu.update(:updated_by=>session[:kitchen_user_id])\n format.html { redirect_to @normal_menu, notice: 'Normal menu was successfully updated.' }\n format.json { render :show, status: :ok, location: @normal_menu }\n else\n format.html { render :edit }\n format.json { render json: @normal_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @forms_menutree = FormsMenutree.find(params[:id])\n\n respond_to do |format|\n if @forms_menutree.update_attributes(params[:forms_menutree])\n flash[:notice] = 'FormsMenutree was successfully updated.'\n format.html { redirect_to(@forms_menutree) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @forms_menutree.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @house_menu = HouseMenu.find(params[:id])\n\n respond_to do |format|\n if @house_menu.update_attributes(params[:house_menu])\n flash[:notice] = 'HouseMenu was successfully updated.'\n format.html { redirect_to(@house_menu) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @house_menu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_header_menu\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n @yaml = ApplicationHelper.get_config_yaml\n\n @yaml[:general]['header_menus'] = [] if @yaml[:general]['header_menus'].nil?\n\n entry = [params[:header_menu]['name'], params[:header_menu]['target'], params[:header_menu]['url']]\n\n unless @yaml[:general]['header_menus'].nil?\n if params[:org_name].nil? or params[:org_name] != entry[0]\n @yaml[:general]['header_menus'].each do |header_menu|\n if header_menu[0] == entry[0]\n flash[:notice] = 'ERROR:' + t('msg.menu_duplicated')\n render(:partial => 'ajax_header_menu', :layout => false)\n return\n end\n end\n end\n end\n\n idx = nil\n unless params[:org_name].nil? or @yaml[:general]['header_menus'].nil?\n i = 0\n @yaml[:general]['header_menus'].each do |header_menu|\n if header_menu[0] == params[:org_name]\n idx = i\n break\n end\n i += 1\n end\n end\n\n if idx.nil?\n @yaml[:general]['header_menus'] << entry\n else\n @yaml[:general]['header_menus'][idx] = entry\n end\n\n ApplicationHelper.save_config_yaml(@yaml)\n\n render(:partial => 'ajax_header_menu', :layout => false)\n end",
"def update\n @menu_section = MenuSection.find(params[:id])\n\n respond_to do |format|\n if @menu_section.update_attributes(params[:menu_section])\n format.html { redirect_to(@menu_section, :notice => 'Menu section was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu_section.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @menu_page = MenuPage.find(params[:id])\n\n respond_to do |format|\n if @menu_page.update_attributes(params[:menu_page])\n format.html { redirect_to(@menu_page, :notice => 'Menu page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu_page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @menu = uhook_new_menu\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end",
"def update\n @menu_list = MenuList.find(params[:id])\n\n respond_to do |format|\n if @menu_list.update_attributes(params[:menu_list])\n format.html { redirect_to @menu_list, notice: 'Menu list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @menu_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def set_menu\n id = params[:id]\n @menu = Menu.find(id)\n end",
"def update\n respond_to do |format|\n if @menuindex.update(menuindex_params)\n format.html { redirect_to @menuindex, notice: 'Menuindex was successfully updated.' }\n format.json { render :show, status: :ok, location: @menuindex }\n else\n format.html { render :edit }\n format.json { render json: @menuindex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @top_menu = TopMenu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @top_menu }\n end\n end",
"def update\n @menu_item = MenuItem.find(params[:id])\n\n\t@menu_item.ingredients.destroy_all\n\tsave_ingrediants\n\n respond_to do |format|\n if @menu_item.update_attributes(params[:menu_item])\n flash[:notice] = 'MenuItem was successfully updated.'\n format.html { redirect_to(@menu_item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def index\n @top_menus = TopMenu.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @top_menus }\n end\n end",
"def update\n respond_to do |format|\n if @role_menu.update(role_menu_params)\n format.html { redirect_to @role_menu, notice: 'Role menu was successfully updated.' }\n format.json { render :show, status: :ok, location: @role_menu }\n else\n format.html { render :edit }\n format.json { render json: @role_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @security_role_menu.update(security_role_menu_params)\n format.html { redirect_to @security_role_menu, notice: 'Menú actualizado exitosamente para este rol.' }\n format.json { render :show, status: :ok, location: @security_role_menu }\n else\n format.html { render :edit }\n format.json { render json: @security_role_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:id])\n end",
"def set_menu\n @menu = Menu.find(params[:menu_id])\n end",
"def update\n get_system\n @nav_entry = NavEntry.find(params[:id])\n get_parents\n\n respond_to do |format|\n if @nav_entry.update_attributes(params[:nav_entry])\n format.html { redirect_to(system_nav_entry_path(@system, @nav_entry), :notice => 'Nav entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nav_entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_admin_menu\n @admin_menu = Menu.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @places_menu.update(places_menu_params)\n format.html { redirect_to places_menus_path, notice: 'Places menu was successfully updated.' }\n format.json { render :show, status: :ok, location: @places_menu }\n else\n format.html { render :edit }\n format.json { render json: @places_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # Upload menu images.\n upload_images\n \n respond_to do |format|\n if @menu.update(menu_params)\n current_user.device_table_mappings.each do |device|\n device.updated = false\n device.save\n end\n format.html { redirect_to menus_path(:q => {:category_name_cont => @menu.category.name}), notice: 'Menu was successfully updated.' }\n format.json { render :show, status: :ok, location: @menu }\n else\n format.html { render :edit }\n format.json { render json: @menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @menu_item_id = args[:menu_item_id] if args.key?(:menu_item_id)\n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def create\n @api_v1_menu = Menu.new(api_v1_menu_params)\n\n if @api_v1_menu.save\n render json: @api_v1_menu\n else\n render json: @api_v1_menu.errors\n end\n\n end",
"def set_normal_menu\n @normal_menu = NormalMenu.find(params[:id])\n end",
"def api_v1_menu_params\n params.require(:menu).permit(:data , :weekday , :price , :status)\n end",
"def admin_xml(path,method=:get,options={})\n xml_message(amee_admin,\"/admin#{path}\",method,options)\n end",
"def update\n respond_to do |format|\n if @menu_item.update(menu_item_params)\n format.html { redirect_to admin_menu_menu_items_url, notice: 'Menu item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @menu_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @original_menu = OriginalMenu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @original_menu }\n end\n end",
"def update\n @user_menu = UserMenu.find(params[:id])\n\n respond_to do |format|\n if @user_menu.update_attributes(params[:user_menu])\n get_data_menus_all\n # format.html { redirect_to @user_menu, notice: 'User menu was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n # format.html { render action: \"edit\" }\n format.json { render json: @user_menu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n Menu.transaction do\n @menu.update!(menu_params)\n Menu.sort_position!\n end\n redirect_to admin_menus_path, notice: \"メニューを更新しました。\"\n end",
"def set_menu\n\t\t@menu = Menu.find(params[:id])\n\tend",
"def update\n respond_to do |format|\n if @menu_item.update(menu_item_params)\n format.html { redirect_to @menu_item, notice: 'Menu item was successfully updated.' }\n format.json { render :show, status: :ok, location: @menu_item }\n else\n format.html { render :edit }\n format.json { render json: @menu_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @menu_item.update(menu_item_params)\n format.html { redirect_to @menu_item, notice: 'Menu item was successfully updated.' }\n format.json { render :show, status: :ok, location: @menu_item }\n else\n format.html { render :edit }\n format.json { render json: @menu_item.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.632901",
"0.6314483",
"0.63054293",
"0.629356",
"0.6290709",
"0.6290709",
"0.6290709",
"0.6290709",
"0.6189342",
"0.6180102",
"0.6137505",
"0.61203146",
"0.6113594",
"0.6053739",
"0.6023369",
"0.6000966",
"0.6000806",
"0.593913",
"0.5928133",
"0.5923923",
"0.5886376",
"0.5883696",
"0.58648974",
"0.5842857",
"0.5835914",
"0.5835914",
"0.5835914",
"0.5835914",
"0.5829074",
"0.58181703",
"0.58095276",
"0.5807626",
"0.57927865",
"0.57873255",
"0.57859933",
"0.5766566",
"0.57399535",
"0.5719992",
"0.57176715",
"0.5687568",
"0.5680303",
"0.56671894",
"0.5658334",
"0.565332",
"0.56245786",
"0.562248",
"0.56036776",
"0.55723745",
"0.5556469",
"0.55480117",
"0.5538851",
"0.5495022",
"0.54906976",
"0.54590434",
"0.5445485",
"0.54427934",
"0.54413426",
"0.54328483",
"0.5424922",
"0.54188365",
"0.541376",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.54010606",
"0.5399625",
"0.5394101",
"0.5390341",
"0.5389518",
"0.5389518",
"0.5389518",
"0.5388797",
"0.53780806",
"0.5362603",
"0.5350624",
"0.53448296",
"0.53245676",
"0.5318531",
"0.5312974",
"0.5311272",
"0.53107476",
"0.52998394",
"0.5298603",
"0.5293222",
"0.5292703",
"0.5292449",
"0.5290412",
"0.52797437",
"0.52797437"
] | 0.71934277 | 0 |
DELETE /top_menus/1 DELETE /top_menus/1.xml | def destroy
@top_menu = TopMenu.find(params[:id])
@top_menu.destroy
respond_to do |format|
format.html { redirect_to(top_menus_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @menu = Menu.find(params[:id])\n @menu.destroy\n\t \n respond_to do |format|\n format.html { redirect_to(menus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu = Menu.find(params[:id])\n @menu.destroy\n\n respond_to do |format|\n format.html { redirect_to(menus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu = Menu.find(params[:id])\n @links = Link.find_by_menu_id(@menu.id)\n @menu.destroy\n\n respond_to do |format|\n format.html { redirect_to(menus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu_item = current_site.menu_items.find(params[:id])\n @menu_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_menu_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @original_menu = OriginalMenu.find(params[:id])\n @original_menu.destroy\n\n respond_to do |format|\n format.html { redirect_to(original_menus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu = Menu.find(params[:id])\n @menu.destroy\n \n respond_to do |format|\n format.html { redirect_to(menu_index_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu_item = MenuItem.find(params[:id])\n if uhook_destroy_menu_item(@menu_item)\n flash[:notice] = t('ubiquo.menus.sitemap_removed')\n else\n flash[:error] = t('ubiquo.menus.sitemap_remove_error')\n end\n\n respond_to do |format|\n format.html { redirect_to(ubiquo_menu_items_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menutree = Menutree.find(params[:id])\n @menutree.destroy\n\n respond_to do |format|\n format.html { redirect_to(menutrees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu_item = MenuItem.find(params[:id])\n @menu_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(menu_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu = @menus.find(params[:id])\n @menu.destroy\n\n respond_to do |format|\n format.html { redirect_to menus_url }\n end\n end",
"def destroy\n @menu = Menu.find(params[:id])\n if uhook_destroy_menu(@menu)\n flash[:notice] = t(\"ubiquo.menu.destroyed\")\n else\n flash[:error] = t(\"ubiquo.menu.destroy_error\")\n end\n respond_to do |format|\n format.html { redirect_to(ubiquo.menus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu_item_default = MenuItemDefault.find(params[:id])\n @menu_item_default.destroy\n\n respond_to do |format|\n format.html { redirect_to(menu_item_defaults_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n @menu_item = MenuItem.find(params[:id])\n @menu = @menu_item.menu if @menu_item.present?\n if uhook_destroy_menu_item(@menu_item)\n flash[:notice] = t('ubiquo.menu_item.removed')\n else\n flash[:error] = t('ubiquo.menu_item.remove_error')\n end\n\n respond_to do |format|\n format.html { redirect_to(ubiquo.edit_menu_path(@menu_item.menu)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n menu_id = @product.menu_id\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to :controller=>'menus', :action=>'index', :parent_id => menu_id }\n format.xml { head :ok }\n end\n end",
"def destroy\n if params[:delete] == \"true\"\n @menu.destroy\n else\n menus_to_delete = []\n unless @menu.submenus.empty?\n menus_to_delete += @menu.submenus\n end\n menus_to_delete << @menu\n @system_config.menus.delete(menus_to_delete)\n\n menus_to_destroy = menus_to_delete.select{|menu| menu.system_configs.empty?}\n unless menus_to_destroy.empty?\n Menu.destroy(menus_to_destroy)\n end\n end\n respond_to do |format|\n format.html { redirect_to backend_shop_system_config_menus_url(@current_shop, @system_config) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_item.destroy\n respond_to do |format|\n format.html {redirect_to xmt_nav_menu_items_url(parent_id: @menu_item.root.id), notice: '菜单项删除成功.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @store = Store.find(params[:store_id])\n @menu = @store.menus.find(params[:id])\n @menu.destroy\n\n respond_to do |format|\n format.html { redirect_to store_menus_url(@store) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @house_menu = HouseMenu.find(params[:id])\n @house_menu.destroy\n\n respond_to do |format|\n format.html { redirect_to(house_menus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin_menu.destroy\n respond_to do |format|\n format.html { redirect_to admin_menus_path, notice: 'Запис успішно видалено.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n menu = Menu.find params[:id]\n menu.destroy\n redirect_to new_menu_path\n end",
"def destroy\n @admin_menu.destroy\n respond_to do |format|\n format.html { redirect_to admin_menus_url, notice: \"#{ t 'activerecord.successful.messages.menu_deleted'}\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forms_menutree = FormsMenutree.find(params[:id])\n @forms_menutree.destroy\n\n respond_to do |format|\n format.html { redirect_to(forms_menutrees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu_page = MenuPage.find(params[:id])\n @menu_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(menu_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @api_v1_menu.destroy\n render json: {message: 'deletado com sucesso'}\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to canteen_menus_path(@canteen) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu = Menu.find(params[:id])\n @menu.destroy\n\n respond_to do |format|\n format.html { redirect_to menus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to cafeteria_url(@cafeteria), notice: 'El menú se ha eliminado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to menus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menuitem = Menuitem.find(params[:id])\n @menuitem.destroy\n\n respond_to do |format|\n format.html { redirect_to menuitems_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @menu_section = MenuSection.find(params[:id])\n @menu_section.destroy\n\n respond_to do |format|\n format.html { redirect_to(menu_sections_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @menu_item.destroy\n respond_to do |format|\n format.html { redirect_to admin_menu_menu_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\[email protected]\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to menus_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @table_menu = Table::Menu.find(params[:id])\n @table_menu.destroy\n\n respond_to do |format|\n format.html { redirect_to table_menus_url }\n format.json { head :no_content }\n end\n end",
"def delete_menu_item\n @menu_item = MenuItem.find(params[:menu_item_id])\n\n MenuItem.delete_menu_item @menu_item\n\n render :json => {:success => true}.to_json\n end",
"def destroy\n @forms_selfmenu = FormsSelfmenu.find(params[:id])\n @forms_selfmenu.destroy\n\n respond_to do |format|\n format.html { redirect_to(forms_selfmenus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @normal_menu.destroy\n respond_to do |format|\n format.html { redirect_to normal_menus_url, notice: 'Normal menu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n Menu.transaction do\n @menu.destroy!\n Menu.sort_position!\n end\n redirect_to admin_menus_path, notice: \"メニューを削除しました。\"\n end",
"def destroy\n # Test this query on rail console for menu section that has food\n ActiveRecord::Base.connection.exec_query(\n \"DELETE FROM menu_sections\n WHERE url_id = #{params[:id]}\n AND NOT EXISTS (\n SELECT 1\n FROM Foods\n WHERE ms_url_id = #{params[:id]}\n );\"\n ) \n\n menu_section = ActiveRecord::Base.connection.exec_query(\n \"SELECT 1\n FROM menu_sections\n WHERE url_id = #{params[:id]}\"\n )\n\n if (!menu_section.empty?)\n render json: {errors: \"Cannot delete menu section that has dish in it!\"}, status: 500\n end\n end",
"def destroy\n @menu = Menu.find(params[:id])\n @image = Image.find(:first, :conditions => [\"id = ?\",@menu.image_id])\n @image.destroy unless @image.nil?\n @menu.destroy\n\n respond_to do |format|\n format.html { redirect_to(menus_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @homepage_submenu.destroy\n respond_to do |format|\n format.html { redirect_to homepage_submenus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_item = MenuItem.find(params[:id])\n @menu_item.destroy\n\n respond_to do |format|\n format.html { redirect_to menu_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n menu.destroy\n\n respond_to do |format|\n format.html { redirect_to [place, :menus] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_category.destroy\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to menus_url, notice: 'O Cardapio foi removido.' }\n format.json { head :no_content }\n end\n end",
"def destroy \n get_system\n @nav_entry = NavEntry.find(params[:id])\n @nav_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(system_url(@system)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @main_menu.destroy\n respond_to do |format|\n format.html { redirect_to main_menus_url, notice: \"Main menu was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete!\n\t\t\tClient.delete @root\n\t\tend",
"def destroy\n @dish_menu.destroy\n respond_to do |format|\n format.html { redirect_to edit_cafeteria_menu_path(@dish_menu.menu.cafeteria, @dish_menu.menu), notice: 'El plato se eliminó del menú.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to menus_path(:q => {:category_name_cont => @menu.category.name}), notice: 'Menu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_side_menu = Admin::SideMenu.find(params[:id])\n @admin_side_menu.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_side_menus_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user_menu = UserMenu.find(params[:id])\n @user_menu.destroy\n\n respond_to do |format|\n format.html { redirect_to user_menus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_item.destroy\n @menu_items = @menu.menu_items.all\n @menu_item = @menu.menu_items.build\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to menus_url, notice: 'Menu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to menus_url, notice: 'Menu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to menus_url, notice: 'Menu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to menus_url, notice: 'Menu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to menus_url, notice: 'Menu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @current_admin_user = current_admin_user\n @menu = Menu.find(params[:id])\n @menu.destroy\n\n respond_to do |format|\n format.html { redirect_to menus_url }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\n @menu.destroy\n respond_to do |format|\n format.html { redirect_to menus_url, notice: \"Menu was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n expire_one(params[:id])\n\n @article = Article.find(params[:id])\n @article.destroy\n @menu = Menu.find_by_article_id(params[:id])\n if [email protected]?\n @menu.destroy\n end\n respond_to do |format|\n format.html { redirect_to(admin_articles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sitemenu.destroy\n respond_to do |format|\n format.html { redirect_to sitemenus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_list = MenuList.find(params[:id])\n @menu_list.destroy\n\n respond_to do |format|\n format.html { redirect_to menu_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete(path)\n root.delete(path)\n end",
"def destroy\n if @site.columns.size > 0\n flash[:error] = \"该站点存在多个栏目,不能删除\"\n else\n delete_file(@site.logo_file) if [email protected]_file.blank?\n @site.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to cms.sites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_lists.destroy\n respond_to do |format|\n format.html { redirect_to menu_lists_url, notice: 'Menu list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @administrator_menu_nivel0_menu_nivel1.destroy\n respond_to do |format|\n format.html { redirect_to administrator_menu_nivel0_menu_nivel1s_path(@administrator_menu_nivel0_menu_nivel1.administrator_menu_nivel0_id), notice: 'la página ha sido eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_item.destroy\n respond_to do |format|\n format.html { redirect_to menu_path, notice: 'Menu item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bottom_menu.destroy\n respond_to do |format|\n format.html { redirect_to bottom_menus_url, notice: 'Bottom menu was successfully destroyed.' }\n end\n end",
"def delete_essence_menu_if_trashed\n #deletes essence menu if the element containing the essence has been trashed in the cms\n Alchemy::EssenceMenu2.all.each do |e|\n if e.element.trashed? == true\n e.destroy\n end\n end\n Alchemy::EssenceMenu.all.each do |e|\n if e.element.trashed? == true\n e.destroy\n end\n end\n end",
"def destroy\n @diymenu.destroy\n respond_to do |format|\n format.html { redirect_to diymenus_url, notice: 'Diymenu was successfully destroyed.' }\n end\n end",
"def destroy\n @fdn_menu.destroy\n respond_to do |format|\n format.html { redirect_to fdn_menus_url, notice: 'Menu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurant.menu.destroy \n restaurant_id = @restaurant.id\n @restaurants = Menu.restaurant.where(:restaurant_id=>restaurant_id)\n end",
"def destroy\n @menu_item.destroy\n respond_to do |format|\n format.html { redirect_to menu_items_url, notice: 'Menu item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_item.destroy\n respond_to do |format|\n format.html { redirect_to menu_items_url, notice: 'Menu item was successfully destroyed.' }\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 destroy\n @menu_item.destroy\n respond_to do |format|\n format.html { redirect_to menu_items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tree.destroy\n redirect_to user_url(current_user), notice: '削除しました'\n end",
"def destroy\n @menuindex.destroy\n respond_to do |format|\n format.html { redirect_to menuindices_url, notice: 'Menuindex was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @drink_menu.destroy\n respond_to do |format|\n format.html { redirect_to drink_menus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @menu_section = MenuSection.find(params[:id])\n @menu_section.destroy\n\n respond_to do |format|\n format.html { redirect_to menu_sections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipient_menu.destroy\n respond_to do |format|\n format.html { redirect_to recipient_menus_url }\n format.json { head :no_content }\n end\n end",
"def TreeView_DeleteItem(hwnd, hitem) send_treeview_message(hwnd, :DELETEITEM, lparam: hitem) end",
"def destroy\n if Pizzerium.exists?(:id => params[:id])\n pizzeria = Pizzerium.find(params[:id])\n position = Position.find(pizzeria.position_id)\n menus = Menu.where(pizzeria_id: params[:id])\n\n menus.each do |m|\n Dish.where(menu_id: m.id).destroy_all\n end\n PizzeriaTag.where(pizzeria_id: pizzeria.id).delete_all\n menus.destroy_all\n position.destroy\n pizzeria.destroy\n \n render 'delete'\n else\n @message = \"Pizzerian gick inte att radera. Pizzerian existerar inte.\"\n error400\n end\n end",
"def destroy\n @markup = Markup.find(params[:id])\n @markup.destroy\n\n respond_to do |format|\n format.html { redirect_to [@parent, :markups] }\n format.xml { head :ok }\n end\n end",
"def delete_all(xpath); end",
"def TreeView_DeleteAllItems(hwnd)\r\n send_treeview_message(hwnd, :DELETEITEM, lparam: TVI_ROOT) end",
"def deleteSite _args\n \"deleteSite _args;\" \n end",
"def destroy!\n self.update(:menu_match => nil, :link_url => nil, :deletable => true)\n\n self.destroy\n end",
"def destroy_header_menu\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n @yaml = ApplicationHelper.get_config_yaml\n\n unless params[:org_name].nil? or @yaml[:general]['header_menus'].nil?\n @yaml[:general]['header_menus'].each do |header_menu|\n if header_menu[0] == params[:org_name]\n @yaml[:general]['header_menus'].delete(header_menu)\n ApplicationHelper.save_config_yaml(@yaml)\n break\n end\n end\n end\n\n render(:partial => 'ajax_header_menu', :layout => false)\n end",
"def destroy\n @nav_item = NavItem.find(params[:id])\n @nav_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(nav_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bar_menu_item.destroy\n respond_to do |format|\n format.html { redirect_to bar_menu_items_url }\n format.json { head :no_content }\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 @custom_menu.destroy\n respond_to do |format|\n format.html { redirect_to project_sub_project_custom_menus_path(@project, @sub_project), notice: 'Custom menu was successfully destroyed.' }\n format.json { head :no_content }\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 remove_configuration_product\r\n # node = ProductPackageProduct.find(params[:id].to_i).destroy\r\n # redirect_to :action => \"configuration_products\", :id => node.parent_id\r\n ExampleConfigurationProduct.delete params[:id]\r\n redirect_to :action => \"configuration_products\", :id => params[:id]\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 @menu_group.destroy\n respond_to do |format|\n format.html { redirect_to menu_groups_url, notice: 'Menu group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.69103146",
"0.6850569",
"0.6846406",
"0.6832385",
"0.6813448",
"0.6770644",
"0.6713109",
"0.66989785",
"0.6623276",
"0.659216",
"0.6590314",
"0.653764",
"0.65283144",
"0.6480373",
"0.6478835",
"0.64753336",
"0.64356166",
"0.6426243",
"0.64042795",
"0.63951087",
"0.6394833",
"0.6388735",
"0.63694155",
"0.63531333",
"0.6351782",
"0.6330658",
"0.632283",
"0.63141215",
"0.6309648",
"0.6308432",
"0.6307238",
"0.62717557",
"0.62581944",
"0.62525433",
"0.62431276",
"0.62380433",
"0.62307566",
"0.6223471",
"0.6217701",
"0.6216762",
"0.62165433",
"0.62086767",
"0.6206185",
"0.6165815",
"0.61518526",
"0.609992",
"0.609771",
"0.60941476",
"0.6089512",
"0.6063482",
"0.6062491",
"0.6054001",
"0.6043682",
"0.60352486",
"0.60352486",
"0.60352486",
"0.60352486",
"0.60346144",
"0.6032879",
"0.60311294",
"0.6025388",
"0.6006907",
"0.5965982",
"0.594804",
"0.59332335",
"0.58810425",
"0.5867054",
"0.58643836",
"0.58528745",
"0.58522004",
"0.584919",
"0.5843825",
"0.58282727",
"0.58234525",
"0.5815517",
"0.5815517",
"0.58150077",
"0.58150077",
"0.580968",
"0.5791961",
"0.5784994",
"0.578381",
"0.57783824",
"0.57763803",
"0.5757311",
"0.5727073",
"0.572635",
"0.5726114",
"0.572354",
"0.572016",
"0.57190543",
"0.5716518",
"0.5705765",
"0.5691872",
"0.56905884",
"0.5686521",
"0.56656325",
"0.5647068",
"0.56424266",
"0.56318295"
] | 0.7189245 | 0 |
executes the connection if the arguments match | def try args
# the argument conditions matched
@blk.call *args if match? args
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(*args)\n friendly_name = args[0]\n connection_info = args[1]\n\n return all unless friendly_name\n delegate(friendly_name, connection_info)\n end",
"def execute_query(sql, args)\n\t\t\t\t\[email protected]_connection_yield(sql, self, args){args ? self.async_exec(sql, args) : self.async_exec(sql)}\n\t\t\t\tend",
"def execute_query(sql, args)\n @db.log_connection_yield(sql, self, args){args ? async_exec(sql, args) : async_exec(sql)}\n end",
"def test_connection\n x = execute('test')\n return !x.empty?\n rescue StandardError\n return false\n end",
"def real_connect(*args)\n @connection_params = args unless args.empty?\n super(*@connection_params)\n end",
"def connection(*args, **_arg1, &block); end",
"def execute *params\r\n sql = parse_args( *params )\r\n @driver.execute( sql )\r\n end",
"def execute(sql, args=nil)\n\t\t\t\t\targs = args.map{|v| @db.bound_variable_arg(v, self)} if args\n\t\t\t\t\tq = check_disconnect_errors{execute_query(sql, args)}\n\t\t\t\t\tbegin\n\t\t\t\t\t\tblock_given? ? yield(q) : q.cmd_tuples\n\t\t\t\t\tensure\n\t\t\t\t\t\tq.clear if q && q.respond_to?(:clear)\n\t\t\t\t\tend\n\t\t\t\tend",
"def exec_query_dblink_connect\n execute_remote(query_enable_dblink + query_dblink_connect)\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|conn| check_database_errors{_execute(conn, sql, opts, &block)}}\n end",
"def exec(*args, &block)\n if current = Thread.current[:squirm_connection]\n current.exec(*args, &block)\n else\n use {|conn| conn.exec(*args, &block)}\n end\n end",
"def query(sql, args=nil)\n args = args.map{|v| @db.bound_variable_arg(v, self)} if args\n check_disconnect_errors{super}\n end",
"def exec(_cmd, _args = {})\n false\n end",
"def connection_established(*args)\n\tend",
"def execute_prepared_statement(name, args)\n check_disconnect_errors{exec_prepared(name, args)}\n end",
"def _execute(sql, name = nil)\n @connection.execute(sql)\n end",
"def execute(sql, opts=OPTS, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)}\n end\n rescue Connection::Error => e\n raise_error(e)\n end",
"def _execute(conn, sql, opts, &block)\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n conn.execute(sql, opts[:arguments], &block)\n end\n end",
"def execute(*args)\n @db.execute(*args)\n end",
"def connect(opts)\n c = super\n connection_pragmas.each{|s| log_connection_yield(s, c){c.execute(s)}}\n c\n end",
"def check_connection( conn )\n\tbegin\n\t\tconn.exec( \"SELECT 1\" )\n\trescue PG::Error => err\n\t\t$stderr.puts \"%p while testing connection: %s\" % [ err.class, err.message ]\n\t\tconn.reset\n\tend\nend",
"def do_execute(sql, name = 'SQL')\n log(sql, name) { raw_connection_do(sql) }\n end",
"def log_connection_execute(conn, sql)\n conn.execute(sql)\n end",
"def exec(connection = @connection)\n connection.exec(statement)\n end",
"def execute(sql, opts=OPTS, &block)\n synchronize(opts[:server]){|c| _execute(c, sql, opts, &block)} \n end",
"def call(query, *args)\n execute(query, *args)\n rescue *RESCUABLE_CONNECTION_ERRORS => e\n raise ConnectionError, \"#{e.class}: #{e.message}\"\n end",
"def run\n case @command\n when \"update\"\n puts \"Updating database\"\n update_database\n when \"search\"\n # Make sure the database exists\n ensure_database\n @search.do_search(@args[0], @args[1])\n when \"\"\n # Make sure the database exists\n ensure_database\n @search.main\n else\n puts \"Invalid command, please try again.\"\n end\n\n end",
"def execute(sql, args=nil)\n args = args.map{|v| @db.bound_variable_arg(v, self)} if args\n q = check_disconnect_errors{execute_query(sql, args)}\n begin\n block_given? ? yield(q) : q.cmd_tuples\n ensure\n q.clear if q && q.respond_to?(:clear)\n end\n end",
"def allow_remote_database_url=(_arg0); end",
"def execute(sql, name = nil, binds = [])\n log(sql, name) do\n sql = bind_params(binds, sql) if prepared_statements\n @connection.do(sql)\n end\n end",
"def execute(sql, opts={}, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def execute!; end",
"def execute(sql, opts=OPTS, &block)\n if opts[:sproc]\n call_sproc(sql, opts, &block)\n elsif sql.is_a?(Symbol)\n execute_prepared_statement(sql, opts, &block)\n else\n synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}\n end\n end",
"def execute; end",
"def execute; end",
"def reexecute_connections?\n return true\n end",
"def execute(sql, *bind_values)\n @pool.acquire { |conn| conn.execute(sql, *bind_values) }\n end",
"def check_connection( conn )\n begin\n @conn.exec(\"SELECT 1\")\n rescue PG::Error => err\n $stderr.puts \"%p while CHECKING TESTING connection: %s\" % [ err.class, err.message ]\n @conn.reset\n puts \"--------- PG CONNECTION RESETED -------------\"\n end\nend",
"def _execute(conn, sql, opts)\n stmt = log_connection_yield(sql, conn){conn.execute(sql)}\n if block_given?\n yield(stmt)\n else \n stmt.affected\n end\n ensure\n stmt.free if stmt\n end",
"def tunnelled?(args); end",
"def log_connection_execute(conn, sql)\n conn.execute(sql)\n end",
"def run_connection_scenario\n test_connection(min_expected_size: scenario.min_result_size, scenario_type_name: 'search') do\n replacements = scenario.replacements.dup\n authority.search(scenario.query,\n subauth: scenario.subauthority_name,\n replacements: replacements)\n end\n end",
"def execute(sql, name = nil, _binds = [])\n log(sql, name) do\n @connection.do(sql)\n end\n end",
"def run_sql(sql_query)\n begin\n CONNECTION.execute(sql_query)\n rescue Exception => msg\n @errors << msg\n false\n end\n end",
"def initialize(args)\n @sql = args[:sql] || nil\n \n #Mandatory args:\n req(:required => [:connection_name],\n :args_object => args)\n @dbh = Mysqladmin::Pool.connections[args[:connection_name]][:dbh]\n end",
"def execute_query?\n [email protected]?\n end",
"def _execute(conn, sql, opts)\n begin\n r = log_yield(sql){conn.query(sql)}\n if opts[:type] == :select\n yield r if r\n elsif block_given?\n yield conn\n end\n rescue ::Mysql2::Error => e\n raise_error(e, :disconnect=>MYSQL_DATABASE_DISCONNECT_ERRORS.match(e.message))\n end\n end",
"def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n end",
"def sys_exec_cmd(dbc, cmd)\n begin\n q = dbc.query(\"SELECT sys_exec('#{cmd}');\")\n q.each do |x|\n if x[0].to_i == 0\n return true\n else\n return false\n end\n end\n rescue Mysql::Error => e\n puts \"Problem Executing Command\".light_red + \"!\".white\n puts \"\\t=> \".white + \"#{e}\".light_red\n return false\n end\nend",
"def database_exists?(connection_string, db_name)\n exists = false\n\n run \"#{connection_string} --execute=\\\"show databases;\\\"\" do |channel, stream, data|\n exists = exists || data.include?(db_name)\n end\n\n exists\nend",
"def execute(sql, opts=OPTS, &block)\n super(sql, {:arguments=>bind_arguments}.merge(opts), &block)\n end",
"def call(*args)\n in_context do\n self.execute(*args)\n end\n end",
"def execute(method, host, *args)\n options = args.last.is_a?(Hash) ? args.pop : Hash.new\n\n connector = connector_for(host, options)\n if connector.nil?\n log.warn { \"No connector ports open on '#{host}'\" }\n HostConnector::Response.new(host, stderr: \"No connector ports open on '#{host}'\")\n elsif connector.is_a?(winrm.class)\n options.delete(:ssh)\n connector.send(method, host, *args, options)\n elsif connector.is_a?(ssh.class)\n options.delete(:winrm)\n connector.send(method, host, *args, options)\n end\n end",
"def execute\n end",
"def execute\n end",
"def connect_db_method\n begin\n self.con = PG.connect :dbname => self.dbname, :user => self.username, :password => self.password\n return true\n rescue PG::Error => e\n puts e.message\n puts \"Sorry Connection cannot be established\"\n # => Forceful exit from the program\n Kernel.exit(0)\n end\n end",
"def run\n basecmd = []\n basecmd << command(:psql)\n basecmd << \"-U\" unless @resource[:role].nil?\n basecmd << \"#{@resource[:role]}\" unless @resource[:role].nil?\n basecmd << \"-d\" unless @resource[:database].nil?\n basecmd << \"#{@resource[:database]}\" unless @resource[:database].nil?\n \n # We execute by default.\n execute = true\n unless @resource[:query].nil?\n cmd = basecmd\n cmd << '-qAtc'\n \n sqlcmd = \"#{@resource[:query]}\"\n \n cmd << sqlcmd\n \n raw, status = Puppet::Util::SUIDManager.run_and_capture(cmd, 'postgres')\n if status == 0\n execute = false # Got an ok result, so we'll evaluate.\n\n if ! @resource[:rows].nil?\n target_rows = Integer(@resource[:rows].gsub(/[^\\d]/,''))\n operand = @resource[:rows].gsub(/[\\d]/,'').chomp.downcase\n returned_rows = (raw.length <= 0 ? 0 : raw.lines.count)\n if operand.match(/lte|less than or equal|<=/)\n execute = true if returned_rows <= target_rows\n elsif operand.match(/gte|greater than or equal|>=/)\n execute = true if returned_rows >= target_rows\n elsif operand.match(/lt|less than|</)\n execute = true if returned_rows < target_rows \n elsif operand.match(/gt|greater than|>/)\n execute = true if returned_rows > target_rows\n else\n execute = true if returned_rows == target_rows\n end\n end\n else\n # We stop an execution if rows or result params are set\n # on the assumption that if you want to evaluate against criteria like those\n # you want to actually do so.\n execute = false if (! @resource[:rows].nil? or ! @resource[:result].nil?)\n end\n end\n \n unless execute == false\n cmd = basecmd\n if ! @resource[:command].nil?\n cmd << '-qAtc'\n \n sqlcmd = \"#{@resource[:command]}\"\n \n cmd << sqlcmd \n elsif ! @resource[:file].nil?\n cmd << '-qAtf'\n \n sqlcmd = \"#{@resource[:file]}\"\n \n cmd << sqlcmd\n else\n # Right now we send a warning. This should still trigger a refresh if you\n # want to use queries to conditionally do things for some insane reason.\n self.warning(\"Nothing to do.\")\n end\n \n raw, status = Puppet::Util::SUIDManager.run_and_capture(cmd, 'postgres')\n if status != 0\n self.fail(\"Error executing SQL - result #{raw}\")\n else\n @ran = true\n end\n else\n self.fail(\"Execution criteria failed. Failing to prevent dependant resources from executing.\")\n end\n end",
"def use(args)\n @dbh.select_db(args[:db_name])\n end",
"def execute\n\n end",
"def do_sql_command(sql, use_global_connection = true, close_connection = false)\n begin\n \n if use_global_connection \n dbconn = open_conn\n else\n dbconn = open_conn(false)\n end\n \n dbres = dbconn.query(sql)\n\n rescue Mysql::Error => err\n raise err\n ensure\n close_conn(dbconn) if close_connection\n end\n \n dbres\nend",
"def execute(method, *args)\n yield_connection do |connection|\n connection.send(method, *args)\n end\n end",
"def setup_connection(conn)\n conn = super(conn)\n statement(conn) do |stmt|\n connection_pragmas.each{|s| log_connection_yield(s, conn){stmt.execute(s)}}\n end\n conn\n end",
"def connect_to_database\n # If no input parameters are defined then read the database params\n # from the command line or the default ones\n unless @db_params then self.database_params= DB_PARAMS end\n\n PGconn.connect( @db_params[:host],\n @db_params[:port],\n @db_params[:options],\n @db_params[:tty],\n @db_params[:dbname],\n @db_params[:login],\n @db_params[:password] )\n end",
"def connection_execute_method\n :query\n end",
"def connection_execute_method\n :query\n end",
"def connect(args)\n begin\n # sensible? defaults\n args[:host] ||= 'localhost'\n args[:port] ||= 3306\n args[:user] ||= 'root'\n args[:password] ||= ''\n \n db = Mysql.connect(args[:host], args[:user], args[:password], args[:name], args[:port])\n @debug and puts \"-- #{args[:host]} #{args[:name]} server version: \" + db.get_server_info\n return db\n rescue Mysql::Error => e\n $stderr.puts \"Error code: #{e.errno}\"\n $stderr.puts \"Error message: #{e.error}\"\n $stderr.puts \"Error SQLSTATE: #{e.sqlstate}\" if e.respond_to?(\"sqlstate\")\n exit\n end\n end",
"def execute(sql)\r\n\t\[email protected](sql)\r\n\tend",
"def execute(params = nil)\n params ||= @params\n request.uri = \"#{@db_name}\"\n request.params = params\n Couchdbtools.execute(request)\n end",
"def execute(sql, opts = {}, &block)\n res = nil\n synchronize(opts[:server]) do |conn|\n res = check_database_errors do\n if sql.is_a?(Symbol)\n execute_prepared_statement(conn, sql, opts, &block)\n else\n log_yield(sql) do\n conn.query(sql, opts[:arguments])\n end\n end\n end\n yield res if block_given?\n res.cmd_tuples\n end\n end",
"def cmd_poortego_connect(*args)\n ## TODO: add logic from Constructor\n if (args[0] == nil)\n cmd_poortego_connect_help\n return\n end\n \n connection_config = Hash.new()\n \n @@connect_opts.parse(args) {|opt, idx, val|\n #print_line \"[DEBUG] opt #{opt} idx #{idx} val #{val}\"\n #print_line \"[DEBUG] opt class: #{opt.class}\"\n #print_line \"[DEBUG] Arg #{args[idx]}\"\n #case opt # Change this to opt if \"-h\" style arguments are being passed\n # Change this to val if \"help\" style arguments are being passed\n case (args[idx-1])\n when \"-h\", \"-?\"\n cmd_poortego_connect_help\n when \"-adapter\"\n connection_config['adapter'] = val\n puts \"[DEBUG] Setting adapter to #{val}\"\n when \"-database\"\n connection_config['database'] = val\n puts \"[DEBUG] Setting database to #{val}\"\n when \"-username\"\n connection_config['username'] = val\n puts \"[DEBUG] Setting username to #{val}\"\n when \"-password\"\n connection_config['password'] = val\n puts \"[DEBUG] Setting password to #{val}\"\n when \"-host\"\n connection_config['host'] = val\n puts \"[DEBUG] Setting host to #{val}\" \n else\n print_error(\"Invalid option.\")\n return\n end \n }\n \n if (connection_config.length > 1)\n begin\n ActiveRecord::Base.establish_connection(connection_config)\n rescue Exception => e\n puts \"Exception establishing activerecord connection\"\n puts self.inspect\n puts e.message \n end\n end\n \n end",
"def execute(sql, opts)\n r = synchronize(opts[:server]) do |conn|\n log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn) do\n conn.query_with_flags(sql, timezone.nil? || timezone == :local ? LOCAL_TIME_QUERY_FLAGS : QUERY_FLAGS)\n end\n end\n yield r\n rescue ::Trilogy::Error => e\n raise_error(e)\n end",
"def perform\n return if @exit\n\n args, opts = @arguments, @options\n [:to, :from, :to_safe, :exclude, :schemas].each do |opt|\n opts[opt] ||= config[opt.to_s]\n end\n map_deprecations(args, opts)\n\n if opts[:init]\n setup(db_config_file(args[0]) || config_file || \".pgsync.yml\")\n else\n sync(args, opts)\n end\n\n true\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_non_query(*args)\n raise NotImplementedError.new\n end",
"def exec\n proxied_connection.exec\n end",
"def execute(sql, args=nil)\n q = query(sql, args)\n block_given? ? yield(q) : q.cmd_tuples\n end",
"def execute\n raise \"you need to define #execute\"\n end",
"def execute\n fail NotImplementedError\n end",
"def exec_query(sql, name = 'SQL', binds = [])\n if name == :skip_logging\n #execute(sql, name)\n hash_query(sql, name, binds)\n else\n log(sql, name) do\n #execute(sql, name)\n hash_query(sql, name, binds)\n end\n end \n end",
"def setup_connection(conn)\n conn = super(conn)\n statement(conn) do |stmt|\n connection_configuration_sqls.each{|sql| log_yield(sql){stmt.execute(sql)}}\n end\n conn\n end",
"def check_execute\n unless executed?\n execute\n end\n end",
"def execute_dui(sql, opts={})\n synchronize(opts[:server]) do |conn|\n begin\n conn.execute(sql)\n rescue SwiftError => e\n raise_error(e)\n end\n end\n end",
"def exec(sql, *bindvars, &block)\n ret = nil\n thread = Thread.new { ret = super }\n thread.join\n ret\n rescue Interrupt\n self.break\n raise\n end",
"def execute?(cmd)\n execution_result = execute(cmd)\n !execution_result.nil? && execution_result\n end",
"def execute\n unless args.skip?\n if args.chained?\n execute_command_chain\n else\n exec(*args.to_exec)\n end\n end\n end",
"def execute sql\n db[sql]\n end",
"def database_params= params\n # Checks the presence of the postgres extension\n begin\n require 'postgres'\n rescue LoadError\n @db_params = nil\n raise\n end\n\n begin\n #check if database connection works\n conn = PGconn.connect( params[:host],\n params[:port],\n params[:options],\n params[:tty],\n params[:dbname],\n params[:login],\n params[:password] )\n conn.close\n rescue PGError\n @db_params = nil\n raise\n end\n\n # If everything went ok, assigns the parameters\n @db_params = params\n return true\n end",
"def execute(sql)\n @logger.debug(\"SQL: #{sql}\") if @logger\n retrieve_connection.query(sql)\n end",
"def _connect_database\n _send_command(\"db_connect #{@options[:db_user]}:#{@options[:db_pass]}@#{@options[:db_host]}/#{@options[:db_name]}\")\n end",
"def execute\n @executors.each(&:execute)\n true\n end",
"def connect(*args)\n raise NotImplementedError\n end",
"def execute_remote(query)\n raise \"You must override `execute_remote' in your class\"\n end",
"def execute_query(sql, *vars)\n if vars && vars.count > 0\n @database.prepare(sql).execute(*vars.flatten)\n else\n @database.prepare(sql).execute\n end\n rescue\n puts \"MyMysql.execute_query(): #{$!}\" if @@verbose\n end",
"def execute(args=nil)\r\n puts \"Executing #{name}\"\r\n execute_base(args)\r\n end",
"def connect!(options={})\n execute_on_servers(options) { }\n end",
"def run_command(cmd, opts = {}, &data_handler)\n # Some implementations do not accept an opts argument.\n # We cannot update all implementations to accept opts due to them being separate plugins.\n # Therefore here we check the implementation's arity to maintain compatibility.\n case method(:run_command_via_connection).arity.abs\n when 1\n return run_command_via_connection(cmd, &data_handler) unless cache_enabled?(:command)\n\n @cache[:command][cmd] ||= run_command_via_connection(cmd, &data_handler)\n when 2\n return run_command_via_connection(cmd, opts, &data_handler) unless cache_enabled?(:command)\n\n @cache[:command][cmd] ||= run_command_via_connection(cmd, opts, &data_handler)\n else\n raise NotImplementedError, \"#{self.class} does not implement run_command_via_connection with arity #{method(:run_command_via_connection).arity}\"\n end\n end",
"def connect(args)\n if (args.size != 2)\n puts \"usage: connect [host] [port]\"\n return\n else\n @connections.add(args[0], args[1])\n puts \"connected to #{args[0]}:#{args[1]}\"\n end\n end",
"def execute\n end",
"def connection(env); end",
"def test_conn_with_named_parameters \n db = MonetDB.new()\n \n db.conn({ :user => \"monetdb\", :passwd => \"monetdb\", :port => 50000, :host => \"localhost\", :database => \"ruby_test\"})\n assert_equal(true, db.is_connected?)\n db.close\n end",
"def execute(sql, name = nil) #:nodoc:\n log(sql, name) { @connection.exec sql }\n end"
] | [
"0.68335134",
"0.6104026",
"0.59829855",
"0.5970492",
"0.59658456",
"0.59260046",
"0.59149253",
"0.5849628",
"0.58461386",
"0.58339953",
"0.5793814",
"0.5782586",
"0.5762568",
"0.57589775",
"0.56875837",
"0.5662337",
"0.5660602",
"0.5652283",
"0.5616386",
"0.5598863",
"0.55901265",
"0.55894816",
"0.5563688",
"0.5557487",
"0.5554439",
"0.5552251",
"0.55491",
"0.5542161",
"0.55413854",
"0.5519405",
"0.5509669",
"0.5487593",
"0.5481229",
"0.5480391",
"0.5480391",
"0.54799986",
"0.54768294",
"0.5451554",
"0.5448909",
"0.54406285",
"0.5440355",
"0.5435303",
"0.5434466",
"0.5429362",
"0.54271585",
"0.542024",
"0.54140735",
"0.540765",
"0.53992426",
"0.5388677",
"0.53876823",
"0.53837043",
"0.5375788",
"0.5370794",
"0.5370794",
"0.53688025",
"0.5362053",
"0.5339115",
"0.53342646",
"0.5323769",
"0.53194016",
"0.5304299",
"0.528269",
"0.5282091",
"0.5282091",
"0.52818435",
"0.5274076",
"0.5268521",
"0.52643645",
"0.5263943",
"0.5261369",
"0.5254374",
"0.5244691",
"0.52442724",
"0.52383506",
"0.52316666",
"0.52299726",
"0.52297413",
"0.5222618",
"0.52173305",
"0.52145654",
"0.5199428",
"0.51964086",
"0.5196003",
"0.5195044",
"0.51916903",
"0.51905656",
"0.51873195",
"0.51824445",
"0.51810837",
"0.51791346",
"0.5178897",
"0.5178825",
"0.517791",
"0.5176278",
"0.5171785",
"0.5168178",
"0.5166638",
"0.51637596",
"0.5163422",
"0.51621956"
] | 0.0 | -1 |
:any is a condition that always matches returns the new connection (that can be useful later to delete it) | def on_event event, *args_cond, &blk
# in first call initialize @event_connections
@event_connections = Hash.new(Set.new) if @event_connections.nil?
new_conn = HH::EventConnection.new event, args_cond, &blk
@event_connections[event] += [new_conn]
#debug "#{new_conn} added"
#emit :new_event_connection, new_conn
new_conn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def any\n con = @connections[rand(@connections.length)]\n if block_given?\n yield con\n else\n con\n end\n end",
"def any_raw_connection\n @raw_connection || valid_raw_connection\n end",
"def all_connections\n yield @conn.first if @conn\n end",
"def exit?; @outgoing_connectors.empty?; end",
"def reexecute_connections?\n return true\n end",
"def checkin_connection(conn)\n @available_connections << conn\n conn\n end",
"def connections?\n @connections.any?\n end",
"def test_connection\n @pool.hold {|conn|}\n true\n end",
"def new_connection; end",
"def available(server)\n available_connections(server).pop || make_new(server)\n end",
"def resurrect_dead_connections!\n connections.dead.each { |c| c.resurrect! }\n end",
"def disconnect!; true; end",
"def disconnected?; connection_state == :disconnected end",
"def connected?; connection_state == :connected end",
"def hold(server=nil)\n begin\n unless c = @conn.first\n @conn.replace([c = make_new(:default)])\n end\n yield c\n rescue Sequel::DatabaseDisconnectError, *@error_classes => e\n disconnect if disconnect_error?(e)\n raise\n end\n end",
"def all_active_connections\n super\n end",
"def checkout_new_connection\n c = new_connection\n @connections << c\n checkout_and_verify(c)\n end",
"def disconnect!() @connections.each_value(&:disconnect) end",
"def any!\n self.any = true\n end",
"def extract_connections!\n # Get the connections.\n cnxs = self.each_connection.to_a\n # Remove them from the scope.\n # cnxs.each { |cnx| self.delete_connection!(cnx) }\n # cnxs.delete_all_connections!\n self.delete_all_connections!\n # Return the connections.\n return cnxs\n end",
"def connection_exists?(name)\n @connections.include?(name)\n end",
"def test_connections\n @doors.all? do |k, v|\n v[-1] ? v[-1].leads_to?(self.class, k): true\n end\n end",
"def connected?\n [email protected]?\n end",
"def accept_new_connection\n new_socket = @host.accept\n @connections << new_socket\n new_socket.write(\"Write QUIT to disconnect\\n\")\n end",
"def active?\n @conn.handler == self\n end",
"def disconnecting?; connection_state == :disconnecting end",
"def cleanup_connections\n @connections.keep_if do |thread, conns|\n thread.alive?\n end\n end",
"def some(conn_id, *args)\n find(conn_id, :some, *args)\n end",
"def include_conn_to?(ip, port)\n self.each do |conn|\n return true if conn.ip == ip and conn.port == port\n end\n return false\n end",
"def connected?; end",
"def connected?; end",
"def connected?; end",
"def flag_single_connection!\n if (!flag_single_connection?)\n @flags = @flags | TAC_PLUS_SINGLE_CONNECT_FLAG\n else\n @flags = @flags & (~TAC_PLUS_SINGLE_CONNECT_FLAG)\n end\n return(nil)\n end",
"def remote_connections; end",
"def all_connections\n hold do |conn|\n yield conn\n\n # Use a hash to record all connections already seen. As soon as we\n # come across a connection we've already seen, we stop the loop.\n conns = {}\n conns.compare_by_identity\n while true\n conn = nil\n begin\n break unless (conn = @queue.pop(timeout: 0)) && !conns[conn]\n conns[conn] = true\n yield conn\n ensure\n @queue.push(conn) if conn\n end\n end\n end\n end",
"def checkin_connection(conn)\n @available_connections << conn\n if USE_WAITER\n @waiter.signal\n Thread.pass\n end\n conn\n end",
"def conn?\n conn != nil\n end",
"def connected?\n @connections.any?\n end",
"def all_connections\n hold do |c|\n sync do\n yield c\n @available_connections.each{|conn| yield conn}\n end\n end\n end",
"def all_connections\n hold do |c|\n sync do\n yield c\n @available_connections.each{|conn| yield conn}\n end\n end\n end",
"def connection_established(*args)\n\tend",
"def delete_all_active_connections\n super\n end",
"def connections\n @connections ||= []\n end",
"def activeConnections?\n if @connectedClients then do return true else return false end\n end",
"def connection\n @reserved_connections[current_connection_id] ||= checkout\n end",
"def connection_failure(actor, reason)\n connections.delete_if do |key, value|\n if(value == actor && reason.nil?)\n warn \"Connection failure detected. Removing connection: #{key} - #{reason || 'no reason provided'}\"\n begin\n distribution.remove_connection(key)\n rescue Error::ConnectionUnavailable, Error::ConnectionFailure\n warn 'Caught connection unavailability'\n end\n distribution.redistribute!\n true\n end\n end\n nil\n end",
"def flag_single_connection?()\n return(true) if(@flags & TAC_PLUS_SINGLE_CONNECT_FLAG == TAC_PLUS_SINGLE_CONNECT_FLAG)\n return(false)\n end",
"def recon\n !!ActiveRecord::Base.establish_connection\nend",
"def checkin_connection(conn)\n @queue.push(conn)\n conn\n end",
"def with_duplicate_conn\n\t\toriginal_conn = self.conn\n\t\t@conn = original_conn.dup\n\t\tself.log.info \"Executing with %p, a copy of connection %p\" % [ @conn, original_conn ]\n\t\tyield\n\tensure\n\t\tself.log.info \" restoring original connection %p.\" % [ original_conn ]\n\t\t@conn = original_conn\n\tend",
"def connected?\n synchronize { @connections.any? }\n end",
"def reap\n stale_connections = @connections.select do |conn|\n conn.in_use? && !conn.owner.alive?\n end\n\n stale_connections.each do |conn|\n if conn.active?\n conn.reset!\n checkin conn\n else\n remove conn\n end\n end\n end",
"def each\n @mutex.synchronize do\n # Don't include the ones in a reserved_placeholder state because that object is meaningless\n @connections.each { |connection| yield connection unless connection.kind_of?(Thread) }\n end\n end",
"def reap\n stale_connections = synchronize do\n @connections.select do |conn|\n conn.in_use? && !conn.owner.alive?\n end\n end\n\n stale_connections.each do |conn|\n synchronize do\n if conn.active?\n conn.reset!\n checkin conn\n else\n remove conn\n end\n end\n end\n end",
"def conn= x\n @conn_owned = false\n @conn = x\n end",
"def checkin(conn)\n synchronize do\n release conn\n @available.add conn\n end\n end",
"def ignore_disconnect; end",
"def verify_active_connections! #:nodoc:\n clear_stale_cached_connections!\n @connections.each do |connection|\n connection.verify!\n end\n end",
"def communicates?; !disconnected? end",
"def fullconn(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"fullconn \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def connection(*args, **_arg1, &block); end",
"def bound?\n\t\treturn self.conn.bound?\n\tend",
"def connections\n @connections ||= {}\n end",
"def bind_connections_as_friend\n connections.where(friend_id: nil).each {|fshp| bind_connection(fshp)}\n end",
"def bind_connections_as_friend\n connections.where(friend_id: nil).find_each { |fshp| bind_connection(fshp) }\n end",
"def ignore_disconnect=(_arg0); end",
"def checkout_new_socket(host, port)\n return nil if @all.size >= @size\n\n begin\n socket = TCPSocket.new(host, port)\n socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)\n rescue => ex\n raise ConnectionFailure, \"Failed to connect to host #{@host} and port #{@port}: #{ex}\"\n end\n\n # If any saved authentications exist, we want to apply those\n # when creating new sockets.\n @connection.apply_saved_authentication(:socket => socket)\n\n socket\n end",
"def socket?() end",
"def connection\n if conn = @reserved_connections[current_connection_id]\n conn\n else\n @reserved_connections[current_connection_id] = checkout\n end\n end",
"def active_connections?\n self.ensure_ready\n self.connection_pool_list.any?(&:active_connection?)\n end",
"def empty_connection_pools!; end",
"def connections\n @_connections ||= {}\n end",
"def hold(server=:default)\n begin\n begin\n server = @servers[server]\n yield(c = (@conns[server] ||= make_new(server)))\n rescue Sequel::DatabaseDisconnectError\n disconnect_server(server, &@disconnection_proc)\n raise\n end\n rescue Exception => e\n # if the error is not a StandardError it is converted into RuntimeError.\n raise(@convert_exceptions && !e.is_a?(StandardError) ? RuntimeError.new(e.message) : e)\n end\n end",
"def clear_reloadable_connections!\n synchronize do\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n end\n\n @connections.delete_if(&:finished?)\n\n @available.clear\n @connections.each do |conn|\n @available.add conn\n end\n end\n end",
"def connected?\n connections = nil\n @lock.lock\n begin\n connections = @connections\n ensure\n @lock.unlock\n end\n connections.any?\n end",
"def clean\r\n if @conns\r\n @conns.objects.each do |data|\r\n data[:object].clean if data[:object].respond_to?(\"clean\")\r\n end\r\n elsif @conn\r\n @conn.clean if @conn.respond_to?(\"clean\")\r\n end\r\n end",
"def connection\n begin\n @connections.hold { |dbh| yield(dbh) }\n rescue Mysql::Error => me\n \n @configuration.log.fatal(me)\n \n @connections.available_connections.each do |sock|\n begin\n sock.close\n rescue => se\n @configuration.log.error(se)\n end\n end\n \n @connections.available_connections.clear\n raise me\n end\n end",
"def connect?\n connect != false\n end",
"def clear_reloadable_connections!\n @reserved_connections.clear\n @connections.each do |conn|\n checkin conn\n conn.disconnect! if conn.requires_reloading?\n end\n @connections.delete_if do |conn|\n conn.requires_reloading?\n end\n @available.clear\n @connections.each do |conn|\n @available.add conn\n end\n end",
"def valid_raw_connection\n (@verified && @raw_connection) ||\n # `allow_retry: false`, to force verification: the block won't\n # raise, so a retry wouldn't help us get the valid connection we\n # need.\n with_raw_connection(allow_retry: false, materialize_transactions: false) { |conn| conn }\n end",
"def disconnect!\n @reserved_connections.each do |name,conn|\n checkin conn\n end\n @reserved_connections = {}\n @connections.each do |conn|\n conn.disconnect!\n end\n @connections = []\n end",
"def turn_off\n MAX_CONNECTIONS.times do\n connections << Sequel.connect(DATABASE_URL)\n end\n rescue Sequel::DatabaseConnectionError\n end",
"def connection_stale!\n log(:debug, :socket, 'connection is stale.')\n close_connection\n end",
"def receive_any(packet)\n RightLinkLog.debug(\"RECV #{packet.to_s}\")\n case packet\n when Advertise\n RightLinkLog.info(\"RECV #{packet.to_s}\") unless RightLinkLog.level == :debug\n advertise_services\n when Request, Push\n RightLinkLog.info(\"RECV #{packet.to_s([:from, :tags])}\") unless RightLinkLog.level == :debug\n @dispatcher.dispatch(packet)\n when Result\n RightLinkLog.info(\"RECV #{packet.to_s([])}\") unless RightLinkLog.level == :debug\n @mapper_proxy.handle_result(packet)\n else\n RightLinkLog.error(\"Agent #{@identity} received invalid packet: #{packet.to_s}\")\n end\n true\n end",
"def valid_connection?(conn)\n conn.servers.length\n true\n rescue Excon::Errors::Forbidden, Excon::Errors::Unauthorized\n false\n end",
"def acquire(*a)\n conn = nil\n\n 1.times do\n if (conn = super) &&\n (timer = sync{@connection_timestamps.delete(conn)}) &&\n Sequel.elapsed_seconds_since(timer) > @connection_validation_timeout &&\n !db.valid_connection?(conn)\n\n case pool_type\n when :sharded_threaded, :sharded_timed_queue\n sync{@allocated[a.last].delete(Sequel.current)}\n else\n sync{@allocated.delete(Sequel.current)}\n end\n\n disconnect_connection(conn)\n redo\n end\n end\n\n conn\n end",
"def connections\n @connections ||= {}\n end",
"def connected?\n @connections.size > 0 # synchronize { @connections.any? }\n end",
"def grab_connections\n connections = []\n connections << @host\n end",
"def disconnect_all\n raise NotImplementedError\n end",
"def clear_reloadable_connections!\n @reserved_connections.each do |name, conn|\n checkin conn\n end\n @reserved_connections = {}\n @connections.each do |conn|\n conn.disconnect! if conn.requires_reloading?\n end\n @connections = []\n end",
"def connect(*) end",
"def include?(conn)\n return @uuids.include? conn.uuid\n end",
"def with_connection_auto_remove\n with_connection do |connection|\n begin\n yield connection\n rescue Exception\n remove(connection)\n raise\n end\n end\n end",
"def connection\n self.class.connection[id] unless new_record?\n end",
"def without_reconnect(&block); end",
"def stage_over_connection?\n\t\tfalse\n\tend",
"def default_connection\r\n raise NotConnected unless connected?\r\n\t\t\t\t\treturn @connections.last\r\n\t\t\t\tend",
"def any; end",
"def supports_concurrent_connections?\n !@memory_database\n end"
] | [
"0.6586675",
"0.6545786",
"0.5975575",
"0.59430224",
"0.5804205",
"0.57386565",
"0.56829685",
"0.56104183",
"0.5569609",
"0.55111426",
"0.5471555",
"0.5461563",
"0.54329264",
"0.5400737",
"0.53838587",
"0.5362495",
"0.53452045",
"0.5335859",
"0.53325564",
"0.5315534",
"0.5314716",
"0.5276816",
"0.52680796",
"0.52663434",
"0.52606195",
"0.5255488",
"0.5251496",
"0.52324337",
"0.52291554",
"0.5228528",
"0.5228528",
"0.5228528",
"0.5220569",
"0.5196793",
"0.5183397",
"0.51748616",
"0.51514137",
"0.5142229",
"0.5136126",
"0.5136126",
"0.5132801",
"0.5130972",
"0.5121649",
"0.512049",
"0.51152325",
"0.5107009",
"0.50969625",
"0.50910133",
"0.50823087",
"0.5075226",
"0.5074635",
"0.50715935",
"0.5070497",
"0.50704074",
"0.50526834",
"0.50500935",
"0.50488657",
"0.50484216",
"0.5044107",
"0.50438356",
"0.502957",
"0.5024685",
"0.5016791",
"0.49934784",
"0.4986671",
"0.49851808",
"0.49787948",
"0.49715963",
"0.4968791",
"0.49666002",
"0.49643886",
"0.49636373",
"0.49511763",
"0.49477878",
"0.49394944",
"0.493925",
"0.49390978",
"0.4938542",
"0.49370632",
"0.49345598",
"0.49247217",
"0.49238423",
"0.49218145",
"0.49169505",
"0.49150538",
"0.49073237",
"0.49061304",
"0.49029163",
"0.48988828",
"0.4898446",
"0.48825797",
"0.4878981",
"0.48754743",
"0.4873133",
"0.4870918",
"0.48630482",
"0.48614618",
"0.48612484",
"0.48558593",
"0.4845123"
] | 0.54447496 | 12 |
GET /my_cvs GET /my_cvs.json | def index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @cvs = Cv.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cvs }\n end\n end",
"def index\n @cvs = Cv.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cvs }\n end\n end",
"def index\n @cgvs = Cgv.order('created_at')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cgvs }\n end\n end",
"def index\n @csv_files = CsvFile.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @csv_files }\n end\n end",
"def show\n @csv = Csv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @csv }\n end\n end",
"def index\n @cvis = Cvi.all(:order => \"cvi_number DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cvis }\n end\n end",
"def index\n use_secure_headers_override :headers_stats_index\n @project_stats = ProjectStat.all\n respond_to do |format|\n format.csv do\n headers['Content-Disposition'] =\n 'attachment; filename=\"project_stats.csv\"'\n render csv: @project_stats, filename: @project_stats.name\n end\n format.json\n # { render :show, status: :created, location: @project_stat }\n format.html\n end\n end",
"def index\n @cn_curves = CnCurve.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cn_curves }\n end\n end",
"def index\n @cvs = Cv.all\n end",
"def index\n @cvs = Cv.all\n end",
"def index\n @transects = Transect.all.order(transect_code: :asc)\n respond_to do |format|\n format.html\n format.json\n format.csv {send_data @transects.to_csv,\n filename: \"transects-#{Date.today}.csv\"}\n end\n end",
"def index\n @contract_doc_categories = ContractDocCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contract_doc_categories }\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def index\n if params[:year]\n @yearly_infos = YearlyInfo.where(year: params[:year])\n else\n @yearly_infos = YearlyInfo.all\n end\n\n respond_to do |format|\n format.html\n format.csv { send_data(@yearly_infos.to_csv(:except => [:created_at, :updated_at])) }\n end\n end",
"def index\n @contracts = Contract\n .where(customer_id: @customer.id)\n .order(:created_at)\n .page params[:page]\n\n respond_to do |format|\n format.html {}\n format.js { render json: @contracts.to_json }\n format.json { render json: @contracts.to_json }\n end\n\n end",
"def index\n @contracts = Contract.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contracts }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: CompaniesDatatable.new(view_context) }\n end\n end",
"def index\n @accounts = Account.all\n respond_to do |format|\n format.html \n format.json\n format.csv { send_data @accounts.to_csv, filename: \"accounts-#{Date.today}.csv\" }\n end\n end",
"def index\n @cfos = Cfo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cfos }\n end\n end",
"def index\n @vinyls = Vinyl.all\n respond_to do |format|\n format.html\n format.csv { send_data @vinyls.to_csv(['catalog','artist', 'title', 'label', 'format', 'rating', 'released', 'release_id', 'notes', 'date']) }\n end\n end",
"def index\n @cities = City.all\n\n render json: @cities\n end",
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def index\n # @nfl_teams = NflTeam.all\n @afc = NflTeam.afc\n @nfc = NflTeam.nfc\n @all_teams = NflTeam.order(:city)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nfl_teams }\n format.csv { send_data @all_teams.to_csv }\n end\n end",
"def index\n @cruise = Cruise.find(params[:cruise_id])\n @observations = @cruise.observations.order(observed_at: :desc).accessible_by(current_ability)\n \n \n \n respond_to do |format|\n format.csv { send_data build_csv, filename: \"observations-#{@cruise.id}.csv\"}\n format.json { send_data build_json, filename: \"observations-#{@cruise.id}.json\"}\n format.geojson { send_data build_geojson, filename: \"observations-#{@cruise.id}.geojson\"}\n format.sigrid3\n end\n end",
"def index\n @svc_criteria = SvcCriterium.all.paginate(page: params[:page])\n respond_to do |format|\n format.html\n format.js\n format.csv { send_data SvcCriterium.as_csv }\n end\n end",
"def index\n \tif params[:sector_id] and @sector = Sector.find(params[:sector_id])\n \t\t@projects = @sector.projects\n \telse\n\t @projects = Project.all\n\t\tend\n\t\t\n respond_to do |format|\n format.html # index.html.erb\n format.json # index.json.erb\n format.csv { render :csv => Project.all, :filename => 'projects' }\n end\n end",
"def index\n @cp_changes = CpChange.all\n\n render json: @cp_changes\n end",
"def index\n if params[:format].nil? or params[:format] == 'html'\n @iteration = params[:iteration][/\\d+/] rescue 1\n @cultivars = Cultivar.sorted_order(\"#{sort_column('cultivars')} #{sort_direction}\").search(params[:search]).paginate(\n :page => params[:page],\n :per_page => params[:DataTables_Table_0_length]\n )\n log_searches(Cultivar)\n else # Allow url queries of data, with scopes, only xml & csv ( & json? )\n @cultivars = Cultivar.api_search(params)\n log_searches(Cultivar.method(:api_search), params)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js # index.html.erb\n format.xml { render :xml => @cultivars }\n format.csv { render :csv => @cultivars }\n format.json { render :json => @cultivars }\n end\n end",
"def index\n @cys_envs = CysEnv.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cys_envs }\n end\n end",
"def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def index\n @disciplines = Discipline.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @disciplines }\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html\n format.json {render json: @students, each_serializer: StudentSerializer, include: '**'}\n format.csv {send_data to_csv, filename:\"Student_data.csv\"}\n end\n end",
"def index\n @clips = Clip.order(params[:sort])\n respond_to do |wants|\n wants.html\n wants.csv do\n csv_string = FasterCSV.generate do |csv|\n # header row\n csv << [\"Name\", \"File Size in Bytes\", \"Running Time\", \"Resolution\", \"Notes\", \"MD5 Source\", \"MD5 Destination\", \"Project ID\"]\n\n # data rows\n @clips.each do |clip|\n csv << [clip.clip_name, clip.size, (Time.mktime(0)+(clip.running_time || 0)).strftime(\"%Hh%Mm%Ss\"), clip.resolution, clip.notes, clip.md5source, clip.md5dest, clip.project_id]\n end\n end\n\n # send it to the browsah\n send_data csv_string,\n :type => 'text/csv; charset=iso-8859-1; header=present',\n :disposition => \"attachment; filename=clips.csv\"\n end\n end\n\n end",
"def index\n # Check for filters\n @courses = Course.getCourseInformation(params[:dept],params[:course])\n @page_title = \"Browse Courses\"\n respond_to do |format|\n format.html\n format.json {render json: @courses }\n end\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def index\n authorize Contrato\n @contratos = Contrato.all\n respond_to do |format|\n format.html\n format.csv {render text: @contratos.to_csv }\n end\n end",
"def index\n @civilizations = Civilization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @civilizations }\n end\n end",
"def index\n @commemts = Commemt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commemts }\n end\n end",
"def index\n @curriculum_vitaes = findable_curriculum_vitaes.all\n respond_to do |format|\n format.html {}\n format.json { render json: @curriculum_vitaes }\n end\n end",
"def index\n @disciplines = Discipline.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @disciplines }\n end\n end",
"def index\n @datasets = Dataset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @datasets }\n end\n end",
"def index\n @criminal_codes = CriminalCode.includes(:translations).order(:name)\n\n respond_to do |format|\n format.html\n format.csv do\n send_data CriminalCode.to_csv,\n filename: GeneratedFile.clean_filename('criminal_codes', 'csv'),\n type: 'text/csv'\n end\n end\n end",
"def index\n @recoleccions = Recoleccion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recoleccions }\n format.csv { send_data @recoleccions.to_csv }\n end\n end",
"def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb (no data required)\n format.ext_json { render :json => find_contracts.to_ext_json(:class => Contract, :count => Contract.count(options_from_search(Contract)), :include => [:contract_category, :contract_type]) }\n end\n end",
"def index\n @clinician_orders = ClinicianOrder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clinician_orders }\n end\n end",
"def index\n respond_to do |format|\n format.html do\n @recent_objects = Descriptor.recent_from_project_id(sessions_current_project_id)\n .order(updated_at: :desc).limit(10)\n render '/shared/data/all/index'\n end\n format.json {\n @descriptors = ::Queries::Descriptor::Filter.new(params).all\n .page(params[:page])\n .per(params[:per])\n .order('descriptors.name')\n }\n end\n end",
"def index\n @ctypes = Ctype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ctypes }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.csv\n format.json { render json: @proposals }\n end\n end",
"def index\n @financial_aid_sources = @financial_aid_package.sources\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @financial_aid_sources }\n end\n end",
"def index\n @boxes = Box.order('id DESC').paginate(page: params[:page], per_page: 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxes }\n format.csv { render csv: boxes_scoped, filename: \"Cajas #{Date.today}\" }\n end\n end",
"def index\n respond_to do |format|\n format.html{}\n format.pdf{\n scope = Case\n scope = case params[:status_type]\n when 'all' then scope.all_data\n when 'opened' then scope.opened\n when 'closed' then scope.closed\n when 'flagged' then scope.flagged\n else\n scope.opened\n end\n scope = scope.include_enumerations\n scope = if User.current.can?(:manage_roles)\n scope.where(assigned_to_id: User.current)\n else\n scope.visible\n end\n @cases = scope\n }\n format.csv{ params[:length] = 500\n options = Hash.new\n options[:status_type] = params[:status_type]\n json = CaseDatatable.new(view_context, options).as_json\n send_data Case.to_csv(json[:data]), filename: \"case-#{Date.today}.csv\"\n }\n format.json{\n options = Hash.new\n options[:subcases] = false\n options[:status_type] = params[:status_type]\n render json: CaseDatatable.new(view_context,options)\n }\n end\n end",
"def index\n @circulos = Circulo.all\n\n respond_to do |format|\n format.html\n format.csv { render csv: @circulos.to_csv, filename: \"#{Time.now.to_i}_circulos\" }\n end\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def index\n @verticals = Vertical.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @verticals }\n end\n end",
"def index\n @c14s = C14.includes(\n {sample: [\n :material,\n :taxon,\n :context\n ]},\n :references\n )\n\n # filter\n unless c14_params.blank?\n @c14s = @c14s.where(c14_params)\n end\n\n # order\n if params.has_key?(:c14s_order_by)\n order = { params[:c14s_order_by] => params.fetch(:c14s_order, \"asc\") }\n @c14s = @c14s.reorder(order)\n end\n\n respond_to do |format|\n format.html {\n @pagy, @c14s = pagy(@c14s)\n }\n format.json\n format.csv {\n @c14s = @c14s.select(index_csv_template)\n render csv: @c14s\n }\n end\n end",
"def index\n @disciplines = Discipline.all\n #respond_to do |format|\n # format.json { render json: @disciplines, status: :ok }\n #end\n #render json: @disciplines, status: :ok\n respond_with @disciplines\n end",
"def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cocktails }\n end\n end",
"def catalogs\n path = \"#{api_root}/index/catalogs\"\n process_api_request(:get, path)\n end",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def index\n \tcustomers = Customer.all\n \trender json: customers\n \tend",
"def index\n @goldmeasures = Goldmeasure.all\n\n respond_to do |format|\n format.html \n format.json\n format.csv { send_data @goldmeasures.to_csv }\n\n end\n end",
"def index\n @airports = Airport.paginate(:page => params[:page], :per_page => 30)\n \n respond_to do |format|\n format.html { }\n format.csv { send_data @airports.to_csv }\n format.json { render json: @airports }\n end\n end",
"def index\n @matrix = CourseMatrix.find(params[:course_matrix_id])\n @matrix_disciplines = MatrixDiscipline.where(:matrix_id => @matrix.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @matrix_disciplines }\n end\n end",
"def index\n @student_sources = StudentSource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student_sources }\n end\n end",
"def index\n render jsonapi: Seances::UseCases::FetchAll.new.call\n end",
"def index\n if params[:format].nil? or params[:format] == 'html'\n @iteration = params[:iteration][/\\d+/] rescue 1\n @covariates = Covariate.sorted_order(\"#{sort_column('covariates')} #{sort_direction}\").search(params[:search]).paginate(\n :page => params[:page], \n :per_page => params[:DataTables_Table_0_length]\n )\n log_searches(Covariate)\n else # Allow url queries of data, with scopes, only xml & csv ( & json? )\n @covariates = Covariate.api_search(params)\n log_searches(Covariate.method(:api_search), params)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js \n format.xml { render :xml => @covariates }\n format.csv { render :csv => @covariates }\n format.json { render :json => @covariates }\n end\n end",
"def index\n @care_plans = CarePlan.all\n render json: @care_plans\n end",
"def indexcsv\n @videos = Video.order(\"videos.time ASC\")\n respond_to do |wants|\n\t\t wants.csv do\n\t\t render_csv(\"videos-#{Time.now.strftime(\"%Y%m%d\")}\")\n\t\t end\n\t\tend\n end",
"def index\n @dev_folios = DevFolio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dev_folios }\n end\n end",
"def index\n respond_to do |format|\n format.html do\n @recent_objects = Source.created_this_week.order(updated_at: :desc).limit(10)\n render '/shared/data/all/index'\n end\n format.json {\n @sources = Queries::Source::Filter.new(params).all\n .order(:cached)\n .page(params[:page])\n .per(params[:per])\n }\n format.bib {\n # TODO - handle count and download\n @sources = Queries::Source::Filter.new(params).all\n .order(:cached)\n .page(params[:page])\n .per(params[:per] || 2000)\n }\n end\n end",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def index\n @backend_tutorial_stats = Backend::TutorialStat.order('created_at ASC')\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @backend_tutorial_stats }\n format.csv do\n backend_tutorial_stats = Backend::TutorialStat.order('created_at ASC')\n data = Backend::TutorialStat.download_tutorial_stats_csv(backend_tutorial_stats) \n filename = \"tutorial_stats#{Time.now.strftime(\"%Y%m%d%H%M%S\")}.csv\" \n send_data(data, :type => \"text/csv; charset=utf-8; header=present\", :filename => filename) \n end\n end \n end",
"def index\n @imports = Import.all\n respond_to do |format|\n format.html\n format.json { render json: ImportsDatatable.new(view_context)}\n end\n end",
"def index\n #@csosns = Csosn.all\n @csosns = Csosn.paginate(:page => params[:page], :per_page => 10)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @csosns }\n end\n end",
"def index\n @companies = companies_scope\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n respond_to do |format|\n format.html { @chefs = Chef.all }\n format.json { @chefs = Chef.order(:name) }\n end\n end",
"def index\n @cultures = Culture.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cultures }\n end\n end",
"def index\n @schools = School.filter(params.slice(:City, :State, :Zip, :District, :Region))\n respond_to do |format|\n format.html\n format.csv { send_data @schools.to_csv }\n end\n end",
"def index\n @sample_sheet = SampleSheet.find(params[:sample_sheet_id])\n @sample_rows = @sample_sheet.sample_rows.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @sample_sheet.sample_rows.map(&:attributes) }\n format.csv { send_data @sample_rows.to_csv, :filename => 'sample_sheet.csv' }\n \n end\n end",
"def index\n # @product_imports = ImportFile.where(:company_id => @company.id, :item_type => 1).order(\"created_at DESC\")\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render :json => @product_imports }\n format.json { render :json => ProductImportDatatable.new(view_context,@company)}\n end\n end",
"def index\n @data_collections = DataCollection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_collections }\n end\n end",
"def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @clientes = current_user.vendedor ? current_user.vendedor.clientes : Cliente.all\n\n\t\trespond_to do |format|\n format.html { render layout: \"dataTables\" }\n\t\t\tformat.csv { send_data @clientes.to_csv }\n end\n end",
"def index\n\t\t@clubs = Club.all\n\t\trender json: @clubs\n\tend",
"def index\n @court_types = CourtType.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @court_types }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nodes }\n format.csv {render :text=>Node.to_csv}\n end\n end",
"def render_csv_fileset_response( filesets )\n @records = filesets\n headers['Content-Disposition'] = 'attachment; filename=\"fileset-list.csv\"'\n headers['Content-Type'] ||= 'text/csv'\n render 'csv/v1/filesets'\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: CustomersDatatable.new(view_context) }\n end\n @customers = Customer.all\n end",
"def index\n @curriculums = Curriculum.all\n respond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@curriculums) }\n\t\tend\n end",
"def index\n @conseilles = Conseille.all\n respond_to do |format|\n format.html\n format.json { render json: @conseilles}\n end\n end",
"def index\n @studies = Study.all\n\n respond_to do |format|\n format.html\n format.csv {render text: @studies.to_csv}\n end\n end",
"def index\n @course_statuses = CourseStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @course_statuses }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @line_items }\n end\n end",
"def creditCardIndex\n render json: Approved.allCreditCard\n end",
"def index\n @customers = Customer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end",
"def index\n @samples = Sample.approved_or_rejected.page(params[:page]).per(100)\n respond_to do |format|\n format.html\n format.csv do\n render_csv\n end\n end\n end"
] | [
"0.6411343",
"0.6411343",
"0.63516605",
"0.63173515",
"0.6269345",
"0.6210472",
"0.6205684",
"0.6190279",
"0.6165491",
"0.6165491",
"0.6158682",
"0.6140083",
"0.61375576",
"0.605609",
"0.60512817",
"0.6046386",
"0.6025219",
"0.6020452",
"0.59997445",
"0.5990619",
"0.59777087",
"0.5975247",
"0.5967463",
"0.5955158",
"0.5913712",
"0.5906362",
"0.5905258",
"0.589772",
"0.5896606",
"0.5888894",
"0.5885998",
"0.58823997",
"0.5882294",
"0.587451",
"0.58736634",
"0.58727044",
"0.58680505",
"0.5862869",
"0.5845382",
"0.58422565",
"0.58385515",
"0.58222044",
"0.58182424",
"0.58139765",
"0.5811735",
"0.5791761",
"0.5789215",
"0.57869995",
"0.5783979",
"0.5777306",
"0.5773571",
"0.57734025",
"0.577033",
"0.57689726",
"0.5758214",
"0.57568663",
"0.57531667",
"0.5735352",
"0.5731576",
"0.57303655",
"0.57282573",
"0.5726786",
"0.5725848",
"0.5723679",
"0.5723553",
"0.57197934",
"0.5718916",
"0.571699",
"0.5715311",
"0.5710179",
"0.56948996",
"0.569267",
"0.5690162",
"0.56881195",
"0.56879056",
"0.5686651",
"0.5682087",
"0.56797165",
"0.56757826",
"0.5675456",
"0.56744504",
"0.5673048",
"0.56692034",
"0.5664813",
"0.5664813",
"0.5664813",
"0.5664813",
"0.56575406",
"0.5649293",
"0.56489646",
"0.56485355",
"0.56483775",
"0.5645076",
"0.5644373",
"0.56419784",
"0.5640741",
"0.5637221",
"0.56356007",
"0.56348276",
"0.5631925",
"0.56273776"
] | 0.0 | -1 |
GET /my_cvs/1 GET /my_cvs/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @csv = Csv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @csv }\n end\n end",
"def index\n @cvs = Cv.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cvs }\n end\n end",
"def index\n @cvs = Cv.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cvs }\n end\n end",
"def index\n @csv_files = CsvFile.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @csv_files }\n end\n end",
"def index\n @cvis = Cvi.all(:order => \"cvi_number DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cvis }\n end\n end",
"def index\n @cgvs = Cgv.order('created_at')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cgvs }\n end\n end",
"def index\n use_secure_headers_override :headers_stats_index\n @project_stats = ProjectStat.all\n respond_to do |format|\n format.csv do\n headers['Content-Disposition'] =\n 'attachment; filename=\"project_stats.csv\"'\n render csv: @project_stats, filename: @project_stats.name\n end\n format.json\n # { render :show, status: :created, location: @project_stat }\n format.html\n end\n end",
"def index\n @cvs = Cv.all\n end",
"def index\n @cvs = Cv.all\n end",
"def index\n @transects = Transect.all.order(transect_code: :asc)\n respond_to do |format|\n format.html\n format.json\n format.csv {send_data @transects.to_csv,\n filename: \"transects-#{Date.today}.csv\"}\n end\n end",
"def index\n if params[:year]\n @yearly_infos = YearlyInfo.where(year: params[:year])\n else\n @yearly_infos = YearlyInfo.all\n end\n\n respond_to do |format|\n format.html\n format.csv { send_data(@yearly_infos.to_csv(:except => [:created_at, :updated_at])) }\n end\n end",
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def index\n @cn_curves = CnCurve.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cn_curves }\n end\n end",
"def index\n @cruise = Cruise.find(params[:cruise_id])\n @observations = @cruise.observations.order(observed_at: :desc).accessible_by(current_ability)\n \n \n \n respond_to do |format|\n format.csv { send_data build_csv, filename: \"observations-#{@cruise.id}.csv\"}\n format.json { send_data build_json, filename: \"observations-#{@cruise.id}.json\"}\n format.geojson { send_data build_geojson, filename: \"observations-#{@cruise.id}.geojson\"}\n format.sigrid3\n end\n end",
"def index\n @contracts = Contract.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contracts }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: CompaniesDatatable.new(view_context) }\n end\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def index\n if params[:format].nil? or params[:format] == 'html'\n @iteration = params[:iteration][/\\d+/] rescue 1\n @cultivars = Cultivar.sorted_order(\"#{sort_column('cultivars')} #{sort_direction}\").search(params[:search]).paginate(\n :page => params[:page],\n :per_page => params[:DataTables_Table_0_length]\n )\n log_searches(Cultivar)\n else # Allow url queries of data, with scopes, only xml & csv ( & json? )\n @cultivars = Cultivar.api_search(params)\n log_searches(Cultivar.method(:api_search), params)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js # index.html.erb\n format.xml { render :xml => @cultivars }\n format.csv { render :csv => @cultivars }\n format.json { render :json => @cultivars }\n end\n end",
"def index\n @contracts = Contract\n .where(customer_id: @customer.id)\n .order(:created_at)\n .page params[:page]\n\n respond_to do |format|\n format.html {}\n format.js { render json: @contracts.to_json }\n format.json { render json: @contracts.to_json }\n end\n\n end",
"def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def index\n @contract_doc_categories = ContractDocCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contract_doc_categories }\n end\n end",
"def index\n @accounts = Account.all\n respond_to do |format|\n format.html \n format.json\n format.csv { send_data @accounts.to_csv, filename: \"accounts-#{Date.today}.csv\" }\n end\n end",
"def index\n @vinyls = Vinyl.all\n respond_to do |format|\n format.html\n format.csv { send_data @vinyls.to_csv(['catalog','artist', 'title', 'label', 'format', 'rating', 'released', 'release_id', 'notes', 'date']) }\n end\n end",
"def index\n \tif params[:sector_id] and @sector = Sector.find(params[:sector_id])\n \t\t@projects = @sector.projects\n \telse\n\t @projects = Project.all\n\t\tend\n\t\t\n respond_to do |format|\n format.html # index.html.erb\n format.json # index.json.erb\n format.csv { render :csv => Project.all, :filename => 'projects' }\n end\n end",
"def index\n @datasets = Dataset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @datasets }\n end\n end",
"def index\n # @product_imports = ImportFile.where(:company_id => @company.id, :item_type => 1).order(\"created_at DESC\")\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render :json => @product_imports }\n format.json { render :json => ProductImportDatatable.new(view_context,@company)}\n end\n end",
"def index\n @cfos = Cfo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cfos }\n end\n end",
"def index\n @cp_changes = CpChange.all\n\n render json: @cp_changes\n end",
"def index\n @civilizations = Civilization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @civilizations }\n end\n end",
"def index\n @clips = Clip.order(params[:sort])\n respond_to do |wants|\n wants.html\n wants.csv do\n csv_string = FasterCSV.generate do |csv|\n # header row\n csv << [\"Name\", \"File Size in Bytes\", \"Running Time\", \"Resolution\", \"Notes\", \"MD5 Source\", \"MD5 Destination\", \"Project ID\"]\n\n # data rows\n @clips.each do |clip|\n csv << [clip.clip_name, clip.size, (Time.mktime(0)+(clip.running_time || 0)).strftime(\"%Hh%Mm%Ss\"), clip.resolution, clip.notes, clip.md5source, clip.md5dest, clip.project_id]\n end\n end\n\n # send it to the browsah\n send_data csv_string,\n :type => 'text/csv; charset=iso-8859-1; header=present',\n :disposition => \"attachment; filename=clips.csv\"\n end\n end\n\n end",
"def index\n respond_to do |format|\n format.html{}\n format.pdf{\n scope = Case\n scope = case params[:status_type]\n when 'all' then scope.all_data\n when 'opened' then scope.opened\n when 'closed' then scope.closed\n when 'flagged' then scope.flagged\n else\n scope.opened\n end\n scope = scope.include_enumerations\n scope = if User.current.can?(:manage_roles)\n scope.where(assigned_to_id: User.current)\n else\n scope.visible\n end\n @cases = scope\n }\n format.csv{ params[:length] = 500\n options = Hash.new\n options[:status_type] = params[:status_type]\n json = CaseDatatable.new(view_context, options).as_json\n send_data Case.to_csv(json[:data]), filename: \"case-#{Date.today}.csv\"\n }\n format.json{\n options = Hash.new\n options[:subcases] = false\n options[:status_type] = params[:status_type]\n render json: CaseDatatable.new(view_context,options)\n }\n end\n end",
"def index\n respond_to do |format|\n format.html do\n @recent_objects = Descriptor.recent_from_project_id(sessions_current_project_id)\n .order(updated_at: :desc).limit(10)\n render '/shared/data/all/index'\n end\n format.json {\n @descriptors = ::Queries::Descriptor::Filter.new(params).all\n .page(params[:page])\n .per(params[:per])\n .order('descriptors.name')\n }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.csv\n format.json { render json: @proposals }\n end\n end",
"def index\n respond_to do |format|\n format.html do\n @recent_objects = Source.created_this_week.order(updated_at: :desc).limit(10)\n render '/shared/data/all/index'\n end\n format.json {\n @sources = Queries::Source::Filter.new(params).all\n .order(:cached)\n .page(params[:page])\n .per(params[:per])\n }\n format.bib {\n # TODO - handle count and download\n @sources = Queries::Source::Filter.new(params).all\n .order(:cached)\n .page(params[:page])\n .per(params[:per] || 2000)\n }\n end\n end",
"def index\n @circulos = Circulo.all\n\n respond_to do |format|\n format.html\n format.csv { render csv: @circulos.to_csv, filename: \"#{Time.now.to_i}_circulos\" }\n end\n end",
"def index\n @disciplines = Discipline.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @disciplines }\n end\n end",
"def index\n @imports = Import.all\n respond_to do |format|\n format.html\n format.json { render json: ImportsDatatable.new(view_context)}\n end\n end",
"def index\n # @nfl_teams = NflTeam.all\n @afc = NflTeam.afc\n @nfc = NflTeam.nfc\n @all_teams = NflTeam.order(:city)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nfl_teams }\n format.csv { send_data @all_teams.to_csv }\n end\n end",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def index\n @cys_envs = CysEnv.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cys_envs }\n end\n end",
"def index\n if params[:format].nil? or params[:format] == 'html'\n @iteration = params[:iteration][/\\d+/] rescue 1\n @covariates = Covariate.sorted_order(\"#{sort_column('covariates')} #{sort_direction}\").search(params[:search]).paginate(\n :page => params[:page], \n :per_page => params[:DataTables_Table_0_length]\n )\n log_searches(Covariate)\n else # Allow url queries of data, with scopes, only xml & csv ( & json? )\n @covariates = Covariate.api_search(params)\n log_searches(Covariate.method(:api_search), params)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js \n format.xml { render :xml => @covariates }\n format.csv { render :csv => @covariates }\n format.json { render :json => @covariates }\n end\n end",
"def index\n @financial_aid_sources = @financial_aid_package.sources\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @financial_aid_sources }\n end\n end",
"def indexcsv\n @videos = Video.order(\"videos.time ASC\")\n respond_to do |wants|\n\t\t wants.csv do\n\t\t render_csv(\"videos-#{Time.now.strftime(\"%Y%m%d\")}\")\n\t\t end\n\t\tend\n end",
"def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cocktails }\n end\n end",
"def index\n @recoleccions = Recoleccion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recoleccions }\n format.csv { send_data @recoleccions.to_csv }\n end\n end",
"def index\n @backend_tutorial_stats = Backend::TutorialStat.order('created_at ASC')\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @backend_tutorial_stats }\n format.csv do\n backend_tutorial_stats = Backend::TutorialStat.order('created_at ASC')\n data = Backend::TutorialStat.download_tutorial_stats_csv(backend_tutorial_stats) \n filename = \"tutorial_stats#{Time.now.strftime(\"%Y%m%d%H%M%S\")}.csv\" \n send_data(data, :type => \"text/csv; charset=utf-8; header=present\", :filename => filename) \n end\n end \n end",
"def index\n @ctypes = Ctype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ctypes }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb (no data required)\n format.ext_json { render :json => find_contracts.to_ext_json(:class => Contract, :count => Contract.count(options_from_search(Contract)), :include => [:contract_category, :contract_type]) }\n end\n end",
"def index\n @sample_sheet = SampleSheet.find(params[:sample_sheet_id])\n @sample_rows = @sample_sheet.sample_rows.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @sample_sheet.sample_rows.map(&:attributes) }\n format.csv { send_data @sample_rows.to_csv, :filename => 'sample_sheet.csv' }\n \n end\n end",
"def index\n @disciplines = Discipline.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @disciplines }\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html\n format.json {render json: @students, each_serializer: StudentSerializer, include: '**'}\n format.csv {send_data to_csv, filename:\"Student_data.csv\"}\n end\n end",
"def index\n @pend_crates = Overview.get_pending_crates \n @paid_crates = Overview.get_last_paid_crates \n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render :json => @crates }\n end\n end",
"def index\n @c14s = C14.includes(\n {sample: [\n :material,\n :taxon,\n :context\n ]},\n :references\n )\n\n # filter\n unless c14_params.blank?\n @c14s = @c14s.where(c14_params)\n end\n\n # order\n if params.has_key?(:c14s_order_by)\n order = { params[:c14s_order_by] => params.fetch(:c14s_order, \"asc\") }\n @c14s = @c14s.reorder(order)\n end\n\n respond_to do |format|\n format.html {\n @pagy, @c14s = pagy(@c14s)\n }\n format.json\n format.csv {\n @c14s = @c14s.select(index_csv_template)\n render csv: @c14s\n }\n end\n end",
"def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end",
"def index\n @curriculum_vitaes = findable_curriculum_vitaes.all\n respond_to do |format|\n format.html {}\n format.json { render json: @curriculum_vitaes }\n end\n end",
"def index\n respond_to do |format|\n format.html { @chefs = Chef.all }\n format.json { @chefs = Chef.order(:name) }\n end\n end",
"def index\n @matrix = CourseMatrix.find(params[:course_matrix_id])\n @matrix_disciplines = MatrixDiscipline.where(:matrix_id => @matrix.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @matrix_disciplines }\n end\n end",
"def index\n @cities = City.all\n\n render json: @cities\n end",
"def index\n @disciplines = Discipline.all\n #respond_to do |format|\n # format.json { render json: @disciplines, status: :ok }\n #end\n #render json: @disciplines, status: :ok\n respond_with @disciplines\n end",
"def index\n @commemts = Commemt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commemts }\n end\n end",
"def get_subject_by_curricular_line\n @subjects = Subject.get_by_career(params[:career_id],params[:cl_id])\n render :json => @subjects\n end",
"def index\n #chart = Chart.find(params[:chart_id])\n chart = Chart.where(\"id = ? AND user_id = ?\", params[:chart_id], current_user.id).limit(1)[0]\n data_sets = chart.data_sets.all\n\n respond_with(data_sets) do |format|\n \t#response string in specified format\n format.json { render json: { success: true, data_sets: data_sets } }\n end\n end",
"def index\n @opttrucks = Opttruck.all\n @shortopttrucks = Opttruck.first(100)\n \n respond_to do |format|\n format.html \n format.json\n format.csv { send_data @opttrucks.to_csv }\n\n end\n end",
"def index\n @historicals = @project.historical\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @historicals }\n end\n end",
"def render_csv_fileset_response( filesets )\n @records = filesets\n headers['Content-Disposition'] = 'attachment; filename=\"fileset-list.csv\"'\n headers['Content-Type'] ||= 'text/csv'\n render 'csv/v1/filesets'\n end",
"def show\n respond_to do |format|\n format.html\n format.csv { send_data @plate.to_csv, filename: \"plate-#{@plate.uid}.csv\" }\n format.json\n end\n end",
"def index\n @criminal_codes = CriminalCode.includes(:translations).order(:name)\n\n respond_to do |format|\n format.html\n format.csv do\n send_data CriminalCode.to_csv,\n filename: GeneratedFile.clean_filename('criminal_codes', 'csv'),\n type: 'text/csv'\n end\n end\n end",
"def index\n if index_params.present?\n @complaints = Complaint.where(status: index_params[:filter], customer_id: current_user.customer_id)\n else\n @complaints = Complaint.all\n end\n render json: @complaints, status: 200\n end",
"def index\n @samples = Sample.approved_or_rejected.page(params[:page]).per(100)\n respond_to do |format|\n format.html\n format.csv do\n render_csv\n end\n end\n end",
"def index\n @file_versions = FileVersion.all\n\n render json: @file_versions\n end",
"def index\n @student_sources = StudentSource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @student_sources }\n end\n end",
"def new\n @csv = Csv.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @csv }\n end\n end",
"def index\n # Check for filters\n @courses = Course.getCourseInformation(params[:dept],params[:course])\n @page_title = \"Browse Courses\"\n respond_to do |format|\n format.html\n format.json {render json: @courses }\n end\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def index\n authorize Contrato\n @contratos = Contrato.all\n respond_to do |format|\n format.html\n format.csv {render text: @contratos.to_csv }\n end\n end",
"def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def index\n @disciplines = @course.disciplines.latest_versions\n @disciplines = @disciplines.where_code_or_name(params[:term]) if params[:term]\n @disciplines = @disciplines.paginate :page => params[:page] \n \n respond_with @disciplines\n end",
"def show\n puts params[:id]\n @file_versions = FileVersion.where(versioned_file_id: params[:id]) \n #@file_versions = FileVersion.find(:versioned_file_id => params[:versioned_file_id])\n render json: @file_versions\n end",
"def index\n @airports = Airport.paginate(:page => params[:page], :per_page => 30)\n \n respond_to do |format|\n format.html { }\n format.csv { send_data @airports.to_csv }\n format.json { render json: @airports }\n end\n end",
"def index\n render jsonapi: Seances::UseCases::FetchAll.new.call\n end",
"def index\n respond_to do |format|\n format.html do\n @recent_objects = Extract.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)\n render '/shared/data/all/index'\n end\n format.json {\n @extracts = Queries::Extract::Filter\n .new(params).all\n .where(project_id: sessions_current_project_id)\n .page(params[:page]).per(params[:per])\n }\n end\n end",
"def index\n @svc_criteria = SvcCriterium.all.paginate(page: params[:page])\n respond_to do |format|\n format.html\n format.js\n format.csv { send_data SvcCriterium.as_csv }\n end\n end",
"def index\n @clinician_orders = ClinicianOrder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clinician_orders }\n end\n end",
"def index\n respond_to do |format|\n format.html {\n @recent_objects = DataAttribute.where(project_id: sessions_current_project_id).order(updated_at: :desc).limit(10)\n render '/shared/data/all/index'\n }\n format.json {\n @data_attributes = Queries::DataAttribute::Filter.new(params).all\n .page(params[:page])\n .per(params[:per])\n }\n end\n end",
"def index\n @boxes = Box.order('id DESC').paginate(page: params[:page], per_page: 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxes }\n format.csv { render csv: boxes_scoped, filename: \"Cajas #{Date.today}\" }\n end\n end",
"def index\n @applics=KofstApplic.limit(100).order(\"id\")\n authorize! :index, @applics\n respond_to do |format|\n format.html\n format.csv { render text: @applics.to_csv }\n format.xls #{ send_data @applics.to_csv(col_sep: \"\\t\") }\n end\n end",
"def data\n \tif request.method == \"GET\"\n\t\t\t#This is tmp path for testing\n\t\t\t#csvfile = Rails.root + \"CSV/bksvfr_calldetails_master.csv\"\n\n\t\t\t# csv file path .\n\t\t\tcsvfile = $csv\n\t\t\tlines = CSV.open(csvfile).readlines\n\t\t\t# Remove the first line from the csv file, because it is in index details\n\t\t\t# So we don't need those details\n\t\t\tkeys = lines.delete lines.first\n\t\t\t# conver csv to json.\n \t\t\tjsondata = JSON.pretty_generate(lines)\n \t render json: jsondata\n\t\t\t\n \tend\n\tend",
"def index\n @customers = Customer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end",
"def index\n \tcustomers = Customer.all\n \trender json: customers\n \tend",
"def index\n @clientes = filter(params[:filter]) || Cliente.includes(:plano, :atividades, historicos: [:status_transacao_pag_seguro]).all # Cliente.all\n \n respond_to do |format|\n format.html # show index.html.erb\n format.csv { send_data @clientes.to_csv }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: CustomersDatatable.new(view_context) }\n end\n @customers = Customer.all\n end",
"def index\n @journal_imports = JournalImport.all\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render :json => @journal_imports }\n format.json { render :json => JournalImportDatatable.new(view_context,@company)}\n end\n end",
"def index\n if params[:format] == 'csv'\n headers.merge!({\n 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',\n 'Content-Type' => 'text/csv',\n 'Content-Disposition' => \"attachment; filename=\\\"data.csv\\\"\",\n 'Content-Transfer-Encoding' => 'binary'\n })\n @column_names, @column_spans = get_csv_columns\n end\n if params[:id].blank?\n @roles = get_roles\n else\n @roles = [get_role]\n end\n respond_with @event, @roles\n end",
"def index\n @dev_folios = DevFolio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dev_folios }\n end\n end",
"def index\n @labor_cost_lines = LaborCostLine.scoped\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @labor_cost_lines }\n end\n end",
"def creditCardIndex\n render json: Approved.allCreditCard\n end",
"def index\n @goldmeasures = Goldmeasure.all\n\n respond_to do |format|\n format.html \n format.json\n format.csv { send_data @goldmeasures.to_csv }\n\n end\n end",
"def index\n @course_statuses = CourseStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @course_statuses }\n end\n end",
"def index\n @api_calls = ApiCall.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(per_page: 10,page: params[:page])\n @api_calls_temp = ApiCall.search(params[:search]).order(sort_column + \" \" + sort_direction)\n puts @api_calls\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_calls }\n format.csv { send_data @api_calls_temp.to_csv(session[:user_id].to_s ) }\n format.xls #{ send_data @api_calls.to_csv(col_sep: \"\\t\")}\n format.js\n\n end\n end"
] | [
"0.63668716",
"0.6155676",
"0.6155676",
"0.61290824",
"0.60915947",
"0.6022015",
"0.60146636",
"0.58855855",
"0.58855855",
"0.5880981",
"0.58800197",
"0.58443105",
"0.58388346",
"0.5824022",
"0.5795927",
"0.5789033",
"0.57780397",
"0.57641226",
"0.57558507",
"0.5744086",
"0.57430845",
"0.573545",
"0.5702605",
"0.56923926",
"0.5690077",
"0.5681584",
"0.5681392",
"0.5676035",
"0.5634095",
"0.561453",
"0.5608948",
"0.56075895",
"0.5604623",
"0.5603311",
"0.56014866",
"0.55939513",
"0.5589874",
"0.55849653",
"0.5582479",
"0.5572104",
"0.5571974",
"0.5571917",
"0.55694336",
"0.5566497",
"0.556166",
"0.55558044",
"0.55479074",
"0.5547178",
"0.55463356",
"0.55453855",
"0.5544623",
"0.5542198",
"0.55396056",
"0.55353343",
"0.55263203",
"0.5519366",
"0.55181193",
"0.55151",
"0.5512028",
"0.5503369",
"0.54986864",
"0.54919845",
"0.54915124",
"0.54870594",
"0.54855204",
"0.5473896",
"0.5473789",
"0.5473023",
"0.54712266",
"0.5469567",
"0.54694194",
"0.5467666",
"0.5461422",
"0.54583895",
"0.54542696",
"0.5450916",
"0.54481584",
"0.5443873",
"0.54431844",
"0.5436586",
"0.54364526",
"0.5433122",
"0.54259145",
"0.5422337",
"0.54217535",
"0.5419099",
"0.541811",
"0.5415845",
"0.5412804",
"0.54112077",
"0.54110515",
"0.5408241",
"0.5407906",
"0.5402532",
"0.5398618",
"0.5393708",
"0.5393016",
"0.5392552",
"0.5392546",
"0.5390782",
"0.5387768"
] | 0.0 | -1 |
POST /my_cvs POST /my_cvs.json | def create
@my_cv = MyCv.new(my_cv_params)
respond_to do |format|
if @my_cv.save
format.html { redirect_to @my_cv, notice: 'My cv was successfully created.' }
format.json { render :show, status: :created, location: @my_cv }
else
format.html { render :new }
format.json { render json: @my_cv.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postEntityBulkCsv( filedata)\n params = Hash.new\n params['filedata'] = filedata\n return doCurl(\"post\",\"/entity/bulk/csv\",params)\n end",
"def export\n headers = JSON[params[:column_array]]\n rows = JSON[params[:row_array]]\n column_names = Array.new\n headers.each do |col|\n column_names << col\n end\n csv_string = CSV.generate do |csv|\n csv << column_names\n rows.each do |row|\n csv << row\n end\n end\n\n filename = params[:file_name] + \".csv\"\n send_data(csv_string,\n :type => 'text/csv; charset=utf-8; header=present',\n :filename => filename)\n end",
"def create\n @data_collection = DataCollection.new\n @data_collection.name = params[:data_collection][:name]\n @data_collection.description = params[:data_collection][:description]\n @data_collection.institution = params[:data_collection][:institution]\n @data_collection.collection_name = params[:data_collection][:collection_name]\n @data_collection.country_id = params[:data_collection][:country_id]\n @data_collection.province_id = params[:data_collection][:province_id]\n @data_collection.city_id = params[:data_collection][:city_id]\n\n params[:categories].each do |category|\n\n collection_category = DataCollectionCategory.new\n collection_category.data_collection = @data_collection\n collection_category.category_id = category\n collection_category.save\n\n end\n\n respond_to do |format|\n if @data_collection.save\n format.html { redirect_to importador_csv_path (@data_collection.id), notice: 'Data collection was successfully created.' }\n format.json { render action: 'show', status: :created, location: @data_collection, params:data_collection_params }\n else\n format.html { render action: 'new' }\n format.json { render json: @data_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @transects = Transect.all.order(transect_code: :asc)\n respond_to do |format|\n format.html\n format.json\n format.csv {send_data @transects.to_csv,\n filename: \"transects-#{Date.today}.csv\"}\n end\n end",
"def download_csv\n query = params[:query]\n company_id = params[:company_id]\n file = Operation.create_csv(query, company_id) \n send_file file\n end",
"def submit_report(json, cookbookname)\n data = File.read(json)\n uri = URI.parse($SPEC_ENDPOINT)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(\"/api/reports\")\n request.add_field('Content-Type', 'application/json')\n request.body = {\n :spec_result => data,\n :hostname => `hostname`.chomp,\n :cookbook_name => cookbookname\n }.to_json\n response = http.request(request)\n end",
"def index\n @sample_sheet = SampleSheet.find(params[:sample_sheet_id])\n @sample_rows = @sample_sheet.sample_rows.all\n \n respond_to do |format|\n format.html\n format.json { render :json => @sample_sheet.sample_rows.map(&:attributes) }\n format.csv { send_data @sample_rows.to_csv, :filename => 'sample_sheet.csv' }\n \n end\n end",
"def new\n @csv = Csv.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @csv }\n end\n end",
"def upload_csv\n datafile = params['csv-file']\n begin\n response = Request.post_request(URL_QUESTION, {\n questions: parse_json(datafile['tempfile'])\n })\n rescue\n redirect '/upload-csv'\n end\n @questions = []\n if response.success?\n data = Request.manage_response(response)\n data.each do |question|\n @questions << Question.new(question)\n end\n erb :table, layout: :session\n end\nend",
"def measurements_request_csv_post(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: MeasurementApi#measurements_request_csv_post ...\"\n end\n \n # resource path\n path = \"/measurements/request_csv\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\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 = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:POST, 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 => 'Integer')\n if Configuration.debugging\n Configuration.logger.debug \"API called: MeasurementApi#measurements_request_csv_post. Result: #{result.inspect}\"\n end\n return result\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def index\n @svc_criteria = SvcCriterium.all.paginate(page: params[:page])\n respond_to do |format|\n format.html\n format.js\n format.csv { send_data SvcCriterium.as_csv }\n end\n end",
"def create\n @bank_transactions = []\n\n lines = Base64.decode64 params[:file].sub('data:text/csv;base64,','')\n transactions = lines.split(\"\\n\").reverse\n\n transactions.each do |transaction|\n transaction = transaction.split(\",\")\n time = DateTime.strptime(transaction[0], '%Y-%m-%d')\n puts transaction[0]\n @bank_transactions << BankTransaction.create(description: transaction[1], amount: transaction[2], created_at: time, updated_at: time)\n end\n\n respond_to do |format|\n format.html\n format.json { render json: @bank_transactions, callback: params[:callback] }\n format.xml { render xml: @bank_transactions }\n end\n end",
"def index\n @cruise = Cruise.find(params[:cruise_id])\n @observations = @cruise.observations.order(observed_at: :desc).accessible_by(current_ability)\n \n \n \n respond_to do |format|\n format.csv { send_data build_csv, filename: \"observations-#{@cruise.id}.csv\"}\n format.json { send_data build_json, filename: \"observations-#{@cruise.id}.json\"}\n format.geojson { send_data build_geojson, filename: \"observations-#{@cruise.id}.geojson\"}\n format.sigrid3\n end\n end",
"def chart_data\n\t# This is a a reference to the file so that it can be read\n\t@data = File.new(\"./public/data/clean_train.csv\", \"r\")\n\n\t# Initializes a CSV representation for Ruby\n\t@csv = CSV.new(@data, :headers => true, :converters => :all)\n\n\t# Parses the CSV to the @accounts_to_create array as JSON object\n\[email protected]_a.map {|row| ret = row.to_hash; ret.delete(ret.keys.first); ret.slice(\"Overall Qual\",\"Year Built\",\"Overall Cond\", \"SalePrice\",\"Year Remod/Add\", \"Yr Sold\") }.to_json\nend",
"def post_csv(path, csv)\n file = Tempfile.new(['dotmailer-contacts', '.csv'])\n file.write csv\n file.rewind\n\n post path, :csv => file\n end",
"def create\n data = \"date,r,s\\r\\n\"+params[:data]\n csv = CSV.new(data, :headers => true, :header_converters => :symbol, :converters => :all)\n\n h = csv.to_a.map {|row| row.to_hash }\n\n h.each do |e|\n t = Traffic.find_by date:e[:date]\n if t!=nil \n t.delete \n end\n Traffic.create(e)\n end\n\n @traffics = Traffic.all\n render \"index\"\n end",
"def create\n @livingexpense = Livingexpense.new(params[:livingexpense])\n a=['City','Country Name','Food Cost','Accomodation Cost','Transportation Cost','User Email']\n b=[params[:livingexpense][:City],params[:livingexpense][:Country_name],params[:livingexpense][:FoodCost],params[:livingexpense][:AccomodationCost],params[:livingexpense][:TransportationCost],params[:livingexpense][:UserID]]\n \n respond_to do |format|\n if Writetocsv.writedata(a,b)\n format.html { redirect_to @livingexpense, notice: 'Thanks for your feedback!' }\n format.json { render json: @livingexpense, status: :created, location: @livingexpense }\n else\n format.html { render action: \"new\" }\n format.json { render json: @livingexpense.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @clips = Clip.order(params[:sort])\n respond_to do |wants|\n wants.html\n wants.csv do\n csv_string = FasterCSV.generate do |csv|\n # header row\n csv << [\"Name\", \"File Size in Bytes\", \"Running Time\", \"Resolution\", \"Notes\", \"MD5 Source\", \"MD5 Destination\", \"Project ID\"]\n\n # data rows\n @clips.each do |clip|\n csv << [clip.clip_name, clip.size, (Time.mktime(0)+(clip.running_time || 0)).strftime(\"%Hh%Mm%Ss\"), clip.resolution, clip.notes, clip.md5source, clip.md5dest, clip.project_id]\n end\n end\n\n # send it to the browsah\n send_data csv_string,\n :type => 'text/csv; charset=iso-8859-1; header=present',\n :disposition => \"attachment; filename=clips.csv\"\n end\n end\n\n end",
"def postEntityBulkJson( data)\n params = Hash.new\n params['data'] = data\n return doCurl(\"post\",\"/entity/bulk/json\",params)\n end",
"def create\n @customer_set = CustomerSet.new\n\n unless params[:csv_file].nil?\n csv_file = params[:csv_file]\n records = CSV.parse(csv_file.read)\n \n records.each do |record|\n customer = Customer.new\n customer.company = Company.find(current_user.company.id)\n customer.first_name = record[0]\n customer.last_name = record[1]\n customer.email = record[2]\n customer.mobile_phone = record[3]\n customer.save\n\n @customer_set.customers << customer\n end\n else\n customer_inputs = params[:customers]\n \n customer_inputs.each do |customer_input|\n customer = Customer.new(customer_input)\n customer.company = Company.find(current_user.company.id)\n customer.save\n\n @customer_set.customers << customer\n end\n end\n\n respond_to do |format|\n if @customer_set.save\n format.html {\n flash[:notice] = I18n.t(:successfully_created, :model_name => CustomerSet.model_name.human)\n redirect_to controller: 'customers', action: 'multiple_new'\n }\n format.json {\n render :json => {\n status: :created,\n location: @customer_set\n }\n }\n else\n format.html {\n flash[:error] = I18n.t(:creation_failed, :model_name => CustomerSet.model_name.human)\n redirect_to controller: 'customers', action: 'multiple_new'\n }\n format.json { render json: @customer_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @csv_file = CsvFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @csv_file }\n end\n end",
"def index\n @example_inputs = ExampleInput.all\n\n respond_to do |format|\n format.html\n format.csv { send_data @example_inputs.to_csv(['purchaser name' , 'item description' , 'item price' , 'purchase count' , 'merchant address' , 'merchant name']) }\n end\n end",
"def convert\n agent = Mechanize.new\n data = agent.get(\"http://dataset1:8080/runs/bm_insurance_licenses_raw/latest\").body\n JSON.parse(data).each do |s|\n d = {\n sample_date: s[\"last_updated_at\"],\n company: {\n name: s[\"name\"],\n jurisdiction: \"bm\"\n },\n source_url: s[\"licence_url\"],\n data: [{\n data_type: :licence,\n properties: {\n category: 'Financial',\n jurisdiction_code: \"bm\",\n jurisdiction_classification: \"Insurance: #{s[\"licence_class\"]}\"\n }\n }]\n }\n puts JSON.dump(d).strip\n end\nend",
"def create\n\n # { clinic: {\"license_id\"=>nil, \"name\"=>string } }\n clinic = @license.clinics.new(params[:clinic])\n clinic.api_license = @api_license\n if clinic.save\n render json: clinic, status: :created\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def index\n @accounts = Account.all\n respond_to do |format|\n format.html \n format.json\n format.csv { send_data @accounts.to_csv, filename: \"accounts-#{Date.today}.csv\" }\n end\n end",
"def create\n @csv_filter = CsvFilter.new(csv_filter_params)\n binding.pry\n respond_to do |format|\n if @csv_filter.save\n format.html { redirect_to project_csv_type_csv_attribute_csv_filters_path(@csv_filter.csv_attribute.csv_type.project, @csv_filter.csv_attribute.csv_type, @csv_filter.csv_attribute), notice: 'Csv type was successfully created.' }\n format.json { render :show, status: :created, location: @csv_filter }\n else\n format.html { render :new }\n format.json { render json: @csv_filter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @vinyls = Vinyl.all\n respond_to do |format|\n format.html\n format.csv { send_data @vinyls.to_csv(['catalog','artist', 'title', 'label', 'format', 'rating', 'released', 'release_id', 'notes', 'date']) }\n end\n end",
"def render_csv_fileset_response( filesets )\n @records = filesets\n headers['Content-Disposition'] = 'attachment; filename=\"fileset-list.csv\"'\n headers['Content-Type'] ||= 'text/csv'\n render 'csv/v1/filesets'\n end",
"def index\n respond_to do |format|\n format.html{}\n format.pdf{\n scope = Case\n scope = case params[:status_type]\n when 'all' then scope.all_data\n when 'opened' then scope.opened\n when 'closed' then scope.closed\n when 'flagged' then scope.flagged\n else\n scope.opened\n end\n scope = scope.include_enumerations\n scope = if User.current.can?(:manage_roles)\n scope.where(assigned_to_id: User.current)\n else\n scope.visible\n end\n @cases = scope\n }\n format.csv{ params[:length] = 500\n options = Hash.new\n options[:status_type] = params[:status_type]\n json = CaseDatatable.new(view_context, options).as_json\n send_data Case.to_csv(json[:data]), filename: \"case-#{Date.today}.csv\"\n }\n format.json{\n options = Hash.new\n options[:subcases] = false\n options[:status_type] = params[:status_type]\n render json: CaseDatatable.new(view_context,options)\n }\n end\n end",
"def create\n selected_courses = []\n account_id = Account.find_by_name('Simon Fraser University').id\n username = params[:course_for]\n cross_list = params[:cross_list]\n params.each do |key, value|\n if key.to_s.starts_with? \"selected_course\"\n selected_courses.push value\n end\n end\n\n @course_csv = []\n @section_csv = []\n @enrollment_csv = []\n selected_courses.each do |course|\n # 20131:::ensc:::351:::d100:::Real Time and Embedded Systems\n course_info = course.split(\":::\")\n term = course_info[0]\n name = course_info[1]\n number = course_info[2]\n section = course_info[3]\n title = course_info[4]\n\n course_id = \"#{term}-#{name}-#{number}-#{section}:::course\"\n section_id = \"#{term}-#{name}-#{number}-#{section}:::section\"\n short_name = \"#{name.upcase}#{number} #{section.upcase}\"\n long_name = \"#{short_name} #{title}\"\n\n @course_csv.push \"#{course_id},#{short_name},#{long_name},#{account_id},active\"\n @section_csv.push \"#{section_id},#{course_id},#{section.upcase},active,,,\"\n @enrollment_csv.push \"#{course_id},#{username},teacher,#{section_id},active\"\n\n end\n\n end",
"def save\n if row_data[:id] == 0\n row = Vh.new\n else\n row = Vh.find(row_data[:id])\n end\n\n row.name = row_data[:name]\n row.exp1_type = row_data[:exp1_type]\n row.exp1_value = row_data[:exp1_value]\n row.exp2_type = row_data[:exp2_type]\n row.exp2_value = row_data[:exp2_value]\n row.condition = row_data[:condition]\n row.save\n\n render json: {\n data: Vh.all\n }\n end",
"def test_csv_export\n get :export\n assert_response :success\n end",
"def multiple_new\n @customer_set = CustomerSet.new\n\n respond_to do |format|\n format.html # multiple_new.html.erb\n format.json { render json: @customer_set }\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html\n format.json {render json: @students, each_serializer: StudentSerializer, include: '**'}\n format.csv {send_data to_csv, filename:\"Student_data.csv\"}\n end\n end",
"def index\n @surveys = Survey.all\n\n respond_to do |format|\n format.html\n #format.csv { send_data @surveys.to_csv }\n end\n end",
"def create\n skip_authorization\n if !params[:from] && !params[:from]\n records = Record.where(:user_id => @current_user.id)\n else\n records = Record.where(\"user_id = ? and created_at >= ? and created_at <= ?\", @current_user.id, params[:from], params[:to])\n end\n\n records = records.select(\"date(created_at) as created_date, sum(distance) as distance,sum(time) as time,(sum(distance) / sum(time)) as average_speed\").group(\"created_date\")\n @filename = \"report-#{Date.today}.csv\"\n attributes = %w{created_date distance time}\n csvfile = CSV.generate(headers: true) do |csv|\n csv << attributes\n\n records.each do |data|\n csv << attributes.map{ |attr| data.send(attr)}\n end\n end\n\n render json:{ csvdata: csvfile}\n end",
"def create\n @scheme = Scheme.new(params[:scheme])\n\n respond_to do |format|\n if @scheme.save\n if @scheme.from_file == true\n #TODO: Get this working right depending on file extension\n if @scheme.json_scaffold.content_type == \"application/octet-stream\"\n\t\t\t@file = File.read(@scheme.json_scaffold.path)\n\t\t\t@json_scaffold = JSON.parse(@file)\n\t\t\tputs @json_scaffold.inspect\n\t\t\[email protected] = @json_scaffold[\"collectionname\"]\n\t\t\t@json_scaffold[\"columns\"].each do |col|\n\t\t\t puts col.to_hash.with_indifferent_access\n\t\t\t begin\n\t\t\t @scheme.schemer_columns.create!(col.to_hash.symbolize_keys)\n\t\t\t rescue Exception => e\n\t\t\t\tputs e.to_s\n\t\t\t end\n\t\t\tend\n\t\t\[email protected]\n\t\t elsif @scheme.json_scaffold.content_type == \"text/csv\"\n\t\t @file = File.read(@scheme.json_scaffold.path)\n\t\t begin\n\t\t csv = CSV.parse(@file, :headers => true)\n\t\t rescue Exception => e\n\t\t puts e.to_s\n\t\t end\n\t\t unless csv.nil?\n\t\t\t csv.each do |row|\n\t\t\t row = row.to_hash.with_indifferent_access\n\t\t\t @row_hash = row.to_hash.symbolize_keys\n\t\t\t puts @row_hash\n\t\t\t @scheme.collectionname = @row_hash[\"dataset\"]\n\t\t\t begin\n\t\t\t\t @scheme.schemer_columns.create!(row.to_hash.symbolize_keys)\n\t\t\t rescue Exception => e\n\t\t\t\t puts e.to_s\n\t\t\t end\n\t\t\t end\n\t\t end\n\t\t @scheme.save\n\t\t else\n\t\t #TODO: Txt/CSV, XML\n\t\t end\n\t\tend\n format.html { redirect_to @scheme, notice: 'Scheme was successfully created.' }\n format.json { render json: @scheme, status: :created, location: @scheme }\n else\n format.html { render action: \"new\" }\n format.json { render json: @scheme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_dataset(name, description, columns)\n authenticate unless authenticated?\n payload = {\n name: name,\n description: description,\n }\n schema = {columns: []}\n columns.each { |col| schema[:columns].push(col) }\n payload[:schema] = schema\n response = RestClient::Request.execute(\n url: @@datasets_endpoint,\n method: :post,\n headers: headers('application/json'),\n payload: JSON.generate(payload)\n )\n return JSON.parse(response.body)\n end",
"def index\n @schools = School.filter(params.slice(:City, :State, :Zip, :District, :Region))\n respond_to do |format|\n format.html\n format.csv { send_data @schools.to_csv }\n end\n end",
"def collection_to_csv(filepaths, csv_name)\n output_file = CSV.open(csv_name, \"w\")\n header = JSON.parse!(File.read(filepaths[0])).keys\n output_file << header\n\n filepaths.each do |path|\n data = JSON.parse!(File.read(path))\n output_file << data.values\n end\nend",
"def create\n @csv_attribute = CsvAttribute.new(csv_attribute_params)\n\n respond_to do |format|\n if @csv_attribute.save\n format.html { redirect_to project_csv_type_csv_attributes_path(@csv_attribute.csv_type.project, @csv_attribute.csv_type), notice: 'Csv type was successfully created.' }\n\n format.json { render :show, status: :created, location: @csv_attribute }\n else\n format.html { render :new }\n format.json { render json: @csv_attribute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @data_set = DataSet.new(params[:data_set])\n\n respond_to do |format|\n if @data_set.save\n format.html { redirect_to @data_set, notice: 'Project data set was successfully created.' }\n format.json { render json: @data_set.to_hash(false), status: :created, location: @data_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @data_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @recoleccions = Recoleccion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recoleccions }\n format.csv { send_data @recoleccions.to_csv }\n end\n end",
"def v2_measurements_request_csv_post_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MeasurementsApi.v2_measurements_request_csv_post ...\"\n end\n # resource path\n local_var_path = \"/v2/measurements/request_csv\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\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 = ['quantimodo_oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Integer')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MeasurementsApi#v2_measurements_request_csv_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end",
"def index\n @airports = Airport.paginate(:page => params[:page], :per_page => 30)\n \n respond_to do |format|\n format.html { }\n format.csv { send_data @airports.to_csv }\n format.json { render json: @airports }\n end\n end",
"def import_data\n @formatted_data = []\n @customers.shift\n @customers.each do |customer|\n customer_data = {\n name: \"#{customer[0]} #{customer[1]}\",\n emails: [\n {\n type: \"\",\n email: customer[2]\n }\n ],\n phones: [\n {\n type: @home_phone_type,\n phone: customer[4]\n },\n {\n type: @work_phone_type,\n phone: customer[5]\n }\n ],\n type: customer[6],\n birthdayAt: customer[3]\n # socials: [\n # {\n # type: \"\",\n # userid: \"\",\n # username: \"\",\n # url: \"\"\n # }\n # ],\n # urls: [\n # {\n # url: \"\"\n # }\n # ],\n # locations: [\n # {\n # type: \"\",\n # address: \"\"\n # }\n # ],\n # locale: \"\",\n # gender: \"\",\n # tags: [\n # ]\n }\n # p @formatted_data << JSON.pretty_generate(customer_data)\n\n @formatted_data << customer_data\n end\n File.open(\"data.json\",\"w\") do |f|\n f.write(@formatted_data.to_json)\n end\n File.open(\"nojsondata.json\",\"w\") do |f|\n f.write(@formatted_data)\n end\n end",
"def index\n @items = Item.all\n respond_to do |format|\n format.html\n format.csv { send_data @items.to_csv }\n format.xls\n format.json\n end\n end",
"def main()\n request_url = \"#{$canvas_url}/api/v1/users/#{$canvas_user_id}/page_views?per_page=100&start_time=#{$start_time}&end_time=#{$end_time}\"\n method = \"get\"\n options = {}\n data = canvasApiRequest(method,request_url,options)\n compiledHash = []\n data.each do |hash|\n hashData = flattenHash(hash)\n compiledHash.push(hashData)\n end\n outputToCSV(compiledHash)\nend",
"def index\n # @nfl_teams = NflTeam.all\n @afc = NflTeam.afc\n @nfc = NflTeam.nfc\n @all_teams = NflTeam.order(:city)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nfl_teams }\n format.csv { send_data @all_teams.to_csv }\n end\n end",
"def create_batch\n all_months.each do |month|\n cash_flow = find_or_build_cash_flow(month, @category.id)\n\n cash_flow.planned = cash_flow_params[:value]\n cash_flow.save!\n end\n\n render json: { success: true }, status: :created\n end",
"def test_list_csv\n get :index, :format => 'csv'\n assert_response_csv\n end",
"def index\n @midsurveys = Midsurvey.all\n respond_to do |format|\n format.html\n format.csv { send_data @midsurveys.to_csv }\n end\n end",
"def index\n @conditions = Condition.all.order(created_at: :desc)\n respond_to do |format|\n format.html\n format.csv do\n headers['Content-Disposition'] = \"attachment; filename=\\\"condition-list.csv\\\"\"\n headers['Content-Type'] ||= 'text/csv'\n end\n end \n end",
"def index\n @user_studies = UserStudy.all\n \n respond_to do |format|\n format.html\n format.csv { send_data @user_studies.to_csv }\n end\n end",
"def index\n @patrons = Patron.order(sort_column + \" \" + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @patrons }\n format.csv { send_data @patrons.to_csv(force_quotes: true) }\n end\n end",
"def export\n send_data current_user.records.select(:json).order('updated_at desc').collect(&:json).to_json, filename: 'records.json'\n end",
"def index\n @submissions = Submission.all\n respond_to do |format|\n format.html\n format.csv { send_data @submissions.as_csv }\n format.xls { send_data @submissions.as_csv(col_sep: \"\\t\") }\n end\n end",
"def index\n @goldmeasures = Goldmeasure.all\n\n respond_to do |format|\n format.html \n format.json\n format.csv { send_data @goldmeasures.to_csv }\n\n end\n end",
"def index\n respond_to do |format|\n format.html{ redirect_to medical_record_path + \"#tabs-surgical\" }\n format.js{ render 'application/index' }\n format.pdf{}\n format.csv{ params[:length] = 500\n options = Hash.new\n options[:status_type] = params[:status_type]\n json = SurgeryDatatable.new(view_context, options).as_json\n send_data Surgical.to_csv(json[:data]), filename: \"surgical-#{Date.today}.csv\"\n }\n format.json{\n options = Hash.new\n options[:status_type] = params[:status_type]\n render json: SurgeryDatatable.new(view_context,options)\n }\n end\n end",
"def index\n @smallsurveys = Smallsurvey.all\n respond_to do |format|\n format.html\n format.csv { send_data @smallsurveys.to_csv }\n end\n end",
"def index\n @csv_files = CsvFile.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @csv_files }\n end\n end",
"def to_csv_dash_data\n @grant_data = dash_data_create\n respond_to do |format|\n format.html\n format.csv do\n send_data @grant_data, filename: \"all_dashboard_data#{Time.now.to_s(:db)}.csv\"\n end\n # format.CSV {render csv: @grant_data.to_csv}\n # format.xls {render text: @grant_data.to_csv(col_sep: \"\\t\")}\n end\n end",
"def index\n respond_to do |format|\n format.html{ redirect_to socioeconomic_record_path + \"#tabs-socioeconomic\" }\n format.js{ render 'application/index' }\n format.pdf{}\n format.csv{ params[:length] = 500\n options = Hash.new\n options[:status_type] = params[:status_type]\n json = SocioeconomicDatatable.new(view_context, options).as_json\n send_data Socioeconomic.to_csv(json[:data]), filename: \"socioeconimic-#{Date.today}.csv\"\n }\n format.json{\n options = Hash.new\n options[:status_type] = params[:status_type]\n render json: SocioeconomicDatatable.new(view_context,options)\n }\n end\n end",
"def create\n unless params[:voucher][:voucher_rows_attributes].present?\n params[:voucher][:voucher_rows_attributes] = params[:voucher_rows_attributes]\n end\n @voucher = Voucher.new(voucher_params)\n @voucher.fiscal_year = current_user.companies.find(params[:company_id]).fiscal_years.find(params[:fiscal_year_id])\n\n respond_to do |format|\n if @voucher.save\n format.html { redirect_to @voucher, notice: 'Voucher was successfully created.' }\n format.json { render action: 'show', status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @voucher.errors, status: :unprocessable_entity }\n end\n end\n end",
"def export(params={})\n columns = delimited_string_to_array(Settings.export.travel_fields)\n send_data Travel.export(columns), :filename => \"travel.csv\"\n end",
"def index\n @datatable = InventoryMovementsDatatable.new\n respond_to do |format|\n format.html\n format.csv do\n day_before_start_date = (@imr_start_date <= @initial_date) ? DateTime.now.end_of_day : (@imr_start_date.to_datetime - 1.day).end_of_day\n ekanek = Organisation::EKANEK_ORG\n a3m = Organisation::A3M_ORG\n params[:organisation_id] = params[:organisation_id].to_i\n\n # \"Brand Name\", \"Brand Owner\", \"Item Name\", \"Item Type\", \"MRP\", \"GWP/Surprise\"\n brand_name_hash, brand_owner_hash, name_hash, item_type_hash, mrp_hash, gwp_surprise_hash = Sku.create_item_detail_hashes\n\n # Opening Stock\n organisation_ids = params[:organisation_id] == 0 ? [ekanek.id, a3m.id] : params[:organisation_id]\n opening_stock_quantity_hash, opening_stock_value_hash = InventoryItem.create_opening_stock_hashes(day_before_start_date, organisation_ids)\n\n organisation_ids = (params[:organisation_id].in? [0, ekanek.id]) ? [ekanek.id, a3m.id] : params[:organisation_id]\n # Total Purchase = 1. Putaway GRN Items\n sku_purchased_quantity_hash, sku_purchased_value_hash = InventoryItem.create_purchased_hashes(@imr_start_date, @imr_end_date, organisation_ids)\n # Bad purchase = 1. Putaway GRN Items Bad\n sku_bad_qty_purchased_hash, sku_bad_value_purchased_hash = InventoryItem.create_bad_purchased_hashes(@imr_start_date, @imr_end_date, organisation_ids)\n\n organisation_id = params[:organisation_id] == 0 ? a3m.id : params[:organisation_id]\n # 2. Putaway Returned by Customers\n sku_quantity_returned_by_customers_hash, sku_value_returned_by_customers_hash = InventoryItem.create_returned_by_customer_hashes(@imr_start_date, @imr_end_date, organisation_id)\n # 2. Putaway Returned by Customers Bad\n sku_qty_bad_stock_returned_by_customer_hash, sku_value_bad_stock_returned_by_customer_hash = InventoryItem.create_bad_returned_by_customer_hashes(@imr_start_date, @imr_end_date, organisation_id)\n # Sold\n sku_quantity_sold_hash, sku_value_sold_hash = InventoryItem.create_sold_hashes(@imr_start_date, @imr_end_date, organisation_id)\n\n # Gatepasses\n organisation_id = params[:organisation_id] == 0 ? ekanek.id : params[:organisation_id]\n sku_quantity_returned_to_vendor_hash, sku_value_returned_to_vendor_hash = InventoryItem.create_gatepass_reason_hashes(@imr_start_date, @imr_end_date, 'rtv', organisation_id)\n sku_self_consumed_quantity_hash, sku_self_consumed_value_hash = InventoryItem.create_gatepass_reason_hashes(@imr_start_date, @imr_end_date, 'self_consumption', organisation_id)\n sku_quantity_sent_for_brand_collabs_hash, sku_value_sent_for_brand_collabs_hash = InventoryItem.create_gatepass_reason_hashes(@imr_start_date, @imr_end_date, 'brand_collabs', organisation_id)\n sku_quantity_sent_to_agency_hash, sku_value_sent_to_agency_hash = InventoryItem.create_gatepass_reason_hashes(@imr_start_date, @imr_end_date, 'agency', organisation_id)\n sku_gift_quantity_hash, sku_gift_value_hash = InventoryItem.create_gatepass_reason_hashes(@imr_start_date, @imr_end_date, 'gift', organisation_id)\n sku_quantity_liquidated_hash, sku_value_liquidated_hash = InventoryItem.create_gatepass_reason_hashes(@imr_start_date, @imr_end_date, 'liquidation', organisation_id)\n sku_stock_transfer_quantity_hash, sku_stock_transfer_value_hash = InventoryItem.create_gatepass_reason_hashes(@imr_start_date, @imr_end_date, 'stock_transfer', organisation_id)\n # Bad Gatepasses\n sku_bad_qty_gatepass_hash, sku_bad_value_gatepass_hash = InventoryItem.create_bad_gatepass_hashes(@imr_start_date, @imr_end_date, organisation_id)\n # Blocked Qty\n sku_blocked_qty_hash = Inventory.create_sku_blocked_qty_hash\n\n require 'csv'\n filename = \n case params[:organisation_id].to_i\n when 0\n 'Consolidated-IMR.csv'\n when ekanek.id\n 'EkAnek-IMR.csv'\n when a3m.id\n 'A3M-IMR.csv'\n end\n\n CSV.open(\"#{filename}\", \"wb\") do |response_csv|\n response_csv << [\"SKU ID\", \"Brand Name\", \"Brand Owner\", \"Item Name\", \"Item Type\", \"MRP\", \"GWP/Surprise\", \"Opening Stock Qty\", \"Opening Stock Value\", \"Qty Purchased\", \"Value Purchased\",\n \"Qty Returned By Customer\", \"Value Returned By Customer\", \"Total Putaway Qty\", \"Total Putaway Value\",\n \"Qty Sold\", \"Value Sold\", \"Qty Returned to Vendor\", \"Value Returned to Vendor\", \"Qty Used for Self Consumption\",\n \"Value Used for Self Consumption\", \"Qty used for Brand Collabs\", \"Value used for Brand Collabs\", \"Qty sent to Agency\",\n \"Value sent to Agency\", \"Qty used as Gift\", \"Value used as Gift\", \"Qty Liquidated\", \"Value Liquidated\",\n \"Stock Transfer Qty\", \"Stock Transfer Value\", \"Gatepass Bad Qty\", \"Gatepass Bad Value\", \"Total Gatepass\", \"Total Gatepass Value\", \"Stock Adjustment\",\n \"Closing Stock Qty\", \"Closing Stock Value\" , \"Good Qty\", \"Good Qty Value\", \"Bad Qty\", \"Bad Qty Value\", \"Qty Blocked\"]\n\n skus = InventoryItem.pluck(:sku_id).uniq\n skus.each do |sku_id|\n report = []\n report << sku_id\n sku = Sku.find sku_id\n\n report << brand_name_hash[sku_id]\n report << brand_owner_hash[sku_id]\n report << name_hash[sku_id]\n report << item_type_hash[sku_id]\n report << mrp_hash[sku_id]\n report << gwp_surprise_hash[sku_id]\n\n opening_stock_quantity = (@imr_start_date <= @initial_date) ? 0 : opening_stock_quantity_hash[sku_id].to_i\n opening_stock_value = (@imr_start_date <= @initial_date) ? 0 : opening_stock_value_hash[sku_id].to_f\n report << opening_stock_quantity\n report << opening_stock_value\n report << sku_purchased_quantity_hash[sku_id].to_i\n report << sku_purchased_value_hash[sku_id].to_f\n report << sku_quantity_returned_by_customers_hash[sku_id].to_i\n report << sku_value_returned_by_customers_hash[sku_id].to_f\n total_putaway_qty = sku_purchased_quantity_hash[sku_id].to_i + sku_quantity_returned_by_customers_hash[sku_id].to_i\n total_putaway_value = sku_purchased_value_hash[sku_id].to_f + sku_value_returned_by_customers_hash[sku_id].to_f\n report << total_putaway_qty\n report << total_putaway_value\n report << sku_quantity_sold_hash[sku_id].to_i\n report << sku_value_sold_hash[sku_id].to_f\n report << sku_quantity_returned_to_vendor_hash[sku_id].to_i\n report << sku_value_returned_to_vendor_hash[sku_id].to_f\n report << sku_self_consumed_quantity_hash[sku_id].to_i\n report << sku_self_consumed_value_hash[sku_id].to_f\n report << sku_quantity_sent_for_brand_collabs_hash[sku_id].to_i\n report << sku_value_sent_for_brand_collabs_hash[sku_id].to_f\n report << sku_quantity_sent_to_agency_hash[sku_id].to_i\n report << sku_value_sent_to_agency_hash[sku_id].to_f\n report << sku_gift_quantity_hash[sku_id].to_i\n report << sku_gift_value_hash[sku_id].to_f\n report << sku_quantity_liquidated_hash[sku_id].to_i\n report << sku_value_liquidated_hash[sku_id].to_f\n report << sku_stock_transfer_quantity_hash[sku_id].to_i\n report << sku_stock_transfer_value_hash[sku_id].to_f\n report << sku_bad_qty_gatepass_hash[sku_id].to_i\n report << sku_bad_value_gatepass_hash[sku_id].to_f\n total_gp_qty = sku_quantity_returned_to_vendor_hash[sku_id].to_i +\n sku_self_consumed_quantity_hash[sku_id].to_i +\n sku_quantity_sent_for_brand_collabs_hash[sku_id].to_i +\n sku_quantity_sent_to_agency_hash[sku_id].to_i +\n sku_gift_quantity_hash[sku_id].to_i +\n sku_quantity_liquidated_hash[sku_id].to_i +\n sku_stock_transfer_quantity_hash[sku_id].to_i +\n sku_bad_qty_gatepass_hash[sku_id].to_i\n total_gp_value = sku_value_returned_to_vendor_hash[sku_id].to_f +\n sku_self_consumed_value_hash[sku_id].to_f +\n sku_value_sent_for_brand_collabs_hash[sku_id].to_f +\n sku_value_sent_to_agency_hash[sku_id].to_f +\n sku_gift_value_hash[sku_id].to_f +\n sku_value_liquidated_hash[sku_id].to_f +\n sku_stock_transfer_value_hash[sku_id].to_f +\n sku_bad_value_gatepass_hash[sku_id].to_f\n report << total_gp_qty\n report << total_gp_value\n report << 0 # stock adjustment 0 for now\n\n inwarded_quantity = total_putaway_qty\n inwarded_value = total_putaway_value\n\n outwarded_quantity = sku_quantity_sold_hash[sku_id].to_i + total_gp_qty\n outwarded_value = sku_value_sold_hash[sku_id].to_f + total_gp_value\n\n closing_stock_quantity = opening_stock_quantity + inwarded_quantity - outwarded_quantity\n closing_stock_value = opening_stock_value + inwarded_value - outwarded_value\n\n # total_bad = putaway_grn_bad + putaway_return_bad - gatepass_bad\n bad_qty = sku_bad_qty_purchased_hash[sku_id].to_i +\n sku_qty_bad_stock_returned_by_customer_hash[sku_id].to_i -\n sku_bad_qty_gatepass_hash[sku_id].to_i\n bad_stock_value = sku_bad_value_purchased_hash[sku_id].to_f +\n sku_value_bad_stock_returned_by_customer_hash[sku_id].to_f -\n sku_bad_value_gatepass_hash[sku_id].to_f\n\n good_qty = closing_stock_quantity - bad_qty\n good_stock_value = closing_stock_value - bad_stock_value\n\n report << closing_stock_quantity\n report << closing_stock_value\n report << good_qty\n report << good_stock_value\n report << bad_qty\n report << bad_stock_value\n report << sku_blocked_qty_hash[sku_id].to_i\n response_csv << report\n end\n\n send_file(\n \"#{filename}\",\n filename: \"#{filename}\",\n )\n end\n end\n end\n end",
"def index\n @students = Student.all\n respond_to do |format|\n format.html\n format.csv { send_data @students.to_csv }\n end\n end",
"def create\n if !params[:_json].blank?\n params[:_json] = JSON.parse params[:_json] if params[:_json].is_a? String\n \n #Routine de transformation en CSV\n json = params[:_json][0]\n headers = []\n values = []\n csv_string = CSV.generate do |csv|\n json.each do |key, value|\n if (!key.blank? && !value.blank? && value!=\"Autre\")\n #Exclusion de certain champs Limesurvey\n if !['id','Complété','Dernière page vue','Langue de départ', 'FusionQuestion', 'Code'].include?(key)\n #Nettoyage des champs du type \"champs [other]\"\n if key.include?(\" [other]\")\n #puts \"test [other]\"\n key = key.split(\" [other]\")[0] \n end\n headers << key\n values << value \n end\n end\n end\n csv << headers\n csv << values\n end\n \n @questionnaire = Questionnaire.new(params[:questionnaire])\n @questionnaire.content = csv_string\n profil_id, category_id = json['FusionQuestion'].to_s.split(\"/\")\n @questionnaire.profil = Profil.find(id=profil_id)\n @questionnaire.category = Category.find(id=category_id)\n end\n \n respond_to do |format|\n if @questionnaire.save\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully created.' }\n format.json { render json: @questionnaire, status: :created, location: @questionnaire }\n else\n format.html { render action: \"new\" }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def index\n @my_products = MyProduct.all\n respond_to do |format|\n format.html\n format.csv { send_data @my_products.to_csv(['product_id','name','price','description','specs','tags','permalink','position','cost','hts'])}\n end\n end",
"def index\n @pay_plans = PayPlan.all.paginate(page: params[:page])\n respond_to do |format|\n format.js\n format.csv { send_data PayPlan.as_csv }\n format.html\n end\n end",
"def genupload data\n CSV.open(\"update-data.csv\", \"wb\") do |csv|\n csv << @uhead\n data.each { |a| csv << a }\n end\nend",
"def csv\n claim_filter = ClaimFilter.new()\n claim_filter.restore_from_session(session,:claim_filter)\n claim_filter.organisation_id = params[:id].to_i\n\n content_type = ( request.user_agent =~ /windows/i ? 'application/vnd.ms-excel' : 'text/csv' )\n content = Claim.csv_by_filter(claim_filter)\n send_data(content,:type => content_type, :filename => 'claims.csv' )\n end",
"def index\n @backend_tutorial_stats = Backend::TutorialStat.order('created_at ASC')\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @backend_tutorial_stats }\n format.csv do\n backend_tutorial_stats = Backend::TutorialStat.order('created_at ASC')\n data = Backend::TutorialStat.download_tutorial_stats_csv(backend_tutorial_stats) \n filename = \"tutorial_stats#{Time.now.strftime(\"%Y%m%d%H%M%S\")}.csv\" \n send_data(data, :type => \"text/csv; charset=utf-8; header=present\", :filename => filename) \n end\n end \n end",
"def index\n tasks = Task.where(user_id: session[:user_id])\n @tasks = tasks.sort_by(&:created_at).reverse\n\n #binding.pry\n\n respond_to do |format|\n format.html\n format.csv { send_data as_csv(@tasks), filename: \"tasks-#{Date.today}.csv\" }\n end\n end",
"def postGroupBulk_ingest( group_id, filedata, category_type)\n params = Hash.new\n params['group_id'] = group_id\n params['filedata'] = filedata\n params['category_type'] = category_type\n return doCurl(\"post\",\"/group/bulk_ingest\",params)\n end",
"def data\n \tif request.method == \"GET\"\n\t\t\t#This is tmp path for testing\n\t\t\t#csvfile = Rails.root + \"CSV/bksvfr_calldetails_master.csv\"\n\n\t\t\t# csv file path .\n\t\t\tcsvfile = $csv\n\t\t\tlines = CSV.open(csvfile).readlines\n\t\t\t# Remove the first line from the csv file, because it is in index details\n\t\t\t# So we don't need those details\n\t\t\tkeys = lines.delete lines.first\n\t\t\t# conver csv to json.\n \t\t\tjsondata = JSON.pretty_generate(lines)\n \t render json: jsondata\n\t\t\t\n \tend\n\tend",
"def index\n use_secure_headers_override :headers_stats_index\n @project_stats = ProjectStat.all\n respond_to do |format|\n format.csv do\n headers['Content-Disposition'] =\n 'attachment; filename=\"project_stats.csv\"'\n render csv: @project_stats, filename: @project_stats.name\n end\n format.json\n # { render :show, status: :created, location: @project_stat }\n format.html\n end\n end",
"def datatables_editor_cud\n\t\tjson_data = MatchCategory.datatables_editor_cud(request.POST[:action], params[:data].to_a)\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: json_data }\n\t\tend\n\tend",
"def index\n if params[:format] == 'csv'\n headers.merge!({\n 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',\n 'Content-Type' => 'text/csv',\n 'Content-Disposition' => \"attachment; filename=\\\"data.csv\\\"\",\n 'Content-Transfer-Encoding' => 'binary'\n })\n @column_names, @column_spans = get_csv_columns\n end\n if params[:id].blank?\n @roles = get_roles\n else\n @roles = [get_role]\n end\n respond_with @event, @roles\n end",
"def create_team_member\n clinics = params[:clinics].split(\", \")\n\n team_member = TeamMember.create(\n email: params[:email],\n first_name: params[:first_name],\n last_name: params[:last_name],\n user: params[:user],\n status: \"Active\",\n role: params[:role]\n )\n\n clinics.each do |clinic|\n Clinic.find(clinic).team_members << team_member\n end\n\n render json: team_member, include: ['clinics']\n end",
"def index\n @initial_surveys = InitialSurvey.all\n respond_to do |format|\n format.html { render :action => \"index\" }\n format.csv { send_data InitialSurvey.to_csv(@initial_surveys) }\n end\n end",
"def index\n # @incidents = Incident.all.order(\"id desc\")\n @search = IncidentSearch.new(params[:search])\n @incidents = @search.scope.order('id desc')\n @incident = Incident.new\n @incidentcategory = Incidentcategory.all\n respond_to do |format|\n format.html\n format.csv { send_data @incidents.to_csv }\n format.xlsx { send_data @incidents.to_csv(col_sep: \"\\t\") }\n end\n @city = request.location.city\n end",
"def bulk_new\n @bulk_new = BulkNew.new\n\n respond_to do |format|\n format.html # bulk_new.html.erb\n format.json { render json: @bulk_new }\n end\n end",
"def index\n @pagetitle = \"Suppliers\"\n \n @companies = Company.all\n\n @path = 'suppliers'\n\n @suppliercsv = Supplier.all \n respond_to do |format|\n format.html\n format.csv { send_data @suppliercsv.to_csv }\n \n end\n\n\n end",
"def index\n @ocorrencias = Ocorrencia.all\n respond_to do |format|\n format.csv { send_data @ocorrencias.to_csv}\n format.html\n end\n end",
"def csv_report\n tire_cols = params[:tire] || {}\n ar_cols = params[:activerecord] || {}\n assocs_to_include = params[:assoc][:include] || {}\n params[:assoc][:max] ||= {}\n klass = model_class.constantize\n @filename = \"#{model_class.humanize}.csv\"\n\n response.headers['Content-Type'] ||= 'text/plain'\n response.headers['Content-Disposition'] = \"attachment; filename=#{@filename}\"\n response.headers['Content-Transfer-Encoding'] = 'binary'\n response.headers['Last-Modified'] = Time.now.to_s\n\n # Right, try to define a header:\n header = []\n tire_cols.keys.each { |x| header.push(x.humanize) }\n ar_cols.keys.each { |x| header.push(x.humanize) }\n assocs_to_include.keys.each do |assoc|\n if params[:assoc][:max][assoc] == 'join' # Is a has_many with only one real column\n header.push params[:assoc][assoc.to_sym].keys.first\n elsif params[:assoc][:max][assoc] # has_many\n (1 .. (params[:assoc][:max][assoc].to_i)).each do |i|\n params[:assoc][assoc.to_sym].keys.each do |k|\n header.push(\"#{assoc.singularize.humanize} #{i} #{k.humanize}\")\n end\n end\n else # has_a\n params[:assoc][assoc.to_sym].keys.each do |k| # Each key requested from the associated record\n header.push \"#{assoc.humanize} #{k.humanize}\"\n end\n end\n end\n\n results = klass.search({ per: TireSearch::INFINITY }, 1, '')\n self.response_body = Enumerator.new do |y|\n results.each_with_index do |result, i|\n y << header.to_csv if i == 0\n\n line = []\n tire_cols.keys.each { |x| line.push(result[x]) }\n\n result = result.load if ar_cols.count > 0 || assocs_to_include.keys.count > 0\n\n ar_cols.keys.each { |x| line.push(result.send(x)) } if ar_cols.count > 0\n\n assocs_to_include.keys.each do |assoc|\n related = result.send(assoc)\n if params[:assoc][:max][assoc] == 'join' # Is a has_many with only one real column\n col = params[:assoc][assoc.to_sym].keys.first\n line.push related.map { |x| x.send(col) }.join(' // ')\n elsif params[:assoc][:max][assoc]\n (0 .. (params[:assoc][:max][assoc].to_i - 1)).each do |j|\n params[:assoc][assoc.to_sym].keys.each do |k|\n line.push(related[j] ? related[j].send(k) : nil)\n end\n end\n else\n params[:assoc][assoc.to_sym].keys.each do |k| # Each key requested from the associated record\n line.push related ? related.send(k) : nil\n end\n end\n end\n y << line.to_csv\n GC.start if i % 500 == 0\n end\n end\n end",
"def create_csvs(csv_count)\n for num in 1..csv_count\n headers = filtered_schema_headers(num)\n CSV.open(\"data#{num}.csv\", \"w\",:write_headers => true, :headers => headers) do |csv|\n populate_csv(csv, headers)\n end\n end\n end",
"def index\n @case_studies = CaseStudy.order(:project_name => :asc)\n respond_to do |format|\n format.html {\n @grouped_case_studies = CaseStudy.group(:country).count\n @case_studies = @case_studies.where(\"LOWER(project_name)=?\", params[:q].downcase) if params[:q].present?\n }\n format.csv { send_data @case_studies.to_csv }\n end\n end",
"def create\n #chart = Chart.find(params[:chart_id])\n chart = Chart.where(\"id = ? AND user_id = ?\", params[:chart_id], current_user.id).limit(1)[0]\n data_set = chart.data_sets.new(params[:data_set])\n data_set.save\n\n respond_with(data_set) do |format|\n if data_set.valid?\n format.json { render json: { success: true, data_sets: data_set } }\n else\n format.json { render json: { success: false, errors: data_set.errors } }\n end\n end\n end",
"def index\n @cvs = Cv.all\n end",
"def index\n @cvs = Cv.all\n end",
"def index\n respond_to do |format|\n @people = Person.all\n format.html\n format.json { render json: PersonDatatable.new(params, view_context: view_context) }\n format.csv { send_data @people.to_csv(col_sep: ';'), filename: \"inscripciones-#{Date.today}.csv\" }\n end\n end",
"def create\n @cultivar = Cultivar.new(params[:cultivar])\n\n respond_to do |format|\n if @cultivar.save\n flash[:notice] = 'Cultivar was successfully created.'\n format.html { redirect_to(@cultivar) }\n format.xml { render :xml => @cultivar, :status => :created, :location => @cultivar }\n format.csv { render :csv => @cultivar, :status => :created, :location => @cultivar }\n format.json { render :json => @cultivar, :status => :created, :location => @cultivar }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cultivar.errors, :status => :unprocessable_entity }\n format.csv { render :csv => @cultivar.errors, :status => :unprocessable_entity }\n format.json { render :json => @cultivar.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def csv_for_company\n filter = params[:filter]\n company_name = Company.find(params[:company_id]).name\n csv_name = filter.present? ?\n \"#{company_name}_operations_filtered_by_#{filter}.csv\" :\n \"#{company_name}_operations.csv\"\n respond_to do |format|\n format.csv { send_data to_csv ,filename: csv_name}\n end\n end",
"def create\n #Creates a new data file to be saved\n @data_file = DataFile.new(params[:data_file])\n #creates an array of all components\n @all_components = Component.all\n #creates an array of all products\n @all_products = Product.all\n #creates an array of all valuefields\n @all_valuefields = Valuefield.all\n respond_to do |format|\n if @data_file.save\n format.html { redirect_to @data_file, notice: 'Data file was successfully created.' }\n format.json { render json: @data_file, status: :created, location: @data_file }\n else\n format.html { render action: \"new\" }\n format.json { render json: @data_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def export_csv\n\n group_array = []\n @page = 1\n @per_page = 50\n\n groups = @context.get(:groups, :page => @page, :per_page => @per_page, :access_token => ENV[\"API_TOKEN\"])\n group_array << groups\n group_array, group_hash = check_paging(groups, group_array, \"groups\", @context, true)\n\n group_array.each_with_index do |group, index|\n is_new = index == 0 ? true : false\n membership_array = []\n @page = 1\n\n group_model = Group.find(group['id'], :params => { :access_token => ENV[\"API_TOKEN\"] })\n memberships = group_model.get(:memberships, :page => @page, :per_page => @per_page, :access_token => ENV[\"API_TOKEN\"])\n membership_array << memberships\n membership_array, @membership_hash = check_paging(memberships, membership_array, \"memberships\", group_model, is_new)\n end\n\n export_data = [group_array, @membership_hash]\n perform_export(export_data) \n\n respond_to do |format|\n format.html { render :inline => \"<a href=<%= @download_url %>>Download CSV</a>\" }\n format.json { render :json => @download_url.to_json }\n end\n end",
"def export_transactions_csvv3_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PaymentAuditServiceDeprecatedApi.export_transactions_csvv3 ...'\n end\n # resource path\n local_var_path = '/v3/paymentaudit/transactions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'payorId'] = opts[:'payor_id'] if !opts[:'payor_id'].nil?\n query_params[:'startDate'] = opts[:'start_date'] if !opts[:'start_date'].nil?\n query_params[:'endDate'] = opts[:'end_date'] if !opts[:'end_date'].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/csv', 'application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'PayorAmlTransactionV3'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['OAuth2']\n\n new_options = opts.merge(\n :operation => :\"PaymentAuditServiceDeprecatedApi.export_transactions_csvv3\",\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: PaymentAuditServiceDeprecatedApi#export_transactions_csvv3\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def fee_reciepts_export_csv\n parameters={:search => params[:search] ,:filename => filename}\n csv_export('finance_transaction', 'fee_reciepts_export', parameters) \n end",
"def index\n @contacts = Contact.order(sort_column + \" \" + sort_direction).find_all_by_company_id_and_status(current_user.company_id,false).paginate(:per_page => 2, :page => params[:page])\n @group = Group.new\n \n \n respond_to do |format|\n format.html\n format.csv { send_data Contact.to_csv }\n format.xls { send_data Contact.to_csv(col_sep: \"\\t\") }\n end\n end"
] | [
"0.6022466",
"0.56225675",
"0.5614967",
"0.54706836",
"0.5466791",
"0.54501754",
"0.5426591",
"0.5426021",
"0.5416774",
"0.5403759",
"0.5372391",
"0.535391",
"0.5351444",
"0.53249407",
"0.5312718",
"0.52447623",
"0.52411735",
"0.5222332",
"0.5202818",
"0.5193996",
"0.5185114",
"0.51702714",
"0.5132316",
"0.51078963",
"0.51041484",
"0.51019675",
"0.50998837",
"0.50852376",
"0.5081468",
"0.50788534",
"0.5073392",
"0.50720394",
"0.5043664",
"0.50418645",
"0.5033378",
"0.50304556",
"0.50285196",
"0.5026207",
"0.5021462",
"0.5020263",
"0.50128007",
"0.5009176",
"0.5006983",
"0.50031227",
"0.49857196",
"0.49849895",
"0.49833533",
"0.4965414",
"0.49587467",
"0.49580154",
"0.49557805",
"0.49501082",
"0.49483293",
"0.49428895",
"0.493966",
"0.49359936",
"0.49326193",
"0.4931237",
"0.49246967",
"0.4919665",
"0.4913451",
"0.49094072",
"0.49071893",
"0.4904553",
"0.48980734",
"0.4895997",
"0.48926717",
"0.4887832",
"0.4885788",
"0.48806956",
"0.486499",
"0.48637033",
"0.48622474",
"0.48602578",
"0.48599967",
"0.48582885",
"0.48573226",
"0.4849098",
"0.48455787",
"0.48455408",
"0.4843807",
"0.4839393",
"0.48369962",
"0.48366156",
"0.48327008",
"0.4828632",
"0.48267892",
"0.4824673",
"0.48227638",
"0.4822188",
"0.4819886",
"0.4816151",
"0.4816151",
"0.48159653",
"0.48119012",
"0.48090523",
"0.48078394",
"0.48045352",
"0.48033118",
"0.48031572",
"0.4802424"
] | 0.0 | -1 |
PATCH/PUT /my_cvs/1 PATCH/PUT /my_cvs/1.json | def update
respond_to do |format|
if @my_cv.update(my_cv_params)
format.html { redirect_to @my_cv, notice: 'My cv was successfully updated.' }
format.json { render :show, status: :ok, location: @my_cv }
else
format.html { render :edit }
format.json { render json: @my_cv.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch(path, **args); end",
"def update\n params[:cv][:existing_cs] ||= {}\n \n respond_to do |format|\n if @cv.update_attributes(params[:cv])\n flash[:notice] = 'Cv was successfully updated.'\n # format.html { redirect_to(cvs_path) }\n format.html{ redirect_to :action => \"edit\"}\n format.js { render :json => {:status => :ok}.to_json }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js { render :json => {:status => :fail}.to_json }\n format.xml { render :xml => @cv.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n @collab = Collab.find(params[:id])\n\n respond_to do |format|\n if @collab.update_attributes(params[:collab])\n format.html { redirect_to @collab, notice: 'Collab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @collab.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!(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 @csv = Csv.find(params[:id])\n\n respond_to do |format|\n if @csv.update_attributes(params[:csv])\n format.html { redirect_to @csv, notice: 'Csv was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @csv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = if @resource\n DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user) # update dataset\n else\n DatasetParser.new(hash: params['dataset'], user: @user, id_string: params[:id]) # upsert dataset with identifier\n end\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end",
"def update\n @csv_file = CsvFile.find(params[:id])\n\n respond_to do |format|\n if @csv_file.update_attributes(params[:csv_file])\n format.html { redirect_to @csv_file, notice: 'Csv file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @csv_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cvi = Cvi.find(params[:id])\n @people = Person.all\n\n respond_to do |format|\n if @cvi.update_attributes(params[:cvi])\n format.html { redirect_to @cvi, notice: 'Cvi was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cvi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update\n @complaint = Complaint.find(params[:id])\n\n updated = @complaint.update_attributes(params[:complaint])\n\n update_files if updated\n\n respond_to do |format|\n if updated\n format.html { redirect_to @complaint, notice: I18n.t('complaints.notice.update') }\n format.json { head :ok }\n else\n\t\t\t\t# to initialize the datetime fields\n\t\t\t\tgon.edit_complaint = true\n\t\t\t\tgon.violation_time = @complaint.violation_time.strftime('%m/%d/%Y %H:%M') if @complaint.violation_time\n\n format.html { render action: \"edit\" }\n format.json { render json: @complaint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def contact_updated(freshdesk_data,contact_id)\n\t\t#Rails.logger.info \"Update method id and data\"\n\t\t#Rails.logger.debug \"#{@api_domain}-#{contact_id}-#{@api_key}\"\n\t\t#Rails.logger.debug \"#{freshdesk_data.to_json}\"\n\t response = HTTParty.put(\n\t \"#{@api_domain}contacts/#{contact_id}\", \n\t\t basic_auth: { username: @api_key, password: \"password\" },\n\t\t headers: { 'Content-Type' => 'application/json' },\n\t\t body: freshdesk_data.to_json\n\t )\n\tend",
"def update\n contract = Contract.find_by_id(params[:id])\n (head :unauthorized unless contract) and return\n \n # try to update the attributes\n if contract.update_attributes(edit_contract_params)\n render json: contract\n else\n render json: { errors: contract.error.full_messages}\n end\n end",
"def update\n @col = Col.find(params[:id])\n\n respond_to do |format|\n if @col.update_attributes(params[:col])\n format.html { redirect_to @col, notice: 'Col was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @col.errors, status: :unprocessable_entity }\n end\n end\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 http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\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 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 @cto.update(cto_params)\n format.html { redirect_to @cto, notice: 'Cto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n end",
"def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end",
"def patch_model dataset_id, model_id, patched_model_gapi, etag = nil\n patch_with_backoff = false\n options = { skip_deserialization: true }\n if etag\n options[:header] = { \"If-Match\" => etag }\n # The patch with etag operation is considered idempotent\n patch_with_backoff = true\n end\n execute backoff: patch_with_backoff do\n json_txt = service.patch_model @project, dataset_id, model_id, patched_model_gapi, options: options\n JSON.parse json_txt, symbolize_names: true\n end\n end",
"def patch(path, data, options = {})\n uri = build_uri(path, options)\n\n request = Net::HTTP::Patch.new(uri.request_uri)\n set_authorisation_header(request)\n request.set_form_data(data)\n\n response = https_client(uri).request(request)\n end",
"def update\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end",
"def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end",
"def update\n respond_to do |format|\n if @cof.update(cof_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cof.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @caso.update_attributes(caso_params)\n format.html { redirect_to @caso, notice: 'Caso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(uri, options = T.unsafe(nil)); end",
"def update\n fn = params[:id].gsub('DOTDOT','.').gsub('SLASHSLASH','/')\n File.open(fn,'w+') { |f| \n f.puts params[:content]\n }\n respond_to do |format|\n format.json { render json: { success: true} }\n end\n end",
"def put!\n request! :put\n end",
"def update\n @cso = Cso.find(params[:id])\n\n respond_to do |format|\n if @cso.update_attributes(params[:cso])\n format.html { redirect_to @cso, notice: 'Cso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cso.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 test_update_object_by_id\r\n\t VCR.use_cassette('edit_object') do\r\n\t\t cred=JSON.parse(YAML::load_file('test/fixtures/credential.yml').to_json)\r\n\t\t json = JSON.parse(File.read(\"test/fixtures/edit_specimen.json\"))\r\n\t\t id = json[\"id\"]\r\n\t\t json[\"id\"] = \"\" #id cannot be updated\r\n\t\t result=CordraRestClient::DigitalObject.update(API_URL, id, json, cred[\"uc_1\"])\r\n\r\n\t\t #check that the result is saved\r\n\t\t assert_equal 200, result[:code]\r\n\t\t assert_equal \"OK\", result[\"message\"]\r\n\t\tend\r\n\t end",
"def update\n @cerc = Cerc.find(params[:id])\n\n if @cerc.update_attributes(params[:cerc])\n head :no_content\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_concern.update(api_v1_concern_params)\n format.html { redirect_to @api_v1_concern, notice: 'Concern was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_concern }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_concern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cable = Cable.find(params[:id])\n respond_to do |format|\n if @cable.update_attributes(params[:cable])\n format.html { render(:json => {:success => true}) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cable.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cfct.update(cfct_params)\n format.html { redirect_to @cfct, notice: 'Cfct was successfully updated.' }\n format.json { render :show, status: :ok, location: @cfct }\n else\n format.html { render :edit }\n format.json { render json: @cfct.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 respond_to do |format|\n if @csv_attribute.update(csv_attribute_params)\n format.html { redirect_to @csv_attribute, notice: 'Csv attribute was successfully updated.' }\n format.json { render :show, status: :ok, location: @csv_attribute }\n else\n format.html { render :edit }\n format.json { render json: @csv_attribute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update(path)\n output { patch(path, params) }\n end",
"def update\n respond_to do |format|\n if @catched.update(catched_params)\n format.html { redirect_to @catched, notice: 'Catched was successfully updated.' }\n format.json { render :show, status: :ok, location: @catched }\n else\n format.html { render :edit }\n format.json { render json: @catched.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clinica.update(clinica_params)\n format.html { redirect_to @clinica, notice: 'Clinica was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clinica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def patch(path, 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\n respond_to do |format|\n if @couch.update(couch_params)\n format.html { redirect_to @couch, notice: 'Couche was successfully updated.' }\n format.json { render :show, status: :ok, location: @couch }\n else\n format.html { render :edit }\n format.json { render json: @couch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cp_change = CpChange.find(params[:id])\n\n if @cp_change.update(cp_change_params)\n head :no_content\n else\n render json: @cp_change.errors, status: :unprocessable_entity\n end\n end",
"def update\n @project = Project.find(params[:id])\n<<<<<<< HEAD:app/controllers/projects_controller.rb\n handle_disciplines_projects\n \n=======\n\n>>>>>>> 336471e6be257cf55c9afa2a65f928fde34e41fe:app/controllers/projects_controller.rb\n respond_to do |format|\n if @project.update_attributes(params[:project])\n flash[:notice] = 'Project was successfully updated.'\n format.html { redirect_to(@project) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch!(src, patchset)\n patch(src, patchset, :patch)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @historical_source.update(historical_source_params)\n format.html { redirect_to @historical_source, notice: 'Historical source was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @historical_source.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @json_schemas = args[:json_schemas] if args.key?(:json_schemas)\n @schema = args[:schema] if args.key?(:schema)\n end",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end",
"def multi_update\n errors = false\n return_value = []\n file_infos_params = params.permit(file_infos: [:id, :review_done, :component_id]).require(:file_infos)\n file_infos_params.each do |key, file_info_entry|\n (return_value << nil) and (errors = true) and next unless file_info_entry[:id]\n file_info = FileInfo.find(file_info_entry[:id])\n (return_value << nil) and (errors = true) and next unless file_info\n if file_info.update(file_info_entry)\n return_value << file_info_entry\n else\n return_value << file_info.errors\n errors = true\n end\n end\n respond_to do |format|\n format.json { render json: return_value }\n if errors\n format.html { redirect_to :back, notice: 'Some entries have errors'}\n else\n format.html { redirect_to :back }\n end\n end\n end",
"def update\n respond_to do |format|\n if @couch.update(couch_params)\n format.html { redirect_to @couch, notice: 'Couch was successfully updated.' }\n format.json { render :show, status: :ok, location: @couch }\n else\n format.html { render :edit }\n format.json { render json: @couch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cpf.update(cpf_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cpf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n id = shift_argument\n validate_arguments!\n dataclip_reference = options[:dataclip]\n uri = URI(\"#{base_url}/#{id}\")\n req = Net::HTTP::Patch.new(uri.path)\n body = prepare_body(dataclip_reference)\n execute_and_print(uri, req, body)\n end",
"def update\n team_name = params[:name]\n team_description = params[:description]\n team_id = params[:id]\n\n respond_to do |format|\n if OkrTeam.where(id: team_id).update_all(name: team_name, description: team_description)\n format.json { render json: 'Team is updated successfully!', status: :ok }\n else\n format.json { render json: 'Error!', status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @complaintfile.update(complaintfile_params)\n render json: @complaintfile, status: :ok\n else\n render json: @complaintfile.errors, status: :unprocessable_entity\n end\n\n #respond_to do |format|\n # if @complaintfile.update(complaintfile_params)\n # format.html { redirect_to @complaintfile, notice: 'Complaintfile was successfully updated.' }\n # format.json { render :show, status: :ok, location: @complaintfile }\n # else\n # format.html { render :edit }\n # format.json { render json: @complaintfile.errors, status: :unprocessable_entity }\n # end\n #end\n end",
"def update\n # @contract = Contract.find(cfile_params[:contract_id])\n\n puts cfile_params.inspect\n \n # respond_to do |format|\n # if \n @cfile.update(cfile_params)\n puts @cfile.errors.full_messages\n \n # format.html { render \"contracts/show\", notice: 'Cfile was successfully updated.' }\n # format.json { render :show, status: :ok, location: @cfile }\n # else\n # format.html { render \"contracts/show\" }\n # format.json { render json: @cfile.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update\n @foo = Foo.find(params[:id])\n\n respond_to do |format|\n if @foo.update_attributes(params[:foo])\n format.html { redirect_to @foo, notice: 'Foo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @compression_format = args[:compression_format] if args.key?(:compression_format)\n @csv = args[:csv] if args.key?(:csv)\n @format = args[:format] if args.key?(:format)\n @iceberg = args[:iceberg] if args.key?(:iceberg)\n @json = args[:json] if args.key?(:json)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end",
"def update\n @model = Model.find(params[:id])\n\n respond_to do |format|\n if @model.update_attributes(params[:model])\n format.html { redirect_to(@model, :notice => 'Model was successfully updated.') }\n format.xml { head :ok }\n format.csv { head :ok }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @model.errors, :status => :unprocessable_entity }\n format.csv { render :csv => @model.errors, :status => :unprocessable_entity }\n format.json { render :json => @model.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def 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 patch(url, data, headers = {})\n request(:patch, url, headers, :data => data)\n end",
"def update\nlogger.debug \"update discipline: \"[email protected]\n discipline_params.each_pair do |property,value|\n @discipline.send(property+'=',value)if @discipline.respond_to?(property+'=')\n end\n @discipline.updater_id = current_user\n if @discipline.save\n set_discipline\n #respond_with @discipline\n render json: @discipline, status: :ok\n else\n ##render json: @discipline.errors, status: :unprocessable_entity\n respond_with @discipline.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end",
"def update\n respond_to do |format|\n if @cn_curve.update(cn_curve_params)\n format.html { redirect_to @cn_curve, notice: 'Cn curve was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cn_curve.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cocktail = Cocktail.find(params[:id])\n respond_to do |format|\n if @cocktail.update_attributes(params[:cocktail])\n format.html { redirect_to @cocktail, :notice => 'Cocktail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cocktail.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n puts ('entro al update')\n @credit_line = CreditLine.find(params[:id])\n\n respond_to do |format|\n if @credit_line.update_attributes(params[:credit_line])\n format.html { redirect_to @credit_line, notice: 'Credit line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @credit_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trein_consul_comercial.update(trein_consul_comercial_params)\n format.html { redirect_to @trein_consul_comercial, notice: 'Trein consul comercial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trein_consul_comercial.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_companies_batch()\n # Parameters for the API call\n\n company_model_A = CompanyModel.new()\n company_model_A.modified_time = Time.now.utc.iso8601\n company_model_A.company_id = \"12345\"\n\n company_model_B = CompanyModel.new()\n company_model_B.modified_time = Time.now.utc.iso8601\n company_model_B.company_id = \"67890\"\n company_model_B.metadata = JSON.parse('{'\\\n '\"string_field\": \"value_1\",'\\\n '\"name\": \"ruby api user\",'\\\n '\"custom\": \"testdata\"'\\\n '}')\n\n companies = [company_model_A, company_model_B]\n\n # Perform the API call through the SDK function\n self.class.controller.update_companies_batch(companies)\n\n # Test response code\n assert_equal(@response_catcher.response.status_code, 201)\n end",
"def update\n @file_version = FileVersion.find(params[:id])\n params[:versioned_file_id] = @file_version.versioned_file_id\n if update_versioned_files? \n if @file_version.update(:isActive => true)\n head :no_content\n else\n render json: @file_version.errors, status: :unprocessable_entity\n end \n else \n render json: @file_version.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @datafile.update(datafile_params)\n format.html { redirect_to @datafile, notice: 'Datafile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @datafile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n record = InvoiceLineItem.find(params[:id])\n print record.to_json\n record.update_attributes(params[:record]) \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end",
"def update\n @ccl = Ccl.find(params[:id])\n\n respond_to do |format|\n if @ccl.update_attributes(params[:ccl])\n format.html { redirect_to(@ccl, :notice => 'Ccl was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ccl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if :opr == 'edit'\n update\n else\n @team = Team.find_by_id(params[:id])\n @team.update_attributes({:id => params[:id], :name => params[:name], :status => params[:status]})\n\n if request.xhr?\n render :json => @team\n end\n end\n end",
"def update\n respond_to do |format|\n if @chef_att_source.update(chef_att_source_params)\n format.html { redirect_to @chef_att_source, notice: 'Chef att source was successfully updated.' }\n format.json { render :show, status: :ok, location: @chef_att_source }\n else\n format.html { render :edit }\n format.json { render json: @chef_att_source.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"
] | [
"0.6127421",
"0.580229",
"0.579714",
"0.5760648",
"0.5739394",
"0.5684298",
"0.5634248",
"0.5609227",
"0.5594514",
"0.5581622",
"0.55648065",
"0.5550822",
"0.5540473",
"0.5497106",
"0.5485396",
"0.54765177",
"0.5468778",
"0.5468778",
"0.54621226",
"0.54448587",
"0.543447",
"0.54249454",
"0.54212874",
"0.54042137",
"0.53962314",
"0.5394986",
"0.5394986",
"0.5377368",
"0.537467",
"0.537256",
"0.537256",
"0.5362057",
"0.5359053",
"0.5337802",
"0.5332692",
"0.5332446",
"0.53250855",
"0.5322968",
"0.5320142",
"0.5312562",
"0.52747965",
"0.5274221",
"0.52704966",
"0.52663976",
"0.5261773",
"0.5253467",
"0.52412844",
"0.52381545",
"0.5232626",
"0.5225396",
"0.5221865",
"0.5218601",
"0.5212714",
"0.521225",
"0.52094764",
"0.52052957",
"0.5201752",
"0.5192764",
"0.5178389",
"0.516958",
"0.5157672",
"0.5154284",
"0.5153333",
"0.5152701",
"0.5152701",
"0.5152701",
"0.5152701",
"0.5152701",
"0.5152701",
"0.51522475",
"0.5149812",
"0.51467156",
"0.51426405",
"0.51424897",
"0.5134986",
"0.5134327",
"0.51299936",
"0.51262015",
"0.5125991",
"0.5125757",
"0.51254815",
"0.512478",
"0.5122785",
"0.51225066",
"0.5119187",
"0.51129115",
"0.51046795",
"0.51025456",
"0.51021886",
"0.50986236",
"0.5097602",
"0.50964326",
"0.5092989",
"0.5089431",
"0.5089099",
"0.5088484",
"0.50869465",
"0.508575",
"0.50809574",
"0.50805604"
] | 0.52103287 | 54 |
DELETE /my_cvs/1 DELETE /my_cvs/1.json | def destroy
@my_cv.destroy
respond_to do |format|
format.html { redirect_to my_cvs_url, notice: 'My cv was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @csv = Csv.find(params[:id])\n @csv.destroy\n\n respond_to do |format|\n format.html { redirect_to csvs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @csv_file = CsvFile.find(params[:id])\n @csv_file.destroy\n\n respond_to do |format|\n format.html { redirect_to csv_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cv.destroy\n\n respond_to do |format|\n format.html { redirect_to(cvs_path) }\n format.xml { head :ok }\n end\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 @cfile.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @csv_attribute.destroy\n respond_to do |format|\n format.html { redirect_to project_csv_type_csv_attributes_url, notice: 'Csv attribute was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @csv_import.destroy\n respond_to do |format|\n format.html { redirect_to csv_imports_url, notice: 'Csv import was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @csv_upload = CsvUpload.find(params[:id])\n @csv_upload.destroy\n\n respond_to do |format|\n format.html { redirect_to csv_uploads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cv = Cv.find(params[:id])\n @cv.destroy\n\n respond_to do |format|\n format.html { redirect_to(cvs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @covariate = Covariate.find(params[:id])\n @covariate.destroy\n\n respond_to do |format|\n format.html { redirect_to(covariates_url) }\n format.xml { head :ok }\n format.csv { head :ok }\n format.json { head :ok }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @history_file_delete.destroy\n respond_to do |format|\n format.html { redirect_to history_file_deletes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cfile.destroy\n respond_to do |format|\n format.html { redirect_to cfiles_url, notice: 'Cfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def cfa_delete\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in cfa titles cfa_delete method\"\n begin\n id=params[\"format\"] \n cfa=RestClient.delete $api_service+'/cfa_titles/'+id\n rescue =>e\n Rails.logger.custom_log.error { \"#{e} Cfa controller delete method\" }\n end\n redirect_to action: \"index\"\n end",
"def delete(*rest) end",
"def destroy\n @cv.destroy\n respond_to do |format|\n format.html { redirect_to cvs_url, notice: 'Cv was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cv.destroy\n respond_to do |format|\n format.html { redirect_to cvs_url, notice: 'Cv was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n make_call(mk_conn(path), :delete)\n end",
"def destroy\n @line = Line.find_by_no(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sample_line = SampleLine.find(params[:id])\n @sample_line.destroy\n\n respond_to do |format|\n format.html { redirect_to sample_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datafile.destroy\n respond_to do |format|\n format.html { redirect_to datafiles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @commit_filepath.destroy\n respond_to do |format|\n format.html { redirect_to commit_filepaths_url, notice: 'Commit filepath was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #Finds selected data file\n @data_file = DataFile.find(params[:id])\n #destroys data file\n @data_file.destroy\n respond_to do |format|\n format.html { redirect_to '/admin' }\n format.json { head :ok }\n end\n end",
"def destroy\n @historical_source.destroy\n respond_to do |format|\n format.html { redirect_to historical_sources_url }\n format.json { head :no_content }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @col = Col.find(params[:id])\n @col.destroy\n\n respond_to do |format|\n format.html { redirect_to cols_url }\n format.json { head :no_content }\n end\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def destroy\n @collab = Collab.find(params[:id])\n @collab.destroy\n\n respond_to do |format|\n format.html { redirect_to collabs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataset_datum.destroy\n respond_to do |format|\n format.html { redirect_to dataset_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @csvupload.destroy\n respond_to do |format|\n format.html { redirect_to csvuploads_url, notice: 'Csvupload was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, **options)\n execute :delete, path, options\n end",
"def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cfct.destroy\n respond_to do |format|\n format.html { redirect_to cfcts_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @hdfs_path = HdfsPath.find(params[:id])\n @hdfs_path.destroy\n\n respond_to do |format|\n format.html { redirect_to hdfs_paths_url }\n format.json { head :ok }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete_row(row_id); rest_delete(\"#{link('rows')}/#{row_id}\"); nil; end",
"def destroy\n record = InvoiceLineItem.find(params[:id])\n record.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def destroy\n @arquivo = Arquivo.find(params[:id])\n\n @comentarios = Comentario.where(:comentavel_id => @arquivo.id)\n\n if @comentarios\n @comentarios.delete_all\n end\n\n @arquivo.destroy\n\n respond_to do |format|\n format.html { redirect_to arquivos_url }\n format.json { head :no_content }\n end\n end",
"def delete(bucket, file); end",
"def destroy\n @cvi = Cvi.find(params[:id])\n @cvi.destroy\n\n respond_to do |format|\n format.html { redirect_to cvis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @source = Source.find(params[:id])\n @source.destroy\n\n respond_to do |format|\n format.html { redirect_to report_sources_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coverage.destroy\n respond_to do |format|\n format.html { redirect_to coverages_url, notice: 'Coverage was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def destroy\n @seo_file.destroy\n respond_to do |format|\n format.html { redirect_to seo_files_url, notice: 'Seo file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ct_gov_import_export.destroy\n respond_to do |format|\n format.html { redirect_to ct_gov_import_exports_url, notice: 'Ct gov import export was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_case.destroy\n respond_to do |format|\n format.html { redirect_to line_cases_url, notice: 'Line case was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @csv_filter.destroy\n respond_to do |format|\n format.html { redirect_to project_csv_type_csv_attribute_url, notice: 'Csv filter was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice_row.destroy\n respond_to do |format|\n format.html { redirect_to invoice_rows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incidentfile.destroy\n respond_to do |format|\n format.html { redirect_to incidentfiles_url, notice: 'Incidentfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, headers = {})\n process :delete, path, headers\n end",
"def destroy\n @expenses_file.destroy\n respond_to do |format|\n format.html { redirect_to expenses_files_url, notice: 'Expenses file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @source_file.destroy\n respond_to do |format|\n format.html { redirect_to source_files_url, notice: 'Source file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to datasets_url }\n format.xml { head :ok }\n end\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @agent_import_file.destroy\n\n respond_to do |format|\n format.html { redirect_to(agent_import_files_url) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def delete_category(name)\n data_array = JSON.parse(File.read(File_path))\n category_item = find_category(name)\n data_array.delete(category_item)\n File.open(File_path, 'w') { |f| f.write(data_array.to_json) }\nend",
"def destroy\n @line_detail.destroy\n respond_to do |format|\n format.html { redirect_to line_details_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def delete_file(path)\n \n puts \"Sending path via MCollective Files client\"\n @mc.delete(:path => path)\n printrpcstats\n \n end",
"def delete_course_by_id(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/courses/#{org_unit_id}\" # setup user path\n # ap path\n _delete(path)\n puts '[+] Course data deleted successfully'.green\nend",
"def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end",
"def destroy\n @crowd = Crowd.find(params[:id])\n @crowd.destroy\n\n respond_to do |format|\n format.html { redirect_to crowds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couch was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n \n end",
"def destroy\n @indexed_file = IndexedFile.find(params[:id])\n @indexed_file.destroy\n\n respond_to do |format|\n format.html { redirect_to indexed_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @climb_datum = ClimbDatum.find(params[:id])\n @climb_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to climb_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @export.destroy\n respond_to do |format|\n format.html { redirect_to exports_url }\n format.json { head :no_content }\n end\n end",
"def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end",
"def destroy\n @jargon_file = JargonFile.find(params[:id])\n @source = @jargon_file.source\n @jargon_file.destroy\n\n respond_to do |format|\n format.html { redirect_to @source }\n format.json { head :no_content }\n end\n end",
"def delete(name)\n\n end",
"def destroy\n @tgl_row = TglRow.find(params[:id])\n @tgl_row.destroy\n\n respond_to do |format|\n format.html { redirect_to tgl_rows_url }\n format.json { head :no_content }\n end\n end",
"def delete\n\n end",
"def destroy\n record = Asset.find(params[:id])\n record.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def destroy\n @cso = Cso.find(params[:id])\n @cso.destroy\n\n respond_to do |format|\n format.html { redirect_to csos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n @attachment = Attachment.find(params[:attachment_id])\n @attachment.destroy\n Keys.where(attachment_id: @attachment.id).destroy_all\n GetModel(params[:type]).where(file_id: @attachment.id).destroy_all\n \n respond_to do |format| \n format.html { redirect_to '/imports/'+params[:profile_id].to_s+'/csv/'+params[:type].to_s,notice: 'File has been deleted!' }\n end\n \n end",
"def destroy\n @clinical_visit.destroy\n respond_to do |format|\n format.html { redirect_to clinical_visits_url, notice: 'Clinical visit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couche was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete_index\n @customer = Customer.with_deleted.find(params[:id])\n if params[:type]=='normal'\n @customer.delete\n elsif params[:type]=='restore'\n @customer.restore\n @customer.update(deleted_at: nil)\n end\n\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_path, notice: 'Customer was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@clinica.destroy\n @clinica.update(:status => 0)\n respond_to do |format|\n format.html { redirect_to clinicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @case.update_columns(deleted: true)\n respond_to do |format|\n format.html { redirect_to cases_url, notice: 'Case was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cage.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_file = TestFile.find(params[:id])\n @test_file.destroy\n\n respond_to do |format|\n format.html { redirect_to test_files_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n sql = \"DELETE from customers WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\n# => Deleting customer record, nothing to return\n end",
"def destroy\n @datasource.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def deletes_to(path,opts={},&block) #:nodoc: \n crud_to(:delete,path,opts[:params] || {},opts,&block)\n end",
"def destroy\n @cruise_line.destroy\n respond_to do |format|\n format.html { redirect_to cruise_lines_url, notice: 'Cruise line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete\n end",
"def destroy\n @record = Asset.find(params[:id])\n @record.trash\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end"
] | [
"0.6609228",
"0.64587283",
"0.6304385",
"0.622321",
"0.6170572",
"0.61592263",
"0.614689",
"0.61330384",
"0.6108112",
"0.6099616",
"0.60768783",
"0.60524577",
"0.60247165",
"0.6020342",
"0.60003686",
"0.599854",
"0.59887326",
"0.59887326",
"0.5964407",
"0.596325",
"0.5960245",
"0.59569997",
"0.59566015",
"0.5955692",
"0.5954249",
"0.593894",
"0.5935354",
"0.5934316",
"0.5924173",
"0.5920713",
"0.591958",
"0.5919417",
"0.59174967",
"0.5913868",
"0.59088516",
"0.59018403",
"0.5899429",
"0.58973974",
"0.5897262",
"0.58843994",
"0.5880959",
"0.5876339",
"0.58742595",
"0.58697975",
"0.5869181",
"0.586836",
"0.58662313",
"0.58650744",
"0.5855511",
"0.58534074",
"0.5852618",
"0.58523065",
"0.5849115",
"0.5848085",
"0.58478403",
"0.5847772",
"0.5847378",
"0.5844283",
"0.5843072",
"0.5843072",
"0.58418274",
"0.5840563",
"0.5832332",
"0.58295923",
"0.58292186",
"0.5826974",
"0.5826929",
"0.58267105",
"0.5824137",
"0.5822607",
"0.5822602",
"0.58186835",
"0.58175534",
"0.5816556",
"0.5815301",
"0.5813715",
"0.581261",
"0.5810383",
"0.58082414",
"0.58069927",
"0.58058965",
"0.5802908",
"0.58011717",
"0.58002585",
"0.57987547",
"0.5797053",
"0.5796084",
"0.57950914",
"0.57941127",
"0.5788066",
"0.5786139",
"0.5785998",
"0.57813287",
"0.5780544",
"0.57795936",
"0.57759356",
"0.57717294",
"0.5769454",
"0.5769454",
"0.5769454"
] | 0.6266653 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_my_cv
@my_cv = MyCv.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 my_cv_params
params.fetch(:my_cv, {})
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 valid_params_request?; 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 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 safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\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 user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\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 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 valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\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 parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\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"
] | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",
"0.6290449",
"0.6282986",
"0.6241265",
"0.62392694",
"0.62192893",
"0.621427",
"0.62099457",
"0.6195319",
"0.61785376",
"0.61747766",
"0.6172739",
"0.6162921",
"0.6152228",
"0.6152062",
"0.6148811",
"0.6122391",
"0.6117956",
"0.61083806",
"0.6106195",
"0.609274",
"0.60815483",
"0.60710186",
"0.6064253",
"0.60213476",
"0.6018128",
"0.60146624",
"0.601063",
"0.60068774",
"0.60068774",
"0.60026145",
"0.6000521",
"0.59987193",
"0.5992379",
"0.59922844",
"0.5991889",
"0.59803206",
"0.5966244",
"0.5959778",
"0.5959708",
"0.59588563",
"0.5956974",
"0.5953329",
"0.59528023",
"0.59439695",
"0.59413165",
"0.59397036",
"0.59397036",
"0.5933782",
"0.59323835",
"0.59258395",
"0.59253365",
"0.5917244",
"0.59111005",
"0.59093463",
"0.5907942",
"0.59047514",
"0.58979666",
"0.58971125",
"0.589613",
"0.5895083",
"0.5893643",
"0.5892825",
"0.5887658",
"0.5883417",
"0.5878839",
"0.5874345",
"0.5869008",
"0.5868205",
"0.58672875",
"0.5867031",
"0.58662426",
"0.5864551",
"0.5863614",
"0.5862626",
"0.5861952",
"0.58596134",
"0.5855716",
"0.58536863",
"0.5851665",
"0.5850823"
] | 0.0 | -1 |
GET /cours GET /cours.json | def index
@cours = Cour.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def show\n @court = Court.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court }\n end\n end",
"def index\n @courts = Court.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def show\n @court = Court.friendly.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court }\n end\n end",
"def index\n @courts = Court.all\n end",
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end",
"def index\n @courses = Course.all\n render json: @courses, status: :ok\n end",
"def index\n begin\n conditions = [\"club_id = ?\",@club.id]\n @courses = Course.find(:all, :order => 'id', :conditions => conditions)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def index\n @courses = Course.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses}\n end\n end",
"def show\n @cours = Cour.all\n end",
"def index\n\t\t@courses = Course.all\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @courses }\n\t\tend\n\tend",
"def new\n @court = Court.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @court }\n end\n end",
"def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end",
"def show\n @court_type = CourtType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court_type }\n end\n end",
"def show\n render json: @course, status: :found\n end",
"def index\n @courseras = Coursera.all\n end",
"def show\n render json: @course\n end",
"def index\n # Check for filters\n @courses = Course.getCourseInformation(params[:dept],params[:course])\n @page_title = \"Browse Courses\"\n respond_to do |format|\n format.html\n format.json {render json: @courses }\n end\n end",
"def show\n @concour = Concour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concour }\n end\n end",
"def index\n @soccer_courts = SoccerCourt.all\n end",
"def index\n @courses = Course.all.includes(:translations)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def show\n @courtstation = Courtstation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @courtstation }\n end\n end",
"def show_course\n\t\t@course = Course.find(params[:course_id])\n\t\trender json: @course\n\tend",
"def show\n @course = Course.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n render json: course\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def index\n @court_types = CourtType.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @court_types }\n end\n end",
"def index\n @study_courses = StudyCourse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @study_courses }\n end\n end",
"def index\n @courses = Course.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => Course.all }\n end\n end",
"def index\n\t\t@courses = @teacher.courses\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @courses }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @course }\n end\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @course }\n end\n end",
"def index\n course = Course.find(params[:course_id])\n sections = course.sections.all\n render json: sections.order(:id)\n end",
"def index\n query = params[:q]\n @courses = query ? Course.search(query) : Course.all.order(:id)\n\n render json: @courses\n end",
"def index\n @courses = Courses.all\n end",
"def index\n authorize! :read, Course\n\n if is_student?\n @course_sections = Course.find_student_courses(current_user.id)\n else\n @course_sections = Course.find_professor_courses(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def show\r\n @course = Course.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @course }\r\n\r\n end\r\n end",
"def course\n\t\t@course = Course.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.json\n\t\tend\n\tend",
"def show\n @court = Court.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @court }\n end\n end",
"def index\n @coursubs = Coursub.all\n end",
"def show\n @study_course = StudyCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @study_course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @course }\n end\n end",
"def cours_list\n @cours = Haiwet::Cour.list\n @cours.each.with_index(1) do |cour, i|\n puts \"#{i}- #{cour.name}\"\n end\n end",
"def show\n @golf_cource = GolfCource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @golf_cource }\n end\n end",
"def new\n @court = Court.new\n\n respond_to do |format|\n format.html { render \"new\", :layout=>false}\n format.json { render json: @court }\n end\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def student_show\n @course = Course.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n \n end",
"def index\n @assessment_courses = AssessmentCourse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assessment_courses }\n end\n end",
"def index\n @courts = Court.all.paginate(default_paginate_options)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @courts }\n end\n end",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def show\n @course = Course.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n if !params.has_key?(:section)\n redirect_to courses_path and return\n end\n\n @course = Course.find(params[:id])\n authorize! :read, @course\n @section = Section.find(params[:section])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def courses(institution, pageIndex=0, options={})\n options.merge!({:query => {:pageIndex => pageIndex}})\n self.class.get(\"/Institution/#{institution}/Courses.json\", options)\n end",
"def faculties\n @faculties = Faculty.where(university_id: params[:university_id]).order(:name)\n @courses = []\n respond_to do |format|\n format.json { render json: @faculties }\n end\n end",
"def index\n if (params[:query])\n @courses = Course.full_course_search(params[:query]).listed.page(params[:page]).per_page(10)\n else \n @courses = Course.listed.paginate(:page => params[:page], :per_page => 10).order(\"created_at desc\")\n end\n @followers = Course.get_number_people_following_published_courses\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def show\n @lab_course = LabCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lab_course }\n end\n end",
"def courses\n request(COURSES_URL, {}, 'GET').map do |course|\n Course.new(self, course)\n end\n end",
"def show\n #@course = Course.find(params[:course_id])\n @course_lesson = CourseLesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_lesson }\n end\n end",
"def new\n @concour = Concour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concour }\n end\n end",
"def show\n @user = current_user #User.find(params[:id])\n @taking_courses = @user.takes\n @offering_courses = Array.new\n \n Authour.where(:user_id => @user.id).each do |authour|\n @offering_courses << Course.find(authour.course_id)\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mypage }\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def index\n @enrolleds = Enrolled.all\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enrolleds }\n end\n end",
"def index\n @current_user = User.find_by_id(session[:user_id])\n @courses = @current_user.courses.paginate page: params[:page], order: 'created_at asc', per_page: 25\n if @current_user.courses.empty?\n redirect_to new_course_url, notice: \"You Have No Courses Yet\"\n return\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def new\n @courtstation = Courtstation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @courtstation }\n end\n end",
"def index\n\t\t@course = Course.find(params[:course_id])\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\tend\n\tend",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end"
] | [
"0.7937811",
"0.7689072",
"0.7597698",
"0.7337674",
"0.7317332",
"0.71578103",
"0.7137326",
"0.71024925",
"0.70347553",
"0.70347553",
"0.70241255",
"0.69868535",
"0.6973225",
"0.696184",
"0.69473886",
"0.6931684",
"0.6918508",
"0.6917514",
"0.68833226",
"0.68764555",
"0.6870119",
"0.68497974",
"0.6802915",
"0.67872393",
"0.67724234",
"0.67455494",
"0.67436546",
"0.67429984",
"0.67429984",
"0.67429984",
"0.67429984",
"0.67429984",
"0.67429984",
"0.6742741",
"0.6739717",
"0.67285943",
"0.6718194",
"0.6709416",
"0.6689429",
"0.6666737",
"0.6653538",
"0.6641903",
"0.66415876",
"0.66324323",
"0.6627762",
"0.6618124",
"0.66158795",
"0.65955174",
"0.65820014",
"0.65798724",
"0.6561751",
"0.65612274",
"0.6541278",
"0.65368354",
"0.65368134",
"0.65368134",
"0.6521716",
"0.64750016",
"0.6463525",
"0.6418834",
"0.64170516",
"0.6416514",
"0.64109474",
"0.64078254",
"0.64025074",
"0.63983953",
"0.639632",
"0.638991",
"0.63690543",
"0.6352571",
"0.63363916",
"0.63309854",
"0.63252056",
"0.63244",
"0.62792724",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726",
"0.6270726"
] | 0.7225956 | 5 |
GET /cours/1 GET /cours/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @court = Court.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court }\n end\n end",
"def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def show\n @court = Court.friendly.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court }\n end\n end",
"def index\n @courts = Court.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def show\n @court_type = CourtType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court_type }\n end\n end",
"def show\n @concour = Concour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concour }\n end\n end",
"def new\n @court = Court.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @court }\n end\n end",
"def index\n @courts = Court.all\n end",
"def index\n @cours = Cour.all\n end",
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end",
"def show\n @cours = Cour.all\n end",
"def show\n @courtstation = Courtstation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @courtstation }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n render json: @course, status: :found\n end",
"def show_course\n\t\t@course = Course.find(params[:course_id])\n\t\trender json: @course\n\tend",
"def show\n @course = Course.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @course }\n end\n end",
"def show\n render json: @course\n end",
"def index\n @courses = Course.all\n render json: @courses, status: :ok\n end",
"def show\n @course = Course.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @course }\n end\n end",
"def index\n begin\n conditions = [\"club_id = ?\",@club.id]\n @courses = Course.find(:all, :order => 'id', :conditions => conditions)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def show\n @court = Court.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @court }\n end\n end",
"def show\r\n @course = Course.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @course }\r\n\r\n end\r\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def index\n @courses = Course.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def show\n @course = Course.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @course }\n end\n end",
"def show\n render json: course\n end",
"def index\n @courses = Course.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses}\n end\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def show\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clue }\n end\n end",
"def course\n\t\t@course = Course.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.json\n\t\tend\n\tend",
"def show\n @golf_cource = GolfCource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @golf_cource }\n end\n end",
"def new\n @court = Court.new\n\n respond_to do |format|\n format.html { render \"new\", :layout=>false}\n format.json { render json: @court }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end",
"def show\n @study_course = StudyCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @study_course }\n end\n end",
"def index\n # Check for filters\n @courses = Course.getCourseInformation(params[:dept],params[:course])\n @page_title = \"Browse Courses\"\n respond_to do |format|\n format.html\n format.json {render json: @courses }\n end\n end",
"def index\n @courseras = Coursera.all\n end",
"def new\n @concour = Concour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concour }\n end\n end",
"def index\n @court_types = CourtType.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @court_types }\n end\n end",
"def show\n @lab_course = LabCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lab_course }\n end\n end",
"def cours_list\n @cours = Haiwet::Cour.list\n @cours.each.with_index(1) do |cour, i|\n puts \"#{i}- #{cour.name}\"\n end\n end",
"def student_show\n @course = Course.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n \n end",
"def index\n\t\t@courses = Course.all\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @courses }\n\t\tend\n\tend",
"def show\n @critic = Critic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critic }\n end\n end",
"def show\n #@course = Course.find(params[:course_id])\n @course_lesson = CourseLesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_lesson }\n end\n end",
"def index\n @courses = Course.all.includes(:translations)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def index\n @courses = Course.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => Course.all }\n end\n end",
"def show\n @cue = Cue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cue }\n end\n end",
"def show\n @clinical_course = ClinicalCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinical_course }\n end\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def new\n @lecture = Lecture.new\n @course = Course.find(params[:course_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lecture }\n end\n end",
"def index\n @coursubs = Coursub.all\n end",
"def show\n @course = Course.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student }\n end\n end",
"def show\n if !params.has_key?(:section)\n redirect_to courses_path and return\n end\n\n @course = Course.find(params[:id])\n authorize! :read, @course\n @section = Section.find(params[:section])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end",
"def index\n @soccer_courts = SoccerCourt.all\n end",
"def show\n @courses = Courses.first\n end",
"def new\n @courtstation = Courtstation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @courtstation }\n end\n end",
"def set_cour\n @cour = Cour.find(params[:id])\n end",
"def index\n @study_courses = StudyCourse.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @study_courses }\n end\n end",
"def index\n\t\t@courses = @teacher.courses\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @courses }\n end\n end",
"def index\n course = Course.find(params[:course_id])\n sections = course.sections.all\n render json: sections.order(:id)\n end",
"def index\n @courses = Courses.all\n end",
"def show\n @type_course = TypeCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type_course }\n end\n end",
"def show\n @course_programme = CourseProgramme.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_programme }\n end\n end",
"def show\n @lab = Lab.find(params[:id])\n @lab_student = Student.where(\"cname = ?\",@lab.course.name)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lab }\n end\n end",
"def show\n @course_request = CourseRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_request }\n end\n end",
"def show\n @course_category = CourseCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_category }\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def create\n @court = Court.new(params[:court])\n\n respond_to do |format|\n if @court.save\n format.html { redirect_to @court, notice: 'Court was successfully created.' }\n format.json { render json: @court, status: :created, location: @court }\n else\n format.html { render action: \"new\" }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @course = Course.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def index\n\t\t@course = Course.find(params[:course_id])\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\tend\n\tend",
"def show\n @assessment_course = AssessmentCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assessment_course }\n end\n end",
"def faculties\n @faculties = Faculty.where(university_id: params[:university_id]).order(:name)\n @courses = []\n respond_to do |format|\n format.json { render json: @faculties }\n end\n end",
"def show\n @course_asset = CourseAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course_asset }\n end\n end",
"def show\n @course_status = CourseStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @course_status }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def index\n query = params[:q]\n @courses = query ? Course.search(query) : Course.all.order(:id)\n\n render json: @courses\n end",
"def index\n @course = Course.find params[:course_id]\n end",
"def one args\n @courses = args[:courses]\n render\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json=> @course }\n end\n end",
"def show\n @inscriptionprepaconcour = Inscriptionprepaconcour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inscriptionprepaconcour }\n end\n end",
"def show\n @course = Course.load params[:id] # load object from TISS REST API\n end",
"def set_court\n @court = Court.find(params[:id])\n end",
"def new\n @court = Court.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @court }\n end\n end",
"def show\n @cerc = Cerc.find(params[:id])\n\n render json: @cerc\n end"
] | [
"0.79235655",
"0.78617215",
"0.75764483",
"0.7471491",
"0.72778654",
"0.7197549",
"0.7165486",
"0.71375126",
"0.7127398",
"0.699773",
"0.6996515",
"0.69663846",
"0.6963188",
"0.6963188",
"0.6963188",
"0.6963188",
"0.6963188",
"0.6963188",
"0.69529766",
"0.69518846",
"0.6950742",
"0.69136655",
"0.6896865",
"0.68846923",
"0.68772995",
"0.6844638",
"0.68432534",
"0.6838496",
"0.6811368",
"0.6811368",
"0.6803296",
"0.6802886",
"0.6799366",
"0.6799194",
"0.6799194",
"0.67975605",
"0.6779623",
"0.67640257",
"0.67394155",
"0.67292696",
"0.67220706",
"0.6717658",
"0.6708108",
"0.66831034",
"0.66674477",
"0.666271",
"0.6625426",
"0.66001326",
"0.6582172",
"0.6575676",
"0.657543",
"0.6557281",
"0.6546655",
"0.65452516",
"0.65005314",
"0.6498637",
"0.64982295",
"0.64937973",
"0.64911854",
"0.6490266",
"0.64885724",
"0.6477755",
"0.6466699",
"0.64601135",
"0.645339",
"0.64378536",
"0.6434112",
"0.64281386",
"0.64075327",
"0.63883555",
"0.6365525",
"0.6352499",
"0.63493127",
"0.63309944",
"0.63211125",
"0.6302434",
"0.6300512",
"0.62952375",
"0.6290758",
"0.6287002",
"0.62848854",
"0.627541",
"0.62650025",
"0.62650025",
"0.62650025",
"0.62650025",
"0.62650025",
"0.62650025",
"0.62650025",
"0.62650025",
"0.62650025",
"0.62650025",
"0.6264303",
"0.62620825",
"0.62577635",
"0.6257662",
"0.6251597",
"0.62489486",
"0.6244035",
"0.6240472",
"0.62372756"
] | 0.0 | -1 |
POST /cours POST /cours.json | def create
params[:cour][:ecole_id] = ecole.id if ecole?
#Ajout de la classe en groupe
params[:cour][:classe_room_id].unshift(params[:cour][:first_classe_room_id])
@creneau = params[:cour][:creneau_debut].to_i
@nombre_heure = params[:cour][:creneau_fin].to_i - params[:cour][:creneau_debut].to_i + 1
@classe_rooms = params[:cour][:classe_room_id]
# Enregistrement des cours pour chaque creneau
@nombre_heure.times do
# Enregistrement pour chaque chaque par creneau
@classe_rooms.size.times do |i|
@cour = current_user.cours.create(enseignant_id: params[:cour][:enseignant_id], matiere_id: params[:cour][:matiere_id], salle_id: params[:cour][:salle_id], creneau_id: @creneau, jour_id: params[:cour][:jour_id], nombre_heure: @nombre_heure, annee_id: params[:cour][:annee_id], ecole_id: params[:cour][:ecole_id], semestre_id: params[:cour][:annee_id], classe_room_id: @classe_rooms[i])
end
@creneau = @creneau + 1
end
respond_to do |format|
if @cour
format.html { redirect_to @cour, notice: 'Cours was successfully created.' }
format.json { render :show, status: :created, location: @cour }
else
format.html { render :new }
format.json { render json: @cour.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @court = Court.new(params[:court])\n\n respond_to do |format|\n if @court.save\n format.html { redirect_to @court, notice: 'Court was successfully created.' }\n format.json { render json: @court, status: :created, location: @court }\n else\n format.html { render action: \"new\" }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @court = Court.new(court_params)\n\n respond_to do |format|\n if @court.save\n format.html { redirect_to @court, notice: 'Court was successfully created.' }\n format.json { render :show, status: :created, location: @court }\n else\n format.html { render :new }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @concour = Concour.new(params[:concour])\n\n respond_to do |format|\n if @concour.save\n format.html { redirect_to @concour, notice: 'Concour was successfully created.' }\n format.json { render json: @concour, status: :created, location: @concour }\n else\n format.html { render action: \"new\" }\n format.json { render json: @concour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @coursera = Coursera.new(coursera_params)\n respond_to do |format|\n if @coursera.save\n format.html { redirect_to @coursera, notice: 'Coursera was successfully created.' }\n format.json { render :show, status: :created, location: @coursera }\n else\n format.html { render :new }\n format.json { render json: @coursera.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @coursub = Coursub.new(coursub_params)\n\n respond_to do |format|\n if @coursub.save\n format.html { redirect_to @coursub, notice: 'Coursub was successfully created.' }\n format.json { render :show, status: :created, location: @coursub }\n else\n format.html { render :new }\n format.json { render json: @coursub.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @soccer_court = SoccerCourt.new(soccer_court_params)\n\n respond_to do |format|\n if @soccer_court.save\n format.html { redirect_to @soccer_court, notice: 'Soccer court was successfully created.' }\n format.json { render :show, status: :created, location: @soccer_court }\n else\n format.html { render :new }\n format.json { render json: @soccer_court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @court = Court.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @court }\n end\n end",
"def create\n # render plain: params[:courses].inspect\n @courses = Courses.new(courses_params)\n\n respond_to do |format|\n if @courses.save\n format.html { redirect_to @courses, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @courses }\n else\n format.html { render :new }\n format.json { render json: @courses.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, :notice=> 'Curso creado' }\n format.json { render :json=> @course, :status=> :created, :location=> @course }\n else\n format.html { render :action=> \"new\" }\n format.json { render :json=> @course.errors, :status=> :unprocessable_entity }\n end\n end\n end",
"def create\n @court_complex = CourtComplex.new(court_complex_params)\n\n respond_to do |format|\n if @court_complex.save\n format.html { redirect_to @court_complex, notice: 'Court complex was successfully created.' }\n format.json { render :show, status: :created, location: @court_complex }\n else\n format.html { render :new }\n format.json { render json: @court_complex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n @course.save\n render_jsonapi_response(@course)\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_path(), notice: 'El curso fue exitosamente creado.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { redirect_to new_course_path, notice: \"Debe escribir por lo menos el nombre del curso para crearlo.\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @food_court = FoodCourt.new(food_court_params)\n\n respond_to do |format|\n if @food_court.save\n format.html { redirect_to @food_court, notice: 'Food court was successfully created.' }\n format.json { render :show, status: :created, location: @food_court }\n else\n format.html { render :new }\n format.json { render json: @food_court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_url, notice: 'Curso creado satisfactoriamente' }\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 create\n @course = Course.new(courses_params)\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 create\n @courtstation = Courtstation.new(params[:courtstation])\n\n respond_to do |format|\n if @courtstation.save\n format.html { redirect_to @courtstation, notice: 'Courtstation was successfully created.' }\n format.json { render json: @courtstation, status: :created, location: @courtstation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @courtstation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @court = Court.new(params[:court])\n\n respond_to do |format|\n if @court.save\n purge_all_pages\n format.html { redirect_to edit_admin_court_path(@court), notice: 'Page was successfully created.' }\n format.json { render json: @court, status: :created, location: @court }\n else\n format.html { render action: \"new\" }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @court = Court.new\n\n respond_to do |format|\n format.html { render \"new\", :layout=>false}\n format.json { render json: @court }\n end\n end",
"def create\n\n @course = Course.new(params[:course])\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 json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n #section_chunks = get_chunks(params)\n sections = JSON.parse(params['sections'])\n\n # The course has been created by the signed-in user.\n @course.user_id = current_user.id\n respond_to do |format|\n if @course.save\n # Save the course's subcomponents to the course.\n update_section_chunks(sections)\n\n format.html { redirect_to @course }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render new_course_path }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\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 json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\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 json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\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 json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\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 json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\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 json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\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 json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\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 json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :manage, Course\n @course = Course.new(course_params)\n @course.course_sections.each do |course_section|\n course_section.name = \"#{@course.name} #{course_section.grade_section.name}\"\n end\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 create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Curso criado com sucesso.' }\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 create\n @inscriptionprepaconcour = Inscriptionprepaconcour.new(params[:inscriptionprepaconcour])\n\n respond_to do |format|\n if @inscriptionprepaconcour.save\n format.html { redirect_to @inscriptionprepaconcour, notice: 'Inscriptionprepaconcour was successfully created.' }\n format.json { render json: @inscriptionprepaconcour, status: :created, location: @inscriptionprepaconcour }\n else\n format.html { render action: \"new\" }\n format.json { render json: @inscriptionprepaconcour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\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 create\n professor = Professor.new(professor_params)\n \n if professor.save\n render json: professor.to_json(include: :courses)\n else\n render :json => { :errors => professor.errors }, :status => 422\n end\n end",
"def create\n begin\n @course = Course.new(params[:course])\n @course.club = @club\n \n respond_to do |format|\n if @course.save\n format.html { redirect_to club_course_path(@club, @course)}\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def new\n @concour = Concour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concour }\n end\n end",
"def create\n @course = Course.new(course_params)\n respond_to do |format|\n if @course.save\n\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 create\n course = Course.new(course_params)\n\n if course.save\n render json: course, status: :created\n else\n render json: course.errors, status: :unprocessable_entity\n end\n end",
"def create\n @course = Course.new(course_params)\n\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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 create\n @course = Course.new(course_params)\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, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @curriculum_course = CurriculumCourse.new(curriculum_course_params)\n\n respond_to do |format|\n if @curriculum_course.save\n format.html { redirect_to @curriculum_course, notice: 'Curriculum course was successfully created.' }\n format.json { render :show, status: :created, location: @curriculum_course }\n else\n format.html { render :new }\n format.json { render json: @curriculum_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def court_params\n params.require(:court).permit(:city, :court_number, :surface)\n end",
"def createSection(section)\r\n uri = sprintf(\"/api/v1/courses/%d/sections/\", $tocid) \r\n \r\n dbg(\"POST #{uri}\")\r\n dbg(\"course_section[name]=#{section[\"name\"]}\")\r\n newSection = $canvas.post(uri, {'course_section[name]' => section[\"name\"]})\r\n dbg(newSection)\r\n return newSection\r\nend",
"def create\n @study_course = StudyCourse.new(params[:study_course])\n\n respond_to do |format|\n if @study_course.save\n format.html { redirect_to @study_course, notice: 'Study course was successfully created.' }\n format.json { render json: @study_course, status: :created, location: @study_course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @study_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_course\r\n @course = Course.create(fast_course_params)\r\n respond_to do |format|\r\n if @course.save\r\n format.html { redirect_to courses_path, notice: 'Course was successfully created.' }\r\n format.json { render courses_path, status: :created, location: @course }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @course.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @golf_cource = GolfCource.new(params[:golf_cource])\n\n respond_to do |format|\n if @golf_cource.save\n format.html { redirect_to scaffold_golf_cource_url(@golf_cource), notice: 'Golf cource was successfully created.' }\n format.json { render json: @golf_cource, status: :created, location: @golf_cource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @golf_cource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @courtstation = Courtstation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @courtstation }\n end\n end",
"def create\n @clue = Clue.new(params[:clue])\n\n respond_to do |format|\n if @clue.save\n format.html { redirect_to @clue, notice: 'Clue was successfully created.' }\n format.json { render json: @clue, status: :created, location: @clue }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clue = Clue.new(params[:clue])\n\n respond_to do |format|\n if @clue.save\n format.html { redirect_to @clue, notice: 'Clue was successfully created.' }\n format.json { render json: @clue, status: :created, location: @clue }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cour_params\n params.require(:cour).permit(:enseignant_id, :matiere_id, :salle_id, :creneau_debut, :creneau_fin, :jour_id, :nombre_heure, :numero_cours, :numero_cours_g, :annee_id, :ecole_id, :semestre_id, :user_id, :first_classe_room_id, :classe_room_id)\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n \n format.html { redirect_to @course, notice: 'course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n ppp @course.errors.full_messages\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = CourseAccount.new(id_user:11,id_course: params[:course],coin:5000)\n @course.save()\n session[:id_course] =params[:course]\n render :json =>[@course,session[:id_course]]\n\n end",
"def create\n @course = Course.new(course_params)\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 action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course ' + @course.course_id + ' 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 create\n course = Course.includes(:professors).new(course_params)\n course.professor_ids=(params[:professors])\n\n if course.save\n render json: course.to_json(include: :professors)\n else\n render :json => { :errors => course.errors }, :status => 422\n end\n end",
"def create\n @lecture = Lecture.new(params[:lecture])\n @lecture.course_id = params[:course_id]\n @course= Course.find(params[:course_id])\n \n respond_to do |format|\n if @lecture.save\n format.html { redirect_to [@course,@lecture], notice: 'Lecture was successfully created.' }\n format.json { render json: @lecture, status: :created, location: @lecture }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lecture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @course = current_user.courses.build(course_params)\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, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @critique = Critique.new(critique_params)\n\n respond_to do |format|\n if @critique.save\n format.html { redirect_to @critique, notice: 'Critique was successfully created.' }\n format.json { render :show, status: :created, location: @critique }\n else\n format.html { render :new }\n format.json { render json: @critique.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @semester ? semester_course_path(@semester, @course) : @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n @course.publisher = current_user\n respond_to do |format|\n if @course.save\n format.html { redirect_to new_course_lesson_path(@course), :notice => 'Course was successfully created.' }\n format.json { render :json => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n params[:course][:user_id]=current_user.id\n \n @course = Course.new(params[:course])\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 json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n # Add the course just created to this student's courses, better use the drop down list \n if params[:course] != nil then\n @student.courses << Course.find(params[:course][:id])\n end\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_course = UserCourse.new(user_course_params)\n respond_to do |format|\n if @user_course.save\n format.html { redirect_to @user_course, notice: 'User course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user_course }\n else\n format.html { render action: 'new' }\n format.json { render json: @user_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to [:admin, @course], :notice => 'Course was successfully created.' }\n format.json { render :json => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def coursera_params\n params.require(:coursera).permit(:cid, :name, :email)\n end",
"def create\n @course = current_teacher.courses.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_url, 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 create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to static_pages_admin_url, notice: 'Course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = current_teacher.courses.new(course_params)\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 index\n @courts = Court.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def create\n @course = @student.courses.new(params[:course])\n @course.save\n redirect_to @course.student\n end",
"def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def create\n @university_course = UniversityCourse.new(university_course_params)\n\n respond_to do |format|\n if @university_course.save\n format.html { redirect_to @university_course, notice: 'University course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @university_course }\n else\n format.html { render action: 'new' }\n format.json { render json: @university_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cue = Cue.new(params[:cue])\n\n respond_to do |format|\n if @cue.save\n format.html { redirect_to @cue, notice: 'Cue was successfully created.' }\n format.json { render json: @cue, status: :created, location: @cue }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n @course.user = current_user\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, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @novanet_course = NovanetCourse.new(novanet_course_params)\n\n respond_to do |format|\n if @novanet_course.save\n format.html { redirect_to @novanet_course, notice: 'Novanet course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @novanet_course }\n else\n format.html { render action: 'new' }\n format.json { render json: @novanet_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student_sub_course = StudentSubCourse.new(params[:student_sub_course])\n\n respond_to do |format|\n if @student_sub_course.save\n format.html { redirect_to @student_sub_course, notice: 'Student sub course was successfully created.' }\n format.json { render json: @student_sub_course, status: :created, location: @student_sub_course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_sub_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @courier_request = current_user.courier_requests.build(courier_request_params)\n\n respond_to do |format|\n if @courier_request.save\n format.html { redirect_to @courier_request, notice: \"Courier request was successfully created.\" }\n format.json { render :show, status: :created, location: @courier_request }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @courier_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end",
"def create\n @enrolled = Enrolled.new(:student_id => current_student.student_id, :course_id => params[:course_id])\n\n respond_to do |format|\n if @enrolled.save\n format.html { redirect_to @enrolled, notice: 'Enrolled was successfully created.' }\n format.json { render json: @enrolled, status: :created, location: @enrolled }\n else\n format.html { render action: \"new\" }\n format.json { render json: @enrolled.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n \n respond_to do |format|\n if @course.save\n #format.html { redirect_to course_build_path(:id =>\"courseinfo\", :course_id => @course.id), notice: \"Course Created\" }\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 create\n @courses_teacher = CoursesTeacher.new(courses_teacher_params)\n\n respond_to do |format|\n if @courses_teacher.save\n format.html { redirect_to @courses_teacher, notice: 'Courses teacher was successfully created.' }\n format.json { render :show, status: :created, location: @courses_teacher }\n else\n format.html { render :new }\n format.json { render json: @courses_teacher.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clinical_course = ClinicalCourse.new(params[:clinical_course])\n\n respond_to do |format|\n if @clinical_course.save\n format.html { redirect_to @clinical_course, notice: 'Clinical course was successfully created.' }\n format.json { render json: @clinical_course, status: :created, location: @clinical_course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clinical_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tesda_course = TesdaCourse.new(tesda_course_params)\n\n respond_to do |format|\n if @tesda_course.save\n format.html { redirect_to @tesda_course, notice: 'Tesda course was successfully created.' }\n format.json { render :show, status: :created, location: @tesda_course }\n else\n format.html { render :new }\n format.json { render json: @tesda_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course added. Warning no Instructor assigned. Go to the manage user history tab and add instructor' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params) # crea un curso con todos los parametros que le envia el formulario\n @course.save\n @courses = Course.all # aqui consultamos por todos los cursos\n render :index # y pintamos otra vez la lista de cursos\n\n end",
"def new\n @lecture = Lecture.new\n @course = Course.find(params[:course_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lecture }\n end\n end",
"def new\n @course = Course.new\n 2.times do\n [email protected]\n end\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end",
"def create\n @classcourse = Classcourse.new(classcourse_params)\n\n respond_to do |format|\n if @classcourse.save\n format.html { redirect_to @classcourse, notice: 'Classcourse was successfully created.' }\n format.json { render :show, status: :created, location: @classcourse }\n else\n format.html { render :new }\n format.json { render json: @classcourse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @court = Court.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @court }\n end\n end"
] | [
"0.7497775",
"0.7415521",
"0.7075326",
"0.7074207",
"0.705048",
"0.69766545",
"0.68226254",
"0.67933404",
"0.6598003",
"0.6578499",
"0.65570635",
"0.6546124",
"0.6534781",
"0.6502597",
"0.6470315",
"0.6430534",
"0.64242977",
"0.6412038",
"0.6410684",
"0.6402201",
"0.63982266",
"0.63982266",
"0.63982266",
"0.63982266",
"0.63982266",
"0.63982266",
"0.63982266",
"0.6386694",
"0.6384853",
"0.63354015",
"0.6317921",
"0.6309592",
"0.6305038",
"0.63040364",
"0.63022757",
"0.630149",
"0.6298548",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62967414",
"0.62966204",
"0.62699884",
"0.6268909",
"0.6259364",
"0.62570363",
"0.62569165",
"0.6248514",
"0.6244454",
"0.624338",
"0.62405276",
"0.62405276",
"0.6238898",
"0.62363225",
"0.6234943",
"0.62341565",
"0.62228215",
"0.62036204",
"0.6187148",
"0.61799645",
"0.6177865",
"0.6174709",
"0.61611223",
"0.60999614",
"0.60880345",
"0.6071383",
"0.6067534",
"0.6056694",
"0.60522574",
"0.6041159",
"0.6039303",
"0.60360825",
"0.60299027",
"0.6025246",
"0.6024177",
"0.60107684",
"0.6004282",
"0.60030013",
"0.598768",
"0.5987175",
"0.5976472",
"0.59759396",
"0.5964355",
"0.59630835",
"0.59579295",
"0.59578866",
"0.594959",
"0.59444255",
"0.5943332",
"0.59426147",
"0.5940922",
"0.5934017"
] | 0.6163879 | 70 |
PATCH/PUT /cours/1 PATCH/PUT /cours/1.json | def update
respond_to do |format|
if @cour.update(cour_params)
format.html { redirect_to @cour, notice: 'Time table was successfully updated.' }
format.json { render :show, status: :ok, location: @cour }
else
format.html { render :edit }
format.json { render json: @cour.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @court = Court.find(params[:id])\n\n respond_to do |format|\n if @court.update_attributes(params[:court])\n format.html { redirect_to @court, notice: 'Court was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @court.update(court_params)\n format.html { redirect_to @court, notice: 'Court was successfully updated.' }\n format.json { render :show, status: :ok, location: @court }\n else\n format.html { render :edit }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @concour = Concour.find(params[:id])\n\n respond_to do |format|\n if @concour.update_attributes(params[:concour])\n format.html { redirect_to @concour, notice: 'Concour was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @court_complex.update(court_complex_params)\n format.html { redirect_to @court_complex, notice: 'Court complex was successfully updated.' }\n format.json { render :show, status: :ok, location: @court_complex }\n else\n format.html { render :edit }\n format.json { render json: @court_complex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @coursera.update(coursera_params)\n format.html { redirect_to @coursera, notice: 'Coursera was successfully updated.' }\n format.json { render :show, status: :ok, location: @coursera }\n else\n format.html { render :edit }\n format.json { render json: @coursera.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @coursub.update(coursub_params)\n format.html { redirect_to @coursub, notice: 'Coursub was successfully updated.' }\n format.json { render :show, status: :ok, location: @coursub }\n else\n format.html { render :edit }\n format.json { render json: @coursub.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @golf_cource = GolfCource.find(params[:id])\n\n respond_to do |format|\n if @golf_cource.update_attributes(params[:golf_cource])\n format.html { redirect_to scaffold_golf_cource_url(@golf_cource), notice: 'Golf cource was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @golf_cource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @soccer_court.update(soccer_court_params)\n format.html { redirect_to @soccer_court, notice: 'Soccer court was successfully updated.' }\n format.json { render :show, status: :ok, location: @soccer_court }\n else\n format.html { render :edit }\n format.json { render json: @soccer_court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course.update(course_params)\n render_jsonapi_response(@course)\n end",
"def update\n begin\n @course = Course.find(params[:id])\n raise if @course.nil?\n \n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to club_course_path }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, :notice=> 'Curso actualizado' }\n format.json { head :ok }\n else\n format.html { render :action=> \"edit\" }\n format.json { render :json=> @course.errors, :status=> :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @food_court.update(food_court_params)\n format.html { redirect_to @food_court, notice: 'Food court was successfully updated.' }\n format.json { render :show, status: :ok, location: @food_court }\n else\n format.html { render :edit }\n format.json { render json: @food_court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, :notice => 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n if @clue.update_attributes(params[:clue])\n format.html { redirect_to @clue, notice: 'Clue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clue = Clue.find(params[:id])\n\n respond_to do |format|\n if @clue.update_attributes(params[:clue])\n format.html { redirect_to @clue, notice: 'Clue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to courses_path(:option=>2), notice: 'El curso fue exitosamente editado!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n format.html { redirect_to @courses, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @courses }\n\n\n end\n end",
"def update\n @lecture = Lecture.find(params[:id])\n @course= Course.find(params[:course_id])\n \n respond_to do |format|\n if @lecture.update_attributes(params[:lecture])\n format.html { redirect_to [@course, @lecture], notice: 'Lecture was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lecture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course.update_attributes(parama[:course])\n respond_with(@course)\n end",
"def update\n respond_to do |format|\n if @courier_request.update(courier_request_params)\n format.html { redirect_to @courier_request, notice: \"Courier request was successfully updated.\" }\n format.json { render :show, status: :ok, location: @courier_request }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @courier_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n #don't need to add user_id here.. already exists.\n \n @course = Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @courier_detail.update(courier_detail_params)\n format.html { redirect_to @courier_detail, notice: \"Courier detail was successfully updated.\" }\n format.json { render :show, status: :ok, location: @courier_detail }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @courier_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @novanet_course.update(novanet_course_params)\n format.html { redirect_to @novanet_course, notice: 'Novanet course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @novanet_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to user_course_path(current_user,@course), notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_course.update(admin_course_params)\n format.html { redirect_to (params[:ref] || @admin_course), notice: t('crud.updated_successfully!', name: Admin::Course.model_name.human) }\n format.json { render :show, status: :ok, location: @admin_course }\n else\n format.html { render :edit }\n format.json { render json: @admin_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Curso editado satisfactoriamente' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course.update(course_params)\n respond_with(@course, location: course_path)\n end",
"def patch!\n request! :patch\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 @course = Course.find(params[:id])\n @course.user_id=current_user.id\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to(@course, :notice => 'Course was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Curso atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n course = Course.includes(:professors).find(params[:id])\n course.update!(course_params)\n \n course.professor_ids=(params[:professors])\n\n render json: course.to_json(include: :professors)\n end",
"def update\n respond_to do |format|\n if @api_v1_concern.update(api_v1_concern_params)\n format.html { redirect_to @api_v1_concern, notice: 'Concern was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_concern }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_concern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @caso.update_attributes(caso_params)\n format.html { redirect_to @caso, notice: 'Caso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @lecture.update(lecture_params)\n format.html { redirect_to lectures_url }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lecture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n respond_to do |format|\n if @course.update(courses_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @camp.update(camp_params)\n format.html { redirect_to @camp, notice: \"#{@camp.name} was revised in the system.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.jdson { render json: @camp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course ' + @course.course_id + ' was successfully updated!' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\nlogger.debug \"update discipline: \"[email protected]\n discipline_params.each_pair do |property,value|\n @discipline.send(property+'=',value)if @discipline.respond_to?(property+'=')\n end\n @discipline.updater_id = current_user\n if @discipline.save\n set_discipline\n #respond_with @discipline\n render json: @discipline, status: :ok\n else\n ##render json: @discipline.errors, status: :unprocessable_entity\n respond_with @discipline.errors, status: :unprocessable_entity\n end\n end",
"def update\n @squishee_cup = SquisheeCup.find(params[:id])\n puts params.to_json\n respond_to do |format|\n if @squishee_cup.update_attributes(params[:squishee_cup])\n format.html { redirect_to @squishee_cup, notice: 'Squishee cup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @squishee_cup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @person_course.update(person_course_params)\n format.html { redirect_to @person_course, notice: 'Person course was successfully updated.' }\n format.json { render :show, status: :ok, location: @person_course }\n else\n format.html { render :edit }\n format.json { render json: @person_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lab_course = LabCourse.find(params[:id])\n\n if params[:grand]\n grand = params[:grand].to_s\n params[:lab_course].merge!(:grand=>grand)\n end\n\n respond_to do |format|\n if @lab_course.update_attributes(params[:lab_course])\n format.html { redirect_to @lab_course, notice: 'Lab course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @courtstation = Courtstation.find(params[:id])\n\n respond_to do |format|\n if @courtstation.update_attributes(params[:courtstation])\n format.html { redirect_to @courtstation, notice: 'Courtstation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @courtstation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n respond_to do |format|\n if @people_course.update(people_course_params)\n format.html { redirect_to @people_course, notice: 'People course was successfully updated.' }\n format.json { render :show, status: :ok, location: @people_course }\n else\n format.html { render :edit }\n format.json { render json: @people_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n professor = Professor.find(params[:id])\n professor.update!(professor_params)\n\n render json: professor.to_json(include: :courses)\n end",
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n @course_request = CourseRequest.find(params[:id])\n\n respond_to do |format|\n if @course_request.update_attributes(params[:course_request])\n format.html { redirect_to @course_request, notice: 'Course request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_course.update(user_course_params)\n format.html { redirect_to @user_course, notice: 'User course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Admin::Course.find(params[:id])\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to [:admin, @course], :notice => 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n \n if (!params[:course])\n params[:course] = {:name=>params[:title], \n :f_day=>params[:description], \n :l_day=>params[:price]\n } \n end\n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n # format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n # format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course_section.update(course_section_params)\n format.html { redirect_to @course_section, notice: 'Course section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course_section.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cla.update(cla_params)\n format.html { redirect_to clas_path, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: \"Course was successfully updated.\" }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: \"Course was successfully updated.\" }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: \"Course was successfully updated.\" }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @course.update(course_params)\n format.html { redirect_to @course, notice: \"Course was successfully updated.\" }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @inscriptionprepaconcour = Inscriptionprepaconcour.find(params[:id])\n\n respond_to do |format|\n if @inscriptionprepaconcour.update_attributes(params[:inscriptionprepaconcour])\n format.html { redirect_to @inscriptionprepaconcour, notice: 'Inscriptionprepaconcour was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inscriptionprepaconcour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @study_course = StudyCourse.find(params[:id])\n\n respond_to do |format|\n if @study_course.update_attributes(params[:study_course])\n format.html { redirect_to @study_course, notice: 'Study course was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @study_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course = Course.find(params[:id])\n \n params[:course][:started_at].gsub!(\"/\",\".\") \n params[:course][:ended_at].gsub!(\"/\",\".\") \n\n respond_to do |format|\n if @course.update_attributes(params[:course])\n format.html { redirect_to @course, :notice => 'Curso atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n block_non_user\n @contest = Contest.find(params[:id])\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 respond_to do |format|\n if @clase.update(clase_params)\n format.html { redirect_to @clase, notice: 'La Clase fue modificada exitosamente.' }\n format.json { render :show, status: :ok, location: @clase }\n else\n @partidas_parciales = PartidaParcial.all\n format.html { render :edit }\n format.json { render json: @clase.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7166964",
"0.69608766",
"0.6829402",
"0.6826383",
"0.6665849",
"0.66395736",
"0.6563518",
"0.651923",
"0.65129983",
"0.6475539",
"0.64570355",
"0.6441262",
"0.6393419",
"0.63925433",
"0.63730115",
"0.63730115",
"0.6367086",
"0.63614196",
"0.63614196",
"0.63614196",
"0.63614196",
"0.63614196",
"0.63614196",
"0.63614196",
"0.63614196",
"0.6352733",
"0.63524073",
"0.63229406",
"0.63184726",
"0.6303291",
"0.6303291",
"0.6303291",
"0.6303291",
"0.6296291",
"0.6271034",
"0.6263896",
"0.62604326",
"0.625748",
"0.62354153",
"0.6234875",
"0.62207484",
"0.62190276",
"0.6216529",
"0.62070817",
"0.62068594",
"0.62044007",
"0.6196426",
"0.6190895",
"0.6175498",
"0.6169482",
"0.6161426",
"0.6159858",
"0.6141052",
"0.6140103",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.6139932",
"0.61394894",
"0.6137807",
"0.61283857",
"0.6123147",
"0.6122632",
"0.61201173",
"0.6116922",
"0.6114562",
"0.6113228",
"0.6112534",
"0.6106401",
"0.6102187",
"0.61017084",
"0.6098736",
"0.6097275",
"0.6094902",
"0.6094902",
"0.6094902",
"0.6094902",
"0.60701996",
"0.60601056",
"0.60571593",
"0.6053622",
"0.6049669"
] | 0.65952927 | 6 |
DELETE /cours/1 DELETE /cours/1.json | def destroy
@cour.destroy
respond_to do |format|
format.html { redirect_to cours_url, notice: 'Time table was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @court = Court.find(params[:id])\n @court.destroy\n\n respond_to do |format|\n format.html { redirect_to courts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @concour = Concour.find(params[:id])\n @concour.destroy\n\n respond_to do |format|\n format.html { redirect_to concours_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @court.destroy\n respond_to do |format|\n format.html { redirect_to courts_url, notice: 'Court was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @court = Court.find(params[:id])\n @court.destroy\n respond_to do |format|\n format.html { redirect_to(courts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @coursub.destroy\n respond_to do |format|\n format.html { redirect_to coursubs_url, notice: 'Coursub was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coursera.destroy\n respond_to do |format|\n format.html { redirect_to courseras_url, notice: 'Coursera was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @court = Court.friendly.find(params[:id])\n @court.destroy\n purge_all_pages\n\n respond_to do |format|\n format.html { redirect_to admin_courts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @golf_cource = GolfCource.find(params[:id])\n @golf_cource.destroy\n\n respond_to do |format|\n format.html { redirect_to scaffold_golf_cources_url }\n format.json { head :ok }\n end\n end",
"def delete_course_by_id(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/courses/#{org_unit_id}\" # setup user path\n # ap path\n _delete(path)\n puts '[+] Course data deleted successfully'.green\nend",
"def destroy\n @soccer_court.destroy\n respond_to do |format|\n format.html { redirect_to soccer_courts_url, notice: 'Soccer court was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @court_complex.destroy\n respond_to do |format|\n format.html { redirect_to court_complexes_url, notice: 'Court complex was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @novanet_course.destroy\n respond_to do |format|\n format.html { redirect_to novanet_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inscriptionprepaconcour = Inscriptionprepaconcour.find(params[:id])\n @inscriptionprepaconcour.destroy\n\n respond_to do |format|\n format.html { redirect_to inscriptionprepaconcours_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @Course = Course__c.find(params[:id])\n @Course.destroy\n\n respond_to do |format|\n format.html { redirect_to Courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @food_court.destroy\n respond_to do |format|\n format.html { redirect_to food_courts_url, notice: 'Food court was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @study_course = StudyCourse.find(params[:id])\n @study_course.destroy\n\n respond_to do |format|\n format.html { redirect_to study_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n puts \"WTF I GOT HERE\"\n @course = Course.find(params[:id])\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_path, notice: 'Course was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to coursees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Kurs je uspješno izbrisan. ' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clue = Clue.find(params[:id])\n @clue.destroy\n\n respond_to do |format|\n format.html { redirect_to clues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clue = Clue.find(params[:id])\n @clue.destroy\n\n respond_to do |format|\n format.html { redirect_to clues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Curso destruído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @critique.destroy\n respond_to do |format|\n format.html { redirect_to critiques_url, notice: 'Critique was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @course = Course.find(params[:id])\r\n @course.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to courses_path }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @three60.destroy\n respond_to do |format|\n format.html { redirect_to edit_admin_good_url(@good, anchor: \"three60\") }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cue = Cue.find(params[:id])\n @cue.destroy\n\n respond_to do |format|\n format.html { redirect_to cues_url }\n format.json { head :no_content }\n end\n end",
"def delete_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _delete(path)\n puts '[+] Course template data deleted successfully'.green\nend",
"def destroy\n @chaine = Chaine.find(params[:id])\n @chaine.destroy\n\n respond_to do |format|\n format.html { redirect_to chaines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @path_course.destroy\n respond_to do |format|\n format.html { redirect_to path_courses_url, notice: 'Path course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n LearningMaterial.destroy_course(@course)\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_path(:option=>2), notice: 'El curso fue exitosamente eliminado!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clinical_course = ClinicalCourse.find(params[:id])\n @clinical_course.destroy\n\n respond_to do |format|\n format.html { redirect_to clinical_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @university_course.destroy\n respond_to do |format|\n format.html { redirect_to university_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to my_created_courses_path, notice: 'Course was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @courier_detail.destroy\n respond_to do |format|\n format.html { redirect_to courier_details_url, notice: \"Courier detail was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @critic = Critic.find(params[:id])\n @critic.destroy\n\n respond_to do |format|\n format.html { redirect_to critics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cla.destroy\n respond_to do |format|\n format.html { redirect_to clas_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n course_name = @course.course_id\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course ' + course_name + ' was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @first_aid_course = FirstAidCourse.find(params[:id])\n @first_aid_course.destroy\n\n respond_to do |format|\n format.html { redirect_to first_aid_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lab_course = LabCourse.find(params[:id])\n @lab_course.destroy\n\n respond_to do |format|\n format.html { redirect_to lab_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @discipline = Discipline.find(params[:id])\n @discipline.destroy\n\n respond_to do |format|\n format.html { redirect_to disciplines_url }\n format.json { head :ok }\n end\n end",
"def destroy\n begin\n @course = Course.find(params[:id])\n raise if @course.nil?\n \n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to club_courses_path }\n format.json { head :no_content }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def destroy\n @clase_unit.destroy\n respond_to do |format|\n format.html { redirect_to clase_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy # simply delete single course\n begin\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end #end do\n rescue Exception => msgErr # interrogate a rescured exception\n puts msgErr #print error message\n end #end rescue\n end",
"def destroy\n @sivic_discipulo.destroy\n respond_to do |format|\n format.html { redirect_to sivic_discipulos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest.destroy\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @craque = Craque.find(params[:id])\n @craque.destroy\n\n respond_to do |format|\n format.html { redirect_to craques_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @c_titul.destroy\n respond_to do |format|\n format.html { redirect_to c_tituls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def delete\n result = Hash.new\n begin # try\n result = RegistCoursesHlp.delete(params[:id])\n rescue # catch\n result['status'] = false\n result['error'] = \"#{$!}\"\n ensure # finally\n render json: result\n end\n end",
"def destroy\n @colegio = Colegio.find(params[:id])\n @colegio.destroy\n\n respond_to do |format|\n format.html { redirect_to colegios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipy = Recipy.find(params[:id])\n @recipy.destroy\n\n respond_to do |format|\n format.html { redirect_to recipies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course = Course.where(:id=>params[:id]).first()\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_courses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @quiniela = Quiniela.find(params[:id])\n @quiniela.destroy\n\n respond_to do |format|\n format.html { redirect_to quinielas_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @court_type = CourtType.find(params[:id])\n @court_type.destroy\n purge_all_pages\n\n respond_to do |format|\n format.html { redirect_to admin_court_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n block_non_user\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @court_hall.destroy\n respond_to do |format|\n format.html { redirect_to court_halls_url, notice: 'Court hall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @watercourse.destroy\n respond_to do |format|\n format.html { redirect_to watercourses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cont = Cont.find(params[:id])\n @cont.destroy\n\n respond_to do |format|\n format.html { redirect_to conts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: \"Course was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: \"Course was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.7772591",
"0.7494277",
"0.74773806",
"0.7436032",
"0.7373102",
"0.7338597",
"0.7335299",
"0.7180881",
"0.71604013",
"0.7125698",
"0.7103116",
"0.7053597",
"0.7024754",
"0.7001528",
"0.69924736",
"0.6980457",
"0.6971676",
"0.6966079",
"0.6964703",
"0.69583946",
"0.69583946",
"0.69583946",
"0.69583946",
"0.69463235",
"0.69438165",
"0.69436276",
"0.69436276",
"0.69436276",
"0.69436276",
"0.69436276",
"0.69436276",
"0.69436276",
"0.69436276",
"0.69436276",
"0.69436276",
"0.69436276",
"0.69395113",
"0.69395113",
"0.69243985",
"0.69240385",
"0.6878375",
"0.6870844",
"0.6864297",
"0.6863951",
"0.68469214",
"0.6843141",
"0.6833785",
"0.68288887",
"0.6828758",
"0.68204355",
"0.68204355",
"0.681751",
"0.6816902",
"0.6811709",
"0.67959875",
"0.67946887",
"0.67846715",
"0.6779967",
"0.6770163",
"0.6769768",
"0.67690325",
"0.6764117",
"0.67638886",
"0.676286",
"0.6755473",
"0.67532694",
"0.6752849",
"0.67507964",
"0.6749149",
"0.6749149",
"0.6749149",
"0.6749149",
"0.6747886",
"0.67447686",
"0.67426664",
"0.6739617",
"0.67393774",
"0.6732347",
"0.67322564",
"0.67285836",
"0.67250854",
"0.67219895",
"0.6718476",
"0.67131656",
"0.67131656",
"0.670914",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285",
"0.67090285"
] | 0.7345408 | 5 |
Request ajax pour les matieres par rapport a une classe | def matieres
@classe = ClasseRoom.find(params[:id_classe])
@matieres = @classe.matieres.all
if request.xhr?
render :partial => 'matieres', locals: {:matieres => @matieres}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_ajax\n @ajax = Ajax.find(params[:id])\n end",
"def index\n @ajaxes = Ajax.all\n end",
"def ocRecibir\n id = params[:id]\n ocClass = Oc.new\n result = ocClass.recibirOC(id) \n render :json => {:aceptado => result, :idoc => id} \n\n end",
"def camiones\n logger.info 'en camiones' \n self.load_toggle({'q' => params[:q]}.to_s) #enviamos los parametros que vamos a aplilar\n @search = Truck.where(active: 1).includes(:state).search(params[:q])\n @banners = get_banners(params[:q])\n @trucks = @search.result.order(:nombre).page(params[:page]).per(Environment::LIMIT_SEARCH)\n @tiposCaminiones = TypeTruck.all.includes(:sub_trucks)\n @states = State.all.order(:name)\n @states_group = Truck.state_group(params[:q])\n @modelos_group = Truck.modelo_group(params[:q])\n @brand_group = Truck.marcas_group(params[:q])\n #@km_group = Truck.km_group\n @toggle_search = self.nested_search(params[:q])\n respond_to do |format|\n format.html { render :camiones }\n format.js { render :camiones }\n end\n end",
"def consultarFtp\n #Antes de procesar las ordenes, se actualiza la Bodega\n IniciarBodega.new('grupo7').actualizarBodega\n #Se consulta las ordenes\n ordenesConsultadas= ConsultarPedidosFtp.new.consultarOcsFTP\n render json: ordenesConsultadas\nend",
"def getProductType\n @product_type_description=ProductType.where(id: params[:id]).first.description\n @product_type={description: @product_type_description}\n respond_to do |format|\n format.html #need for ajax with html datatype \n format.json { render json: @product_type }#need for ajax with json datatyp \n end\n end",
"def request(klass, path, data={})\n url = url(path)\n http = http(url)\n req = build_request(klass, url, data)\n resp = http.request(req) # send request\n load_json(resp)\n end",
"def getCustomer\n @customer=Customer.where(id: params[:id]).first\n respond_to do |format|\n format.html #need for ajax with html datatype \n format.json { render json: @customer }#need for ajax with json datatyp \n end\n end",
"def search\n find_nota\n respond_to do |format|\n format.html{render :partial=> \"row_index\"}\n format.json { render json: @dependencias }\n format.js { }\n end\n end",
"def render_ajax\n {:partial => 'shared/flexigrid/ajax', :locals => {:grid => self}}\n end",
"def select\n @inventory_type = InventoryType.shod(params[:inventory_transfer_inventory_type_id])\n @inventories = @inventory_type.inventories\n @inventory_types = InventoryType.all\n respond_to do |format|\n format.js {render layout: false if request.xhr?}\n # format.js {render :partial => 'search_all' ,:layout => false}\n end\n end",
"def ajax_detail\n @eob = Eob.find(params[:id])\n @eob_details = []\n if params[:eob]\n @attributes = params[:eob][:eob_details_attributes]\n @attributes.each do |key, value|\n @eob_details.push @eob.eob_details.build(value)\n end\n end\n @count = @eob.eob_details.count\n @eob_details.push @eob.eob_details.build()\n\n respond_to do |format|\n format.js {render :layout => false }\n end\n end",
"def grabar_concesionario\n # puts 'AQUI'\n @concesionario = Concesionario_vehiculos.new\n @usuario = Usuario.new\n @rif=params[:rif]\n @nombre=params[:nombre]\n @correo=params[:correo]\n @telefono=params[:telefono]\n @ciudad=params[:ciudad]\n @direccion=params[:direccion]\n @marca=params[:marca]\n #------\n @nombre_usuario=params[:nombre_usuario]\n @contrasena=params[:contrasena]\n # puts ''+@nombre_usuario+''\n @usuario.grabar_usuario_concesionario(@nombre_usuario, @contrasena);\n # puts '+++++++++++++++++++++++++++++++++++++++++++++++++++++++metio usuario'\n @concesionario.grabar_concesionario(@rif,@nombre,@correo,@telefono,@ciudad,@direccion,@marca,@nombre_usuario)\n render :text => $tirajson\n end",
"def search\n find_organismos\n respond_to do |format|\n format.html{render :partial=> \"row_index\"}\n format.json { render json: @dependencias }\n format.js { }\n end\n end",
"def xhr?; end",
"def dame_institucion\n i = Metamares::Institucion.new\n i.nombre_institucion = params[:nombre_institucion]\n\n respond_to do |format|\n format.json { render json: i.busca_institucion.map{ |i| { id: i.id, value: i.nombre_institucion } } }\n format.html { @institucion = i }\n end\n end",
"def load_new_component_page\n @parent = get_parent(params[:parent_id])\n @items_to_select = [@parent]\n @all_properties = Property.all\n @all_products = Product.all\n @all_groups = Group.all\n respond_to do |format|\n format.js\n end\n end",
"def index\n \n if params[:term] != nil\n @dossiers = Dossier.find(:all, :conditions => ['id LIKE :search OR LOWER(ref_cabinet) LIKE LOWER(:search) OR LOWER(nom_dossier) LIKE LOWER(:search)', {:search => \"%#{params[:term]}%\"}])\n else\n @dossiers = current_user.parametres_cabinet.dossiers\n end\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dossiers }\n format.js {render :json => @dossiers.map {|p| { :label => p.try(:ref_cabinet)+' '+p.try(:nom_dossier) , :value => p.id}} }\n format.json {render :json => {\"success\"=>true,\"data\"=>@dossiers.map {|p| p.attributes.merge(:institution_nom => p.institution.try(:nom), :type_etat_dossier_description => p.type_etat_dossier.try(:description), :juge_mission_id => p.juge_mission.try(:contact_id), :juge_controlleur_id => p.juge_controlleur.try(:contact_id))}}} \n\n end\n end",
"def post_request\n\t\turl = request.fullpath.gsub(\"/api\", \"\")\n\t\t@rr = Rr.where(\"url = ?\", url).first\n\t\trespond_to do |format|\n\t\t\tformat.json { render :json => rr.response}\n\t\t\tformat.xml { render :xml => @rr.response}\n\t\t\tformat.js { render :js => @rr.response}\n\t\tend\n\tend",
"def ajax\n\n uri_string = @params[:uri]\n # uri_string = \"http://www.phase-eight.com#{path_string}\"\n uri = construct_uri_object uri_string\n response = network_response uri\n logger.debug \"XHR response type #{response.content_type}\"\n logger.debug \"XHR response body #{response.body.html_safe}\"\n render text: response.body\n end",
"def new\n @actividad = current_usuario.institucion.actividades.new\n @instituciones = current_usuario.institucion.familia_activa\n respond_to do |format|\n format.js\n end\n end",
"def relatorio_aluno_classe\n session[:classe_id] = params[:classe_id]\n session[:ano_nota] = Time.now.year\n @matriculas = Matricula.find(:all,:conditions =>['classe_id = ? ', params[:classe_id]], :order =>'classe_num')\n @classe = Classe.find(:all,:conditions =>['id = ?', params[:classe_id]])\n @classe.each do |classe|\n session[:num_classe]= classe.classe_classe[0,1].to_i\n end\n @atribuicao_classe = Atribuicao.find(:all,:conditions =>['classe_id = ?', params[:classe_id]])\n render :partial => 'relatorio_classe'\n end",
"def index\n @requerimiento = Requerimiento.find(params[:requerimiento_id])\n @materiales = @requerimiento.materiales\n\n respond_to do |format|\n format.html # index.html.erb\n format.js\n end\n end",
"def search\n find_dependencias\n respond_to do |format|\n format.html{render :partial=> \"row_index\"}\n format.json { render json: @dependencias }\n format.js { }\n end\n end",
"def ajax\n\n# Render json data containing the different fields: (For ajax use)\n render :json => { total: Cache.count, \n uploads: Cache.where(source: 'original').count, \n downloads: Cache.where(source: 'collamine').count, \n urls: Cache.desc(:created_at).limit(10).pluck(:url), \n domains: Cache.desc(:created_at).distinct(:domain).take(10)\n }\n end",
"def load_new_image_page\n\n @parent = get_parent(params[:parent_id])\n @items_to_select = [@parent]\n\n @all_properties = Property.all\n @all_products = Product.all\n @all_components = Component.all\n\n respond_to do |format|\n format.js\n end\n end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def ajax_response params = {}\n if params[:template]\n content = render_to_string :template => params[:template]\n else\n content = render_to_string\n end\n\n send_data resposta, :type => 'text/html', :filename => \"content_#{request.session_options[:id]}.html\"\n end",
"def load_new_vf_page\n @parent = get_parent(params[:parent_id])\n @items_to_select = [@parent]\n\n @all_properties = Property.all\n @all_products = Product.all\n @all_components = Component.all\n\n respond_to do |format|\n format.js\n end\n end",
"def type_objects\n pre = Prereq.new(:need_type => params[:type])\n pre.id = params[:id].to_i\n respond_to do |format|\n format.js {render :partial => 'prereqs/prereq_items_by_type', :locals => {:prereq => pre}}\n end\n end",
"def show\n @dynamique = Dynamique.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dynamique }\n end\n end",
"def findreg\n @detalles = Detalle.find(params[:id])\n render json: @detalles\n end",
"def autocomplete_clase_nombre \n respond_to do |format|\n @clases = Clase.joins(:partida_parcial => [:partida_principal]).where(\"clases.fecha_de_baja IS NULL AND clases.nombre ILIKE ?\", \"%#{params[:term]}%\").order(\"partidas_principales.codigo\").order(\"partidas_parciales.codigo\").order(\"clases.codigo\").paginate(:page => params[:page], :per_page => 30) \n render :json => @clases.map { |clase| {:id => clase.id, :label => clase.nombre, :value => clase.nombre} } \n format.js { } \n end \n end",
"def show\n @tipo_processo = TipoProcesso.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @tipo_processo }\n format.js\n end\n end",
"def load_edit_component_page\n @all_groups = Group.all\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n @component = Component.find(params[:component_id])\n\n @component_components = @component.components\n @component_valuefields = @component.valuefields\n @component_properties = @component.properties\n @component_images = @component.images\n @component_datafiles = @component.data_files\n @component_products = @component.products\n @component_group = @component.group\n respond_to do |format|\n format.js\n end\n end",
"def new\n @realiza = Realiza.new\n @pessoas=Pessoa.select(\"clientes.id,pessoas.nome\").joins(:cliente)\n @funcionarios=Pessoa.select(\"usuarios.id,pessoas.nome\").joins(:usuario)\n #@pessoas=Pessoa.select(\"clientes.id,pessoas.nome\").joins(:clientes)\n #@funcionarios=Pessoa.where(\"id in (?)\",Usuario.select(\"pessoa_id as id\").map(&:id))\n @servicos=Servico.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @realiza and @pessoas and @funcionarios and @servicos}\n end\n end",
"def index\n #@users = User.all\n @respuesta = Consulta.new(300,params[0])\n\n respond_to do |format|\n format.json { render json: @respuesta }\n \n end\n end",
"def new\n @clazz = Clazz.new\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @clazz }\n format.js\n end\n end",
"def load_add_image_page\n\n @parent = get_parent(params[:parent_id])\n @items_to_select = @parent.images\n\n @all_components = Component.all\n @all_images = Image.all\n\n respond_to do |format|\n format.js\n end\n end",
"def ajax_show\n @music_category = MusicCategory.find(params[:id])\n @musics= @music_category.musics\n respond_to do |format|\n format.js { render layout: false }\n end\n end",
"def index\n logement = Logement.find_by(id:params[:logement_id])\n equipement = logement.equi_securites[0].title\n equipements = logement.equi_securites[0]\n\n render json: {\n securites:equipement,\n fichier:equipements\n }\n end",
"def create\n @sro = Sro.find(params[:person][:sro_id])\n case params[:person][:typ].to_i\n when 1\n @all_asso = @sro.people.where(:typ => 1)\n when 2\n @all_mdir = @sro.people.where(:typ => 2)\n when 3\n @all_sup = @sro.people.where(:typ => 2)\n end\n @person = Person.new(person_params)\n case params[:person][:typ].to_i\n when 1\n @person.typ = 1\n when 2\n @person.typ = 2\n when 3\n @person.typ = 3\n end\n @person.sro_id = @sro.id\n @person.funkcia_od = Time.now\n @person.save\n respond_to do |format|\n format.js\n end\n end",
"def ajax_load_node_edit_info\n\n # Get the Node from the DB\n node = Node.find(params[:node_id])\n\n data = {\n :node_id => node.id,\n :node_name => node.name,\n :node_email_template_name => node.email_template_id,\n :node_delay_time => node.delay_time,\n :node_delay_unit => node.delay_unit,\n }\n\n # Return data as JSON\n render json: data\n\n end",
"def xhr_script; end",
"def load_edit_datafile_page\n @all_groups = Group.all\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n @data_file = DataFile.find(params[:datafile_id])\n\n respond_to do |format|\n format.js\n end\n end",
"def new\n @objet = Objet.new\n load_ressources\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @objet }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render json: SerieDetallesDatatable.new(view_context) }\n end\n end",
"def index\n p \"DANS LE PLACARD!\"\n p request.xhr?\n @totos = Toto.all\n end",
"def check_use_ajax\n case self.use_ajax\n when Object, TrueClass\n self.use_ajax= true\n else\n self.use_ajax= false\n end\n end",
"def render_ajax(event)\n render_event(event, :ajax)\n end",
"def load_attributes_form\n @symbole = Symbole.new if @symbole.nil?\n if params[:form_name].present?\n respond_to do |format|\n format.js { render \"ajax_form_\"+params[:form_name] }\n end\n end\n end",
"def lista\n @receitas = Receita.all\n\n respond_to do |format|\n format.html # lista.html.erb\n format.xml { render :xml => @receitas }\n end\n end",
"def getReceiverAddress\n \n $addresses= ReceiverAddress.where(receiver_id: params[:id]);\n respond_to do |format|\n format.html #need for ajax with html datatype \n format.json { render json: $addresses }#need for ajax with json datatyp\n end\n end",
"def show_ajax\n @element = Element.find_by(tag: params[:tag])\n @previous_color = @element.previous_color || \"\" if @element\n respond_to do |format|\n format.js\n end\n end",
"def render_js_ajax\n render_code(@js, :ajax)\n end",
"def show\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @juzgado }\n end\n end",
"def sondagesParAdmin\n sondages = SondageService.instance.listeDesSondagesParAdmin(params[:id])\n render json: sondages, status: :ok\n end",
"def show\n render json: @itemtipo\n end",
"def load_add_vf_page\n #Checks if parent_id is a Product or Component based on a string value\n @parent = get_parent(params[:parent_id])\n @items_to_select = @parent.valuefields\n\n @all_properties = Property.all\n respond_to do |format|\n format.js\n end\n end",
"def show\n @clasificacion_pegi = ClasificacionPegi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clasificacion_pegi }\n end\n end",
"def get_content\n respond_to do |format|\n format.js\n end\n end",
"def get_content\n respond_to do |format|\n format.js\n end\n end",
"def index\n seleccionarMenu(:juzgados)\n @juzgados = Juzgado.order(:ciudad_id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @juzgados }\n end\n end",
"def new\n @tipo_contrato = TipoContrato.new\n \n if params[:modal_ajax]\n render :layout => false\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_contrato }\n end\n end\n end",
"def load_new_df_page\n @parent = get_parent(params[:parent_id])\n @items_to_select = [@parent]\n\n @all_datafiles = DataFile.all\n @all_properties = Property.all\n @all_products = Product.all\n\n respond_to do |format|\n format.js\n end\n end",
"def activos\n render :json => Producto.activo.all\n end",
"def render_rb_ajax\n render_code(@rb, :ajax)\n end",
"def request_data; end",
"def search_matter\n cid = @company.id\n @search_result =[]\n @search_result = matter_search # Common search\n respond_to do |format|\n format.js { render :partial=> 'matter_auto_complete', :object => @search_result }\n format.html { render :partial=> 'matter_auto_complete', :object => @search_result }\n end \n end",
"def buque\n respond_to do |format|\n begin\n if params[:tipo_materia_id] == 1 # Es un buque de bauxita\n @buque = DescargaBauxita.descargar(params)\n else\n @buque = DescargaOtro.descargar(params[:id])\n end\n format.json { render :json => @gabarra }\n rescue Exceptions::PresenciaValoresExcepcion => errores\n format.json { render :json => errores.errors, :status => 400 }\n end\n end\n end",
"def stations\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def show\n @fichier = Fichier.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @fichier }\n format.js {render :action => \"show\"}\n end\n end",
"def index\n #@company = Company.find(1)\n @effects = Effect.page(params[:page]).per(1)\n respond_to do |format|\n format.html\n format.js \n\n end\n end",
"def show\n @conta = Conta.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @conta, :include => {\n :movimentos => {\n :include => [:nota, :pessoa],\n :methods => [:favorecido],\n :except => [:created_at, :updated_at]\n }\n },\n :methods => [:saldo]\n }\n end\n end",
"def new\n @ciudade = Ciudade.new\n\n respond_to do |format|\n format.html{ # new.html.erb\n render({:layout=>false }) if(request.xhr?)\n } \n format.json { render json: @ciudade }\n end\n end",
"def troca\n @remetente = Sobrevivente.where(id: params[:de]).first\n @destinatario = Sobrevivente.where(id: params[:para]).first\n\n enviar = {agua: 1, comida: 2, medicamento: 3, municao: 4}\n receber = {agua: 0, comida: 2, medicamento: 3, municao: 8}\n\n trocou = @remetente.troca(@destinatario, enviar, receber)\n\n render json: { status: trocou }\n end",
"def show\n @lancamento = Lancamento.find(params[:id])\n respond_to do |format|\n format.js\n format.html # show.html.erb\n format.xml { render :xml => @lancamento }\n end\n end",
"def proximos\n @lista = Array.new\n estabelecimentos = Estabelecimento.all\n if (params[:token] != nil)\n user = Usuario.find_by_token(params[:token])\n @favoritos = Favorito.find_all_by_usuario_id(user.id)\n estabelecimentos.each do |estab|\n estab.favorito = false\n @favoritos.each do |fav|\n if (fav.estabelecimento_id == estab.id)\n estab.favorito = true\n break\n end\n end \n end\n end\n \n raio = params[:raio]\n if (raio == nil)\n raio = 1000\n end\n estabelecimentos.each do |estab|\n dist = distancia(params[:latitude].to_f, params[:longitude].to_f,estab.latitude, estab.longitude)\n if (dist.to_f <= raio.to_f && dist.to_f != 0.0)\n if (estab.favorito == nil)\n estab.favorito = false\n end\n @lista.push(estab)\n end\n end\n \n respond_to do |format|\n format.html # proximos.html.erb\n format.json { render :json => @lista, :include => {:precos =>{:only => :valor, :include =>:produto } , \n :caracteristicas => {:only => [:nome, :id]} } }\n end\n \n end",
"def show\n @sesion = Sesion.where(entidad_paraestatal_id: @entidad_paraestatal.id).find(params[:id])\n @sesion.suplente ||= Suplente.new\n @sesion.suplente.empleado ||= Empleado.new\n\n #@emails = Email.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sesion }\n end\n end",
"def ajax_report\n @report = Reporting.find(params[:id])\n\n end",
"def show\n @contrato = Contrato.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @contrato }\n format.js\n end\n end",
"def fees_particulars_new2\n @batch=Batch.find(params[:batch_id])\n @master_fee_particulars = MasterFeeParticular.core\n @fees_category = FinanceFeeCategory.find(params[:category_id])\n @tax_slabs = TaxSlab.all if @tax_enabled\n @student_categories = StudentCategory.active\n respond_to do |format|\n format.js { render :action => 'fees_particulars_new2' }\n end\n end",
"def status_list\n @title=\"审核商品\"\n respond_to do |format|\n format.js { render 'list' }\n end\n end",
"def load_form\n @symbole = Symbole.new if @symbole.nil?\n if params[:form_name].present?\n respond_to do |format|\n format.js { render \"ajax_form_\"+params[:form_name] }\n end\n end\n end",
"def show\n @recoleccion = Recoleccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recoleccion }\n end\n end",
"def show\n @advogados_escritorio = AdvogadosEscritorio.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @advogados_escritorio }\n format.js\n end\n end",
"def create\n \n @error = \"\"\n case params[:oper]\n when \"edit\"\n edit_item_master \n \n when \"add\"\n items= Itemmaster.new(params[:itemmaster]) \n items.save \n \n \n when \"del\"\n params[:id].split(',').each do |id|\n Itemmaster.destroy(id.to_i) \n end\n \n \n end \n #If it is a Ajax then send the json details\n \n if request.xhr?\n if [email protected]? \n render :json => @error.to_json, status: 500\n else\n render :json => items\n end\n end \n end",
"def show\n @respostum = Respostum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.js # Ajax CRUD\n end\n end",
"def result\n case params[:search_type]\n when \"purchaseorders\"\n @class = PurchaseOrder\n @name = \"Purchase Orders\"\n when \"keys\"\n @class = Key\n @name = \"Key Codes\"\n when \"endusers\"\n @class = EndUser\n @name = \"End Users\"\n when \"purchasers\"\n @class = Purchaser\n @name = \"Purchasers\"\n end\n \n @css_class = params[:search_type]\n @search = @class.search(params[:q])\n @list = @search.result\n\n respond_to do |format|\n format.js\n end\n end",
"def list\n do_list\n\n respond_to do |type|\n type.html {\n render :action => 'list', :layout => true\n }\n type.js { \n do_list\n render :action => 'list', :layout => false \n }\n type.xml { render :xml => response_object.to_xml, :content_type => Mime::XML, :status => response_status }\n type.json { render :text => response_object.to_json, :content_type => Mime::JSON, :status => response_status }\n type.yaml { render :text => response_object.to_yaml, :content_type => Mime::YAML, :status => response_status }\n end\n end"
] | [
"0.6200452",
"0.6059195",
"0.60206294",
"0.5843768",
"0.5723455",
"0.5659972",
"0.56199867",
"0.5607161",
"0.55788904",
"0.55769986",
"0.5570233",
"0.55488765",
"0.5512759",
"0.55118906",
"0.55107474",
"0.55093956",
"0.5495089",
"0.54907805",
"0.5484914",
"0.5473539",
"0.54674345",
"0.54547554",
"0.54445845",
"0.54395604",
"0.5396743",
"0.53945583",
"0.53885007",
"0.53885007",
"0.53885007",
"0.53885007",
"0.53885007",
"0.53885007",
"0.53885007",
"0.53885007",
"0.53885007",
"0.53885007",
"0.53885007",
"0.5386735",
"0.5385154",
"0.53780913",
"0.5359899",
"0.53587043",
"0.5349983",
"0.53294057",
"0.53236705",
"0.53221136",
"0.5317217",
"0.53144056",
"0.53137565",
"0.5306546",
"0.5305422",
"0.5295192",
"0.52856266",
"0.52853286",
"0.5280963",
"0.52769613",
"0.52711445",
"0.52673286",
"0.5265029",
"0.5263505",
"0.5261639",
"0.5248774",
"0.5245646",
"0.523087",
"0.52262765",
"0.5216531",
"0.521496",
"0.52104115",
"0.52102685",
"0.5210257",
"0.5210003",
"0.5210003",
"0.52086776",
"0.5208256",
"0.52077913",
"0.5207489",
"0.520596",
"0.5203085",
"0.5201838",
"0.5192428",
"0.51898223",
"0.5188659",
"0.5184687",
"0.5179392",
"0.5178292",
"0.51778287",
"0.5174028",
"0.5173982",
"0.51714104",
"0.5166447",
"0.5163847",
"0.51598686",
"0.515498",
"0.5153492",
"0.5149943",
"0.51463926",
"0.51444954",
"0.5139974",
"0.51389843",
"0.51342773"
] | 0.63314766 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_cour
@cour = Cour.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 cour_params
params.require(:cour).permit(:enseignant_id, :matiere_id, :salle_id, :creneau_debut, :creneau_fin, :jour_id, :nombre_heure, :numero_cours, :numero_cours_g, :annee_id, :ecole_id, :semestre_id, :user_id, :first_classe_room_id, :classe_room_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 valid_params_request?; 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 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 safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\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 user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\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 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 valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\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 parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\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"
] | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",
"0.6290449",
"0.6282986",
"0.6241265",
"0.62392694",
"0.62192893",
"0.621427",
"0.62099457",
"0.6195319",
"0.61785376",
"0.61747766",
"0.6172739",
"0.6162921",
"0.6152228",
"0.6152062",
"0.6148811",
"0.6122391",
"0.6117956",
"0.61083806",
"0.6106195",
"0.609274",
"0.60815483",
"0.60710186",
"0.6064253",
"0.60213476",
"0.6018128",
"0.60146624",
"0.601063",
"0.60068774",
"0.60068774",
"0.60026145",
"0.6000521",
"0.59987193",
"0.5992379",
"0.59922844",
"0.5991889",
"0.59803206",
"0.5966244",
"0.5959778",
"0.5959708",
"0.59588563",
"0.5956974",
"0.5953329",
"0.59528023",
"0.59439695",
"0.59413165",
"0.59397036",
"0.59397036",
"0.5933782",
"0.59323835",
"0.59258395",
"0.59253365",
"0.5917244",
"0.59111005",
"0.59093463",
"0.5907942",
"0.59047514",
"0.58979666",
"0.58971125",
"0.589613",
"0.5895083",
"0.5893643",
"0.5892825",
"0.5887658",
"0.5883417",
"0.5878839",
"0.5874345",
"0.5869008",
"0.5868205",
"0.58672875",
"0.5867031",
"0.58662426",
"0.5864551",
"0.5863614",
"0.5862626",
"0.5861952",
"0.58596134",
"0.5855716",
"0.58536863",
"0.5851665",
"0.5850823"
] | 0.0 | -1 |
GET /ocupations/1 GET /ocupations/1.xml | def show
@ocupation = Ocupation.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @ocupation }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @socioeconomic_ocupation = SocioeconomicOcupation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @socioeconomic_ocupation }\n end\n end",
"def index\n @ocupations = Ocupation.all\n end",
"def index\n @has_ocupations = HasOcupation.all\n end",
"def list\n @oyoyos = Oyoyo.find (:all)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @oyoyo }\n end\n \nend",
"def new\n @socioeconomic_ocupation = SocioeconomicOcupation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @socioeconomic_ocupation }\n end\n end",
"def opensearch\n respond_to do |format|\n format.xml do\n render :layout => false\n end\n format.json do\n render :json => get_opensearch_response\n end\n end\n end",
"def path\n \"/onca/xml\"\n end",
"def new\n @ocupation = Ocupation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ocupation }\n end\n end",
"def opensearch\n respond_to do |format|\n format.xml do\n render :layout => false\n end\n format.json do\n render :json => get_opensearch_response\n end\n end\n end",
"def show\n @odc_i = OdcI.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @odc_i }\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 @oils = Oil.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @oils }\n end\n end",
"def show\n @page_id = \"opinions\"\n @opinion = Opinion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @opinion }\n end\n end",
"def index\n @organs = Organ.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @organs }\n end\n end",
"def show\n @odc_r = OdcR.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @odc_r }\n end\n end",
"def index\n @omatsuris = Omatsuri.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @omatsuris }\n format.json { render :json => @omatsuris }\n end\n end",
"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 opensearch\n respond_to do |format|\n format.xml { render layout: false }\n format.json { render json: search_service.opensearch_response }\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 orgs\n @orgs = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # orgs.html.erb\n format.xml { render :xml => @orgs }\n end\n end",
"def to_xml\n Ox.to_xml document\n end",
"def set_ocupation\n @ocupation = Ocupation.find(params[:id])\n end",
"def show\n @Roc = Roc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @Roc }\n end\n end",
"def index\n @user_openids = UserOpenid.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_openids }\n end\n end",
"def show\n @ocat = Ocat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ocat }\n end\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 index\n @organizations = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @organizations }\n end\n end",
"def show\n @ins_co_office = InsCoOffice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ins_co_office }\n end\n end",
"def opensearch\n respond_to do |format|\n format.xml do\n render :layout => false\n end\n format.json do\n render :json => search_service.opensearch_response\n end\n end\n end",
"def index\n @csos = Cso.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @csos }\n end\n end",
"def show\n @gene_ontology = GeneOntology.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gene_ontology }\n end\n end",
"def show\n @offlearn = Offlearn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @offlearn }\n end\n end",
"def index\n @occupancies = @location.occupancies\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @occupancies }\n end\n end",
"def index\n @officers = Officer.find(:all)\n @clubs = Club.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @officers }\n end\n end",
"def show\n @occurrence = Occurrence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @occurrence }\n end\n end",
"def index\n @ocats = Ocat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ocats }\n end\n end",
"def show\n @obat = Obat.find(params[:id])\n pagination(params[:id], \"show\")\n\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @obat }\n end\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 show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @coating }\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 opensearch\n respond_to do |format|\n format.xml do\n render layout: false\n end\n format.json do\n render json: open_search_data\n end\n end\n end",
"def show\n @occurence = Occurence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @occurence }\n end\n end",
"def destroy\n @ocupation = Ocupation.find(params[:id])\n @ocupation.destroy\n\n respond_to do |format|\n format.html { redirect_to(ocupations_url) }\n format.xml { head :ok }\n end\n end",
"def show\n @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @os_type }\n end\n end",
"def show\n @oligo_order = OligoOrder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @oligo_order }\n end\n end",
"def index\n @occupationclassifications = Occupationclassification.paginate(:page => params[:page], :per_page => 4, :order => \"description ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @occupationclassifications }\n end\n end",
"def show\n @outfit_pair = OutfitPair.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @outfit_pair }\n end\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 oai\n options = params.delete_if { |k,v| %w{controller action}.include?(k) }\n render :text => oai_provider.process_request(options), :content_type => 'text/xml' \n end",
"def index\n @offices = current_user.offices\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @offices }\n end\n end",
"def show\n @oyoyo = Oyoyo.find(params[:id])\n\n respond_to do |s|\n s.html # show.html.erb\n s.xml { render :xml => @oyoyo }\n end\n end",
"def oai\n options = params.delete_if { |k| %w(controller action format).include?(k) }\n render text: oai_provider.process_request(options).gsub('<?xml version=\"1.0\" encoding=\"UTF-8\"?>', \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" ?>\\n<?xml-stylesheet type=\\\"text/xsl\\\" href=\\\"#{ActionController::Base.helpers.asset_path('oai2.xsl')}\\\" ?>\"), content_type: 'text/xml'\n end",
"def show\n @frequencia_orgao = Frequencia::Orgao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb.erb\n format.xml { render :xml => @frequencia_orgao }\n end\n end",
"def index\n @ofreces = Ofrece.all\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 index\n @omises = Omise.all\n end",
"def index\n @exposures = Exposure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @exposures }\n end\n end",
"def index\n\t\t@people = Person.all\n\t\t# respond_to do |format|\n\t\t# \tformat.xml { send_data @entries.to_xml, :type => 'text/xml; charset=UTF-8;', :disposition => 'attachment; filename=entries.xml'}\n\t\t# end\n\tend",
"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 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 index\n @coatings = do_index(Coating, params)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @coatings }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @calibration }\n end\n end",
"def show\n @cso = Cso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cso }\n end\n end",
"def index\n @os_types = OsType.find(:all, :order => 'position')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @os_types }\n end\n end",
"def index\n @accessories = Accessory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @accessories }\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 index\n @ocupacions = Ocupacion.all\n end",
"def show\n @title = \"Show Operations\"\n @operation = Operation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def by_saison\n @saison = Saison.find_by_year(params[:id])\n respond_to do |format|\n format.xml\n end\n end",
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def index\n @correspondences = Correspondence.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @correspondences }\n end\n end",
"def show\n @opml_metadata = OpmlMetadata.find(params[:id])\n @OPML = @opml_metadata.db_file.data\n\n respond_to do |format|\n format.html # show.html.erb\n #format.opml { render :opml => @OPML }\n format.xml { render :xml => @OPML }\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\n @pages = @comic.pages\n \n respond_to do |format|\n format.html\n format.xml\n end\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 @occupationclassification = Occupationclassification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @occupationclassification }\n end\n end",
"def show\n @operating_expense = OperatingExpense.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operating_expense }\n end\n end",
"def show\n @otml_category = OtrunkExample::OtmlCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @otml_category }\n end\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def index\n @boms = Bom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @boms }\n end\n end",
"def index\n @ingresos = Ingreso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ingresos }\n end\n end",
"def index\n @operating_systems = OperatingSystem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @operating_systems }\n end\n end",
"def show\n @convenio = Convenio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @convenio }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def show\n @association = Association.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @association.to_xml }\n end\n end",
"def index\n @page_id = \"opinions\"\n @opinions = Opinion.all\n services = Service.find(:all)\n agents = Agent.all\n @agents_list = agents.collect {|item| [ item.name, item.id ]}\n @agents_table = agents.inject({}) {|h,i| h[i.id] = i.name; h}\n @services_list = services.collect {|item| [ item.name, item.id ]}\n @services_table = services.inject({}) {|h, i| h[i.id] = i.name; h}\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @opinions }\n end\n end",
"def get_xml(url, options = {})\n\t\t\tresponse = get_file(url, options)\n\t\t\tdoc = Hpricot.XML(response)\n\t\t\terrors = doc.search(\"*[@errCode]\")\n\t\t\tif errors.size > 0\n\t\t\t\terrors.each do |error|\n\t\t\t\t\traise Wowr::Exceptions::raise_me(error[:errCode], options)\n\t\t\t\tend\n\n elsif (doc%'achievements')\n\t\t\t return doc\n\t\t\telsif (doc%'dungeons')\n\t\t\t\treturn doc\n\t\t\telsif (doc%'page').nil?\n\t\t\t\traise Wowr::Exceptions::EmptyPage\n\t\t\telse\n\t\t\t\treturn (doc%'page')\n\t\t\tend\n\t\tend",
"def index\n @corporacion_policiacas = CorporacionPoliciaca.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @corporacion_policiacas }\n end\n end",
"def index\n @feria2010observaciones = Feria2010observacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feria2010observaciones }\n end\n end",
"def index\n @ingrediences = Ingredience.search(params[:search], params[:page],10) \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ingrediences }\n end\n end",
"def index\n @association_types = AssociationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @association_types }\n end\n end",
"def create\n @ocupation = Ocupation.new(params[:ocupation])\n\n respond_to do |format|\n if @ocupation.save\n format.html { redirect_to(@ocupation, :notice => 'Ocupation was successfully created.') }\n format.xml { render :xml => @ocupation, :status => :created, :location => @ocupation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ocupation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @oil = Oil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @oil }\n end\n end",
"def show\n @oil = Oil.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @oil }\n end\n end",
"def show\n @operation = Operation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def index\n @asistencias = Asistencia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @asistencias }\n end\n end",
"def index\n @crop_definitions = CropDefinition.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @crop_definitions }\n end\n end",
"def show\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estagio }\n end\n end",
"def index\n @associates = Associate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @associates }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ciclos }\n end\n end"
] | [
"0.6790965",
"0.6476865",
"0.6170878",
"0.61315924",
"0.61057764",
"0.6094056",
"0.60913074",
"0.60798764",
"0.607963",
"0.60550696",
"0.60216063",
"0.6002889",
"0.59724796",
"0.59591585",
"0.5958458",
"0.5935473",
"0.59258676",
"0.59021676",
"0.58776015",
"0.58676744",
"0.58605677",
"0.58212185",
"0.58158046",
"0.5812678",
"0.5809914",
"0.5802641",
"0.5799856",
"0.57978374",
"0.5775838",
"0.5774739",
"0.5767825",
"0.576755",
"0.57624316",
"0.5761512",
"0.57508975",
"0.5748419",
"0.57475984",
"0.57433814",
"0.5732173",
"0.57299906",
"0.57229793",
"0.57221335",
"0.57146716",
"0.57031",
"0.56893843",
"0.5678586",
"0.5661061",
"0.5647371",
"0.56462634",
"0.5643766",
"0.5642497",
"0.5641301",
"0.56396866",
"0.5633962",
"0.5632791",
"0.5632138",
"0.5629592",
"0.56278974",
"0.5625008",
"0.56231266",
"0.5607685",
"0.560743",
"0.5598647",
"0.5598251",
"0.55975276",
"0.5596099",
"0.5582435",
"0.557915",
"0.5575073",
"0.557369",
"0.5563297",
"0.5561529",
"0.5559711",
"0.5549746",
"0.554601",
"0.5542467",
"0.55421835",
"0.55399275",
"0.55334437",
"0.55209726",
"0.55166215",
"0.5514068",
"0.55137837",
"0.5513374",
"0.5512605",
"0.5512014",
"0.550916",
"0.55069643",
"0.54919654",
"0.54887545",
"0.54837984",
"0.5479271",
"0.547216",
"0.5470086",
"0.54664165",
"0.5462146",
"0.54608744",
"0.54580647",
"0.54539096",
"0.54537696"
] | 0.6930736 | 0 |
GET /ocupations/new GET /ocupations/new.xml | def new
@ocupation = Ocupation.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @ocupation }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n @socioeconomic_ocupation = SocioeconomicOcupation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @socioeconomic_ocupation }\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\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @coating }\n end\n end",
"def new\n @occurence = Occurence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occurence }\n end\n end",
"def new\n @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 respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @gene_ontology = GeneOntology.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gene_ontology }\n end\n end",
"def new\n @os_type = OsType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @os_type }\n end\n end",
"def new\n @title = \"New Operations\"\n @operation = Operation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operation }\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 @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 new\n @office = Office.new\n\t\t\n\t\t\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @office }\n end\n end",
"def new\n @association = Association.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @association }\n end\n end",
"def new\n @election = Election.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @election }\n end\n end",
"def new\n @convenio = Convenio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @convenio }\n end\n end",
"def new\n @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 @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 @odc_i = OdcI.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @odc_i }\n end\n end",
"def new\n @ocat = Ocat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ocat }\n end\n end",
"def new\n @ins_co_office = InsCoOffice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ins_co_office }\n end\n end",
"def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @po }\n end\n end",
"def new\n @geoname = Geoname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @geoname }\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 @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 @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recurso }\n end\n end",
"def new\n @documentoclasificacion = Documentoclasificacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documentoclasificacion }\n end\n end",
"def new\n @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 @odc_r = OdcR.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @odc_r }\n end\n end",
"def new\n @aplicacion = Aplicacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aplicacion }\n end\n end",
"def new\n @domino = Domino.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @domino }\n end\n end",
"def new\n @estagio = Estagio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estagio }\n end\n end",
"def new\n @nom = Nom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nom }\n end\n end",
"def new\n @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 @operation = Operation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def new\n @olark = Olark.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @olark }\n end\n end",
"def new\n @opml_metadata = OpmlMetadata.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @opml_metadata }\n end\n end",
"def new\n @offlearn = Offlearn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @offlearn }\n end\n end",
"def new\n @conseq = Conseq.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @conseq }\n end\n end",
"def new\n @estacion = Estacion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estacion }\n end\n end",
"def new\n @representative = Representative.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @representative }\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 @calification = Calification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @calification }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nomina }\n end\n end",
"def new\n @ponto = Ponto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ponto }\n end\n end",
"def new\n @people = People.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @people }\n end\n end",
"def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @location }\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 respond_to do |format|\n format.html\n format.xml\n end\n end",
"def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end",
"def new\n @nostro = Nostro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nostro }\n end\n end",
"def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end",
"def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end",
"def new\n @oil = Oil.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @oil }\n end\n end",
"def new\n @oil = Oil.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @oil }\n end\n end",
"def new\n @occupancy = Occupancy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occupancy }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end",
"def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lore }\n end\n end",
"def new\n @occupationclassification = Occupationclassification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occupationclassification }\n end\n end",
"def new\n @namespace = Namespace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @namespace }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ciclo }\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 # new.html.erb\n format.xml { render :xml => @infraction_type }\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 @colo = Colo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @colo }\n end\n end",
"def new\n @nossos_servico = NossosServico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def new\n @curso = Curso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @curso }\n end\n end",
"def new\n @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 @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 @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @neighborhood }\n end\n end",
"def new\n @ingredience = Ingredience.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ingredience }\n end\n end",
"def new\n @depositocaucion = Depositocaucion.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @depositocaucion }\n end\n end",
"def new\n logger.debug 'new_some interesting information'\n @comdty = Comdty.new\n setvariables\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comdty }\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 @vocab = Vocab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vocab }\n end\n end",
"def new\n @otml_category = OtrunkExample::OtmlCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @otml_category }\n end\n end",
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @relationship = Relationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relationship }\n end\n end",
"def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end",
"def new\n @addition = Addition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @addition }\n end\n end",
"def new\n @index = Indice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @index }\n end\n end",
"def create\n @ocupation = Ocupation.new(params[:ocupation])\n\n respond_to do |format|\n if @ocupation.save\n format.html { redirect_to(@ocupation, :notice => 'Ocupation was successfully created.') }\n format.xml { render :xml => @ocupation, :status => :created, :location => @ocupation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ocupation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @oligo_order = OligoOrder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @oligo_order }\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 new_prc\n\n setup_campuses_and_semesters\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prc }\n end\n end",
"def new \n @how_to = HowTo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @how_to }\n end\n end",
"def new\n @publication = Publication.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @publication }\n end\n end",
"def new\n @title = \"New income classification\"\n @incomeclassification = Incomeclassification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @incomeclassification }\n end\n end",
"def new\n @organ = Organ.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organ }\n end\n end",
"def new\n @calidadtiposdocumento = Calidadtiposdocumento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @calidadtiposdocumento }\n end\n end",
"def new\n @publication = Publication.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @publication }\n end\n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @licence }\n end\n end",
"def new\n @pessoa = Pessoa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def new\n @pessoa = Pessoa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pessoa }\n end\n end",
"def new\n @proceso = Proceso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @proceso }\n end\n end",
"def new\n @solicitation = @representative.solicitations.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitation }\n end\n end"
] | [
"0.73057485",
"0.71672004",
"0.7144566",
"0.70368457",
"0.6906072",
"0.68498653",
"0.6843003",
"0.6812067",
"0.6811108",
"0.679478",
"0.6771034",
"0.6760634",
"0.67339236",
"0.6720273",
"0.67166007",
"0.6713132",
"0.6701063",
"0.6687514",
"0.6680076",
"0.66765267",
"0.6672924",
"0.6665088",
"0.6659669",
"0.66582584",
"0.66563845",
"0.66534114",
"0.66534114",
"0.66534114",
"0.6646435",
"0.6642341",
"0.6642203",
"0.6634905",
"0.6617766",
"0.66166437",
"0.6606744",
"0.66042525",
"0.6602545",
"0.65947115",
"0.65936536",
"0.658934",
"0.65750116",
"0.6572709",
"0.6565063",
"0.6564885",
"0.65635294",
"0.6547751",
"0.65443176",
"0.6544232",
"0.6543667",
"0.6531878",
"0.6528998",
"0.65278673",
"0.6527796",
"0.65277004",
"0.6527085",
"0.6527085",
"0.65220994",
"0.65220994",
"0.65216124",
"0.65195",
"0.65017545",
"0.6496211",
"0.649195",
"0.6488206",
"0.6487203",
"0.64871204",
"0.64846563",
"0.64814186",
"0.64753777",
"0.64717805",
"0.64707655",
"0.6467135",
"0.64645696",
"0.64628375",
"0.6462823",
"0.6459394",
"0.6458937",
"0.645848",
"0.64562213",
"0.64556277",
"0.64555585",
"0.6454113",
"0.64429057",
"0.6440162",
"0.6438667",
"0.6437296",
"0.64363164",
"0.6435639",
"0.64250106",
"0.64230025",
"0.64224833",
"0.6419052",
"0.64095396",
"0.64080125",
"0.64062977",
"0.6406263",
"0.64047927",
"0.64047927",
"0.64032197",
"0.6402353"
] | 0.749265 | 0 |
POST /ocupations POST /ocupations.xml | def create
@ocupation = Ocupation.new(params[:ocupation])
respond_to do |format|
if @ocupation.save
format.html { redirect_to(@ocupation, :notice => 'Ocupation was successfully created.') }
format.xml { render :xml => @ocupation, :status => :created, :location => @ocupation }
else
format.html { render :action => "new" }
format.xml { render :xml => @ocupation.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @ocupation = Ocupation.new(ocupation_params)\n\n respond_to do |format|\n if @ocupation.save\n format.html { redirect_to @ocupation, notice: 'Ocupation was successfully created.' }\n format.json { render :show, status: :created, location: @ocupation }\n else\n format.html { render :new }\n format.json { render json: @ocupation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @socioeconomic_ocupation = SocioeconomicOcupation.new(params[:socioeconomic_ocupation])\n\n respond_to do |format|\n if @socioeconomic_ocupation.save\n format.html { redirect_to(@socioeconomic_ocupation, :notice => 'SocioeconomicOcupation was successfully created.') }\n format.xml { render :xml => @socioeconomic_ocupation, :status => :created, :location => @socioeconomic_ocupation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @socioeconomic_ocupation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def ocupation_params\n params.require(:ocupation).permit(:description)\n end",
"def create\n @opinion = Opinion.new(params[:opinion])\n\n respond_to do |format|\n if @opinion.save\n format.html { redirect_to(opinions_path, :notice => 'Opinion was successfully created.') }\n format.xml { render :xml => @opinion, :status => :created, :location => @opinion }\n else\n format.html { render :action => \"opinions_path\" }\n format.xml { render :xml => @opinion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def create\n @ocat = Ocat.new(params[:ocat])\n\n respond_to do |format|\n if @ocat.save\n format.html { redirect_to @ocat, notice: 'Ocat was successfully created.' }\n format.json { render json: @ocat, status: :created, location: @ocat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ocat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ocupacion = Ocupacion.new(ocupacion_params)\n\n respond_to do |format|\n if @ocupacion.save\n format.html { redirect_to @ocupacion, notice: 'Ocupacion was successfully created.' }\n format.json { render :show, status: :created, location: @ocupacion }\n else\n format.html { render :new }\n format.json { render json: @ocupacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end",
"def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x|\n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x|\n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end",
"def new\n @ocupation = Ocupation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ocupation }\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x| \n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x| \n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end",
"def set_ocupation\n @ocupation = Ocupation.find(params[:id])\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end",
"def destroy\n @ocupation = Ocupation.find(params[:id])\n @ocupation.destroy\n\n respond_to do |format|\n format.html { redirect_to(ocupations_url) }\n format.xml { head :ok }\n end\n end",
"def new\n @socioeconomic_ocupation = SocioeconomicOcupation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @socioeconomic_ocupation }\n end\n end",
"def create\n @occasion = Occasion.new(occasion_params)\n @occasion.administrators << current_user\n respond_to do |format|\n if @occasion.save\n format.html { redirect_to @occasion, notice: 'Occasion was successfully created.' }\n format.json { render :show, status: :created, location: @occasion }\n else\n format.html { render :new }\n format.json { render json: @occasion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @occasion = Occasion.new(occasion_params)\n\n respond_to do |format|\n if @occasion.save\n format.html { redirect_to [:admin, @occasion], notice: 'Occasion was successfully created.' }\n format.json { render :show, status: :created, location: @occasion }\n else\n format.html { render :new }\n format.json { render json: @occasion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @opnion = Opnion.new(opnion_params)\n\n respond_to do |format|\n if @opnion.save\n format.html { redirect_to @opnion, notice: 'Opnion was successfully created.' }\n format.json { render :show, status: :created, location: @opnion }\n else\n format.html { render :new }\n format.json { render json: @opnion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def do_submission(path, xml = nil)\n if xml.nil?\n form = create(:form, question_types: %w(integer integer))\n form.publish!\n xml = build_odk_submission(form)\n end\n\n # write xml to file\n require 'fileutils'\n FileUtils.mkpath('test/fixtures')\n fixture_file = Rails.root.join('test/fixtures/', ODK_XML_FILE)\n File.open(fixture_file.to_s, 'w') { |f| f.write(xml) }\n\n # Upload and do request.\n uploaded = fixture_file_upload(fixture_file, 'text/xml')\n post(path, {:xml_submission_file => uploaded, :format => 'xml'}, 'HTTP_AUTHORIZATION' => encode_credentials(@user.login, 'password'))\n assigns(:response)\n end",
"def create\n @odc_i = OdcI.new(params[:odc_i])\n\n respond_to do |format|\n if @odc_i.save\n format.html { redirect_to(@odc_i, :notice => 'Odc i was successfully created.') }\n format.xml { render :xml => @odc_i, :status => :created, :location => @odc_i }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @odc_i.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ontology = SYMPH::Ontology.save(params[:ontology])\n \n respond_to do |format|\n if @ontology\n flash[:notice] = 'Ontology was successfully created.'\n else\n flash[:notice] = 'Failed on create ontology.'\n end\n format.html { redirect_to :action => :edit, :id => @ontology }\n format.xml { render :xml => @ontology, :status => :created, :location => @ontology }\n end\n end",
"def generate_xml_request\n tax_receipt = generate_tax_receipt\n @certificate.certifica tax_receipt\n @key.sella tax_receipt\n tax_receipt.to_xml\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 @ocupations = Ocupation.all\n @has_ocupation = HasOcupation.new(has_ocupation_params)\n @selected_ocupations = has_ocupation_params[:ocupation_id]\n @ok = false\n\n @selected_ocupations.each do |ocupation_id|\n @ok = true if HasOcupation.create(worker_id: has_ocupation_params[:worker_id], ocupation_id: ocupation_id)\n end if !@selected_ocupations.nil?\n\n\n respond_to do |format|\n if @ok\n format.html { redirect_to @has_ocupation, notice: 'Has ocupation was successfully created.' }\n format.json { render :show, status: :created, location: @has_ocupation }\n else\n format.html { render :new }\n format.json { render json: @has_ocupation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @omise = Omise.new(omise_params)\n\n respond_to do |format|\n if @omise.save\n format.html { redirect_to @omise, notice: 'Omise was successfully created.' }\n format.json { render :show, status: :created, location: @omise }\n else\n format.html { render :new }\n format.json { render json: @omise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @operating_expense = OperatingExpense.new(params[:operating_expense])\n\n respond_to do |format|\n if @operating_expense.save\n format.html { redirect_to(@operating_expense, :notice => 'Operating expense was successfully created.') }\n format.xml { render :xml => @operating_expense, :status => :created, :location => @operating_expense }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @operating_expense.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @appoiment = Appoiment.new(params[:appoiment])\n\n respond_to do |format|\n if @appoiment.save\n \n format.xml { render :xml => @appoiment, :status => :created, :location => @appoiment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @appoiment.errors, :status => :unprocessable_entity }\n end\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 create\n @onsen = Onsen.new(onsen_params)\n\n respond_to do |format|\n if @onsen.save\n format.html { redirect_to @onsen, notice: 'Onsen was successfully created.' }\n format.json { render :show, status: :created, location: @onsen }\n else\n format.html { render :new }\n format.json { render json: @onsen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/investmentaccount/v1\")\n end",
"def ocs_generada_params\n params.require(:ocs_generada).permit(:oc_request_id, :oc_id, :grupo, :cliente, :proveedor, :sku, :fechaEntrega, :cantidad, :cantidadDespachada, :precioUnitario, :canal, :notas, :urlNotificacion, :estado)\n end",
"def add_oidc(doc)\n @logger.debug('sso - in add_oidc')\n oidc = REXML::Element.new('openidConnectClient', doc.root)\n oidc.add_attribute('id', @client_id)\n oidc.add_attribute('clientId', @client_id)\n oidc.add_attribute('clientSecret', @client_secret)\n oidc.add_attribute('authorizationEndpointUrl', @auth_url)\n oidc.add_attribute('tokenEndpointUrl', @token_url)\n oidc.add_attribute('redirectToRPHostAndPort', \"https://#{@host}\")\n oidc.add_attribute('issuerIdentifier', @issuer_identifier)\n oidc.add_attribute('scope', @scope)\n #YD 11102016 start - add PingFederate attributes\n puts '-----> Adding openidConnectClient attributes for PingFederate'\n oidc.add_attribute('grantType', @grantType)\n oidc.add_attribute('jwkEndpointUrl', @jwkEndpointUrl)\n oidc.add_attribute('signatureAlgorithm', @signatureAlgorithm)\n oidc.add_attribute('userIdentityToCreateSubject', @userIdentityToCreateSubject)\n #YD 11102016 start - add PingFederate attributes\n oidc.add_attribute('httpsRequired', 'true')\n oidc.add_attribute('sslRef', 'ssoSSLConfig')\n end",
"def has_ocupation_params\n params.require(:has_ocupation).permit(:worker_id, ocupation_id:[])\n end",
"def create\n @oyoyo = Oyoyo.new(params[:oyoyo])\n\n respond_to do |format|\n if @oyoyo.save\n flash[:notice] = 'Oyoyo was successfully created.'\n format.html { redirect_to(@oyoyo) }\n format.xml { render :xml => @oyoyo, :status => :created, :location => @oyoyo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @oyoyo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @association = Association.new(params[:association])\n\n respond_to do |format|\n if @association.save\n flash[:notice] = 'Association was successfully created.'\n format.html { redirect_to(@association) }\n format.xml { render :xml => @association, :status => :created, :location => @association }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @association.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @doc_ponto_comer = DocPontoComer.new(doc_ponto_comer_params)\n\n respond_to do |format|\n if @doc_ponto_comer.save\n format.html { redirect_to @doc_ponto_comer, notice: 'Doc ponto comer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @doc_ponto_comer }\n else\n format.html { render action: 'new' }\n format.json { render json: @doc_ponto_comer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @socio = Socio.new(params[:socio])\n\n respond_to do |format|\n @socio.save\n format.html { redirect_to socios_url}\n end\n end",
"def create\n @ins_co_office = InsCoOffice.new(params[:ins_co_office])\n\n respond_to do |format|\n if @ins_co_office.save\n format.html { redirect_to(@ins_co_office, :notice => 'Office was successfully created.') }\n format.xml { render :xml => @ins_co_office, :status => :created, :location => @ins_co_office }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ins_co_office.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ocupation.update(ocupation_params)\n format.html { redirect_to @ocupation, notice: 'Ocupation was successfully updated.' }\n format.json { render :show, status: :ok, location: @ocupation }\n else\n format.html { render :edit }\n format.json { render json: @ocupation.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 post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/rewardsaccount/v1\")\n end",
"def create\n @oligo_order = OligoOrder.new(params[:oligo_order])\n\n respond_to do |format|\n if @oligo_order.save\n flash[:notice] = 'OligoOrder was successfully created.'\n format.html { redirect_to(@oligo_order) }\n format.xml { render :xml => @oligo_order, :status => :created, :location => @oligo_order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @oligo_order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @asociacion = Asociacion.new(asociacion_params)\n\n respond_to do |format|\n if @asociacion.save\n format.html { redirect_to @asociacion, notice: 'Asociacion was successfully created.' }\n format.json { render :show, status: :created, location: @asociacion }\n else\n format.html { render :new }\n format.json { render json: @asociacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ovode = Ovode.new(params[:ovode])\n\n respond_to do |format|\n if @ovode.save\n format.html { redirect_to @ovode, notice: 'ovode was successfully created.' }\n format.json { render json: @ovode, status: :created, location: @ovode }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ovode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @opinion = Opinion.new(params[:opinion])\n\n respond_to do |format|\n if @opinion.save\n format.html { redirect_to @opinion, notice: 'Opinion was successfully created.' }\n format.json { render json: @opinion, status: :created, location: @opinion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @Roc = Roc.new(params[:Roc])\n\n respond_to do |format|\n if @Roc.save\n flash[:notice] = 'Roc was successfully created.'\n format.html { redirect_to(@Roc) }\n format.xml { render :xml => @Roc, :status => :created, :location => @Roc }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @Roc.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @obat = Obat.new(params[:obat])\n\n respond_to do |format|\n if @obat.save\n format.html { redirect_to(:action => \"new\", :notice => CREATE_MSG) }\n format.xml { render :xml => @obat, :status => :created, :location => @obat }\n else\n @cancel_url = request.fullpath+\"/new\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @obat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @odc_r = OdcR.new(params[:odc_r])\n\n respond_to do |format|\n if @odc_r.save\n format.html { redirect_to(@odc_r, :notice => 'Odc r was successfully created.') }\n format.xml { render :xml => @odc_r, :status => :created, :location => @odc_r }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @odc_r.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @odist = Odist.new(odist_params)\n\n respond_to do |format|\n if @odist.save\n format.html { redirect_to @odist, notice: 'Odist was successfully created.' }\n format.json { render :show, status: :created, location: @odist }\n else\n format.html { render :new }\n format.json { render json: @odist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @frequencia_orgao = Frequencia::Orgao.new(params[:frequencia_orgao])\n\n respond_to do |format|\n if @frequencia_orgao.save\n format.html { redirect_to(@frequencia_orgao, :notice => 'Orgão criado com sucesso.') }\n format.xml { render :xml => @frequencia_orgao, :status => :created, :location => @frequencia_orgao }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @frequencia_orgao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @estagio = Estagio.new(params[:estagio])\n\n respond_to do |format|\n if @estagio.save\n flash[:notice] = 'Estagio was successfully created.'\n format.html { redirect_to(@estagio) }\n format.xml { render :xml => @estagio, :status => :created, :location => @estagio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @documentoclasificacion = Documentoclasificacion.new(params[:documentoclasificacion])\n\n respond_to do |format|\n if @documentoclasificacion.save\n format.html { redirect_to(@documentoclasificacion, :notice => 'Documentoclasificacion was successfully created.') }\n format.xml { render :xml => @documentoclasificacion, :status => :created, :location => @documentoclasificacion }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @documentoclasificacion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @cancellation = Cancellation.new_from_xml(request.body.read)\n respond_to do |format|\n if @cancellation.save! \n format.xml { render :action => 'show', :status => :created, :location => @cancellation }\n else\n format.xml { render :xml => @cancellation.errors, :status => :unprocessable_entity }\n end\n end \n \n #@orders.each do |order|\n end",
"def create\n @expense = Expense.new(expense_params)\n @gastos = Gasto.all \n @documents = Document.all\n \n respond_to do |format|\n if @expense.save\n @expense.correlativo\n \n format.html { redirect_to @expense, notice: 'Expense was successfully created.' }\n format.json { render :show, status: :created, location: @expense }\n else\n format.html { render :new }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gene_ontology = GeneOntology.new(params[:gene_ontology])\n\n respond_to do |format|\n if @gene_ontology.save\n format.html { redirect_to(@gene_ontology, :notice => 'Gene ontology was successfully created.') }\n format.xml { render :xml => @gene_ontology, :status => :created, :location => @gene_ontology }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gene_ontology.errors, :status => :unprocessable_entity }\n end\n end\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 to_xml\n header = build_header\n body = build_body\n envelope = build_envelope\n envelope << header\n envelope << body\n doc = Ox::Document.new(version: '1.0')\n doc << envelope\n Ox.dump(doc)\n end",
"def index\n @ocupations = Ocupation.all\n end",
"def create\n @opinion = Opinion.new(opinion_params)\n\n respond_to do |format|\n if @opinion.save\n format.html { redirect_to @opinion, notice: 'Opinion was successfully created.' }\n format.json { render action: 'show', status: :created, location: @opinion }\n else\n format.html { render action: 'new' }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @outdonation = Outdonation.new(params[:outdonation])\n\n respond_to do |format|\n if @outdonation.save\n format.html { redirect_to @outdonation, notice: 'Outdonation was successfully created.' }\n format.json { render json: @outdonation, status: :created, location: @outdonation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @outdonation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post #:doc:\n end",
"def create\n \n @doc = Doc.new(params[:doc])\n\n respond_to do |format|\n if @doc.save\n save_object_relationship\n format.html { redirect_to(@doc, :notice => 'Doc was successfully created.') }\n format.xml { render :xml => @doc, :status => :created, :location => @doc }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @depositocaucion = Depositocaucion.new(@depositocaucionnuevo)\n respond_to do |format|\n if @depositocaucion.save\n flash[:notice] = 'Depositocaucion was successfully created.'\n format.html { redirect_to(@depositocaucion) }\n format.xml { render :xml => @depositocaucion, :status => :created, :location => @depositocaucion }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @depositocaucion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_document_save_as(request)\n data, _status_code, _headers = post_document_save_as_with_http_info(request)\n request_token if _status_code == 401\n data\n end",
"def create\n @office = current_user.offices.build(params[:office])\n\n respond_to do |format|\n if @office.save\n flash[:notice] = 'Office was successfully created.'\n format.html { redirect_to(root_path) }\n format.xml { render :xml => @office, :status => :created, :location => @office }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @office.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @socioeconomic_ocupation = SocioeconomicOcupation.find(params[:id])\n @socioeconomic_ocupation.destroy\n\n respond_to do |format|\n format.html { redirect_to(socioeconomic_ocupations_url) }\n format.xml { head :ok }\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 update\n @ocupation = Ocupation.find(params[:id])\n\n respond_to do |format|\n if @ocupation.update_attributes(params[:ocupation])\n format.html { redirect_to(@ocupation, :notice => 'Ocupation was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ocupation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @officer = Officer.new(params[:officer])\n\n respond_to do |format|\n if @officer.save\n flash[:notice] = 'Officer was successfully created.'\n format.html { redirect_to(@officer) }\n format.xml { render :xml => @officer, :status => :created, :location => @officer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @officer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ativo_outro = AtivoOutro.new(params[:ativo_outro])\n\n respond_to do |format|\n if @ativo_outro.save\n format.html { redirect_to @ativo_outro, notice: 'Ativo foi salvo com sucesso.' }\n format.json { render json: @ativo_outro, status: :created, location: @ativo_outro }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ativo_outro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @has_ocupation.update(has_ocupation_params)\n format.html { redirect_to @has_ocupation, notice: 'Has ocupation was successfully updated.' }\n format.json { render :show, status: :ok, location: @has_ocupation }\n else\n format.html { render :edit }\n format.json { render json: @has_ocupation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if election.save\n format.html { redirect_to(election, flash: { success: 'Election created.' }) }\n format.xml { render :xml => election, :status => :created, :location => election }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => election.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_ontology(ont_info)\n uri = URI.parse(TARGET_API)\n http = Net::HTTP.new(uri.host, uri.port)\n\n req = Net::HTTP::Put.new(\"/ontologies/#{ont_info['acronym']}\")\n req['Content-Type'] = 'application/json'\n req['Authorization'] = \"apikey token=#{TARGET_APIKEY}\"\n\n if ont_info['viewingRestriction'] == 'private'\n # In case of private ontology (acl: list of user that have the right to see the ontology)\n req.body = { 'acronym': ont_info['acronym'], 'name': ont_info['name'],\n 'group': ont_info['group'], 'hasDomain': ont_info['hasDomain'],\n 'administeredBy': [TARGETED_PORTAL_USER],\n 'viewingRestriction': 'private',\n 'acl': [TARGETED_PORTAL_USER] }.to_json\n else\n req.body = { 'acronym': ont_info['acronym'], 'name': ont_info['name'],\n 'group': ont_info['group'], 'hasDomain': ont_info['hasDomain'],\n 'administeredBy': [TARGETED_PORTAL_USER] }.to_json\n end\n\n response = http.start do |http|\n http.request(req)\n end\n\n return response\nend",
"def create\n @ofrece = Ofrece.new(ofrece_params)\n\n respond_to do |format|\n if @ofrece.save\n format.html { redirect_to @ofrece, notice: 'Ofrece was successfully created.' }\n format.json { render :show, status: :created, location: @ofrece }\n else\n format.html { render :new }\n format.json { render json: @ofrece.errors, status: :unprocessable_entity }\n end\n end\n end",
"def oai\n options = params.delete_if { |k,v| %w{controller action}.include?(k) }\n render :text => oai_provider.process_request(options), :content_type => 'text/xml' \n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/creditaccount/v1\")\n end",
"def process\n document.add_opinions_layer\n opinions.each.with_index do |opinion, index|\n document.add_opinion opinion, index+1\n end\n\n document.add_linguistic_processor\n\n if document.pretty then pretty_print document else document.to_xml end\n end",
"def create\n @docderivacione = Docderivacione.new(docderivacione_params)\n\n respond_to do |format|\n if @docderivacione.save\n format.html { redirect_to @docderivacione, notice: 'Docderivacione was successfully created.' }\n format.json { render :show, status: :created, location: @docderivacione }\n else\n format.html { render :new }\n format.json { render json: @docderivacione.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @opcao = Opcao.new(opcao_params)\n\n respond_to do |format|\n if @opcao.save\n format.html { redirect_to @opcao, notice: 'Opção criada com sucesso!' }\n format.json { render :show, status: :created, location: @opcao }\n else\n format.html { render :new }\n format.json { render json: @opcao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @ocupation.destroy\n respond_to do |format|\n format.html { redirect_to ocupations_url, notice: 'Ocupation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def save_opf!\n file.write(opf_path, opf_xml.to_s)\n\n opf_xml\n end",
"def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.GroundCloseRequest(:xmlns => \"http://fedex.com/ws/close/v2\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n\n xml.TimeUpToWhichShipmentsAreToBeClosed up_to_time.utc.iso8601(2)\n }\n end\n builder.doc.root.to_xml\n end",
"def create\n @oyun = Oyun.new(oyun_params)\n\n respond_to do |format|\n if @oyun.save\n format.html { redirect_to @oyun, notice: 'Oyun was successfully created.' }\n format.json { render :show, status: :created, location: @oyun }\n else\n format.html { render :new }\n format.json { render json: @oyun.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @thuoc = Thuoc.new(thuoc_params)\n\n respond_to do |format|\n if @thuoc.save\n format.html { redirect_to @thuoc, notice: \"Thuoc was successfully created.\" }\n format.json { render :show, status: :created, location: @thuoc }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @thuoc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @offlearn = Offlearn.new(params[:offlearn])\n\n respond_to do |format|\n if @offlearn.save\n flash[:notice] = 'Offlearn was successfully created.'\n format.html { redirect_to(@offlearn) }\n format.xml { render :xml => @offlearn, :status => :created, :location => @offlearn }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @offlearn.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @omatsuri = Omatsuri.new(params[:omatsuri])\n\n respond_to do |format|\n if @omatsuri.save\n flash[:notice] = 'Omatsuri was successfully created.'\n format.html { redirect_to(@omatsuri) }\n format.xml { render :xml => @omatsuri, :status => :created, :location => @omatsuri }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @omatsuri.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ontology = Ontology.new(ontology_params)\n\n respond_to do |format|\n if @ontology.save\n format.html { redirect_to @ontology, notice: 'Ontology was successfully created.' }\n format.json { render :show, status: :created, location: @ontology }\n else\n format.html { render :new }\n format.json { render json: @ontology.errors, status: :unprocessable_entity }\n end\n end\n end",
"def socioeduk_ocorrencia_params\n params.require(:socioeduk_ocorrencia).permit(:nome, :descricao, :tipo_ocorrencia_id)\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/bankingaccount/v1\")\n end",
"def opinion_params\n params.require(:opinion).permit(:nombre, :nacionalidad, :pais, :ciudad, :comentario)\n end",
"def create\n @calidadtiposdocumento = Calidadtiposdocumento.new(params[:calidadtiposdocumento])\n\n respond_to do |format|\n if @calidadtiposdocumento.save\n format.html { redirect_to(@calidadtiposdocumento, :notice => 'Calidadtiposdocumento was successfully created.') }\n format.xml { render :xml => @calidadtiposdocumento, :status => :created, :location => @calidadtiposdocumento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @calidadtiposdocumento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @orging = Orging.new(orging_params)\n\n respond_to do |format|\n if @orging.save\n format.html { redirect_to @orging, notice: 'Orging was successfully created.' }\n format.json { render :show, status: :created, location: @orging }\n else\n format.html { render :new }\n format.json { render json: @orging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @election = Election.new(params[:election])\n\n respond_to do |format|\n if @election.save\n flash[:notice] = 'Election was successfully created.'\n format.html { redirect_to(@election) }\n format.xml { render :xml => @election, :status => :created, :location => @election }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @election.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @oiseau = Oiseau.new(oiseau_params)\n\n respond_to do |format|\n if @oiseau.save\n format.html { redirect_to @oiseau, notice: 'Oiseau was successfully created.' }\n format.json { render :show, status: :created, location: @oiseau }\n else\n format.html { render :new }\n format.json { render json: @oiseau.errors, status: :unprocessable_entity }\n end\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 ocupacion_params\n params.require(:ocupacion).permit( :code, :name)\n end",
"def opera_params\n params.require(:opera).permit(:numero, :sub, :descrizione, :anno, :ente, :target_id, :target_type, :target, :responsabile_id)\n end",
"def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend",
"def create\n @escalation = Escalation.new(escalation_params)\n\n respond_to do |format|\n if @escalation.save\n format.html { redirect_to @escalation, notice: 'Escalation was successfully created.' }\n format.json { render :show, status: :created, location: @escalation }\n else\n format.html { render :new }\n format.json { render json: @escalation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @socio_doc_fiscais_coring = SocioDocFiscaisCoring.new(socio_doc_fiscais_coring_params)\n\n respond_to do |format|\n if @socio_doc_fiscais_coring.save\n format.html { redirect_to @socio_doc_fiscais_coring, notice: 'Socio doc fiscais coring was successfully created.' }\n format.json { render action: 'show', status: :created, location: @socio_doc_fiscais_coring }\n else\n format.html { render action: 'new' }\n format.json { render json: @socio_doc_fiscais_coring.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.62676764",
"0.6061635",
"0.5767977",
"0.5756089",
"0.57539666",
"0.5698497",
"0.5642777",
"0.55888253",
"0.55632687",
"0.5555623",
"0.55305827",
"0.5456165",
"0.54385304",
"0.54368865",
"0.54179543",
"0.54081476",
"0.5349922",
"0.5347773",
"0.5346056",
"0.53235614",
"0.53153986",
"0.5310036",
"0.5278883",
"0.52784866",
"0.52672243",
"0.52549773",
"0.52501273",
"0.5241232",
"0.5238646",
"0.5230824",
"0.522965",
"0.52122223",
"0.5209314",
"0.52003807",
"0.51853764",
"0.5184767",
"0.5181779",
"0.5178005",
"0.51687294",
"0.5158395",
"0.5152954",
"0.5150679",
"0.51444983",
"0.51442266",
"0.51277673",
"0.51233536",
"0.51231843",
"0.5120653",
"0.5104699",
"0.5085942",
"0.50838274",
"0.5078742",
"0.5059876",
"0.50493",
"0.5040134",
"0.50369644",
"0.5034411",
"0.5031847",
"0.50264096",
"0.50190395",
"0.5012958",
"0.50118214",
"0.5010799",
"0.50043726",
"0.4999191",
"0.49983627",
"0.4994127",
"0.49932015",
"0.4985383",
"0.49831334",
"0.4980911",
"0.49781424",
"0.49732426",
"0.49709862",
"0.49682242",
"0.49670815",
"0.49639988",
"0.49600846",
"0.4953025",
"0.49486646",
"0.49462944",
"0.49459225",
"0.4937928",
"0.4936158",
"0.49325007",
"0.49309614",
"0.49308297",
"0.49296647",
"0.4929193",
"0.49280852",
"0.49248",
"0.49243325",
"0.4909095",
"0.4905362",
"0.49010938",
"0.48974574",
"0.48954397",
"0.4890204",
"0.4888717",
"0.48882693"
] | 0.66049844 | 0 |
PUT /ocupations/1 PUT /ocupations/1.xml | def update
@ocupation = Ocupation.find(params[:id])
respond_to do |format|
if @ocupation.update_attributes(params[:ocupation])
format.html { redirect_to(@ocupation, :notice => 'Ocupation was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @ocupation.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @socioeconomic_ocupation = SocioeconomicOcupation.find(params[:id])\n\n respond_to do |format|\n if @socioeconomic_ocupation.update_attributes(params[:socioeconomic_ocupation])\n format.html { redirect_to(@socioeconomic_ocupation, :notice => 'SocioeconomicOcupation was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @socioeconomic_ocupation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update\n @ontology = SYMPH::Ontology.find(params[:id])\n\n respond_to do |format|\n if @ontology.update_attributes(params[:ontology])\n flash[:notice] = 'Ontology was successfully updated.'\n format.html { redirect_to(ontologies_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ontology.errors, :status => :unprocessable_entity }\n end\n end\n\t\n end",
"def update\n respond_to do |format|\n if @has_ocupation.update(has_ocupation_params)\n format.html { redirect_to @has_ocupation, notice: 'Has ocupation was successfully updated.' }\n format.json { render :show, status: :ok, location: @has_ocupation }\n else\n format.html { render :edit }\n format.json { render json: @has_ocupation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ocat = Ocat.find(params[:id])\n\n respond_to do |format|\n if @ocat.update_attributes(params[:ocat])\n format.html { redirect_to @ocat, notice: 'Ocat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ocat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ocupation.update(ocupation_params)\n format.html { redirect_to @ocupation, notice: 'Ocupation was successfully updated.' }\n format.json { render :show, status: :ok, location: @ocupation }\n else\n format.html { render :edit }\n format.json { render json: @ocupation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_ocupation\n @ocupation = Ocupation.find(params[:id])\n end",
"def update\n @office.update(office_params)\n head :no_content\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 @opinion = Opinion.find(params[:id])\n\n respond_to do |format|\n if @opinion.update_attributes(params[:opinion])\n format.html { redirect_to(@opinion, :notice => 'Opinion was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @opinion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oase = Oasis.find(params[:id])\n\n respond_to do |format|\n if @oase.update_attributes(params[:oase])\n format.html { redirect_to @oase, notice: 'Oasis was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oase.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @doc = Doc.find(params[:id])\n \n respond_to do |format|\n if @doc.update_attributes(params[:doc])\n save_object_relationship\n format.html { redirect_to(@doc, :notice => 'Doc was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oyoyo = Oyoyo.find(params[:id])\n\n respond_to do |format|\n if @oyoyo.update_attributes(params[:oyoyo])\n flash[:notice] = 'Oyoyo was successfully updated.'\n format.html { redirect_to(@oyoyo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @oyoyo.errors, :status => :unprocessable_entity }\n end\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 respond_to do |format|\n if @ontology.update(ontology_params)\n format.html { redirect_to @ontology, notice: 'Ontology was successfully updated.' }\n format.json { render :show, status: :ok, location: @ontology }\n else\n format.html { render :edit }\n format.json { render json: @ontology.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @occasion.update(occasion_params)\n format.html { redirect_to [:admin, @occasion], notice: 'Occasion was successfully updated.' }\n format.json { render :show, status: :ok, location: @occasion }\n else\n format.html { render :edit }\n format.json { render json: @occasion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @uom = Uom.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @uom.update_attributes(params[:uom])\r\n format.html { redirect_to(@uom, :notice => 'Uom was successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n \r\n end\r\n end\r\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 update\n\t\trespond_to do |format|\n\t\t\tif @ontology.update(ontology_params)\n\t\t\t\tformat.html { redirect_to @ontology, notice: 'Ontology was successfully updated.' }\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: @ontology.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n save_doc\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 test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def update\n respond_to do |format|\n if @opo.update(opo_params)\n format.html { redirect_to @opo, notice: 'Opo was successfully updated.' }\n format.json { render :show, status: :ok, location: @opo }\n else\n format.html { render :edit }\n format.json { render json: @opo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n @ins_co_office = InsCoOffice.find(params[:id])\n\n respond_to do |format|\n if @ins_co_office.update_attributes(params[:ins_co_office])\n format.html { redirect_to(@ins_co_office, :notice => 'Office was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ins_co_office.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end",
"def update\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n if @estagio.update_attributes(params[:estagio])\n flash[:notice] = 'Estagio was successfully updated.'\n format.html { redirect_to(@estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @gene_ontology = GeneOntology.find(params[:id])\n\n respond_to do |format|\n if @gene_ontology.update_attributes(params[:gene_ontology])\n format.html { redirect_to(@gene_ontology, :notice => 'Gene ontology was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gene_ontology.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @title = \"Update Operations\"\n @operation = Operation.find(params[:id])\n\n respond_to do |format|\n if @operation.update_attributes(params[:operation])\n flash[:notice] = 'Operation was successfully updated.'\n format.html { redirect_to(@operation) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @operation.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\n @Roc = Roc.find(params[:id])\n\n respond_to do |format|\n if @Roc.update_attributes(params[:Roc])\n flash[:notice] = 'Roc was successfully updated.'\n format.html { redirect_to(@Roc) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @Roc.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n if @socio.update_attributes(params[:socio])\n format.html { redirect_to @socio, :notice => 'Socio atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @socio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @orc_ata = OrcAta.find(params[:id])\n\n respond_to do |format|\n if @orc_ata.update_attributes(params[:orc_ata])\n flash[:notice] = 'SALVO COM SUCESSO'\n format.html { redirect_to(@orc_ata) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @orc_ata.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ocupacion.update(ocupacion_params)\n format.html { redirect_to @ocupacion, notice: 'Ocupacion was successfully updated.' }\n format.json { render :show, status: :ok, location: @ocupacion }\n else\n format.html { render :edit }\n format.json { render json: @ocupacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_oidc(doc, oidc)\n @logger.debug('sso - in update_oidc')\n Utils.find_and_update_attribute(oidc, 'id', @client_id)\n Utils.find_and_update_attribute(oidc, 'clientId', @client_id)\n Utils.find_and_update_attribute(oidc, 'clientSecret', @client_secret)\n Utils.find_and_update_attribute(oidc, 'authorizationEndpointUrl', @auth_url)\n Utils.find_and_update_attribute(oidc, 'tokenEndpointUrl', @token_url)\n Utils.find_and_update_attribute(oidc, 'redirectToRPHostAndPort', \"https://#{@host}\")\n Utils.find_and_update_attribute(oidc, 'issuerIdentifier', @issuer_identifier)\n Utils.find_and_update_attribute(oidc, 'scope', @scope)\n #YD 11102016 start - add PingFederate attributes\n puts '-----> Updating openidConnectClient attributes for PingFederate'\n Utils.find_and_update_attribute(oidc, 'grantType', @grantType)\n Utils.find_and_update_attribute(oidc, 'jwkEndpointUrl', @jwkEndpointUrl)\n Utils.find_and_update_attribute(oidc, 'signatureAlgorithm', @signatureAlgorithm)\n Utils.find_and_update_attribute(oidc, 'userIdentityToCreateSubject', @userIdentityToCreateSubject)\n #YD 11102016 start - add PingFederate attributes\n Utils.find_and_update_attribute(oidc, 'httpsRequired', 'true')\n Utils.find_and_update_attribute(oidc, 'sslRef', 'ssoSSLConfig')\n end",
"def update\n @association = Association.find(params[:id])\n\n respond_to do |format|\n if @association.update_attributes(params[:association])\n flash[:notice] = 'Association was successfully updated.'\n format.html { redirect_to(@association) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @association.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @apoio.update(apoio_params)\n format.html { redirect_to @apoio, notice: 'Apoio was successfully updated.' }\n format.json { render :show, status: :ok, location: @apoio }\n else\n format.html { render :edit }\n format.json { render json: @apoio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @office = Office.find(params[:id])\n\n respond_to do |format|\n if @office.update_attributes(params[:office])\n flash[:notice] = 'Office was successfully updated.'\n format.html { redirect_to(@office) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @office.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 @socio = Socio.find(params[:id])\n\n respond_to do |format|\n if @socio.update_attributes(params[:socio])\n format.html { redirect_to @socio, notice: 'Socio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @socio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @orc_suplementacao = OrcSuplementacao.find(params[:id])\n\n respond_to do |format|\n if @orc_suplementacao.update_attributes(params[:orc_suplementacao])\n flash[:notice] = 'SALVO COM SUCESSO.'\n format.html { redirect_to(@orc_suplementacao) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @orc_suplementacao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @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 set_ocupacion\n @ocupacion = Ocupacion.find(params[:id])\n end",
"def destroy\n @ocupation = Ocupation.find(params[:id])\n @ocupation.destroy\n\n respond_to do |format|\n format.html { redirect_to(ocupations_url) }\n format.xml { head :ok }\n end\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def update\n @ovode = Ovode.find_by_url(params[:id])\n\n respond_to do |format|\n if @ovode.update_attributes(params[:ovode])\n format.html { redirect_to @ovode, notice: 'ovode was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ovode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @coating.update_attributes(params[:coating])\n format.html { redirect_to(@coating, :notice => t(\"screens.notice.successfully_updated\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @coating.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def update\n @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n if @os_type.update_attributes(params[:os_type])\n format.html { redirect_to @os_type, notice: 'Os type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @opml_metadata = OpmlMetadata.find(params[:id])\n\n respond_to do |format|\n if @opml_metadata.update_attributes(params[:opml_metadata])\n flash[:notice] = 'OpmlMetadata was successfully updated.'\n format.html { redirect_to(@opml_metadata) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @opml_metadata.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_occasion\n @occasion = Occasion.find(params[:id])\n end",
"def set_occasion\n @occasion = Occasion.find(params[:id])\n end",
"def set_occasion\n @occasion = Occasion.find(params[:id])\n end",
"def update\n @oligo = Oligo.find(params[:id])\n\n respond_to do |format|\n if @oligo.update_attributes(params[:oligo])\n flash[:notice] = 'Oligo was successfully updated.'\n format.html { redirect_to :action => :index }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @oligo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @frequencia_orgao = Frequencia::Orgao.find(params[:id])\n\n respond_to do |format|\n if @frequencia_orgao.update_attributes(params[:frequencia_orgao])\n format.html { redirect_to(@frequencia_orgao, :notice => 'Orgão atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @frequencia_orgao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @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 respond_to do |format|\n if @opnion.update(opnion_params)\n format.html { redirect_to @opnion, notice: 'Opnion was successfully updated.' }\n format.json { render :show, status: :ok, location: @opnion }\n else\n format.html { render :edit }\n format.json { render json: @opnion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @omise.update(omise_params)\n format.html { redirect_to @omise, notice: 'Omise was successfully updated.' }\n format.json { render :show, status: :ok, location: @omise }\n else\n format.html { render :edit }\n format.json { render json: @omise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @envelope = Envelope.find(params[:id])\n\n respond_to do |format|\n if @envelope.update_attributes(params[:envelope])\n flash[:notice] = 'Envelope was successfully updated.'\n format.html { redirect_to(@envelope) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @envelope.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @documentoclasificacion = Documentoclasificacion.find(params[:id])\n\n respond_to do |format|\n if @documentoclasificacion.update_attributes(params[:documentoclasificacion])\n format.html { redirect_to(@documentoclasificacion, :notice => 'Documentoclasificacion was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @documentoclasificacion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def 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\n @calidadtiposdocumento = Calidadtiposdocumento.find(params[:id])\n\n respond_to do |format|\n if @calidadtiposdocumento.update_attributes(params[:calidadtiposdocumento])\n format.html { redirect_to(@calidadtiposdocumento, :notice => 'Calidadtiposdocumento was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @calidadtiposdocumento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @opinion = Opinion.find(params[:id])\n\n respond_to do |format|\n if @opinion.update_attributes(params[:opinion])\n format.html { redirect_to @opinion, notice: 'Opinion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @opinion.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 update\n @omatsuri = Omatsuri.find(params[:id])\n\n respond_to do |format|\n if @omatsuri.update_attributes(params[:omatsuri])\n flash[:notice] = 'Omatsuri was successfully updated.'\n format.html { redirect_to(@omatsuri) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @omatsuri.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @appoiment = Appoiment.find(params[:id])\n\n respond_to do |format|\n if @appoiment.update_attributes(params[:appoiment])\n format.html { redirect_to(@appoiment, :notice => 'Appoiment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @appoiment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oasis_page = OasisPage.find(params[:id])\n\n respond_to do |format|\n if @oasis_page.update_attributes(params[:oasis_page])\n format.html { redirect_to @oasis_page, notice: 'Oasis page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oasis_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if election.update_attributes(params[:election] ? election_attributes : {})\n format.html { redirect_to(election, flash: { success: 'Election updated.' }) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => election.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def save(request)\n raise ArgumentError, \"PUT does not accept options\" unless request.options.empty?\n update(request) || create(request)\n end",
"def update\n respond_to do |format|\n if @osm.update(osm_params)\n format.html { redirect_to @osm, notice: 'Osm was successfully updated.' }\n format.json { render :show, status: :ok, location: @osm }\n else\n format.html { render :edit }\n format.json { render json: @osm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @depositocaucion = Depositocaucion.find(params[:id])\n respond_to do |format|\n if @depositocaucion.update_attributes(params[:depositocaucion])\n flash[:notice] = 'Depositocaucion was successfully updated.'\n format.html { redirect_to(@depositocaucion) }\n format.xml { head :ok }\n else \n format.html { render :action => \"edit\" }\n format.xml { render :xml => @depositocaucion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ativo_outro = AtivoOutro.find(params[:id])\n\n respond_to do |format|\n if @ativo_outro.update_attributes(params[:ativo_outro])\n format.html { redirect_to @ativo_outro, notice: 'Ativo foi salvo com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ativo_outro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @socio.update(socio_params)\n format.html { redirect_to @socio, notice: 'Socio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def update\n @shop_ose = ShopOse.find(params[:id])\n\n respond_to do |format|\n if @shop_ose.update_attributes(params[:shop_ose])\n format.html { redirect_to @shop_ose, notice: 'Shop ose was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shop_ose.errors, status: :unprocessable_entity }\n end\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 update\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n if @incident.update_attributes(params[:incident])\n format.html { redirect_to(@incident) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @incident.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def _update(type, current_name, metadata={})\n type = type.to_s.camelize\n request :update do |soap|\n soap.body = {\n :metadata => {\n :current_name => current_name,\n :metadata => prepare(metadata),\n :attributes! => { :metadata => { 'xsi:type' => \"ins0:#{type}\" } }\n }\n }\n end\n end",
"def update\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n\n respond_to do |format|\n if @tipo_de_documento.update_attributes(params[:tipo_de_documento])\n format.html { redirect_to(@tipo_de_documento, :notice => 'Tipo de documento atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_de_documento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def override\n document_id = params[:document_id]\n document = params[:document]\n document_type = params[:document_type]\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename if document\n xml.summary document_type\n if document\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n end\n }\n end\n\n url = Document::PATH + \"cmis/i/#{document_id}?alf_ticket=\" + ticket\n\n begin\n RestClient.put url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error updating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end",
"def update\n @odc_i = OdcI.find(params[:id])\n\n respond_to do |format|\n if @odc_i.update_attributes(params[:odc_i])\n format.html { redirect_to(@odc_i, :notice => 'Odc i was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @odc_i.errors, :status => :unprocessable_entity }\n end\n end\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\n @industry = Industry.find(params[:id])\n\n respond_to do |format|\n if @industry.update_attributes(params[:industry])\n flash[:notice] = 'Industry was successfully updated.'\n format.html { redirect_to(@industry) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @industry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def UpdateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n respond_to do |format|\n if @odist.update(odist_params)\n format.html { redirect_to @odist, notice: 'Odist was successfully updated.' }\n format.json { render :show, status: :ok, location: @odist }\n else\n format.html { render :edit }\n format.json { render json: @odist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @office = Office.find(params[:id])\n\n respond_to do |format|\n if @office.update_attributes(params[:office])\n format.html { redirect_to offices_path, notice: 'Office was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @office.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def destroy\n @socioeconomic_ocupation = SocioeconomicOcupation.find(params[:id])\n @socioeconomic_ocupation.destroy\n\n respond_to do |format|\n format.html { redirect_to(socioeconomic_ocupations_url) }\n format.xml { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to @organization }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n\n respond_to do |format|\n if @observacao_vocacionada.update_attributes(params[:observacao_vocacionada])\n format.html { redirect_to @observacao_vocacionada}\n flash[:notice] = \"Registro alterado com sucesso!\"\n else\n format.html { render action: \"edit\" }\n format.json { render json: @observacao_vocacionada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @socio.update(socio_params)\n format.html { redirect_to @socio, notice: 'Socio modificado com sucesso.' }\n format.json { render :show, status: :ok, location: @socio }\n else\n format.html { render :edit }\n format.json { render json: @socio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # binding.pry;''\n @occasion.administrators << User.find(params[:adminstrator]) if params[:adminstrator]\n respond_to do |format|\n if @occasion.update(occasion_params)\n format.html { redirect_to @occasion, notice: 'Occasion was successfully updated.' }\n format.json { render :show, status: :ok, location: @occasion }\n else\n format.html { render :edit }\n format.json { render json: @occasion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_object_xml(object_type, id, xml)\n @client.update_business_object_by_public_id({\n :busObNameOrId => object_type,\n :busObPublicId => id,\n :updateXml => xml\n })\n return last_error\n end",
"def update\n @centro = Centro.find(params[:id])\n\n respond_to do |format|\n if @centro.update_attributes(params[:centro])\n format.html { redirect_to(@centro, :notice => 'Centro atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @centro.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @officer = Officer.find(params[:id])\n\n respond_to do |format|\n if @officer.update_attributes(params[:officer])\n flash[:notice] = 'Officer was successfully updated.'\n format.html { redirect_to(@officer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @officer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @accesot.update(accesot_params)\n format.html { redirect_to @accesot, notice: 'Accesot was successfully updated.' }\n format.json { render :show, status: :ok, location: @accesot }\n else\n format.html { render :edit }\n format.json { render json: @accesot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @osusume.update(osusume_params)\n format.html { redirect_to @osusume, notice: 'Osusume was successfully updated.' }\n format.json { render :show, status: :ok, location: @osusume }\n else\n format.html { render :edit }\n format.json { render json: @osusume.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6224686",
"0.6187895",
"0.6112555",
"0.60966593",
"0.6055364",
"0.60510063",
"0.60175747",
"0.59249896",
"0.5857469",
"0.58312875",
"0.57838434",
"0.57724816",
"0.5768908",
"0.57645357",
"0.57396317",
"0.57268506",
"0.56922543",
"0.5669611",
"0.5646307",
"0.5632905",
"0.5629622",
"0.56099033",
"0.5608823",
"0.56020755",
"0.56003237",
"0.55896777",
"0.55724746",
"0.55704284",
"0.5566592",
"0.55651337",
"0.5562786",
"0.55564123",
"0.5527404",
"0.5524876",
"0.5524423",
"0.5523904",
"0.5515668",
"0.5506374",
"0.5505723",
"0.5505557",
"0.5498328",
"0.5496331",
"0.547999",
"0.5478456",
"0.54751456",
"0.54703826",
"0.5461534",
"0.5450458",
"0.54378575",
"0.542735",
"0.54261506",
"0.5423935",
"0.5423",
"0.5423",
"0.5423",
"0.5399554",
"0.5382465",
"0.5377031",
"0.53754073",
"0.5372501",
"0.5367539",
"0.53652084",
"0.53638905",
"0.53586364",
"0.5354604",
"0.53463864",
"0.53443694",
"0.53423667",
"0.53371704",
"0.53367347",
"0.5333462",
"0.5332413",
"0.53313404",
"0.53255934",
"0.5325036",
"0.53127956",
"0.5304508",
"0.5304152",
"0.5300155",
"0.52960557",
"0.52933836",
"0.52908856",
"0.5287804",
"0.527558",
"0.5274876",
"0.5272389",
"0.52660257",
"0.5255588",
"0.5254152",
"0.5253322",
"0.52525985",
"0.5250287",
"0.52456254",
"0.5241822",
"0.5240084",
"0.5236679",
"0.5235455",
"0.523272",
"0.5230671",
"0.52254325"
] | 0.6459338 | 0 |
DELETE /ocupations/1 DELETE /ocupations/1.xml | def destroy
@ocupation = Ocupation.find(params[:id])
@ocupation.destroy
respond_to do |format|
format.html { redirect_to(ocupations_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\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 @socioeconomic_ocupation = SocioeconomicOcupation.find(params[:id])\n @socioeconomic_ocupation.destroy\n\n respond_to do |format|\n format.html { redirect_to(socioeconomic_ocupations_url) }\n format.xml { head :ok }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def 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 @documento = @externo.documentos.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentos_url(@externo)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @Roc = Roc.find(params[:id])\n @Roc.destroy\n\n respond_to do |format|\n format.html { redirect_to(Rocs_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 @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 delete(slide)\n # ./_rels/presentation.xml.rels\n # Update Relationship ids\n # Insert a new one slideRef\n @doc.edit_xml @doc.presentation.rels.path do |xml|\n # Calucate the next id\n # next_id = xml.xpath('//xmlns:Relationship[@Id]').map{ |n| n['Id'] }.sort.last.succ\n # TODO - Figure out how to make this more MS idiomatic up 9->10 instead of incrementing\n # the character....\n # Insert that into the slide and crakc open the presentation.xml file\n\n target = slide.path.relative_path_from(@doc.presentation.path.dirname)\n relationship = xml.at_xpath(\"/xmlns:Relationships/xmlns:Relationship[@Type='#{Slide::REL_TYPE}' and @Target='#{target}']\")\n # ./presentation.xml\n # Update attr\n # p:notesMasterId\n # Insert attr\n # p:sldId, increment, etc.\n @doc.edit_xml '/ppt/presentation.xml' do |xml|\n xml.at_xpath(\"/p:presentation/p:sldIdLst/p:sldId[@r:id='#{relationship['Id']}']\").remove\n end\n relationship.remove\n end\n\n # Delete slide link and slideNotes link from ./[Content-Types].xml \n @doc.edit_xml @doc.content_types.path do |xml|\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Slide::CONTENT_TYPE}' and @PartName='#{slide.path}']\").remove\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Notes::CONTENT_TYPE}' and @PartName='#{slide.notes.path}']\").remove\n end\n\n # Update ./ppt\n # !!! DESTROY !!!\n # ./slides\n # Delete files\n # ./_rels/notesSlide(\\d+).xml.rels\n @doc.delete slide.notes.rels.path\n # ./notesSlide(\\d+).xml file\n @doc.delete slide.notes.path\n # ./_rels/slide(\\d+).xml.rels\n @doc.delete slide.rels.path\n # ./slide(\\d+).xml file\n @doc.delete slide.path\n # ./notesSlides\n # Delete files\n\n # Hooray! We're done! Ummm, what should we return though? can't be the slide since\n # its destroyed and there's no practical way to keep it around in memory.\n end",
"def destroy\n @oligo = Oligo.find(params[:id])\n @oligo.destroy\n\n respond_to do |format|\n format.html { redirect_to(oligos_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.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.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 @omatsuri = Omatsuri.find(params[:id])\n @omatsuri.destroy\n\n respond_to do |format|\n format.html { redirect_to(omatsuris_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @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 @association = Association.find(params[:id])\n @association.destroy\n\n respond_to do |format|\n format.html { redirect_to(associations_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n @client.delete_document(@path)\n end",
"def destroy\n @ocupation.destroy\n respond_to do |format|\n format.html { redirect_to ocupations_url, notice: 'Ocupation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aplicacion = Aplicacion.find(params[:id])\n @aplicacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(aplicacions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @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 @oyoyo = Oyoyo.find(params[:id])\n @oyoyo.destroy\n\n respond_to do |format|\n format.html { redirect_to(oyoyos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @title = \"Destroy Operations\"\n @operation = Operation.find(params[:id])\n @operation.destroy\n\n respond_to do |format|\n format.html { redirect_to(operations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @uom = Uom.find(params[:id])\r\n @uom.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_back_or_default(uoms_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @domino = Domino.find(params[:id])\n @domino.destroy\n\n respond_to do |format|\n format.html { redirect_to(dominos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @convenio = Convenio.find(params[:id])\n @convenio.destroy\n\n respond_to do |format|\n format.html { redirect_to(convenios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @association = Association.find(params[:id])\n @association.destroy\n\n respond_to do |format|\n format.html { redirect_to associations_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @calidadtiposdocumento = Calidadtiposdocumento.find(params[:id])\n @calidadtiposdocumento.destroy\n\n respond_to do |format|\n format.html { redirect_to(calidadtiposdocumentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ocat = Ocat.find(params[:id])\n @ocat.destroy\n\n respond_to do |format|\n format.html { redirect_to ocats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @correspondence = Correspondence.find(params[:id])\n @correspondence.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondences_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @odc_r = OdcR.find(params[:id])\n @odc_r.destroy\n\n respond_to do |format|\n format.html { redirect_to(odc_rs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n client = Connection::MarkLogic.new.client\n client.send_corona_request(\"/v1/documents?uri=/amandments/amandment_#{@amandment.id}.xml\", :delete)\n @amandment.destroy\n respond_to do |format|\n format.html { redirect_to home_meeting_path, notice: 'Amandman was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @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 @ins_co_office = InsCoOffice.find(params[:id])\n @ins_co_office.destroy\n\n respond_to do |format|\n format.html { redirect_to(ins_co_offices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @office = Office.find(params[:id])\n @office.destroy\n\n respond_to do |format|\n format.html { redirect_to(offices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n \t@doc = Doc.find params[:id]\n @doc.destroy\nend",
"def destroy\n @upload_file = UploadFile.find(params[:id])\n doc_no=@upload_file.doc_no\n @upload_file.destroy\n\n respond_to do |format|\n format.html { redirect_to upload_files_url(:doc_no=>doc_no) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @appoiment = Appoiment.find(params[:id])\n @appoiment.destroy\n\n respond_to do |format|\n format.html { redirect_to(appoiments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @absence_request = AbsenceRequest.find(params[:id])\n @absence_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(absence_requests_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end",
"def destroy\n @operation = Operation.find(params[:id])\n @operation.destroy\n\n respond_to do |format|\n format.html { redirect_to(operations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @auto = Auto.find(params[:id])\n @auto.destroy\n\n respond_to do |format|\n format.html { redirect_to(autos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cso = Cso.find(params[:id])\n @cso.destroy\n\n respond_to do |format|\n format.html { redirect_to(csos_url) }\n format.xml { head :ok }\n end\n 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 @odc_i = OdcI.find(params[:id])\n @odc_i.destroy\n\n respond_to do |format|\n format.html { redirect_to(odc_is_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @document.destroy\n save_log({ :action => 'DELETE', :document => { :before => @old_document }})\n #TODO delete the file from disk\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @estacion = Estacion.find(params[:id])\n @estacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(estaciones_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @has_ocupation.destroy\n respond_to do |format|\n format.html { redirect_to has_ocupations_url, notice: 'Has ocupation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nom = Nom.find(params[:id])\n @nom.destroy\n\n respond_to do |format|\n format.html { redirect_to(noms_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 @documento = Documento.find(params[:id])\n # Eliminar los registros asociativos de las tablas JOIN \n # para las asociaciones HBTM (has_and_belongs_to_many)\n #\n @documento.reconocimientos.destroy_all\n @documento.areas.destroy_all\n\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to documentos_url, :notice => \"#{@documento.titulo} eliminado\" }\n format.json { head :no_content }\n end\n end",
"def delete()\n @ole.Delete()\n end",
"def delete()\n @ole.Delete()\n end",
"def delete()\n @ole.Delete()\n end",
"def delete()\n @ole.Delete()\n end",
"def destroy\n @office.destroy\n head :no_content\n end",
"def destroy\n @docderivacione.destroy\n respond_to do |format|\n format.html { redirect_to docderivaciones_url, notice: 'Docderivacione was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estagio = Estagio.find(params[:id])\n @estagio.destroy\n\n respond_to do |format|\n format.html { redirect_to(estagios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @opinion = Opinion.find(params[:id])\n @opinion.destroy\n\n respond_to do |format|\n format.html { redirect_to(opinions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @auto1h_fold_change = Auto1hFoldChange.find(params[:id])\n @auto1h_fold_change.destroy\n\n respond_to do |format|\n format.html { redirect_to(auto1h_fold_changes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ingredience = Ingredience.find(params[:id])\n @ingredience.destroy\n\n respond_to do |format|\n format.html { redirect_to(ingrediences_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @representative = Representative.find(params[:id])\n @representative.destroy\n\n respond_to do |format|\n format.html { redirect_to(representatives_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n request(:delete)\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to(recursos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @asignacion = Asignacion.find(params[:id])\r\n @asignacion.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(asignacions_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @occurence = Occurence.find(params[:id])\n @occurence.destroy\n\n respond_to do |format|\n format.html { redirect_to(occurences_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 @conseq = Conseq.find(params[:id])\n @conseq.destroy\n\n respond_to do |format|\n format.html { redirect_to(conseqs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @elemento = Elemento.find(params[:id])\n @elemento.destroy\n\n respond_to do |format|\n format.html { redirect_to(elementos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @direccion = Direccion.find(params[:id])\n @direccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(direccions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @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\n client.delete(\"/#{id}\")\n end",
"def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @exalumno = @alumno.exalumno\n @exalumno.destroy\n\n respond_to do |format|\n format.html { redirect_to(alumno_path(@alumno)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @helocagree = Helocagree.find(params[:id])\n @helocagree.destroy\n\n respond_to do |format|\n format.html { redirect_to(helocagrees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @envelope = Envelope.find(params[:id])\n @envelope.destroy\n\n respond_to do |format|\n format.html { redirect_to(envelopes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @opml_metadata = OpmlMetadata.find(params[:id])\n @opml_metadata.destroy\n\n respond_to do |format|\n format.html { redirect_to(opml_metadatas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @colonoscopytest = Colonoscopytest.find(params[:id])\n @colonoscopytest.destroy\n\n respond_to do |format|\n format.html { redirect_to(colonoscopytests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @catastrosdato = Catastrosdato.find(params[:id])\n @catastrosdato.destroy\n\n respond_to do |format|\n format.html { redirect_to(catastrosdatos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @offlearn = Offlearn.find(params[:id])\n @offlearn.destroy\n\n respond_to do |format|\n format.html { redirect_to(offlearns_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @concert = Concert.find(params[:id])\n @concert.destroy\n\n respond_to do |format|\n format.html { redirect_to(concerts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @orc_ata = OrcAta.find(params[:id])\n @orc_ata.destroy\n @ata =\n respond_to do |format|\n format.html { redirect_to( home_path ) }\n\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @expedicao = Expedicao.find(params[:id])\n @expedicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(expedicoes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @segmento = Segmento.find(params[:id])\n @segmento.destroy\n\n respond_to do |format|\n format.html { redirect_to(segmentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/\") }\n format.xml { head :ok }\n end\n end",
"def destroy\n @os_type = OsType.find(params[:id])\n @os_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(os_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @frequencia_orgao = Frequencia::Orgao.find(params[:id])\n @frequencia_orgao.destroy\n\n respond_to do |format|\n format.html { redirect_to(frequencia_orgaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @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; delete end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @correspondenciasclase = Correspondenciasclase.find(params[:id])\n @correspondenciasclase.destroy\n\n respond_to do |format|\n format.html { redirect_to(correspondenciasclases_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @definition_category_association = DefinitionCategoryAssociation.find(params[:id])\n @definition_category_association.destroy\n\n respond_to do |format|\n format.html { redirect_to(definition_category_associations_url) }\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 delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end",
"def destroy\n @aisle = Aisle.find(params[:id])\n @aisle.destroy\n\n respond_to do |format|\n format.html { redirect_to(aisles_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.6760789",
"0.675016",
"0.6699093",
"0.66819334",
"0.6637858",
"0.65412605",
"0.6481246",
"0.64416707",
"0.6423068",
"0.63616216",
"0.6345628",
"0.633338",
"0.633338",
"0.6331698",
"0.6299551",
"0.62822",
"0.62810636",
"0.6281048",
"0.6277849",
"0.62769943",
"0.6276367",
"0.62762326",
"0.62484974",
"0.62423384",
"0.6231911",
"0.6231682",
"0.62307894",
"0.62267405",
"0.6222353",
"0.621847",
"0.6211143",
"0.6206566",
"0.62057686",
"0.6205395",
"0.61992806",
"0.61948264",
"0.6190071",
"0.6189389",
"0.61848027",
"0.618307",
"0.6182659",
"0.617744",
"0.6175562",
"0.6172069",
"0.616142",
"0.61562675",
"0.6155586",
"0.6148487",
"0.6133317",
"0.6131833",
"0.61267936",
"0.6122663",
"0.6122663",
"0.6122663",
"0.6122663",
"0.61226076",
"0.6116693",
"0.61158526",
"0.6111668",
"0.6110376",
"0.610996",
"0.6108982",
"0.6105302",
"0.6104937",
"0.61002386",
"0.61001676",
"0.60974324",
"0.6097264",
"0.6090912",
"0.60887015",
"0.60790443",
"0.60773414",
"0.6071266",
"0.6067477",
"0.6065536",
"0.606395",
"0.6063121",
"0.6062804",
"0.60592145",
"0.6051966",
"0.605026",
"0.6045715",
"0.6044988",
"0.60445213",
"0.604407",
"0.6041338",
"0.60405004",
"0.60363597",
"0.6034171",
"0.6032321",
"0.6026486",
"0.60216045",
"0.6018595",
"0.6017838",
"0.6017154",
"0.6017154",
"0.6017154",
"0.6017154",
"0.60171366",
"0.60163647"
] | 0.7159489 | 0 |
def collection authorize! :read, Scheduler::ShiftAssignment | def collection
apply_scopes(super).order(:date).includes{[person, shift.shift_group, shift.county]}.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def volunteer_portal\n authorize! :volunteer_portal, :Reservation\n end",
"def show\n authorize! :read, @assignment\n end",
"def set_shift\n @shift = Shift.find(params[:id])\n\n authorize @shift\n end",
"def show\n authorize! :read, @collection\n end",
"def authorize_admin\n authorize! :update, convention.events.new\n end",
"def authorize_collection! action, collection\n collection.map do |model|\n authorize! action, model\n end\n end",
"def set_access\n @access = @current_event.accesses.find(params[:id])\n authorize @access\n end",
"def index\n @institutes = Institute.all\n authorize Institute\n end",
"def load_collection\n current_ability.scope_for(authorization_action, resource_class) do\n resource_base.accessible_by(current_ability, authorization_action)\n end\n end",
"def listings\n authorize! :read, @user\n end",
"def show\n authorize @job\n @schedules = @job.schedules\n end",
"def show\n authorize! :read, @task\n end",
"def can_do_collection_scoped_actions\n can :index, :all\n can :new, :all\n can :export, :all\n can :history, :all\n can :destroy, :all\n end",
"def index\n @demands = Demand.all\n authorize @demands\n end",
"def index\n @duty_board_slots = policy_scope(DutyBoardSlot).order(:duty_board_group_id, :name)\n authorize @duty_board_slots\n end",
"def admin\n authorize! :admin, @listings\n end",
"def show\n authorize RoleCutoff\n end",
"def check_permissions\n authorize! :create, RoutingSheet\n end",
"def check_auth\n authorize @equipment_listing\n end",
"def set_resource\n @assignment = Assignment.find(params[:id])\n authorize @assignment\n end",
"def index\n authorize! :index, HoursRegistration\n @hours_registrations = HoursRegistration.accessible_by(current_ability)#HoursRegistration.all\n end",
"def show\n authorize @work_type\n end",
"def show\n authorize @work_category\n end",
"def authorize_reports\n authorize! :read, :report\n end",
"def set_reservation\n @reservation = Reservation.find(params[:id])\n authorize @reservation\n end",
"def show\n authorize @booking\n end",
"def set_timesheet\n @timesheet = Timesheet.find(params[:id])\n skip_authorization\n # authorize @timesheet\n end",
"def ensure_admin!\n authorize! :read, :admin_dashboard\n end",
"def ensure_admin!\n authorize! :read, :admin_dashboard\n end",
"def index\n @assignments = $current_community.assignments.where(:close_date => nil).joins(:assignment_status) \n authorize Assignment\n end",
"def show\n authorize @staff_request\n end",
"def set_shift\n @shift = Shift.find(params[:id])\n skip_authorization\n end",
"def index\n @floor_plans = FloorPlan.all\n authorize @floor_plans\n end",
"def set_attendance\r\n @attendance = Attendance.find(params[:id])\r\n authorize @attendance\r\n end",
"def authorize_warehouse_allocation\n authorize WarehouseAllocation\n end",
"def edit_start_time\n authorize @event\n end",
"def roles_with_permission\n shift.location.loc_group.roles\n end",
"def publication_admin(role)\n can :read, Publication, :id => role.publication_id\n can :update, Publication, :id => role.publication_id\n can :manage, Issue, :publication_id => role.publication_id\n can :update, AdminUser, :id => @user.id\n\n end",
"def show\n authorize! :read, @admin_operator\n end",
"def index\n\n @submissions = Submission.all\n authorize! :manage, @submissions\n end",
"def check_authorization\n @can_edit = can_blank_timetable?('edit')\n @can_show = can_blank_timetable?('show')\n end",
"def authorization; end",
"def authorize_admin!\n authorize! :manage, :all\n end",
"def index\n authorize Document\n end",
"def set_collection\n @collection = Collection.find(params[:collection_id])\n redirect_to :back, alert: 'Not authorized' unless @collection.available?(@current_user)\n end",
"def authorize!\n Ability.allowed?(context[:current_user], :read_milestone, parent) || raise_resource_not_available_error!\n end",
"def show\n @user = current_user\n @course = Course.find(params[:id])\n\n # Only give students the available assignments\n if current_user.has_local_role? :student, @course\n @assignments = @course.assignments.select { |assignment| Time.now > assignment.start_date }\n else\n @assignments = @course.assignments\n end\n\n if current_user.has_local_role? :grader, @course or current_user.has_role? :admin\n render \"courses/manage\" \n end\n end",
"def index\n @mx_assessments = MxAssessment.all\n authorize MxAssessment \n end",
"def show\n authorize! :show, HoursRegistration\n end",
"def index\n @requests = Request.accessible_by(current_ability)\n\n \n\n end",
"def publisher_admin(role)\n\n can :manage, Publication, :publisher_id => role.publisher_id\n can :update, Publisher, :id => role.publisher_id\n can :update, IssueState\n can :update, AdminUser, :id => @user.id\n\n\n\n end",
"def no_admin_set_abilities\n cannot [:edit, :create, :delete], Hydra::Admin::Collection\n end",
"def index\n @moderations = @course.moderations.all\n authorize Moderation\n end",
"def show\n authorize! :manage, @submissions\n end",
"def authorize_access\r\n # authorize!(action_name.to_sym, \"#{controller_name}_controller\".camelcase.constantize)\r\n end",
"def set_access_rights\n @access_rights = current_v1_user.rights.find_by(campground_id: params[:campground_id])\n end",
"def set_access_rights\n @access_rights = current_v1_user.rights.find_by(campground_id: params[:campground_id])\n end",
"def set_access_rights\n @access_rights = current_v1_user.rights.find_by(campground_id: params[:campground_id])\n end",
"def set_access_rights\n @access_rights = current_v1_user.rights.find_by(campground_id: params[:campground_id])\n end",
"def set_access_rights\n @access_rights = current_v1_user.rights.find_by(campground_id: params[:campground_id])\n end",
"def show\n authorize! :create, Administrator\n end",
"def index_week\n @trainings = Training.all\n @sessions = Session.all\n authorize @trainings\n end",
"def index\n # @users = User.all\n # authorize @users \n @users = policy_scope(User)\n authorize @users\n end",
"def index\n @fuel_supplies ||= policy_scope(FuelSupply.all)\n authorize FuelSupply\n end",
"def authorize_edit\n authorize! :edit, @opportunity\n end",
"def show\n authorize @event\n end",
"def authorize_owner_and_planner\n\n can :manage, AttachedDocument do |doc|\n curr_organization == doc.plan.organization\n end\n end",
"def show\n authorize @admin\n end",
"def collection\n @collection ||= Permission.all\n end",
"def show\n @duty_board_slot = DutyBoardSlot.find(params[:id])\n authorize @duty_board_slot\n end",
"def authorize_admin\n permission = params[:action] == 'update' ? :manage : :read\n authorize! permission, convention.event_proposals.new(status: 'reviewing')\n end",
"def index\n @details = Detail.all\n authorize @details \n end",
"def index\n authorize Role\n @roles = Role.all\n end",
"def show\n authorize @formation\n end",
"def AccessRights=(arg0)",
"def show\n authorize! :update, Hospital\n end",
"def set_resource\n @course = Course.find(params[:id])\n authorize @course\n end",
"def show\n authorize! :read, @admin_system_admin\n end",
"def show\n authorize @fuel_supply\n end",
"def show\n authorize @assignment\n @assignment_update = AssignmentUpdate.new\n end",
"def index\n @tasks = policy_scope(Task)\n record.user == current_user\n end",
"def index\n authorize!(:update, @classroom)\n end",
"def access_control\n \n end",
"def set_course\n @course = Course.find(params[:id])\n authorize @course\n end",
"def authorize_resource\n authorize!(:disburse, @disbursement)\n @disbursement.experience_points_records.each do |record|\n authorize!(:create, record)\n end\n end",
"def show\n authorize Section\n end",
"def can_read_schedule?(user)\n scheduled? || can_edit?(user)\n end",
"def index\n authorize!(:view_configuration_management)\n end",
"def index\n\t\tauthorize! :index, Requisito\n @requisitos = Requisito.all\n end",
"def show\n authorize @recorded\n end",
"def show\n # authorize @item\n end",
"def create\n # authorize @user\n #import redirects to import method in this(shifts) controller\n import\n @shift = Shift.new(shift_params)\n end",
"def collection_roles\n # Can create, read, edit/update, destroy, and change visibility (discovery) of all Collections\n models = [Hyrax::PcdmCollection, Hyrax.config.collection_class].uniq\n if collection_manager?\n models.each do |collection_model|\n # Permit all actions (same collection permissions as admin users)\n can :manage, collection_model\n can :manage, ::SolrDocument, &:collection?\n can :manage, ::String do |id|\n doc = permissions_doc(id)\n doc.collection?\n end\n can :create_collection_type, CollectionType\n end\n # Can create, read, and edit/update all Collections\n elsif collection_editor?\n models.each { |collection_model| can %i[edit update create create_any], collection_model }\n can %i[edit update], ::SolrDocument, &:collection?\n can %i[edit update], ::String do |id|\n doc = permissions_doc(id)\n doc.collection?\n end\n models.each { |collection_model| can %i[read read_any view_admin_show view_admin_show_any], collection_model }\n can %i[read read_any view_admin_show view_admin_show_any], ::SolrDocument, &:collection?\n can %i[read read_any view_admin_show view_admin_show_any], ::String do |id|\n doc = permissions_doc(id)\n doc.collection?\n end\n can :create_collection_type, CollectionType\n\n # Can read all Collections\n elsif collection_reader?\n models.each { |collection_model| can %i[read read_any view_admin_show view_admin_show_any], collection_model }\n can %i[read read_any view_admin_show view_admin_show_any], ::SolrDocument, &:collection?\n can %i[read read_any view_admin_show view_admin_show_any], ::String do |id|\n doc = permissions_doc(id)\n doc.collection?\n end\n end\n end",
"def set_access_rights\n # @access_rights = current_v1_user.rights.where(campground_id: params[:campground_id])\n @access_rights = User.find(1).rights.find_by(campground_id: params[:campground_id])\n end",
"def filter_access!\n treat_as get_current_role\n end",
"def show\n authorize @publishers_test\n end",
"def authorize_planner\n\n can [:read], Organization do |organization|\n curr_account == organization.account\n end\n can [:adopt, :search], Employee\n can [:read], Employee do |employee|\n employee.organizations.include?(curr_organization)\n end\n can [:update, :create], Employee do |employee|\n (\n !employee.owner? || curr_employee == employee\n ) &&\n # organization_id is a virtual attribute of employee and is used to\n # create the membership for the current organization after create of the\n # employee. So the following line makes sure that memberships for orgs\n # of other account can not be created.\n (\n employee.organization_id.nil? ||\n employee.organization_id.to_i == curr_organization.id\n ) &&\n (\n employee.account.nil? ||\n curr_account == employee.account\n )\n end\n can :update_role, Employee do |employee|\n curr_employee != employee && # no one can update her/his own role\n curr_organization.employees.include?(employee)\n end\n can :manage, Plan do |plan|\n curr_organization == plan.organization\n end\n can :manage, Scheduling do |scheduling|\n curr_organization == scheduling.plan.organization &&\n ( !scheduling.represents_unavailability? || self_planning?(scheduling) )\n end\n can :manage, Shift do |shift|\n curr_organization == shift.plan_template.organization\n end\n can :manage, CopyWeek do |copy_week|\n curr_organization == copy_week.plan.organization\n end\n can :manage, ApplyPlanTemplate do |apply_plan_template|\n curr_organization == apply_plan_template.plan.organization\n end\n can :manage, Team do |team|\n curr_organization == team.organization\n end\n can :manage, Qualification do |qualification|\n curr_account == qualification.account\n end\n can :manage, PlanTemplate do |plan_template|\n curr_organization == plan_template.organization\n end\n can :manage, TeamMerge do |team_merge|\n (team_merge.team_id.blank? || curr_organization == team_merge.team.try(:organization)) &&\n (team_merge.other_team_id.blank? || curr_organization == team_merge.other_team.try(:organization)) &&\n (team_merge.new_team_id.blank? || curr_organization == team_merge.new_team.try(:organization))\n end\n can [:read, :create], Post do |post|\n curr_organization == post.blog.organization\n end\n can [:read, :create], Comment do |comment|\n commentable = comment.commentable\n if commentable.respond_to?(:blog) # comment on a post\n curr_organization == commentable.blog.organization\n elsif commentable.respond_to?(:plan) # comment on a scheduling\n curr_organization == commentable.plan.organization\n else\n false\n end\n end\n can :manage, Invitation do |invitation|\n curr_account == invitation.employee.account &&\n curr_organization == invitation.organization\n end\n can :manage, Milestone do |milestone|\n curr_organization == milestone.plan.organization\n end\n can :manage, Task do |task|\n curr_organization == task.milestone.plan.organization\n end\n\n can :show, Conflict do |conflict|\n curr_organization == conflict.provoker.plan.organization\n end\n\n # For reports we only check the base on which schedulings will be found. For\n # example we do not need to test if the plan_ids submitted belong to the\n # base.\n # Please see the report model for how records are fetched. The base is\n # always the account and one or more organizations within the account.\n # If the user would submit foreign plan_ids for example, this will not do\n # any harm as the result simply will be empty.\n can :create, Report do |report|\n # A planner is only able to see a report within an organization.\n # The filter for organizations will no be shown on the report page of the\n # organization. Therefore the organization_ids of the report should only\n # include the id of the current organization.\n org_ids = report.organization_ids\n org_ids.size == 1 &&\n org_ids.first.to_i == curr_organization.id\n end\n\n authorize_owner_and_planner\n authorize_employee\n end",
"def authorize_can_read_issuable!\n action = [:read_, params[:template_type]].join\n\n authorize_action!(action)\n end",
"def show\n authorize @labor_request\n end",
"def index\n @trainings = student.trainings \n @user_profile = current_user.profile\n # authorize @trainings \n end",
"def index\n @access_controls = AccessControl.all\n end"
] | [
"0.6795986",
"0.6747096",
"0.66756684",
"0.66584",
"0.6616508",
"0.6601282",
"0.65926504",
"0.6546284",
"0.64773977",
"0.6455889",
"0.64358026",
"0.6401338",
"0.63948977",
"0.63835764",
"0.636969",
"0.6365102",
"0.63581324",
"0.63490564",
"0.6337369",
"0.63346004",
"0.62559813",
"0.6254711",
"0.62486804",
"0.62458855",
"0.6235722",
"0.6201879",
"0.619095",
"0.61893106",
"0.61893106",
"0.61856276",
"0.6171335",
"0.61703616",
"0.616393",
"0.61185455",
"0.6117899",
"0.6115169",
"0.61091155",
"0.6089881",
"0.6088857",
"0.60668933",
"0.6065277",
"0.60602134",
"0.60346794",
"0.6034127",
"0.60114783",
"0.60097873",
"0.59872204",
"0.5986592",
"0.5985311",
"0.59606344",
"0.5959375",
"0.59534717",
"0.59528905",
"0.5949663",
"0.5948602",
"0.59461296",
"0.59461296",
"0.59461296",
"0.59461296",
"0.59461296",
"0.5935415",
"0.5932754",
"0.5917192",
"0.5910452",
"0.5909633",
"0.59038514",
"0.5902836",
"0.5890072",
"0.5882981",
"0.5880629",
"0.5875016",
"0.58744127",
"0.58718705",
"0.58673567",
"0.58608437",
"0.58590025",
"0.58519053",
"0.5849327",
"0.58452064",
"0.5844181",
"0.5839521",
"0.5835753",
"0.5814324",
"0.58112353",
"0.58108956",
"0.57997805",
"0.5799467",
"0.5797291",
"0.57961315",
"0.57957995",
"0.5792767",
"0.5789011",
"0.5786785",
"0.57846487",
"0.5782946",
"0.57791907",
"0.57763827",
"0.5774422",
"0.577135",
"0.5767257",
"0.576579"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def resource_params
[params.require(:shift_assignment).permit(:person_id, :shift_id, :date)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
GET /for_pags GET /for_pags.json | def index
@for_pags = ForPag.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pagamentos = Pagamento.page(params[:page]).per(NUMERO_POR_PAGINA)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n render json: Visitor.paginate(:page => params[:page], :per_page => 300)\n end",
"def index\n @pages = Page.all\n render json: @pages\n end",
"def index\n render json: EndService.paginate(page: params[:page], per_page: 25)\n end",
"def index\n render json: Item.paginate(page: params[:page], per_page: 25)\n end",
"def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json do\n collections = Collection.where.not(published_at: nil)\n .order(published_at: :desc)\n .page(params[:page])\n .per(Collection::COLLECTION_PER)\n is_more_load = collections.total_pages > params[:page].to_i\n render json: { collections: collections, is_more_load: is_more_load }\n end\n end\n end",
"def index\n @pagamentos = Pagamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n respond_with(@pages = Page.all.paginate(:page => params[:page] || 1, :per_page => params[:per_page] || 5))\n end",
"def index\n @orders = Order.paginate page: params[:page], order: 'created_at desc', \n per_page: 10\n \n respond_to do |format|\n format.html\n format.json { render json: @orders } \n end\n end",
"def paginate\n @chirps = Post.timeline(current_user).order(\"created_at DESC\").page(params[:page])\n render json: @chirps, status: 200\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n page_num=params[:page]\n @users= User.page(page_num)\n render json: @users\n end",
"def index\n\n @pagy, @posts = pagy(Post.cleaner)\n\n paginationObj = {\n page: @pagy.page,\n prev: @pagy.prev,\n next: @pagy.next,\n last: @pagy.last, \n }\n\n render :json => { postsArr: @posts, pagyData: paginationObj }\n end",
"def index\n @klasses = Klass.paginate(:page => params[:page], per_page: 30)\n @number = Klass.count\n\n respond_to do |format|\n format.html\n format.json { render :json => Klass.all.to_json(include: :period) }\n end\n end",
"def index\n @urls = @site.urls.paginate(:page => params[:page])\n render json: @urls\n end",
"def index\n @users = User.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @accounts = Account.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @accounts }\n end\n end",
"def index\n @requests = Request.paginate(:page => params[:page], :per_page => 8).order(\"created_at DESC\").find_all_by_user_id(current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requests }\n end\n end",
"def index\n @links = Link.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @links }\n end\n end",
"def index\r\n @books = Book.paginate(:page => params[:page], :per_page => 30)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @books }\r\n end\r\n end",
"def index\n @puntajes = Puntaje.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end",
"def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def list\n response = connect(base_url, :get)\n pagination_links(response)\n self.current_page = JSON.load(response.body)\n end",
"def index\n @calificaciones = Calificacion.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @calificaciones }\n end\n end",
"def index\n @pages = Page.all\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @users = User.all.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @invoices = Invoice.all.order(invoice_date: :desc).order(created_at: :desc).paginate(:page => params[:page], per_page: 10)\n\n render json: {invoices: @invoices, total_pages: @invoices.total_pages, current_page: @invoices.current_page}\n end",
"def pages\n get(\"v1/account/#{@email}/pages\")\n end",
"def index\n page = params[:page] || 1\n\n @users = User.all.page(page)\n respond_to do |format|\n format.json\n format.html\n end\n end",
"def render_paginated(resource, opts = {})\n render json: resource, root: 'items', meta: {}\n end",
"def index\n @families = Family.all.paginate(page: params[:page])\n render json: @families\n end",
"def index\n\t\t@pages = Page.order('created_at DESC').all\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @pages }\n\t\tend\n\tend",
"def index\n @orders = Order.paginate(page: params[:page], conditions: [\"has_paid = true\"], per_page: 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @ideas = current_user.ideas.page(params[\"page\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end",
"def pages\n get(\"v1/event/#{@id}/pages\")\n end",
"def index\n @sites = Site.paginate(:page=>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def index\n\n @houses = House.page(params[:page]).per(House::PER_PAGE_COUNT)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @houses }\n end\n end",
"def index\n @users = User.paginate(page: params[:page], per_page:50)\n render json: @users, status: :ok\n end",
"def index\n @pages = current_site.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @participates = Participate.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @participates }\n end\n end",
"def index\n @sites = current_user.sites.page(params[\"page\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def index\n @anuncios = Anuncio.all.paginate(page: params[:page], per_page: 4 )\n\n respond_to do |format|\n format.html\n format.json { render json: @jobs }\n end\n end",
"def index\n page = valid_page_or_one params[:page]\n @users = User.paginate(:page => page, :per_page => per_page).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n \n @users = User.page(params[:page]).per_page(14)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n \n end",
"def index\n @batches = Batch.page(params[:page]).per(15)\n @page = params[:page] || 1\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batches }\n end\n end",
"def index\n por_pagina = params[:por_pagina] || 18\n @productos = Producto.paginate(page: params[:page], per_page: por_pagina).includes(:fotos)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @productos }\n end\n end",
"def index\n @pages = Page.all\n\n respond_with @pages\n end",
"def index\n @users = User.paginate(page: params[:page], per_page: params[:size])\n .order(created_at: :desc).all\n render json: @users\n end",
"def index\n @usuarios = Usuario.paginate(page: params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def index\n @pagos = Pago.all\n end",
"def index\n @pagos = Pago.all\n end",
"def index\n @pagos = Pago.all\n end",
"def index\n #@queried_hotels = Hotel.page params[:page]\n @hotels = Hotel.all.order(created_at: :desc)\n @hotels = pagy_custom(@hotels)\n render json: @hotels, only: [:id, :name, :phone, :email, :user_id]\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.json { render json: @pages }\n format.xml { render xml: @pages }\n end\n end",
"def index\n @pages = Page.all\n respond_with(@pages)\n end",
"def index\n @pages = Page.all\n respond_with(@pages)\n end",
"def index\n @page = params[:page] || 1\n @posts = @exchange.posts.page(@page, context: 0).for_view\n respond_to do |format|\n format.json do\n serializer = PostSerializer.new(\n @posts,\n links: { self: paginated_json_path(@posts.current_page),\n next: paginated_json_path(@posts.next_page),\n previous: paginated_json_path(@posts.previous_page) },\n include: %i[user]\n )\n render json: serializer.serialized_json\n end\n end\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @songs = Song.page(params[:page]).per(15)\n @page = params[:page]\n @page_count = @songs.total_pages\n\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def index\n @deportes = Deporte.all\n render json: @deportes, status: :ok \n @deportes = Deporte.paginate(:page => params[:page])\n end",
"def index\n #Page.all is fine for small sets of data, for larger sets pagination would be best\n @pages = data_cache('pages', 10.minutes) do\n Page.all\n end\n respond_to do |format|\n format.json { render action: 'index', status: :ok, location: api_pages_url(@pages) }\n format.xml { render xml: @pages, location: api_pages_url(@pages) }\n end\n end",
"def index\n @advertises = current_user.advertises.page(params[:page])\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def index\n @apis = Api.all(:order => \"query\")\n #@apis = Api.order(\"query\").page(params[:page]).per(20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apis }\n end\n end",
"def index\n @employing_units = EmployingUnit.page params[:page]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employing_units }\n end\n end",
"def index\n @gifs = Gif.sorted.paginate(page: params[:page], per_page: 12)\n\n respond_to do |format|\n format.html\n format.json { render json: @gifs }\n end\n end",
"def index\n @teams = Team.page(params[:page])\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def index\n per_page = params[:per_page] ? params[:per_page] : Post::PER_PAGE\n @posts = Post.by_published_date.paginate(page: params[:page], per_page: per_page)\n # Set count of posts and count of pages to query headers\n add_headers\n render json: @posts\n end",
"def index\n @pagos = Pago.find(:all)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pagos }\n end\n end",
"def index\n @book_pages = @book.book_pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_pages }\n end\n end",
"def index\n page = params[:page]\n per_page = params[:per_page]\n\n posts = Post.order(published_at: :desc).page(page).per(per_page)\n\n # Передаём в заголовке общее количество страниц и записей.\n response.headers['Total-Pages'] = posts.total_pages\n response.headers['Total-Count'] = posts.total_count\n\n render json: posts\n end",
"def index\n pages = Page.find_by_sql(\"select * from pages\").map { |page| {page: page} }\n if params[:page]\n @pages = get_page_and_offset(13, params[:page].to_i, pages)\n else\n @pages = get_page_and_offset(13, 1, pages)\n end\n\n respond_to do |format|\n format.html\n format.js {render 'paginate_pages.js.erb'}\n end\n end",
"def index\n @games = Game.paginate page: params[:page], order: 'created_at desc', per_page: 10\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @games }\n end\n end",
"def index\n page = params[:page] || 1\n\n @global_jsons = CfTemplate.global\n\n respond_to do |format|\n format.json { @global_jsons = @global_jsons }\n format.html { @global_jsons = @global_jsons.page(page) }\n end\n end",
"def index\n @users = User.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @products = current_company.products.order('created_at desc').page(params[:page]).per(20)\n render json: @products, meta: {total_pages: @products.total_pages, total_count: @products.total_count}\n end",
"def index\n @users = User.all\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n terminals = scope.page(page).per(per)\n json_response(PageDecorator.decorate(terminals), :ok)\n end",
"def index\n @users = User.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @tags ||= Tag.paging(params[:page])\n respond_with(@tags)\n end",
"def index\n respond_with(pages)\n end",
"def index\n @courts = Court.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def index\n page = params[:page] || 1\n\n @users = User.all.page(page)\n respond_to do |format|\n format.json {@users}\n format.html\n end\n end",
"def index\n @photos = get_possible_photos\n paginate json: @photos, per_page: 10\n end",
"def index\n @cards = Card.page(params[:page]).per(7)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cards }\n end\n end",
"def index\n #remove_cache #if params[:page]\n #@articles = #Article.where(:is_published => true)\n @articles = Article.published.paginated(params[:page], 10)\n respond_to do |format|\n\n format.html # index.html.erb\n format.json { render json: @articles }\n end\n end",
"def index\n @offers = getmydata(\"Offer\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def index\n @title = \"List Books\"\n @books = Book.paginate :page=>params[:page], :per_page => 100, :order => 'title'\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end",
"def index\n @users = User.paginate(:page => params[:page], :per_page => 10).order(\"id\")\n\n respond_with do |format|\n format.html # index.html.erb\n format.json { render :json => @users }\n end\n end",
"def index\n @instances = Instance.page params[:page]\n authorize! :read, @instances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instances }\n end\n end",
"def index\n paginate json: @board.posts.page(params[:page]), per_page: 20\n end",
"def index\n @per_page_options = %w{ 21 51 99 }\n respond_to do |format|\n format.html # index.html.erb\n format.xml # index.xml.builder\n format.atom # index.atom.builder\n format.json { render :json => ServiceCatalographer::Api::Json.index(\"services\", json_api_params, @services).to_json }\n format.bljson { render :json => ServiceCatalographer::Api::Bljson.index(\"services\", @services).to_json }\n end\n end"
] | [
"0.74186146",
"0.7317744",
"0.7218744",
"0.7182654",
"0.7172309",
"0.71505433",
"0.7106154",
"0.7095095",
"0.7081657",
"0.7068147",
"0.70400345",
"0.7036573",
"0.70104414",
"0.70104414",
"0.70104414",
"0.70104414",
"0.70104414",
"0.70104414",
"0.70104414",
"0.69942296",
"0.6990783",
"0.69749355",
"0.6936773",
"0.6917316",
"0.6909499",
"0.69039595",
"0.6891262",
"0.68615633",
"0.68573064",
"0.6854786",
"0.68206507",
"0.6816454",
"0.68130463",
"0.6810332",
"0.68043673",
"0.68030965",
"0.68012863",
"0.6794263",
"0.6784548",
"0.67683804",
"0.676824",
"0.6768233",
"0.67648166",
"0.6764157",
"0.6757856",
"0.6757166",
"0.675608",
"0.6756035",
"0.6749127",
"0.6747514",
"0.6737183",
"0.672717",
"0.67264414",
"0.6723279",
"0.6720585",
"0.6702323",
"0.66957736",
"0.66948664",
"0.6688886",
"0.6688886",
"0.6688886",
"0.66837263",
"0.66814727",
"0.6680488",
"0.6680488",
"0.66732717",
"0.6672927",
"0.6668896",
"0.6665692",
"0.6662144",
"0.66604596",
"0.66555226",
"0.6652922",
"0.665291",
"0.6651949",
"0.6645509",
"0.66407263",
"0.6637696",
"0.6637623",
"0.6634583",
"0.66343635",
"0.6627552",
"0.66256064",
"0.6625533",
"0.66192275",
"0.6619126",
"0.6618341",
"0.6616849",
"0.6616799",
"0.66152686",
"0.66132945",
"0.6612567",
"0.6612453",
"0.6611761",
"0.6602541",
"0.6598127",
"0.65869236",
"0.6586451",
"0.65831405",
"0.65826446"
] | 0.6931178 | 23 |
GET /for_pags/1 GET /for_pags/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pagamentos = Pagamento.page(params[:page]).per(NUMERO_POR_PAGINA)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pagamentos = Pagamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end",
"def index\n @for_pags = ForPag.all\n end",
"def index\n @pages = Page.all\n render json: @pages\n end",
"def index\n render json: Visitor.paginate(:page => params[:page], :per_page => 300)\n end",
"def index\n @klasses = Klass.paginate(:page => params[:page], per_page: 30)\n @number = Klass.count\n\n respond_to do |format|\n format.html\n format.json { render :json => Klass.all.to_json(include: :period) }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @puntajes = Puntaje.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end",
"def index\n render json: Item.paginate(page: params[:page], per_page: 25)\n end",
"def index\n @orders = Order.paginate page: params[:page], order: 'created_at desc', \n per_page: 10\n \n respond_to do |format|\n format.html\n format.json { render json: @orders } \n end\n end",
"def index\n @participates = Participate.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @participates }\n end\n end",
"def index\n @calificaciones = Calificacion.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @calificaciones }\n end\n end",
"def index\n render json: EndService.paginate(page: params[:page], per_page: 25)\n end",
"def index\n @requests = Request.paginate(:page => params[:page], :per_page => 8).order(\"created_at DESC\").find_all_by_user_id(current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requests }\n end\n end",
"def index\n @sites = current_user.sites.page(params[\"page\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n page_num=params[:page]\n @users= User.page(page_num)\n render json: @users\n end",
"def index\n @ideas = current_user.ideas.page(params[\"page\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end",
"def index\n @anuncios = Anuncio.all.paginate(page: params[:page], per_page: 4 )\n\n respond_to do |format|\n format.html\n format.json { render json: @jobs }\n end\n end",
"def index\n @accounts = Account.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @accounts }\n end\n end",
"def index\n @pages = current_site.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @users = User.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n\n @houses = House.page(params[:page]).per(House::PER_PAGE_COUNT)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @houses }\n end\n end",
"def index\n @sites = Site.paginate(:page=>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end",
"def index\n @courts = Court.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def index\n @teams = Team.page(params[:page])\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def show\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pagamento }\n end\n end",
"def show\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pagamento }\n end\n end",
"def show\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pagamento }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json do\n collections = Collection.where.not(published_at: nil)\n .order(published_at: :desc)\n .page(params[:page])\n .per(Collection::COLLECTION_PER)\n is_more_load = collections.total_pages > params[:page].to_i\n render json: { collections: collections, is_more_load: is_more_load }\n end\n end\n end",
"def index\n @invoices = Invoice.all.order(invoice_date: :desc).order(created_at: :desc).paginate(:page => params[:page], per_page: 10)\n\n render json: {invoices: @invoices, total_pages: @invoices.total_pages, current_page: @invoices.current_page}\n end",
"def index\n @pages = Page.all\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @iphs = Iph.paginate(:page => params[:page], :per_page => 10).order('created_at desc')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @iphs }\n end\n end",
"def show\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pago }\n end\n end",
"def index\n @urls = @site.urls.paginate(:page => params[:page])\n render json: @urls\n end",
"def index\n @employing_units = EmployingUnit.page params[:page]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employing_units }\n end\n end",
"def index\n @gifs = Gif.sorted.paginate(page: params[:page], per_page: 12)\n\n respond_to do |format|\n format.html\n format.json { render json: @gifs }\n end\n end",
"def index\n respond_with(@pages = Page.all.paginate(:page => params[:page] || 1, :per_page => params[:per_page] || 5))\n end",
"def index\n @families = Family.all.paginate(page: params[:page])\n render json: @families\n end",
"def index\n @links = Link.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @links }\n end\n end",
"def index\n @orders = Order.paginate(page: params[:page], conditions: [\"has_paid = true\"], per_page: 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n por_pagina = params[:por_pagina] || 18\n @productos = Producto.paginate(page: params[:page], per_page: por_pagina).includes(:fotos)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @productos }\n end\n end",
"def index\n @book_pages = @book.book_pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_pages }\n end\n end",
"def index\n @reserve_stat_has_manifestations = ReserveStatHasManifestation.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @reserve_stat_has_manifestations }\n end\n end",
"def view\n \t@parent = params[:parent]\n\n @pages = Page.where(\"digital_edition_id = ?\", @parent).order(\"page_page ASC\").page( params[:page]).per(20)\n\n respond_to do |format|\n format.html # view.html.erb\n format.json { render json: @page }\n end\n end",
"def index\n @pagos = Pago.all\n end",
"def index\n @pagos = Pago.all\n end",
"def index\n @pagos = Pago.all\n end",
"def index\n page = params[:page] || 1\n\n @users = User.all.page(page)\n respond_to do |format|\n format.json\n format.html\n end\n end",
"def index\r\n @books = Book.paginate(:page => params[:page], :per_page => 30)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @books }\r\n end\r\n end",
"def index\n @pagos = Pago.find(:all)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pagos }\n end\n end",
"def index\n @fundamental_retention_mails = Fundamental::RetentionMail.paginate(:order => 'id', :page => params[:page], :per_page => 50) \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fundamental_retention_mails }\n end\n end",
"def index\n @advertises = current_user.advertises.page(params[:page])\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def paginate\n @chirps = Post.timeline(current_user).order(\"created_at DESC\").page(params[:page])\n render json: @chirps, status: 200\n end",
"def index\n page = params[:page] || 1\n\n @global_jsons = CfTemplate.global\n\n respond_to do |format|\n format.json { @global_jsons = @global_jsons }\n format.html { @global_jsons = @global_jsons.page(page) }\n end\n end",
"def index\n\t\t@pages = Page.order('created_at DESC').all\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @pages }\n\t\tend\n\tend",
"def index\n\n @pagy, @posts = pagy(Post.cleaner)\n\n paginationObj = {\n page: @pagy.page,\n prev: @pagy.prev,\n next: @pagy.next,\n last: @pagy.last, \n }\n\n render :json => { postsArr: @posts, pagyData: paginationObj }\n end",
"def index\n @users = User.all.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end",
"def index\n @genotypes = Genotype.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @genotypes }\n end\n end",
"def index\n @usuarios = Usuario.paginate(page: params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def index\n @deportes = Deporte.all\n render json: @deportes, status: :ok \n @deportes = Deporte.paginate(:page => params[:page])\n end",
"def index\n @assessment_olympiads = AssessmentOlympiad.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_olympiads }\n end\n end",
"def index\n @admin_pricing_foams = Admin::Pricing::Foam.all.paginate(page: params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @admin_pricing_foams.map { |i| { value: i.id, text: i.to_s } }, status: :ok }\n end\n end",
"def index\n page = valid_page_or_one params[:page]\n @users = User.paginate(:page => page, :per_page => per_page).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\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 index\n @tsps = Tsp.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@tsps }\n end\n end",
"def index\n # @documentos = Documento.all\n @documentos = Documento.order(\"fecha_publicacion DESC\").paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documentos }\n end\n end",
"def index\n @aboutshetuans = Aboutshetuan.order(\"created_at desc\").page params[:page]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @aboutshetuans }\n end\n end",
"def show\n @mod_pag = ModPag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mod_pag }\n end\n end",
"def index\n @pagos = Pago.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pagos }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.json { render json: @pages }\n format.xml { render xml: @pages }\n end\n end",
"def index\n #@queried_hotels = Hotel.page params[:page]\n @hotels = Hotel.all.order(created_at: :desc)\n @hotels = pagy_custom(@hotels)\n render json: @hotels, only: [:id, :name, :phone, :email, :user_id]\n end",
"def index\n @jobs = Job.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobs }\n end\n end",
"def index\n @instances = Instance.page params[:page]\n authorize! :read, @instances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instances }\n end\n end",
"def index\n terminals = scope.page(page).per(per)\n json_response(PageDecorator.decorate(terminals), :ok)\n end",
"def index\n @profiles = Profile.all.paginate :page => params[:page], :per_page => 3\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @profiles }\n end\n end",
"def index\n @cards = Card.page(params[:page]).per(7)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cards }\n end\n end",
"def index\n @disciplines = Discipline.paginate(:page => params[:page], per_page: 30)\n @number = Discipline.count\n respond_to do |format|\n format.html\n format.json { render :json => Discipline.all.to_json(include: :department) }\n end\n end",
"def index_participating\n projects = current_user.projects.paginate(:page => params[:page])\n render json: projects\n end",
"def index\n @batches = Batch.page(params[:page]).per(15)\n @page = params[:page] || 1\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batches }\n end\n end",
"def index\n @assessment_insti_tests = AssessmentInstiTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_insti_tests }\n end\n end",
"def get_page\n render_page_sections_json\n end",
"def index\n @concept_maps = ConceptMap.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@concept_maps }\n end\n end",
"def index\n @assessment_practice_tests = AssessmentPracticeTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_practice_tests }\n end\n end",
"def index\n \n @users = User.page(params[:page]).per_page(14)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n \n end",
"def index\n @pages = Page.all\n\n respond_with @pages\n end",
"def index\n @general_frames = @university.general_frames.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @general_frames }\n end\n end",
"def index\n @apis = Api.all(:order => \"query\")\n #@apis = Api.order(\"query\").page(params[:page]).per(20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apis }\n end\n end",
"def index\n @offers = getmydata(\"Offer\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @offers }\n end\n end",
"def index\n @rameurs = Rameur.where(confirmation_token: nil).asc(\"prenom\").asc(\"nom\").paginate(page: params[:page], per_page: 5)\n\n respond_to do |format|\n format.html { @rameurs }\n format.json {\n render json: {\n current_page: @rameurs.current_page,\n per_page: @rameurs.per_page,\n total_entries: @rameurs.total_entries,\n entries: @rameurs\n }\n }\n end\n end",
"def index\n @src_gsts = SrcGst.where(hotel_src_id: current_user.hotel_src_id).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @src_gsts }\n end\n end"
] | [
"0.72397405",
"0.7014571",
"0.7004321",
"0.69238406",
"0.69155943",
"0.6882885",
"0.6825616",
"0.6799138",
"0.67869663",
"0.67869663",
"0.67869663",
"0.67869663",
"0.67869663",
"0.67869663",
"0.67869663",
"0.6739998",
"0.6696968",
"0.6667365",
"0.665863",
"0.6646314",
"0.66410136",
"0.6620577",
"0.6617461",
"0.66065913",
"0.65999615",
"0.65961325",
"0.65818673",
"0.6551905",
"0.65461844",
"0.653684",
"0.6521169",
"0.65160173",
"0.6514598",
"0.6514559",
"0.6505269",
"0.65020114",
"0.65020114",
"0.65020114",
"0.6498402",
"0.64981693",
"0.6495509",
"0.64929914",
"0.6492051",
"0.6489331",
"0.64876074",
"0.6472131",
"0.6470631",
"0.6465542",
"0.6459429",
"0.64568347",
"0.64556867",
"0.64527756",
"0.6450667",
"0.64457846",
"0.6442491",
"0.6442491",
"0.6442491",
"0.64410746",
"0.64325815",
"0.64306056",
"0.64298546",
"0.64264446",
"0.64226526",
"0.64209735",
"0.64167625",
"0.64141005",
"0.64103436",
"0.64088106",
"0.640088",
"0.6400686",
"0.63865554",
"0.63862973",
"0.6383329",
"0.6380083",
"0.63745594",
"0.637149",
"0.63701713",
"0.63681966",
"0.63681686",
"0.63679624",
"0.6367063",
"0.6349197",
"0.63413227",
"0.634123",
"0.6333474",
"0.6332388",
"0.6326389",
"0.6326218",
"0.63182926",
"0.63177025",
"0.63169885",
"0.6314559",
"0.6309808",
"0.6309464",
"0.63090754",
"0.6307737",
"0.63037175",
"0.6298832",
"0.62966216",
"0.6291438",
"0.62881035"
] | 0.0 | -1 |
POST /for_pags POST /for_pags.json | def create
@for_pag = ForPag.new(for_pag_params)
respond_to do |format|
if @for_pag.save
format.html { redirect_to @for_pag, notice: 'For pag was successfully created.' }
format.json { render action: 'show', status: :created, location: @for_pag }
else
format.html { render action: 'new' }
format.json { render json: @for_pag.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\n @pagy, @posts = pagy(Post.cleaner)\n\n paginationObj = {\n page: @pagy.page,\n prev: @pagy.prev,\n next: @pagy.next,\n last: @pagy.last, \n }\n\n render :json => { postsArr: @posts, pagyData: paginationObj }\n end",
"def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end",
"def paginate\n @chirps = Post.timeline(current_user).order(\"created_at DESC\").page(params[:page])\n render json: @chirps, status: 200\n end",
"def index\n render json: Visitor.paginate(:page => params[:page], :per_page => 300)\n end",
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pagamentos = Pagamento.page(params[:page]).per(NUMERO_POR_PAGINA)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n render json: Item.paginate(page: params[:page], per_page: 25)\n end",
"def index\n @puntajes = Puntaje.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end",
"def crear_paginacion\n @page = params[:page].nil? ? 1 : params[:page].to_i\n @per_page = 3\n end",
"def index\n @pages = Page.all\n render json: @pages\n end",
"def index\n render json: EndService.paginate(page: params[:page], per_page: 25)\n end",
"def index\n @orders = Order.paginate page: params[:page], order: 'created_at desc', \n per_page: 10\n \n respond_to do |format|\n format.html\n format.json { render json: @orders } \n end\n end",
"def for_pag_params\n params.require(:for_pag).permit(:description, :days, :active)\n end",
"def index\n @for_pags = ForPag.all\n end",
"def index\n @pagamentos = Pagamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def index\n @batches = Batch.page(params[:page]).per(15)\n @page = params[:page] || 1\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batches }\n end\n end",
"def index\n respond_with(@pages = Page.all.paginate(:page => params[:page] || 1, :per_page => params[:per_page] || 5))\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def page\n\n\t\t# TODO: maybe not good\n\t\tresult = Hash.new\n\t\tlimit = params[:limit].to_i\n\t\tpage = params[:page].to_i\n\t\t# TODO: maybe not good\n\n\t\t# TODO: maybe not good\n\t\t# @tasks = Task.includes( :tags ).order( created_at: :desc ).offset( page * limit )\n\t\t@tasks = Task.order( created_at: :desc ).offset( page * limit )\n\t\t# TODO: maybe not good\n\n\t\tresult[:pages] = @tasks.count / limit + 1 unless @tasks.count % limit == 0\n\t\t@tasks = @tasks.limit( limit )\n\t\tresult[:tasks] = @tasks\n\n\t\ti = 0\n\t\tresult[:tags] = Hash.new\n\n\t\t# TODO: task can not access tags ?\n\t\[email protected] do |task|\n\t\t\tputs task.uuid\n\t\t\tresult[:tags][i] = Tag.where( \"task_id = ?\", task.uuid )\n\t\t\ti += 1\n\t\tend\n\n\t\t# TODO: code need to update\n\t\trender json: result\n\tend",
"def index\n #@queried_hotels = Hotel.page params[:page]\n @hotels = Hotel.all.order(created_at: :desc)\n @hotels = pagy_custom(@hotels)\n render json: @hotels, only: [:id, :name, :phone, :email, :user_id]\n end",
"def index\n @deportes = Deporte.all\n render json: @deportes, status: :ok \n @deportes = Deporte.paginate(:page => params[:page])\n end",
"def create\n @pago = Pago.new(params[:pago])\n\n respond_to do |format|\n if @pago.save\n format.html { render :text => @pago.attributes.merge( :saldo => @pago.saldo ).to_json }\n format.xml { render :xml => @pago, :status => :created, :location => @pago }\n else\n format.html { render :action => \"new\", :status => :unprocessable_entity }\n format.xml { render :xml => @pago.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @anuncios = Anuncio.all.paginate(page: params[:page], per_page: 4 )\n\n respond_to do |format|\n format.html\n format.json { render json: @jobs }\n end\n end",
"def assign_pages!\n payload[\"page\"] = document.to_liquid\n payload[\"paginator\"] = (document.pager.to_liquid if document.respond_to?(:pager))\n end",
"def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end",
"def pages\n project_size = Project.all.length\n\n puts project_size\n\n respond_to do |format|\n format.json {\n @pages = (project_size/10.0).ceil\n render :json => @pages \n }\n end\n end",
"def index\n @klasses = Klass.paginate(:page => params[:page], per_page: 30)\n @number = Klass.count\n\n respond_to do |format|\n format.html\n format.json { render :json => Klass.all.to_json(include: :period) }\n end\n end",
"def controller_paginated_json(records, options={})\r\n controller_as_paginated_json(records, options)\r\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n respond_to do |format|\n format.html do\n @task = current_user.tasks.new\n end\n format.json do\n page = (params[:page] || 1).to_i\n per_page = 5\n total_pages = (@tasks.count.to_f / per_page).ceil\n total_pages = 1 if total_pages.zero?\n @tasks = @tasks.paginate(page: page, per_page: per_page)\n render json: { tasks: @tasks, page: page, totalPages: total_pages }\n end\n end\n end",
"def index\n @orders = Order.paginate(page: params[:page], conditions: [\"has_paid = true\"], per_page: 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n page_num=params[:page]\n @users= User.page(page_num)\n render json: @users\n end",
"def index\n @tsps = Tsp.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@tsps }\n end\n end",
"def index\n @rameurs = Rameur.where(confirmation_token: nil).asc(\"prenom\").asc(\"nom\").paginate(page: params[:page], per_page: 5)\n\n respond_to do |format|\n format.html { @rameurs }\n format.json {\n render json: {\n current_page: @rameurs.current_page,\n per_page: @rameurs.per_page,\n total_entries: @rameurs.total_entries,\n entries: @rameurs\n }\n }\n end\n end",
"def index\n @users = User.paginate(page: params[:page], per_page: params[:size])\n .order(created_at: :desc).all\n render json: @users\n end",
"def index\n @invoices = Invoice.all.order(invoice_date: :desc).order(created_at: :desc).paginate(:page => params[:page], per_page: 10)\n\n render json: {invoices: @invoices, total_pages: @invoices.total_pages, current_page: @invoices.current_page}\n end",
"def index\n @links = Link.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @links }\n end\n end",
"def index\n @accounts = Account.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @accounts }\n end\n end",
"def index\n @assessment_practice_tests = AssessmentPracticeTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_practice_tests }\n end\n end",
"def index\n @pagos = Pago.all\n end",
"def index\n @pagos = Pago.all\n end",
"def index\n @pagos = Pago.all\n end",
"def index\n @assessment_insti_tests = AssessmentInstiTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_insti_tests }\n end\n end",
"def create_many(data)\n command(create: :pages, result: :many).call(data)\n end",
"def test_pages_list\n @project = AzProject.find(params[:id])\n project_hash = @project.to_az_hash\n pp project_hash\n AzProject.build_from_az_hash(project_hash)\n respond_to do |format|\n format.html { render :text => \"OK\"}\n end\n end",
"def index\n @participates = Participate.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @participates }\n end\n end",
"def index\n case\n when @agent\n @creates = @agent.creates.order('creates.position').page(params[:page])\n when @work\n @creates = @work.creates.order('creates.position').page(params[:page])\n else\n @creates = Create.page(params[:page])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @creates }\n end\n end",
"def index\n @calificaciones = Calificacion.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @calificaciones }\n end\n end",
"def index\n @fundamental_retention_mails = Fundamental::RetentionMail.paginate(:order => 'id', :page => params[:page], :per_page => 50) \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fundamental_retention_mails }\n end\n end",
"def index\n @pages = Page.all\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def index\n respond_with(pages)\n end",
"def index\n uri = URI(\"http://107.170.7.58:4567/api/department\")\n parameters = {\"ext\" => \"json\", \"count\" => \"1000\"}\n response = Net::HTTP.post_form(uri, parameters)\n\n list = JSON.parse(response.body)\n @departments = Array.new\n list.each do |department|\n @departments.push Department.new(department['data'])\n end\n\n page = params[:page]\n offset = page.to_s+\"0\"\n @prevPage = page.to_i-1\n @nextPage = page.to_i+1\n\n if params[:department]\n department = params[:department]\n @departmentName = @departments[department.to_i-1].name\n\n parameters = {\"ext\" => \"json\", \"count\" => \"10\", \"offset\" => offset, \"department_id\" => department}\n else\n parameters = {\"ext\" => \"json\", \"count\" => \"10\", \"offset\" => offset}\n end\n\n uri = URI(\"http://107.170.7.58:4567/api/sell\")\n response = Net::HTTP.post_form(uri, parameters)\n\n list = JSON.parse(response.body)\n\n @sells = Array.new\n @books = Array.new\n list.each do |listing|\n if listing[\"kind\"].eql? \"sell\"\n @sells.push Sell.new(listing[\"data\"])\n else if listing[\"kind\"].eql? \"book\"\n @books[listing[\"data\"][\"id\"]] = Edition.new(listing[\"data\"])\n end\n end\n end\n end",
"def index\n @pages = Page.all.sort{|a, b| [a.data_row, a.data_col] <=> [b.data_row, b.data_col] }.paginate(:per_page => 16, :page => params[:page] || 1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @requests = Request.paginate(:page => params[:page], :per_page => 8).order(\"created_at DESC\").find_all_by_user_id(current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requests }\n end\n end",
"def index\n # @donation_year_links = DonationYearLink.all\n @donation_year_links = DonationYearLink.order(:created_at).page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @donation_year_links }\n end\n end",
"def download\n page = params[:page].to_i\n\n a = download_conjugation(page)\n @verbs_conj.each do |verb|\n v = Verb.new(:infinitive => verb[:infinitive], :translation => verb[:translation], :group => verb[:group])\n if v.save\n @tenses.each_with_index do |tense, index|\n @forms.each_with_index do |form, index2|\n if(verb[tense][form].strip != '')\n @form = Form.new(:content => verb[tense][form], :temp => index.to_i, :person => index2.to_i,:verb => v)\n @form.save\n end\n end\n end\n end\n end\n File.open(\"public/temp_#{page}.json\",\"w\") do |f|\n f.write(JSON.pretty_generate(@verbs_conj))\n end\n\n @verbs = Verb.all\n respond_to do |format|\n format.html{ render action: 'index'}\n format.json { head :no_content }\n end\n\n end",
"def pages\n get(\"v1/event/#{@id}/pages\")\n end",
"def index\n @users = User.paginate(page: params[:page], per_page:50)\n render json: @users, status: :ok\n end",
"def create\n respond_to do |format|\n begin\n @page = Page.create_page!\n format.html { redirect_to \"/#{@page.request_id}/inspect\", notice: t('pages.create.success') }\n format.json { render action: 'show', status: :created, location: @page }\n rescue => e\n format.html { render action: 'index' }\n format.json { render json: {:message => \"create page error\"}, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pagina = Pagina.new(pagina_params)\n\n respond_to do |format|\n if @pagina.save\n format.html { redirect_to @pagina, notice: 'Pagina was successfully created.' }\n format.json { render :show, status: :created, location: @pagina }\n else\n format.html { render :new }\n format.json { render json: @pagina.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @families = Family.all.paginate(page: params[:page])\n render json: @families\n end",
"def index\n @users = User.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n pages = Page.find_by_sql(\"select * from pages\").map { |page| {page: page} }\n if params[:page]\n @pages = get_page_and_offset(13, params[:page].to_i, pages)\n else\n @pages = get_page_and_offset(13, 1, pages)\n end\n\n respond_to do |format|\n format.html\n format.js {render 'paginate_pages.js.erb'}\n end\n end",
"def index\n @enq_pages = EnqPage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enq_pages }\n end\n end",
"def index\n # @documentos = Documento.all\n @documentos = Documento.order(\"fecha_publicacion DESC\").paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documentos }\n end\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n\n render json: @posts, each_serializer: Api::V1::PostSerializer, meta: meta_attributes(@posts)\n end",
"def pages\n end",
"def index\n respond_to do |format|\n format.html\n format.json do\n collections = Collection.where.not(published_at: nil)\n .order(published_at: :desc)\n .page(params[:page])\n .per(Collection::COLLECTION_PER)\n is_more_load = collections.total_pages > params[:page].to_i\n render json: { collections: collections, is_more_load: is_more_load }\n end\n end\n end",
"def index\n page = params[:page]\n per_page = params[:per_page]\n\n posts = Post.order(published_at: :desc).page(page).per(per_page)\n\n # Передаём в заголовке общее количество страниц и записей.\n response.headers['Total-Pages'] = posts.total_pages\n response.headers['Total-Count'] = posts.total_count\n\n render json: posts\n end",
"def index\n @page = params[:page] || 1\n @posts = @exchange.posts.page(@page, context: 0).for_view\n respond_to do |format|\n format.json do\n serializer = PostSerializer.new(\n @posts,\n links: { self: paginated_json_path(@posts.current_page),\n next: paginated_json_path(@posts.next_page),\n previous: paginated_json_path(@posts.previous_page) },\n include: %i[user]\n )\n render json: serializer.serialized_json\n end\n end\n end",
"def index\n @assessment_end_chapter_quizzes = AssessmentEndChapterQuiz.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_end_chapter_quizzes }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.json { render json: @pages }\n format.xml { render xml: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_with @pages\n end",
"def my_listings\n page = params[:page]\n offset = page.to_s+\"0\"\n @prevPage = page.to_i-1\n @nextPage = page.to_i+1\n\n userID = session[:user_id]\n\n uri = URI(\"http://107.170.7.58:4567/api/sell\")\n parameters = {\"ext\" => \"json\", \"user_id\" => userID, \"count\" => \"10\", \"offset\" => offset}\n response = Net::HTTP.post_form(uri, parameters)\n\n list = JSON.parse(response.body)\n\n @sells = Array.new\n @books = Array.new\n list.each do |listing|\n if listing[\"kind\"].eql? \"sell\"\n @sells.push Sell.new(listing[\"data\"])\n else if listing[\"kind\"].eql? \"book\"\n @books[listing[\"data\"][\"id\"]] = Edition.new(listing[\"data\"])\n end\n end\n end\n end",
"def index\n @steps = Step.collated.ordered.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end",
"def num_pages\n \n # Retrieve postings that match the given conditions\n postings = getPostings(params)\n \n # Escapes the case when @postings is nil\n num_pages = postings.blank? ? 0 : postings.num_pages\n \n respond_to do |format|\n format.json { render json: num_pages }\n end\n \n end",
"def index\n @assessment_olympiads = AssessmentOlympiad.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_olympiads }\n end\n end",
"def create\n\n @pago = Pago.new(pago_params)\n\n @pago.farmacium_id = session[:farmacia_id]\n @pago.numcomprobante = params[:pago][:numcomprobante]\n\n\n respond_to do |format|\n if (params[:pago][:numcomprobante].length >= 11)\n format.html { redirect_to \"/lab_fars\", notice: 'Comprobante no puede tener mas de 11 carácteres.' }\n else\n if @pago.save\n format.html { redirect_to \"/lab_fars\", notice: 'Comprobante se envió satisfactoriamente.' }\n else\n format.html { redirect_to \"/lab_fars\", notice: 'Reporte de pago no debe estar en blanco.' }\n \n end\n end\n end\n end",
"def index\n @sites = Site.paginate(:page=>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def index\r\n @books = Book.paginate(:page => params[:page], :per_page => 30)\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @books }\r\n end\r\n end",
"def index\n paginate json: @board.posts.page(params[:page]), per_page: 20\n end",
"def render_paginated(resource, opts = {})\n render json: resource, root: 'items', meta: {}\n end",
"def index\n @iphs = Iph.paginate(:page => params[:page], :per_page => 10).order('created_at desc')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @iphs }\n end\n end",
"def index\n @docs = Oa::SentDocument.all#.paginate(:page => params[:page], :order => 'created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @docs }\n end\n end",
"def index\n @pages = Page.all\n respond_with(@pages)\n end",
"def index\n @pages = Page.all\n respond_with(@pages)\n end",
"def index\n page = valid_page_or_one params[:page]\n @users = User.paginate(:page => page, :per_page => per_page).order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @jobs = Job.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @jobs }\n end\n end",
"def create\n @page = Page.new(page_params)\n\n if @page.save\n render json: @page, status: :created, location: @page\n else\n render json: @page.errors, status: :unprocessable_entity\n end\n end",
"def index\n @visits = VisitSearch.new.visits current_physician, params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @visits }\n end\n end",
"def index\n @employing_units = EmployingUnit.page params[:page]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employing_units }\n end\n end",
"def index\n @usuarios = Usuario.paginate(page: params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def create\n @pago = Pago.new(pago_params)\n @pagoPendAplicar = @pago.pago_valor\n case @pago.pago_tipoProducto\n when \"RESERVA\"\n reserva = Reserva.where(\"rsrv_codigo = '#{@pago.pago_productoId}'\").take\n detallesReserva = DetalleReserva.where(\"reserva_id = ? AND detRsrv_estadoReserva IN ('I', 'P')\" ,reserva.id)\n @parentPath = \"/reservas/\" + reserva.id.to_s\n if reserva.rsrv_tipoProducto == \"VUELO\" then\n tarifasViaje = tarifas_viaje(reserva.rsrv_productoId, reserva.rsrv_trayectoViaje)\n if tarifasViaje.viaje_tarifas.blank?\n detallesReserva.each do |h|\n if @pagoPendAplicar > 0 then\n h.detRsrv_tarifaCodigo = \"BASE\"\n h.detRsrv_estadoReserva = \"C\"\n if @pagoPendAplicar > tarifasViaje.trf_base then\n h.detRsrv_valor = tarifasViaje.trf_base \n @pagoPendAplicar = @pagoPendAplicar - tarifasViaje.trf_base\n else\n h.detRsrv_valor = @pagoPendAplicar\n @pagoPendAplicar = 0\n end\n end\n h.save\n end\n else\n end\n end \n reserva.rsrv_estadoReserva = \"C\"\n reserva.save\n end\n\n respond_to do |format|\n if @pago.save\n format.html { redirect_to @parentPath, notice: 'Pago creado exitosamente.' }\n format.json { render :show, status: :created, location: @pago }\n else\n format.html { render :new }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6356638",
"0.63352305",
"0.629253",
"0.6207374",
"0.61574405",
"0.61417615",
"0.614163",
"0.6135821",
"0.60952026",
"0.60897297",
"0.6041269",
"0.60253435",
"0.5962303",
"0.5956969",
"0.59244704",
"0.58757305",
"0.58574796",
"0.58470386",
"0.58470386",
"0.58470386",
"0.58470386",
"0.58470386",
"0.58470386",
"0.58470386",
"0.583514",
"0.582345",
"0.58098805",
"0.58022195",
"0.57929313",
"0.5780321",
"0.5777097",
"0.575296",
"0.57487357",
"0.5731859",
"0.5711962",
"0.5703407",
"0.5699084",
"0.56850743",
"0.5675226",
"0.566691",
"0.56626344",
"0.56615865",
"0.5661345",
"0.56577957",
"0.56557226",
"0.5654159",
"0.5654159",
"0.5654159",
"0.5652373",
"0.56431085",
"0.5642998",
"0.563917",
"0.5633531",
"0.56322604",
"0.56261396",
"0.56253314",
"0.56140506",
"0.56111187",
"0.5610932",
"0.5610284",
"0.5605895",
"0.55941236",
"0.5588994",
"0.5581634",
"0.5578848",
"0.557708",
"0.55767447",
"0.5576662",
"0.5573861",
"0.5572967",
"0.5567788",
"0.5562941",
"0.55585414",
"0.5553663",
"0.55521554",
"0.55463374",
"0.55347",
"0.55331135",
"0.5530321",
"0.5526889",
"0.55260897",
"0.5522896",
"0.55228126",
"0.55142546",
"0.551277",
"0.5512764",
"0.5511268",
"0.5510159",
"0.5507873",
"0.55068713",
"0.5506268",
"0.55043113",
"0.55043113",
"0.550187",
"0.55009425",
"0.5500184",
"0.54976475",
"0.54949677",
"0.5486043",
"0.546793"
] | 0.6289221 | 3 |
PATCH/PUT /for_pags/1 PATCH/PUT /for_pags/1.json | def update
respond_to do |format|
if @for_pag.update(for_pag_params)
format.html { redirect_to @for_pag, notice: 'For pag was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @for_pag.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @pago.update(pago_params)\n format.html { redirect_to @pago, notice: 'Pago was successfully updated.' }\n format.json { render :show, status: :ok, location: @pago }\n else\n format.html { render :edit }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pago.update(pago_params)\n format.html { redirect_to @pago, notice: 'Pago was successfully updated.' }\n format.json { render :show, status: :ok, location: @pago }\n else\n format.html { render :edit }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pago.update(pago_params)\n format.html { redirect_to @pago, notice: 'Pago actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @pago }\n else\n format.html { render :edit }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n\n respond_to do |format|\n if @pago.update_attributes(params[:pago])\n format.html { redirect_to [@cliente, @pago], notice: 'Pago was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pagos_servicio.update(pagos_servicio_params)\n format.html { redirect_to @pagos_servicio, notice: 'Pagos servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagos_servicio }\n else\n format.html { render :edit }\n format.json { render json: @pagos_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n if @pagamento.update_attributes(params[:pagamento])\n format.html { redirect_to @pagamento, notice: 'Pagamento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pagamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pago = Pago.find(params[:id])\n\n respond_to do |format|\n if @pago.update_attributes(params[:pago])\n format.html { redirect_to(@pago, :notice => 'Pago was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pago.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @formapagto.update(formapagto_params)\n format.html { redirect_to @formapagto, notice: 'Forma de pagto alterado com sucesso.' }\n format.json { render :show, status: :ok, location: @formapagto }\n else\n format.html { render :edit }\n format.json { render json: @formapagto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pagamento.update(pagamento_params)\n format.html { redirect_to cliente_venda_path(@cliente, @venda), notice: 'Os dados do Pagamento foram atualizados!' }\n format.json { render :show, status: :ok, location: @pagamento }\n else\n format.html { render :edit }\n format.json { render json: @pagamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pagto_taxa.update(pagto_taxa_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pagto_taxa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @realiza = Realiza.find(params[:id])\n @pagamento=Pagamento.new(:servico_id=>@realiza.servico_id,:cliente_id=>@realiza.cliente_id,:valor=>@realiza.servico.preco,\n :formapagamentoe_id=>params[:pagamento])\n respond_to do |format|\n if @realiza.update_attributes(params[:realiza]) and @pagamento.save\n format.html { redirect_to @realiza, notice: 'Realiza was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @realiza.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:page][:id])\n if current_user.id != @page.owner_id\n not_found\n end\n @page.partial_update(params)\n respond_to do |format|\n format.json {\n render partial: 'pages/page.json'\n }\n end\n end",
"def update\n @pago = Pago.find(params[:id])\n\n respond_to do |format|\n if @pago.update_attributes(params[:pago])\n flash[:notice] = 'Pago was successfully updated.'\n format.html { redirect_to(@pago) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pago.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pagina.update(pagina_params)\n format.html { redirect_to @pagina, notice: 'Pagina was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagina }\n else\n format.html { render :edit }\n format.json { render json: @pagina.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mod_pag = ModPag.find(params[:id])\n\n respond_to do |format|\n if @mod_pag.update_attributes(params[:mod_pag])\n format.html { redirect_to @mod_pag, notice: 'Modalità di pagamento aggiornata con successo.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mod_pag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n respond_to do |format|\n if @pagina.update(pagina_params)\n format.html { redirect_to edit_produto_pagina_path(@produto, @pagina), notice: 'Pagina was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagina }\n else\n format.html { render :edit }\n format.json { render json: @pagina.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #Render the object created or errors\n respond_to do |format|\n if @page.update(page_params)\n #Cache bust pages and updated page. With pagination we would only bust the cache of the page that was updated.\n Rails.cache.delete(\"pages\")\n Rails.cache.delete(\"page-#{@page.id}\")\n format.json { render action: 'show', status: :ok, location: api_page_url(@page) }\n else\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mini_pago = MiniPago.find(params[:id])\n\n respond_to do |format|\n if @mini_pago.update_attributes(params[:mini_pago])\n format.html { redirect_to @mini_pago, notice: 'Mini pago was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mini_pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promocion = Promocion.find(params[:id])\n logger.debug \"-------------------------------------------------------\"\n logger.debug params[:promocion][:formadepago_ids]\n logger.debug \"-------------------------------------------------------\"\n if (params[:promocion][:comercializable_ids] == nil)\n params[:promocion][:comercializable_ids] = []\n end\n\n if (params[:promocion][:formadepago_ids] == nil)\n params[:promocion][:formadepago_ids] = []\n end\n\n respond_to do |format|\n if @promocion.update_attributes(params[:promocion])\n format.html { redirect_to @promocion, :notice => 'Promocion was successfully updated.' }\n format.json { render json: @promocion}\n else\n format.html { render :action => \"edit\" }\n format.json { render json: @promocion.errors }\n end\n end\n end",
"def update\n @congreso = Congreso.find(params[:id])\n @datos_lucrativos = false\n @datos_lucrativos = true if @congreso.talleres.where(\"precio > 0\").count > 0 || @congreso.precio > 0\n\n if params[:congreso][:pago] == \"1\" or @datos_lucrativos\n @congreso.personas_confirmadas.each do |persona|\n persona.update_attribute(\"pago\", false)\n end\n else\n @congreso.personas_sin_confirmar.each do |persona|\n persona.update_attribute(\"pago\", true) \n end\n end\n\n respond_to do |format|\n if @congreso.update_attributes(params[:congreso])\n format.html do \n eliminar_campos_anteriores(params[:id])\n crear_campos_congreso(params, params[:id])\n redirect_to @congreso, notice: 'Congreso actualizado correctamente.'\n end\n format.json { head :ok }\n else\n @campos = Campo.all\n format.html { render action: \"edit\" }\n format.json { render json: @congreso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pagina = Pagina.find(params[:id])\n\n respond_to do |format|\n if @pagina.update_attributes(params[:pagina])\n format.html { redirect_to(@pagina, :notice => t('exito')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pagina.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @docs_ponto.update(docs_ponto_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @docs_ponto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_pago = TipoPago.find(params[:id])\n\n respond_to do |format|\n if @tipo_pago.update_attributes(params[:tipo_pago])\n format.html { redirect_to(@tipo_pago, :notice => 'TipoPago was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_pago.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @prepagada = Prepagada.find(params[:id])\n\n respond_to do |format|\n if @prepagada.update_attributes(params[:prepagada])\n format.html { redirect_to @prepagada, notice: 'Prepagada was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prepagada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @medio_pago = MedioPago.find(params[:id])\n\n respond_to do |format|\n if @medio_pago.update_attributes(params[:medio_pago])\n format.html { redirect_to @medio_pago, notice: 'Medio pago was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @medio_pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @page.errors, status: :unprocessable_entity }\n format.xml { render xml: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @valores_de_pago.update(valores_de_pago_params)\n format.html { redirect_to @valores_de_pago, notice: 'Valores de pago was successfully updated.' }\n format.json { render :show, status: :ok, location: @valores_de_pago }\n else\n format.html { render :edit }\n format.json { render json: @valores_de_pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n @page.update_attributes(params[:page])\n respond_with(@page)\n end",
"def update\n respond_to do |format|\n if @concepto_de_pago.update(concepto_de_pago_params)\n format.html { redirect_to @concepto_de_pago, notice: 'Concepto de pago fue actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @concepto_de_pago }\n else\n format.html { render :edit }\n format.json { render json: @concepto_de_pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_de_pago.update(tipo_de_pago_params)\n format.html { redirect_to @tipo_de_pago, notice: 'Tipo de pago fue actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @tipo_de_pago }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_pago.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @nested_page = Nested::Page.find(params[:id])\n\n respond_to do |format|\n if @nested_page.update_attributes(params[:nested_page])\n format.html { redirect_to @nested_page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nested_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pagare = Pagare.find(params[:id])\n\n respond_to do |format|\n if @pagare.update_attributes(params[:pagare])\n format.html { redirect_to(@pagare, :notice => 'Pagare was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pagare.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n currency_to_number params[:pagamento][:valor]\n\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n if @pagamento.update_attributes(params[:pagamento])\n #format.html { redirect_to @pagamento, notice: 'Pagamento atualizado com sucesso.' }\n format.html { redirect_to @pagamento.os, notice: 'Pagamento atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pagamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @conta_a_pagar.update(conta_a_pagar_params)\n format.html { redirect_to @conta_a_pagar, notice: 'Conta a pagar was successfully updated.' }\n format.json { render :show, status: :ok, location: @conta_a_pagar }\n else\n format.html { render :edit }\n format.json { render json: @conta_a_pagar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pagamento_aceito.update(pagamento_aceito_params)\n format.html { redirect_to @pagamento_aceito, notice: 'Pagamento aceito was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagamento_aceito }\n else\n format.html { render :edit }\n format.json { render json: @pagamento_aceito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pagamento = Pagamento.find(params[:id])\n\n respond_to do |format|\n if @pagamento.update_attributes(params[:pagamento])\n format.html { redirect_to(@pagamento, :notice => 'Pagamento was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pagamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to pages_path, sucess: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n @testimonials = Testimonial.all\n \n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n @page.update_attributes(params[:page])\n respond_with(@page, :status => :updated)\n end",
"def update\n if @page.update_attributes(params[:page])\n respond_with(@page)\n else\n respond_with(@page)\n end\n end",
"def update\n respond_to do |format|\n if @minha_pagina.update(minha_pagina_params)\n format.html { redirect_to @minha_pagina, notice: 'Minha pagina was successfully updated.' }\n format.json { render :show, status: :ok, location: @minha_pagina }\n else\n format.html { render :edit }\n format.json { render json: @minha_pagina.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to [:admin, @page], notice: 'Страница успешно создана.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update\n @pagina = Pagina.find(params[:id])\n\n respond_to do |format|\n if @pagina.update_attributes(params[:pagina])\n flash[:notice] = 'Pagina was successfully updated.'\n format.html { redirect_to(@pagina) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pagina.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n @page.section_id = params[:section_id] unless params[:section_id].nil? \n @page.title = params[:title] unless params[:title].nil? \n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n #ormat.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to pages_path, notice: 'Page was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n respond_with(page)\n end",
"def update\n respond_to do |format|\n if @pago_alquiler.update(pago_alquiler_params)\n format.html { redirect_to pago_alquilers_url, notice: 'Pago alquiler se guardo fino.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pago_alquiler.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = current_site.pages.find(params[:id])\n @site = @page.site\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }\n format.json { respond_with_bip(@page) }\n else\n format.html { render :action => \"edit\" }\n format.json { respond_with_bip(@page) }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:presentacion][:activo]\n id = params[:id]\n Presentacion.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n\n #find the page with given id\n @page = Page.find(params[:id])\n\n #use updated_at manually, it will update the page table if user hits update button.\n # This may not be trivial, so it may change.\n @page.updated_at = Time.now\n\n #retrieving layout id from params and assigning to a variable\n @layout = @page[:layout_id]\n\n # calling method to find all pages and page parts\n find_pages_and_parts(@layout)\n\n #sends in data in different format\n respond_to do |format|\n\n if @page.update_attributes(params[:page]) #page updated successfully\n\n format.html { redirect_to admin_pages_path, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n\n else #page saving failed, re-renders edit template\n\n format.html { render action: \"edit\", :template => 'mcms_pages/admin/pages/edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n\n end # end if\n\n end # end respond_to block\n\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to page_path(@page), notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book_page = @book.book_pages.find(params[:id])\n\n respond_to do |format|\n if @book_page.update_attributes(params[:book_page])\n format.html { redirect_to book_series_collection_book_book_page_url(@book_series, @collection, @book, @book_page), notice: 'Book page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: \"Page was successfully updated. #{undo_link}\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page.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 @patch_jobs = args[:patch_jobs] if args.key?(:patch_jobs)\n end",
"def update\n @pagos_detalhe = PagosDetalhe.find(params[:id])\n @pagos_detalhe.usuario_updated = current_user.id\n @pagos_detalhe.unidade_updated = current_unidade.id\n\n respond_to do |format|\n if @pagos_detalhe.update_attributes(params[:pagos_detalhe])\n flash[:notice] = 'Actualizado con Sucesso'\n format.html { redirect_to \"/pagos/#{@pagos_detalhe.pago_id}\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pagos_detalhe.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @cliente = Cliente.find(params[:id])\n\n #ERRO:\n # Ver o update gerado. Não está atualizando o campo pago ndo parcela corrente\n if !params[:ckb_parcela].nil?\n @cliente.Dividas.each do |divida|\n divida.Parcelas.each_with_index do |parcela, i|\n if params[:ckb_parcela][(i+1).to_s.inspect] == \"on\"\n parcela.update_attribute(:pago, true)\n else\n parcela.update_attribute(:pago, false) \n end\n end\n end\n end\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n flash[:notice] = 'Cliente was successfully updated.'\n format.html { redirect_to(@cliente) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cliente.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @section = Section.find(params[:id])\n @page = @section.page\n\n respond_to do |format|\n if @section.update_attributes(params[:section])\n format.html { redirect_to @page, :notice => 'Section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @section.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = current_site.pages.find_by_permalink(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to quick_page_path(@page), notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n @pagenate = Pagenate.find(params[:id])\n\n respond_to do |format|\n if @pagenate.update_attributes(params[:pagenate])\n format.html { redirect_to @pagenate, notice: 'Pagenate was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pagenate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n format.all { render_501 }\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to all_pages_path(:magazine_id=>@page.magazine_id), notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.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 update\n respond_to do |format|\n if @formaspagamento.update(formaspagamento_params)\n format.html { redirect_to formaspagamentos_url, notice: 'Forma de Pagamento editada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @formaspagamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n if @os_tarefa.update(os_tarefa_params)\n #se as situacao da tarefa nao for aceita, altera a ordem_servico_pagamento para null\n if(@os_tarefa.situacao!=OsTarefa.situacoes[0] && @os_tarefa.situacao!=OsTarefa.situacoes[1])\n\n @os_tarefa.ordem_servico_pagamento=nil\n @os_tarefa.save\n end\n\n if @os_tarefa.ordem_servico.id!=nil\n format.html { redirect_to \"/ordem_servicos/\"+@os_tarefa.ordem_servico.id.to_s, notice: 'A Tarefa foi atualizado(a)' }\n format.json { head :no_content }\n else\n format.html { redirect_to @os_tarefa, notice: 'A Tarefa foi atualizado(a)' }\n format.json { render :show, status: :ok, location: @os_tarefa }\n end\n else\n format.html { render :edit }\n format.json { render json: @os_tarefa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pro_farm_update\n respond_to do |format|\n activo = params[:pro_far][:activo_produc]\n farmacia_id = session[:farmacia_id]\n id = params[:id]\n ProFar.where(producto_id: id, farmacium_id:farmacia_id).update_all(activo_produc: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def edit\n @page = Page.find(params[:id])\n\n respond_to do |format|\n format.json {render json: @page}\n format.xml {render xml: @page}\n end\n end",
"def update\n respond_to do |format|\n if @apolice.update(apolice_params)\n\n if @apolice.page == \"aditivo\"\n format.html { redirect_to aditivos_path, notice: 'Registro alterado com sucesso.' }\n format.json { render :show, status: :ok, location: @apolice } \n else\n format.html { redirect_to @apolice, notice: 'Registro alterado com sucesso.' }\n format.json { render :show, status: :ok, location: @apolice } \n end\n else\n\n if @apolice.page == \"aditivo\"\n format.html { render :edit }\n format.json { render json: @apolice.errors, status: :unprocessable_entity } \n else\n format.html { render :edit }\n format.json { render json: @apolice.errors, status: :unprocessable_entity }\n end \n end\n end\n end",
"def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n # format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.html { redirect_to action: \"edit\", id: params[:id], notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @status_ref_pago_insc = StatusRefPagoInsc.find(params[:id])\n\n respond_to do |format|\n if @status_ref_pago_insc.update_attributes(params[:status_ref_pago_insc])\n format.html { redirect_to @status_ref_pago_insc, notice: 'Status ref pago insc was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @status_ref_pago_insc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pagina_principal.update(pagina_principal_params)\n format.html { redirect_to @pagina_principal, notice: 'Pagina principal was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagina_principal }\n else\n format.html { render :edit }\n format.json { render json: @pagina_principal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n if @page.update_attributes(params[:page])\n respond_to do |format|\n format.json {render json: @page, status: :created }\n format.xml {render xml: @page, status: :created}\n end\n \n else\n respond_to do |format|\n format.json {render json: @page.errors, status: :unprocessable_entity}\n format.xml {render xml: @page.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n @album = Album.find(params[:album_id])\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n \t@goto_page = @photo.pageForUpdate(:id, 5)\n \tif @goto_page < 1\n \t\t@goto_page = 1\n \tend\n format.html { redirect_to(album_photos_url(@album, :page => @goto_page), :notice => 'Photo was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\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 actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end",
"def update\n if page_params[:body]\n @page.versions << Version.new(body: page_params[:body], title: page_params[:title]).save\n page_params.delete :body\n end\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to controller: \"pages\", action: \"show\", slug: @page[:page_slug], notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @recurso = Recurso.find(params[:id])\n\n respond_to do |format|\n if @recurso.update_attributes(params[:recurso])\n format.html { redirect_to @recurso, notice: 'O recurso de auto de infração foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recurso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @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\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 @document_page = DocumentPage.find(params[:id])\n\n respond_to do |format|\n if @document_page.update_attributes(params[:document_page])\n format.html { redirect_to @document_page, notice: 'Document page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @page.update_attributes(params[:page])\n respond_to do |format|\n format.json { render :json => @page }\n format.xml { render :xml => @page }\n end\n else\n respond_to do |format|\n format.json { raise Palani::Api::InvalidUpdateOfRecordJSONException }\n format.xml { raise Palani::Api::InvalidUpdateOfRecordXMLException }\n end\n end\n end",
"def update\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n if @ventas_presupuesto.update_attributes(params[:ventas_presupuesto])\n format.html { redirect_to @ventas_presupuesto, notice: 'Presupuesto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ventas_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @condicao_pagamento.update(condicao_pagamento_params)\n format.html { redirect_to @condicao_pagamento, notice: 'Condicao pagamento was successfully updated.' }\n format.json { render :show, status: :ok, location: @condicao_pagamento }\n else\n format.html { render :edit }\n format.json { render json: @condicao_pagamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n expire_page :action => :show\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n invoice_params[:data_prevenda] = Date.today\n respond_to do |format|\n puts 'esse é o id da venda ' + @invoice.id.to_s + invoice_params[:data_prevenda].to_s\n if @invoice.update(invoice_params)\n #ataualiza a data de prevenda em cada item lançado para o relatorio de analise geral\n #Item.where(invoice_id: @invoice.id).update_all(data_prevenda: invoice_params[:data_prevenda])\n format.html { redirect_to @invoice, notice: 'atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @invoice }\n sweetalert_success('Dados atualizados com sucesso!', 'Sucesso!', useRejections: false)\n else\n format.html { render :edit }\n format.json { render json: @invoice.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6360598",
"0.6360598",
"0.6313854",
"0.62881744",
"0.6281439",
"0.6243139",
"0.6230904",
"0.62261665",
"0.614852",
"0.61258966",
"0.6113327",
"0.6107538",
"0.6095736",
"0.6088949",
"0.60781384",
"0.6058332",
"0.6048065",
"0.6040405",
"0.6036944",
"0.602342",
"0.6008012",
"0.5973697",
"0.59573716",
"0.59409463",
"0.5928641",
"0.5918344",
"0.5912482",
"0.59076077",
"0.5902335",
"0.5887615",
"0.58864594",
"0.5881632",
"0.5858306",
"0.58494496",
"0.58482826",
"0.5843908",
"0.5837861",
"0.58378327",
"0.58303994",
"0.5816066",
"0.58127004",
"0.58017635",
"0.5799731",
"0.579566",
"0.57919306",
"0.57913274",
"0.57913274",
"0.5780337",
"0.5769808",
"0.57498634",
"0.57416886",
"0.5734587",
"0.571222",
"0.5707263",
"0.5707263",
"0.57071763",
"0.5701845",
"0.56991476",
"0.56989247",
"0.56987727",
"0.5695517",
"0.5695517",
"0.5691542",
"0.5688347",
"0.5685753",
"0.56736803",
"0.56725484",
"0.56725484",
"0.5672448",
"0.5668963",
"0.56510633",
"0.5651053",
"0.56449556",
"0.5643129",
"0.56402415",
"0.56359637",
"0.56267166",
"0.5625241",
"0.5619359",
"0.56182206",
"0.56145674",
"0.5607833",
"0.5598337",
"0.5597883",
"0.55940956",
"0.55870193",
"0.5584879",
"0.55791944",
"0.5576668",
"0.5571584",
"0.5570589",
"0.5570227",
"0.55690044",
"0.5565049",
"0.5548385",
"0.55386657",
"0.55357784",
"0.55339044",
"0.5521231",
"0.55199564"
] | 0.70420885 | 0 |
DELETE /for_pags/1 DELETE /for_pags/1.json | def destroy
@for_pag.destroy
respond_to do |format|
format.html { redirect_to for_pags_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @mod_pag = ModPag.find(params[:id])\n @mod_pag.destroy\n\n respond_to do |format|\n format.html { redirect_to mod_pags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagamento = Pagamento.find(params[:id])\n @pagamento.destroy\n\n respond_to do |format|\n format.html { redirect_to pagamentos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n @pagamento = Pagamento.find(params[:id])\n os = @pagamento.os\n @pagamento.destroy\n\n respond_to do |format|\n #format.html { redirect_to pagamentos_url }\n format.html { redirect_to os }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pago.destroy\n respond_to do |format|\n format.html { redirect_to pagos_url, notice: 'Pago eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pago.destroy\n respond_to do |format|\n format.html { redirect_to pagos_url, notice: 'Se ha eliminado exitosamente el pago.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mini_pago = MiniPago.find(params[:id])\n @mini_pago.destroy\n\n respond_to do |format|\n format.html { redirect_to mini_pagos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagamento = Pagamento.find(params[:id])\n @pagamento.destroy\n\n respond_to do |format|\n format.html { redirect_to @pagamento.serata }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pago = Pago.find(params[:id])\n @pago.destroy\n \n respond_to do |format|\n format.html { redirect_to(pagos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pagenate = Pagenate.find(params[:id])\n @pagenate.destroy\n\n respond_to do |format|\n format.html { redirect_to pagenates_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @medio_pago = MedioPago.find(params[:id])\n @medio_pago.destroy\n\n respond_to do |format|\n format.html { redirect_to medio_pagos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pago = Pago.find(params[:id])\n @pago.destroy\n\n respond_to do |format|\n format.html { redirect_to(pagos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pago.destroy\n respond_to do |format|\n format.html { redirect_to pagos_url, notice: 'Pago was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pago.destroy\n respond_to do |format|\n format.html { redirect_to pagos_url, notice: 'Pago was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagto_taxa.destroy\n respond_to do |format|\n format.html { redirect_to pagto_taxas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagos_servicio.destroy\n respond_to do |format|\n format.html { redirect_to pagos_servicios_url, notice: 'Pagos servicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @page_fetch = PageFetch.find(params[:id])\n @page_fetch.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_fetches_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prepagada = Prepagada.find(params[:id])\n @prepagada.destroy\n\n respond_to do |format|\n format.html { redirect_to prepagadas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n @pago.destroy\n\n respond_to do |format|\n format.html { redirect_to [@cliente, @pago] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagos_detalhe = PagosDetalhe.find(params[:id])\n @pagos_detalhe.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/pagos/#{@pagos_detalhe.pago_id}\" }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pagina = Pagina.find(params[:id])\n @pagina.destroy\n\n respond_to do |format|\n format.html { redirect_to(paginas_url) }\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 @pago_alquiler.destroy\n respond_to do |format|\n format.html { redirect_to pago_alquilers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to apuesta_details_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nested_page = Nested::Page.find(params[:id])\n @nested_page.destroy\n\n respond_to do |format|\n format.html { redirect_to nested_pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pageview.destroy\n respond_to do |format|\n format.html { redirect_to pageviews_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_pago = TipoPago.find(params[:id])\n @tipo_pago.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_pagos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagina.destroy\n respond_to do |format|\n format.html { redirect_to paginas_url, notice: 'Pagina was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mypage = Mypage.find(params[:id])\n @mypage.destroy\n\n respond_to do |format|\n format.html { redirect_to mypages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagamento.destroy\n respond_to do |format|\n format.html { redirect_to pagamentos_url, notice: 'Pagamento was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gran_unidad.destroy\n respond_to do |format|\n format.html { redirect_to gran_unidad_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagecount.destroy\n respond_to do |format|\n format.html { redirect_to pagecounts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unlimited.destroy\n respond_to do |format|\n format.html { redirect_to unlimiteds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagare = Pagare.find(params[:id])\n @pagare.destroy\n\n respond_to do |format|\n format.html { redirect_to(pagares_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @uneautrepage.destroy\n respond_to do |format|\n format.html { redirect_to uneautrepages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :ok }\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 @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n \n end",
"def destroy\n @servicio = Servicio.find(params[:id])\n @servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to servicios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @formasdepago.destroy\n respond_to do |format|\n format.html { redirect_to formasdepagos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagamento = Pagamento.find(params[:id])\n @pagamento.destroy\n\n respond_to do |format|\n format.html { redirect_to(pagamentos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pagamento.destroy\n respond_to do |format|\n format.html { redirect_to cliente_venda_path(@cliente, @venda), notice: 'O pagamento foi excluído!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datosgenerale.destroy\n respond_to do |format|\n format.html { redirect_to datosgenerales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @giang_vien = GiangVien.find(params[:id])\n @giang_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.json { render :json => @page }\n format.xml { render :xml => @page }\n end\n end",
"def destroy\n @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to recursos_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\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 @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oasis_page = OasisPage.find(params[:id])\n @oasis_page.destroy\n\n respond_to do |format|\n format.html { redirect_to oasis_pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to admin_pages_url, notice: 'Страница успешно удалена!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @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 @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url, :notice => \"Successfully deleted page. #{undo_link}\" }\n format.json { head :no_content }\n end\n end",
"def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end",
"def destroy\n Generator.where(id: params[:id] ).first.destroy\n respond_to do |format|\n format.html { redirect_to generators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @pagamento_aceito.destroy\n respond_to do |format|\n format.html { redirect_to pagamento_aceitos_url, notice: 'Pagamento aceito was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admined_page1 = AdminedPage1.find(params[:id])\n @admined_page1.destroy\n\n respond_to do |format|\n format.html { redirect_to admined_page1s_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @isfit_page = IsfitPage.find(params[:id])\n @isfit_page.destroy\n\n respond_to do |format|\n format.html { redirect_to isfit_pages_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @minha_pagina.destroy\n respond_to do |format|\n format.html { redirect_to minha_paginas_url, notice: 'Minha pagina was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apologetic.destroy\n respond_to do |format|\n format.html { redirect_to apologetics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pago_factura.destroy\n respond_to do |format|\n format.html { redirect_to pago_facturas_url, notice: 'Pago factura eliminado con éxito.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice.destroy\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_documento = TipoDocumento.find(params[:id])\n @tipo_documento.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_documentos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @peso = Peso.find(params[:id])\n @peso.destroy\n\n respond_to do |format|\n format.html { redirect_to pesos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pagina.destroy\n respond_to do |format|\n format.html { redirect_to produto_paginas_path(@produto), notice: 'Pagina was successfully destroyed.' }\n format.json { head :no_content }\n end\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 @api.destroy\n respond_to do |format|\n format.html { redirect_to apis_url }\n format.json { head :no_content }\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"
] | [
"0.7178697",
"0.71705705",
"0.71151286",
"0.71050733",
"0.7099136",
"0.709174",
"0.7088539",
"0.70454866",
"0.7044028",
"0.7041144",
"0.7008599",
"0.70002836",
"0.69995433",
"0.69995433",
"0.69390345",
"0.69240886",
"0.69235593",
"0.69188386",
"0.6913366",
"0.6911593",
"0.69009763",
"0.68921083",
"0.6879605",
"0.68775314",
"0.6861237",
"0.6861237",
"0.6861237",
"0.6861237",
"0.68606955",
"0.6859618",
"0.6848155",
"0.6834859",
"0.6832524",
"0.682197",
"0.68209726",
"0.681694",
"0.68155617",
"0.68106425",
"0.68106425",
"0.68106425",
"0.68106425",
"0.6806201",
"0.6804283",
"0.6787923",
"0.67867756",
"0.67839515",
"0.67839515",
"0.67839515",
"0.67839515",
"0.67839515",
"0.67839515",
"0.67839515",
"0.67839515",
"0.67796177",
"0.67789465",
"0.67694604",
"0.6767744",
"0.6764042",
"0.67516905",
"0.67516905",
"0.67516905",
"0.6750629",
"0.67401135",
"0.67392987",
"0.6735294",
"0.6727947",
"0.67261547",
"0.67234474",
"0.6711338",
"0.67045426",
"0.6698437",
"0.6693866",
"0.66902095",
"0.6688983",
"0.66811126",
"0.6677706",
"0.6677706",
"0.6674333",
"0.66689205",
"0.66664195",
"0.6660802",
"0.6660731",
"0.66587806",
"0.66561204",
"0.6655213",
"0.6654578",
"0.66535187",
"0.66532093",
"0.664387",
"0.66422904",
"0.66410345",
"0.66378355",
"0.6633613",
"0.6632906",
"0.6631702",
"0.66302556",
"0.66264737",
"0.66230965",
"0.6621473",
"0.6618167"
] | 0.76909953 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_for_pag
@for_pag = ForPag.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup_handler\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def before_dispatch(env); end",
"def process_action(...)\n send_action(...)\n end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def action\n end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def config(action, *args); end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def setup\n # override this if needed\n end",
"def matt_custom_action_begin(label); end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def setup_signals; end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def lookup_action; end",
"def around_hooks; end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def action_target()\n \n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def call\n setup_context\n super\n end",
"def _handle_action_missing(*args); end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def duas1(action)\n action.call\n action.call\nend"
] | [
"0.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.5328757",
"0.5310255",
"0.5300339",
"0.5298796",
"0.5295774",
"0.5256034",
"0.5243039",
"0.5236007",
"0.5235239",
"0.5235239",
"0.5235239",
"0.5235239",
"0.5235239",
"0.52321917",
"0.5227032",
"0.52216744",
"0.5216349",
"0.52161187",
"0.5210265",
"0.5207244",
"0.5177388",
"0.5177142",
"0.51747334",
"0.516293",
"0.51629275",
"0.5155534",
"0.51540613",
"0.515197",
"0.5151636",
"0.5145279",
"0.51380795",
"0.5135777",
"0.5117378",
"0.5115066",
"0.5115066",
"0.5110235",
"0.5106418",
"0.50917816",
"0.50909185",
"0.50855017",
"0.5082105",
"0.506359",
"0.5055345",
"0.50546116",
"0.50523037",
"0.50523037",
"0.50327307",
"0.5024364",
"0.5021113",
"0.50174654",
"0.50163317",
"0.5000553",
"0.50002855",
"0.49991882",
"0.49905527",
"0.49905527",
"0.49849054",
"0.4982546",
"0.4980941",
"0.4979153",
"0.49693102",
"0.4967172",
"0.49594432",
"0.49564302",
"0.49552485",
"0.49533385",
"0.49506924",
"0.49452737",
"0.49442786",
"0.49347955",
"0.49341312",
"0.49295264",
"0.49261844",
"0.4925649",
"0.49251428",
"0.4920729",
"0.49177617",
"0.4916373",
"0.49158472",
"0.4915794",
"0.49156648"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def for_pag_params
params.require(:for_pag).permit(:description, :days, :active)
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 valid_params_request?; 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 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 safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\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 valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\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 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 url_params\n params[:url].permit(:full)\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\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.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"0.62902015",
"0.62826055",
"0.6241474",
"0.6239528",
"0.62192595",
"0.6213959",
"0.6209968",
"0.6195236",
"0.6178428",
"0.6174288",
"0.61730385",
"0.6162674",
"0.615271",
"0.6151781",
"0.61483663",
"0.6122072",
"0.6118153",
"0.61082",
"0.61056745",
"0.6092642",
"0.60814065",
"0.60712725",
"0.6063699",
"0.60218817",
"0.60172415",
"0.6014784",
"0.60113716",
"0.6007368",
"0.6007368",
"0.60013884",
"0.6000211",
"0.5997662",
"0.5992346",
"0.59923387",
"0.59920985",
"0.5979802",
"0.5966599",
"0.59599686",
"0.5958859",
"0.5958176",
"0.59577733",
"0.5953665",
"0.59535724",
"0.5944413",
"0.5939227",
"0.59389156",
"0.59389156",
"0.59350467",
"0.5930765",
"0.5926072",
"0.5925355",
"0.59176385",
"0.5910344",
"0.59092146",
"0.5908764",
"0.5904986",
"0.5897739",
"0.58974844",
"0.58968824",
"0.5894499",
"0.5894097",
"0.58928955",
"0.58877337",
"0.588388",
"0.5880237",
"0.5873962",
"0.5869052",
"0.58690286",
"0.58670396",
"0.5866859",
"0.5866724",
"0.58638793",
"0.58630764",
"0.5862874",
"0.58606905",
"0.58596873",
"0.5854749",
"0.58539575",
"0.58516955",
"0.5849963"
] | 0.0 | -1 |
replicate_match(strs, replication_str) If any of the simple Strings in the Array is found in the current string (possibly in multiple places and possibly overlapping), the String is updated with the matching string in the corresponding location. may also be a single String object. For example, 'abdcbcbcb'.replicate_match(['cbc', 'ab'], '') updates the '' to 'abcbcbc'. | def replicate_match(strs, replication_str)
strs = [ strs ] unless (strs.is_a?(Array))
strs.each do |str|
str_len = str.length
next if (length < str_len)
offset, last_offset = 0, length - str_len
while (offset <= last_offset)
if str_pos = index(str, offset)
replication_str[str_pos, str_len] = str
offset = str_pos
end
offset += 1
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replicate_match(words)\n @text_lines.each_with_index do |line, i|\n line.replicate_match(words, @sltn_lines[i])\n end\n end",
"def repeated_sub_pattern(str)\n smallest_str = smallest_str(str)\n multiplied = str.length / smallest_str\n str[0...smallest_str] * multiplied == str\nend",
"def replace_subseq(arr, subseq, replacement)\n new = []\n matched = []\n i = 0\n arr.each do |elem|\n if elem != subseq[i]\n new.push(*matched)\n matched = []\n i = 0\n new << elem\n next\n end\n\n if i == subseq.length - 1\n matched = []\n i = 0\n new.push(*replacement)\n else\n matched << elem\n i += 1\n end\n end\n new.push(*matched)\n new\n end",
"def in_all_strings?(long_strings, substring)\n new_arr = long_strings.select {|s| s.include?(substring)}\n return new_arr == long_strings\nend",
"def permut_sub_strings(b, s)\n hash = {}\n permutations(s).each do |str|\n hash[str] = true\n end\n for i in 0..b.size-s.size\n if (hash.key?(b[i..i+s.size]))\n return true\n end\n end\nend",
"def replace_array(match_array, replace_arry)\n array = []\n match_array\n self.each_index{|i|\n if self[i].eql?(match_array.first) and self.slice(i, match_array.count).eql?(match_array)\n array.concat self.first(i)\n array.concat replace_arry\n array.concat self.drop(i + match_array.count)\n break\n end\n }\n array = self if array.empty?\n array\n end",
"def isRepeated? subString, str\n\n if str.length % subString.length != 0 then return false end\n\n n = subString.length\n max_repetitions = str.length / n\n (0...max_repetitions).each do |i|\n if str[n*i, n] != subString then return false end\n end\n return true\nend",
"def repeated_substring_pattern(str)\n # N^2 solution\n substr_pattern = \"\"\n str.length.times do |x|\n split_on_this = str[0..x]\n arr = str.split(split_on_this)\n if arr.all? {|x| x == arr[0]} && split_on_this != str\n substr_pattern = split_on_this\n end\n end\n substr_pattern != \"\" ? \"TRUE\" : \"FALSE\"\nend",
"def subsequence\n setup_basecase\n\n ([email protected]).each do |row|\n (1...@matrix[0].length).each do |col|\n substring_one = @str_one[0...row]\n substring_two = @str_two[0...col]\n if substring_one[-1] == substring_two[-1]\n @matrix[row][col] = @matrix[row - 1][col - 1] + substring_one[-1]\n else\n if @matrix[row - 1][col].length > @matrix[row][col - 1].length\n @matrix[row][col] = @matrix[row - 1][col]\n else\n @matrix[row][col] = @matrix[row][col - 1]\n end\n end\n end\n end\n\n @matrix[-1][-1]\n end",
"def repeated_substring_pattern(s)\n return false if !s\n (s + s)[1...-1].include?(s)\nend",
"def repeated_substring(str)\n 0.upto(str.size / 2) do |end_idx|\n slice = str[0..end_idx]\n repeat_nums = str.size / slice.size\n return true if slice * repeat_nums == str\n end\n false\nend",
"def wc_with_placeholder_equals(str, pat, repl_chars)\n return false if pat.size != str.size\n\n fixed_pat = wc_replace(pat, repl_chars)\n wc_equals(str, fixed_pat)\nend",
"def repeat_matcher *pattern\n submatcher = MatchWrapper.new(pattern_matcher(*pattern), SplatExpression)\n\n lambda do |string, index = 0, counts:|\n result = []\n\n while nonempty_match?(found = submatcher.call(string, index, counts: counts))\n index += found.size\n result.push(*found)\n end\n\n result unless result.empty?\n end\n end",
"def one_edit_replace(s1, s2)\n found_difference = false \n\n s1.length.times do |i|\n if s1[i] != s2[i]\n if found_difference\n return false\n end\n\n found_difference = true\n end\n end\n\n return true\nend",
"def replace_str(str, substr, replacement)\n output = \"\"\n i = 0\n substrlength = substr.length\n while i < str.length\n if str[i, substrlength] == substr\n output << replacement\n i += substrlength\n else\n output += str[i]\n i += 1\n end\n end\n return output\nend",
"def substrings_single_shot(str)\n (0..str.length - 1).each_with_object([]) do |idx1, arr|\n (idx1..str.length - 1).each do |idx2|\n arr << str[idx1..idx2]\n end\n end\nend",
"def replaceAll(oldStr,newStr)\n while @container.index(oldStr)!=nil\n repStr = String.new(oldStr)\n if(@container.index(oldStr)==0)\n str1=\"\"\n else\n str1=@container[[email protected](oldStr)-1]\n end\n \n str2=@container[@container.index(oldStr)[email protected]]\n \n if(newStr!=\"\")\n repStr.replace(newStr)\n @container=str1+repStr+str2\n else\n @container=str1+str2\n end\n end\n return @container \n end",
"def unrepeat\n searched = ''\n unsearched = dup\n dupe = match(/(.+)\\1+/)\n # Dupe[0] = pattern found, [1] group found\n\n until unsearched.empty?\n return searched + unsearched unless dupe\n\n location = unsearched.index(dupe[0])\n searched += unsearched[0..location - 1] if location > 0\n searched += if dupe[0].squeeze.length > 1 && dupe[0].has_letters? # &&\n # ([' ', ',', '.'].include?(dupe[0][0]) || dupe[1].length > 8)\n dupe[1]\n else\n dupe[0]\n end\n unsearched = unsearched[location + dupe[0].length..]\n dupe = unsearched.match(/(.+)\\1+/)\n end\n searched\n end",
"def repeater(str)\n str.gsub(/(.)/, '\\1\\1')\nend",
"def repeater(str)\n str.gsub(/(.)/, '\\1\\1')\nend",
"def substrings_at_start(string)\n string.size.times.with_object([]) { |idx, arr| arr << string.chars.take(idx + 1).join}\nend",
"def naive_search(str, match_str)\n count = 0\n for i in 0...str.length do\n\n for j in 0...match_str.length do\n \n if(match_str[j] != str[i+j]) \n break\n end\n \n if(j == match_str.length - 1)\n count += 1\n end\n\n end\n\n end\n\n return count;\nend",
"def repeater(str)\n str.chars.zip(str.chars).join\nend",
"def string_matching(words)\n result_words = []\n\n words.each_with_index do |possible_substring, index|\n (0..words.size - 1).each do |index_w|\n next if index_w == index || words[index_w].size < possible_substring.size\n \n result_words << possible_substring if words[index_w].index(possible_substring)\n end\n end\n \n result_words.uniq\nend",
"def solution(a)\n str = ''\n a.each do |item|\n i = 0\n while i < item.length\n matched = 0\n \n a.each do |string|\n matched += 1 if string.include?(str)\n end\n \n if matched == a.length && i > 0\n str += item[i-1]\n else\n break\n end\n i += 1\n end\n end\n return str\nend",
"def matchingStrings(strings, queries)\n counting_hash = {}\n counting_hash.default = 0\n\n # For Cache\n strings.each do |s|\n counting_hash[s] ? counting_hash[s] += 1 : counting_hash[s] = 1\n end\n\n res = []\n queries.each do |q|\n res << counting_hash[q]\n end\n res\nend",
"def encode_repeating(my_string)\n return nil if my_string.nil?\n return my_string if my_string.length <= 1\n\n i = 0\n j = 0\n k = 0\n while j <= i && i < my_string.length\n k = i\n if my_string[i] != my_string[i + 1]\n my_string[j] = my_string[i]\n\n else\n counter = 1\n while my_string[i] == my_string[i + 1]\n i += 1\n counter += 1\n end\n\n if counter == 2\n my_string[j] = my_string[k]\n my_string[j + 1] = my_string[k]\n else\n my_string[j] = my_string[k]\n my_string[j + 1] = counter.to_s\n end\n j += 1\n end\n j += 1\n i += 1\n end\n\n my_string[j...my_string.length] = \"\"\n return my_string\nend",
"def substrings(string)\n\nend",
"def substrings(string)\r\n \r\nend",
"def no_repeat?(string)\n n = string.length\n for i in 0..n-1\n for j in 0..n-1\n if (i != j) && (string[i] == string[j]) then\n return false\n end\n end\n end\n return true\nend",
"def add_rutabaga_to_string_and_array(str, ary)\n str << \"rutabaga\"\n ary << \"rutabaga\"\nend",
"def reply str, prefix = true\n if str.kind_of? Array\n str.each do |this_str|\n send_reply this_str, prefix\n end\n else\n send_reply str, prefix\n end\n end",
"def common_substrings(string_one, string_two)\n if string_one.length <= string_two.length\n longer_string = string_two\n shorter_string = string_one\n else\n longer_string = string_one\n shorter_string = string_two\n end\n\n\n length = shorter_string.length\n until length == 0\n shorter_string_subs = []\n (0..shorter_string.length - length).each do |start|\n sub = shorter_string[start...start + length]\n return sub if longer_string.include?(sub)\n end\n\n length -= 1\n end\n return \"\"\nend",
"def repeating_letters?(str)\n index = 0\nnew_str = str.split(\"\").sort.join.downcase\n\nwhile index < str.length\n if new_str[index] == new_str[index + 1]\n return true\n end\n index += 1\nend\nfalse\n\nend",
"def match(array)\n array.select {|word| word.chars.sort.join == self.word.chars.sort.join}\n \n\nend",
"def subsequence(str_one = @str_one, str_two = @str_two)\n #If either strings are zero then the subsequence is 0\n if str_one.length == 0 || str_two.length == 0\n 0\n\n #If its already been memoized, don't search again for it!\n\n elsif @matrix[str_one.length - 1][str_two.length - 1]\n return @matrix[str_one.length - 1][str_two.length - 1]\n\n #If the last letters are the same, then the subsequence is\n # equal to 1 + subsequnce minus each of the last letters\n\n elsif str_one[-1] == str_two[-1]\n @matrix[str_one.length - 1][str_two.length - 1] =\n 1 + subsequence(str_one[0...-1], str_two[0...-1])\n\n #If the last letters are NOT the same, then s(\"ab\", \"bc\") =\n # [s(\"ab\", \"b\"), s(\"a\", \"bc\")] because\n # we are decrementing each by one and will eventually find all\n # permutations of choosing letters(i.e. eventually if there are common letters\n #then our previous recursive case will find it.)\n\n\n else\n @matrix[str_one.length - 1][str_two.length - 1] =\n [subsequence(str_one, str_two[0...-1]),\n subsequence(str_one[0...-1], str_two)\n ].max\n end\n end",
"def repeater(string)\n string.chars.zip(string.chars).join\nend",
"def multireg(regpexp, str)\n result = []\n while regpexp.match(str)\n result.push regpexp.match(str)\n str = regpexp.match(str).post_match\n end\n result\n end",
"def encode_repeating(my_string)\n return my_string if !my_string || my_string.length < 2\n current, check_next = 0, 1\n until current == my_string.length\n check_next += 1 while my_string[current] == my_string[check_next]\n repeats = check_next - current\n if repeats > 2\n my_string[current + 1] = repeats.to_s\n check_next -= my_string.slice!((current + repeats.to_s.length + 1)...check_next).length\n end\n current = check_next\n end\n return my_string\nend",
"def encode_repeating(my_string)\r\n return my_string if my_string.length < 3\r\n\r\n engaged = false\r\n counter = 3\r\n n = 0\r\n\r\n while n + 2 < my_string.length\r\n if (engaged && my_string[n] == my_string[n+2]) || (my_string[n] == my_string[n+1] && my_string[n] == my_string[n+2])\r\n engaged = true\r\n my_string[n+1..n+2] = \"#{counter}\" #THIS LINE!\r\n counter += 1\r\n else\r\n engaged = false\r\n counter = 3\r\n n += 1\r\n end\r\n end\r\n\r\n return my_string\r\nend",
"def substring_test(str1, str2)\n #basecase\n if str1.length <= 1 || str2.length <= 1\n return false #if either one of the strings starting or remaining are length one\n elsif str1.downcase.include?(str2[0..1].downcase)\n return true # returns true if the first two letters of modified str2 are in included in the str1\n else #strip away the first char and repeat\n substring_test(str1, str2[1..-1])\n end\nend",
"def globs_match_strings_anywhere? globs, strings\n while (!globs.empty? && !strings.empty? && \n globs.length <= strings.length)\n if globs_match_strings? globs, strings\n return true\n end\n strings.shift\n end\n\n return false\n end",
"def uniq_subs(word)\n subs = {}\n word.length.times do |i|\n (i...word.length).each do |j|\n if !subs[str[i..j]]\n subs[str[i..j]] = str[i..j]\n end\n end\n end\nend",
"def rsub(pattern, replacement)\n if i = rindex(pattern) # rubocop:disable Lint/AssignmentInCondition\n s = @string.dup\n s[i] = replacement\n self.class.new s\n else\n self\n end\n end",
"def repeater(string)\n doubled = ''\n characters = string.chars\n size = characters.size\n counter = 0\n\n while counter < size\n doubled = doubled + string[counter] + string[counter]\n\n counter += 1\n end\n\n doubled\nend",
"def add_s(array)\n array.map do |word|\n if word == word\n word \n else \n word + \"s\"\n end\n end \nend",
"def encode_repeating(my_string)\n\n return nil if my_string.nil?\n\n start = 0\n\n until my_string[start].nil?\n\n count = 1\n\n while my_string[start + count] == my_string[start]\n count += 1\n end\n\n if count < 3\n start += count\n else\n my_string[start + 1] = count.to_s\n my_string.slice!(start + 2, count - 2)\n start += 2\n end\n\n end\n\n return my_string\n\nend",
"def longest_repeated_substring(string)\n\n size = string.length\n\n # put every possible suffix into an array\n suffixes = Array.new(size)\n size.times do |i|\n suffixes[i] = string.slice(i, size)\n end\n\n # sort the array of suffixes, so common substrings (i.e., prefixes\n # of suffixes) will be found in neighboring elements of the array\n suffixes.sort!\n\n best = \"\"\n at_least_size = 1 # the size to meet or exceed to be the new best\n distance = nil\n neighbors_to_check = 1\n\n # compare pairs of consecutive suffixes and see how much initial\n # commonality there is\n # (size - 1).times do |i|\n (1...size).each do |i|\n # p [i, neighbors_to_check]\n s1 = suffixes[i]\n\n # generally we will only need to compare the ith item and the one\n # preceding it; however if we were in a position to reject a long\n # enough common substring due to overlap issues, then we may have\n # to compare an ith item with additional preceding items;\n # neighbors_to_check tracks how many neighbors we need to check\n neighbors_to_check.downto(1) do |neighbor|\n s2 = suffixes[i - neighbor]\n\n # make sure that these to suffixes further apart than the size\n # of the current best; we don't explicitly track the index of\n # these suffixes, but since all suffixes go to the end of the\n # initial string, the size can be used as a proxy\n distance = (s1.size - s2.size).abs\n if distance < at_least_size\n if s1.size >= at_least_size &&\n s2.size >= at_least_size &&\n s1.slice(0, at_least_size) == s2.slice(0, at_least_size)\n neighbors_to_check = max(neighbors_to_check, neighbor + 1)\n else\n neighbors_to_check = neighbor\n end\n next\n end\n\n # if neighboring suffixes don't at least match as far as the best,\n # no need to check more carefully\n unless s1.slice(0, at_least_size) == s2.slice(0, at_least_size)\n neighbors_to_check = neighbor\n next\n end\n\n # get the longest common prefix that's no larger than distance,\n # since at that point the substrings overlap\n best = longest_common_prefix(s1, s2, distance)\n at_least_size = best.size + 1\n if best.size == distance\n neighbors_to_check = max(neighbors_to_check, neighbor + 1)\n else\n neighbors_to_check = neighbor\n end\n end\n end\n\n best.strip\n end",
"def encode_repeating(my_string)\r\n i = 0\r\n j = 0\r\n letter = my_string[i]\r\n while i < my_string.length\r\n j += 1 while my_string[j + 1] == letter\r\n if j - i >= 2\r\n my_string[(i + 1)..j] = (j - i + 1).to_s\r\n end\r\n additional = 0\r\n additional = 1 if j > i\r\n i += 1 + additional\r\n j = i\r\n letter = my_string[i]\r\n end\r\n return my_string\r\nend",
"def shortest_common_supersequence(str1, str2)\n dp = Array.new(str1.size + 1){Array.new(str2.size + 1, 0)}\n# build the minimum length matrix for all sub-problems, 2D-dp means minimum length of the substring for str1's prefix of length L1 and str2's prefix of length L2\n# fill 1st row & col\n for i in 0...str2.size\n dp[0][i] = i\n end\n for i in 0...str1.size\n dp[i][0] = i\n end\n \n for i in 1..str1.size\n for j in 1..str2.size\n if str2[j - 1] == str1[i - 1]\n dp[i][j] = dp[i - 1][j - 1] + 1\n else\n dp[i][j] = [dp[i - 1][j], dp[i][j - 1]].min + 1\n end\n end\n end\n \n new_str = \"\"\n len_str1 = str1.size\n len_str2 = str2.size\n \n while len_str1 != 0 || len_str2 != 0\n if len_str1 == 0 && len_str2 != 0\n new_str << str2[len_str2 - 1]\n len_str2 -= 1\n end\n if len_str2 == 0 && len_str1 != 0\n new_str << str1[len_str1 - 1]\n len_str1 -= 1\n end\n \n if str1[len_str1 - 1] == str2[len_str2 - 1] && len_str1 != 0\n new_str << str1[len_str1 - 1]\n len_str1 -= 1\n len_str2 -= 1\n elsif dp[len_str1 - 1][len_str2] < dp[len_str1][len_str2 - 1] && len_str1 != 0\n new_str << str1[len_str1 - 1]\n len_str1 -= 1\n elsif len_str2 != 0\n new_str << str2[len_str2 - 1]\n len_str2 -= 1\n end\n end\n new_str\nend",
"def sockMerchant(n, ar)\n match_count = 0\n dup_arr = ar\n i = 0\n while i < dup_arr.length\n for j in i+1..dup_arr.length do\n if dup_arr[i] == dup_arr[j]\n match_count = match_count+1\n dup_arr.slice!(j)\n dup_arr.slice!(i)\n i = 0\n break\n end\n i = i+1 if j == dup_arr.length\n\n end\n end\n match_count\nend",
"def one_edit_replace(short, long)\n found_difference = false\n\n (0..short.length-1).each do |i|\n if short[i] != long[i]\n if found_difference\n return false\n break\n end\n\n found_difference = true\n end\n end\n\n true\nend",
"def string_dup\n <<-CODE\n t1 = stack_pop();\n stack_push(string_dup(state, t1));\n CODE\n end",
"def repeat_str n, s\n s * n\nend",
"def str_replace(orig, rep, with)\n s = orig\n while s.include?(rep)\n s.sub! rep, with\n end\n orig\n end",
"def in_all_strings?(long_strings, substring)\n long_strings.each do |string|\n return false unless string.include?(substring)\n end\n\n return true\nend",
"def permutations_with_dups(str)\n permutations(str).uniq\nend",
"def format!\n substitutions.each { |s| sub_string.gsub!(match(s), replace(s)) }\n sub_string\n end",
"def longest_prefix(strings)\n initial_match = ''\n length = strings[0].length\n length.times do |letter|\n if strings[0][letter] == strings[1][letter]\n initial_match.concat(strings[0][letter])\n end\n end\n \n strings.each do |word|\n match = ''\n initial_match.length.times do |letter|\n if initial_match[letter] == word[letter]\n match.concat(word[letter])\n end\n end\n initial_match = match\n end\n \n return initial_match\nend",
"def repeatedSubstring(n, m)\n for i in 1..(m.length * 2)\n n = n * i\n if n.include?(m)\n return i\n end\n end\n -1\nend",
"def substrings(string)\r\n new_array = []\r\n string.size.times do |index|\r\n new_array << leading_substrings(string[index..string.size])\r\n end\r\n new_array.flatten\r\nend",
"def substrings_at_start(string)\n string.size.times.with_object([]) { |idx, arr| arr << string[0..idx] }\nend",
"def uniq_subs(string)\n subs = []\n prev_subs = {}\n\n (0...string.length).each do |first|\n (first...string.length).each do |last|\n sub = string[first..last]\n unless prev_subs[sub]\n subs << sub\n prev_subs[sub] = true\n end\n end\n end\n\n subs\nend",
"def rampant_repeats(str, hash)\n\n new_str = \"\"\n\n str.each_char { |char| new_str += char * ( hash[char] || 1) }\n\n new_str\n\nend",
"def repeat_str (n, s)\n s * n\nend",
"def repeat_str (n, s)\n s * n\nend",
"def repeat_copy(str, n = 1)\n return str * n\nend",
"def rampant_repeats(str, hash)\n str.chars.map { |c| hash.key?(c) ? c * hash[c] : c }.join\nend",
"def matches(smarts_or_string, uniq=true)\n each_match(smarts_or_string, uniq).map.to_a\n end",
"def uniq_subs(str)\n subs = Set.new\n str.length.times do |i|\n (i..str.length-1).each do |j|\n subs.add(str[i..j])\n end\n end\n subs\nend",
"def repeat_string(str, i)\n return \"\" if (i <= 0)\n return str if (i == 1)\n d = repeat_string(str, i >> 1)\n d += d\n d += str if (i & 1)\n return d\n end",
"def consonant_rep(array_of_char)\n array_of_char.map! do | char |\n consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']\n if consonants.include? char\n consonant_index = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', 'b']\n i = consonant_index.index(char) + 1\n char = consonant_index[i] \n else char = char\n end\n end\n array_of_char\nend",
"def populate_suffix_trie_from(string)\n for i in 0..(string.length - 1)\n self.insert_substring_starting_at(i, string)\n end\n end",
"def findMatch str, subStr\n n = 0\n (0..(str.length - subStr.length)).each do |i|\n if subStr == str[i, subStr.length] then n += 1 end\n end\n return n\nend",
"def repeater(string)\n string.chars.map do |char|\n char + char\n end.join\nend",
"def in_all_strings?(long_strings, substring)\n count = 0\n long_strings.each do |string|\n if sub_string?(string, substring)\n count += 1\n end\n end\n\n count == long_strings.length\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all? {|x| x.include?(substring) }\nend",
"def refute_match(pattern, string, msg=nil)\n MatchAssay.refute!(string, pattern, :message=>msg, :backtrace=>caller)\n end",
"def substrings(arr1, arr2)\n subs = []\n arr2.each do |full_str|\n arr1.each do |small_str|\n subs << small_str if full_str.include?(small_str)\n end\n end\n subs.uniq.sort\nend",
"def encode_repeating(my_string)\n # return if nil or empty\n return if (my_string == nil || my_string.length == 0)\n\n entering_index = 0 # this is where characters will get replaced\n examining_index = 0 # this is where the current character is getting examined and counted\n length = my_string.length\n while examining_index < length # all n characters will be examined\n temp = my_string[examining_index] # current character\n count = 1 # current character count\n while my_string[examining_index+1] == temp && examining_index < length\n examining_index += 1 # increment index\n count += 1 # increment current character count\n end\n # update at entering_index on seeing the subsequent character changing\n if count > 2 # enter the current character followed by it's count\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n my_string[entering_index] = count.to_s\n entering_index += 1\n elsif count == 2 # enter the current character twice\n count.times do\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n end\n else # count == 1, enter the current character once\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n end\n examining_index += 1 # move to next character\n end\n\n # delete trailing characters in the string.\n count = length - entering_index\n count.times do # worst case: delete n-2 number of characters\n my_string.slice! entering_index # trim the string\n end\n return\nend",
"def repeat_str (n, s)\n s*n\nend",
"def test_rack_contains_a_word_with_duplicate_letters\n [:A,:B,:A,:C].each{|x| @newTileRack.append(x)}\n assert_equal(true,@newTileRack.has_tiles_for?('AAB'))\n end",
"def substrings_at_start(str)\r\n chars = str.chars\r\n chars.each_with_object([]).with_index { |(el,memo), idx| memo << chars.take(idx+1).join('').to_s }\r\nend",
"def replace(s1,s2,z1,z2)\n for i in 0 ... s1.length do\n if s1[i,1] == z1 then s2[i,1] = z2 end\n end\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all?{|str|str.include?(substring)}\n\nend",
"def leading_substrings(string, result, counter)\r\n counter.upto(string.size - 1) do |index|\r\n result << string[counter..index]\r\n end\r\nend",
"def string_spelled_by_gapped_patterns(patterns, k, d)\n <<-DOC\n StringSpelledByGappedPatterns(GappedPatterns, k, d)\n FirstPatterns ← the collection of initial k-mers from GappedPatterns\n SecondPatterns ← the collection of terminal k-mers from GappedPatterns\n PrefixString ← StringSpelledByPatterns(FirstPatterns, k)\n SuffixString ← StringSpelledByPatterns(SecondPatterns, k)\n for i = k + d + 1 to |PrefixString|\n if the i-th symbol in PrefixString does not equal the (i - k - d)-th symbol in SuffixString\n return \"there is no string spelled by the gapped patterns\"\n return PrefixString concatenated with the last k + d symbols of SuffixString\n DOC\n first_patterns = []\n second_patterns = []\n patterns.each do |pat|\n first_patterns << pat.split(\"|\")[0]\n second_patterns << pat.split(\"|\")[1]\n end\n # puts first_patterns\n # puts second_patterns\n prefix_string = genome_from_path(first_patterns)\n # puts prefix_string\n suffix_string = genome_from_path(second_patterns)\n # puts suffix_string\n ((k+d+1)..(prefix_string.length-1)).each do |i|\n return nil unless prefix_string[i] == suffix_string[i-k-d]\n end\n return (prefix_string + suffix_string.slice(suffix_string.length-k-d, k+d))\n end",
"def non_repeat(a_word)\n chars_array = a_word.chars\n char = \"\"\n i = 0\n while i < chars_array.length\n j = i + 1\n while j < chars_array.length\n if chars_array[i] == chars_array[j]\n puts chars_array[i]\n puts chars_array[j]\n break\n else #if not equal\n #check if end of j loop when it equals length of array\n if j == chars_array.length - 1\n char = chars_array[i]\n return char\n end\n end\n j += 1\n end\n i+= 1\n end\n return char\nend",
"def substrings(dict,str)\n hash = Hash.new\n #checks how many times str shows up in dictionary\n dict.each do |astring|\n if astring == str\n\t if hash[str]\n\t hash[str] += 1\n\t else\n\t hash[str] = 1\n\t end\n\t \n\tend\n end\n dict.each do |astring|\n if str.include?(astring)\n\t if hash[astring]\n\t hash[astring] += 1\n\t else\n\t hash[astring] = 1\n\t end\n\tend\n end\n hash\nend",
"def repeat_str (n, s)\r\n return s * n\r\nend",
"def repeater(string)\n string.chars.map { |char| char + char }.join\nend",
"def add_from_strings(*strings)\n strings.each { |s| merge Set.new(s.split('')) }\n self\n end",
"def in_all_strings?(long_strings, substring)\n long_strings.all?{ |el| el.include?(substring)}\nend",
"def custom_start(str, sub_str)\n str_plc, sub_len = str, sub_str.length\n #str_plc.slice(0, sub_len) == sub_str\n str_plc[0, sub_len] == sub_str\nend",
"def tricky_method_two(a_string_param, an_array_param)\n a_string_param.gsub!('pumpkins', 'pumpkinsrutabaga')\n an_array_param = ['pumpkins', 'rutabaga']\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char| \n if hash[char]\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def string(*strings)\n strings.each(&method(:single_string))\n self\n end",
"def common_prefix(array)\n result = []\n max_index = array.min_by { |string| string.size }.size\n (0...max_index).each do |index|\n current_char = array[0][index]\n if array.all? { |str| str[index] == current_char }\n result << current_char\n else\n return result.join('')\n end\n end\n result.join('')\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all? {|string| string.include?(substring)}\nend",
"def in_all_strings?(long_strings, substring)\n long_strings.all? { |string| string.include?(substring) }\nend"
] | [
"0.5991791",
"0.55497426",
"0.5499499",
"0.54187155",
"0.5373907",
"0.52742976",
"0.5274259",
"0.52606195",
"0.52605444",
"0.52531475",
"0.52168685",
"0.51387066",
"0.5102774",
"0.50846803",
"0.50298786",
"0.50290245",
"0.50208807",
"0.49707037",
"0.49655724",
"0.49655724",
"0.4884994",
"0.48671174",
"0.48655197",
"0.48636308",
"0.4848512",
"0.48403543",
"0.48336855",
"0.48323616",
"0.48312804",
"0.48200375",
"0.48197675",
"0.48137715",
"0.48119417",
"0.48008183",
"0.47976658",
"0.47970957",
"0.47937816",
"0.47918987",
"0.47863978",
"0.47781137",
"0.4772426",
"0.47569293",
"0.47546145",
"0.47415137",
"0.4740411",
"0.4735248",
"0.47347206",
"0.4731297",
"0.47291926",
"0.47286397",
"0.47278583",
"0.4715173",
"0.47124457",
"0.47050822",
"0.47010833",
"0.46915796",
"0.46883047",
"0.46882787",
"0.46872488",
"0.46835595",
"0.4676638",
"0.46765476",
"0.46759114",
"0.46708128",
"0.46676382",
"0.46676382",
"0.466555",
"0.46652627",
"0.4662735",
"0.46620792",
"0.46554476",
"0.46534103",
"0.46436405",
"0.4642871",
"0.4641614",
"0.46366462",
"0.46302795",
"0.46295172",
"0.46294063",
"0.46293682",
"0.4627966",
"0.4625808",
"0.46180135",
"0.46124125",
"0.46082038",
"0.4607907",
"0.4605064",
"0.46040896",
"0.4602367",
"0.45973793",
"0.4595227",
"0.45852023",
"0.45830122",
"0.4579918",
"0.45799088",
"0.45776856",
"0.4572693",
"0.45696792",
"0.45690966",
"0.45673966"
] | 0.9091276 | 0 |
spacey_str = string.space_out Return a copy of the current string with space characters inserted between its characters (plus an initial space character). | def space_out
gsub(/(.)/, ' \1')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_blank_space(input_string)\n\t\tcurrent_index = 0\n\t\tback_of_string = input_string.length - 1\n\n\t\twhile current_index < back_of_string\n\t\t\tif input_string[current_index] == \" \"\n\t\t\t\tinput_string[current_index] = \"%20\"\n\t\t\tend\n\t\t\t\tcurrent_index += 1\n\t\t\t\t#back_of_string needs to update to represent new size of input_string size\n\t\t\t\tp back_of_string = input_string.length - 1\n\t\tend\n\treturn input_string\nend",
"def spaces_suround\n string = self\n unless [-1] == \" \"\n string = string + \" \"\n end\n unless [0] == \" \"\n string = \" \" + string\n end\n string\n end",
"def condense_spaces(str)\n str.gsub(/\\s+/, \" \")\n end",
"def add_spaces(str, chars_per_group = nil)\n return str if chars_per_group.nil?\n str = str.split ''\n out = []\n str.each_slice(chars_per_group) do |group|\n group.push ' '\n out.push group.join('')\n end\n out.join('').strip\n end",
"def get_ride_of_space(my_phrase)\n edited_phrase = \"\"\n i = 0\n while i < my_phrase.length\n temp = my_phrase[i]\n if temp != \" \"\n edited_phrase += temp\n end\n i += 1\n end\n return edited_phrase\nend",
"def string_and_space(str)\n str.blank? ? '' : (str + ' ')\n end",
"def _SPACE\n _tmp = match_string(\" \")\n set_failed_rule :_SPACE unless _tmp\n return _tmp\n end",
"def snake_to_space(string)\n string.to_s.gsub(/_/, ' ')\n end",
"def spacify(str)\n # str.chars.map { |c| c += ' '}.join.rstrip\n str.gsub(/\\w/) {|s| s + ' '}.rstrip\nend",
"def cleanup str\n str2 = str.gsub(/[^A-Za-z]/, ' ')\n str3 = str2.gsub(/[ ]{2,}/, ' ')\nend",
"def space\n @space ||= self.space_after.gsub(/\\s*(\\n|\\r)+\\s*/,\" \")\n end",
"def strip_side_space!\n replace self.gsub(/^\\s+/, \"\").gsub(/\\s+$/, $/)\n end",
"def remove_spaces(string)\n result = ''\n string.chars.each do |k|\n if k == ' '\n result += '%20'\n else\n result +=k\n end\n end\n result\nend",
"def string_output(string)\n return string.gsub /\\s/, \"+\"\nend",
"def no_space(x)\n x = x.split(\" \").join(\"\")\n puts x\nend",
"def no_space(x)\n x.gsub(\" \", \"\")\nend",
"def clean_up_spaces(string)\n string.gsub(\"\\n\", ' ').gsub(/[[:space:]]+/, ' ').strip if string.is_a? String\n end",
"def restore_spaces\n gsub(/(?<=\\S)(_|\\.)(?=\\S)/, ' ')\n end",
"def newline_to_space(input)\n input.to_s.gsub(/\\n/, SPACE)\n end",
"def internal_space(line)\n # For each single quote, if there is an odd number of double quote before\n # we are in a string, but if there is an even number of double quote before\n # we are out of a string.\n double_quote = 0\n previous_char = nil\n output = ''\n i = 0\n line.each_char do |c|\n double_quote += 1 if c == '\"'\n output += c unless previous_char == ' ' && c == ' ' && double_quote.even?\n i += 1\n previous_char = c\n end\n return output\n end",
"def new_word(s)\n\ts[0] = ''\n\treturn s\nend",
"def clean(str)\n return nil unless str\n str.gsub(/\\p{Space}/, ' ').strip.squeeze(' ')\n end",
"def ruspace (short = false)\n rusprice ' ', short\n end",
"def _space\n\n _save = self.pos\n while true # choice\n _tmp = match_string(\" \")\n break if _tmp\n self.pos = _save\n _tmp = match_string(\"\\t\")\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n return _tmp\n end",
"def no_space(x)\n x.delete(' ')\nend",
"def unstretch(str)\n return str.squeeze\nend",
"def _space\n\n _save = self.pos\n while true # choice\n _tmp = match_string(\" \")\n break if _tmp\n self.pos = _save\n _tmp = match_string(\"\\t\")\n break if _tmp\n self.pos = _save\n _tmp = apply(:_eol)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_space unless _tmp\n return _tmp\n end",
"def indent(str, spaces)\n str.split(\"\\n\").map { |s| (' ' * spaces) + s }.join(\"\\n\")\n end",
"def replace(in_str)\n @out_str = in_str + \" \" + in_str\n end",
"def _space\n\n _save = self.pos\n while true # choice\n _tmp = match_string(\" \")\n break if _tmp\n self.pos = _save\n _tmp = match_string(\"\\\\f\")\n break if _tmp\n self.pos = _save\n _tmp = match_string(\"\\\\v\")\n break if _tmp\n self.pos = _save\n _tmp = match_string(\"\\\\t\")\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_space unless _tmp\n return _tmp\n end",
"def snake_to_space(string)\n string.to_s.tr('_', ' ')\nend",
"def squash(text)\n return text.scrub.gsub(/[[:space:]]+/, ' ').strip\nend",
"def squish!\n gsub!(/[[:space:]]+/, \" \")\n strip!\n self\n end",
"def no_leading_spaces str\n return str.force_encoding('ASCII-8BIT').gsub(/\\302\\240/,'').strip # What a hack.\n end",
"def whitespace\n @input = @input.gsub(/\\ +/, ' ').strip\n end",
"def smash(string)\n\tstring.gsub(/[^a-z]/i, '').chars.join ' '\nend",
"def cleanup(str)\n str.gsub(/([^a-z])/, ' ').squeeze(' ')\nend",
"def _Space\n\n _save = self.pos\n while true # choice\n _tmp = match_string(\" \")\n break if _tmp\n self.pos = _save\n _tmp = match_string(\"\\\\t\")\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_Space unless _tmp\n return _tmp\n end",
"def normalize_spacing(text)\n text\n .delete(REMOVED_CHARACTERS)\n .tr(SQUEEZED_SPACES, ' ')\n .squeeze(' ')\n .sub(LEADING_SPACES, '')\n .sub(TRAILING_SPACES, '')\n .tr(NON_BREAKING_SPACE, ' ')\n end",
"def replace_spaces(string, length)\n replaced_string = \"\"\n array = string.split(\"\")\n\n i = 0\n while i < length\n if array[i] != \" \"\n replaced_string << array[i]\n elsif array[i] == \" \"\n replaced_string << \"%20\"\n end\n i += 1\n end\n\n replaced_string\nend",
"def no_space(x)\n # code go here\n x.gsub(' ', '')\nend",
"def compact_whitespace s\n s.gsub(/\\s+/, ' ').gsub(/>\\s</, '><').strip\n end",
"def cleanup(str)\n\tnew_str = str.gsub(/[^a-z]/i, ' ').split.join(' ')\n\t\" #{new_str} \"\nend",
"def squish!\n gsub!(/\\A[[:space:]]+/, '')\n gsub!(/[[:space:]]+\\z/, '')\n gsub!(/[[:space:]]+/, ' ')\n self\n end",
"def squish!\n gsub!(/\\A[[:space:]]+/, '')\n gsub!(/[[:space:]]+\\z/, '')\n gsub!(/[[:space:]]+/, ' ')\n self\n end",
"def pre_proccess(text)\n text.to_s.strip.gsub(/[[:space:]]+/, ' ').gsub(/\\s{2,}/, ' ')\n end",
"def dustoff(str)\n str = str.gsub PERIOD, ' '\n str = str.squeeze ' '\n str.strip\n end",
"def dewhitespace\n gsub(/\\s+/,' ').strip\n end",
"def unique_spaces!\n self.gsub!(ANY_SPACE_PATTERN, UNIQUE_SPACE)\n end",
"def space_out_letters(person)\n return person.split(\"\").join(\" \")\nend",
"def normalize_whitespace(input)\n input.to_s.gsub(%r!\\s+!, \" \").tap(&:strip!)\n end",
"def append_space\n return if @sb_last_was_whitespace\n\n @sb_last_was_whitespace = true\n\n @text_buffer << ' '\n @token_buffer << ' '\n end",
"def spaces\n\t\t@secret_word.map { \" _ \" }\n\tend",
"def smash(words)\n return words * \" \"\nend",
"def justify(str, size)\n if str.include?('-')\n # ' - ' => ' --- '\n str = ('-' * size).center(size + 2, ' ')\n elsif str.include?('|')\n # put _size_ spaces in between bars\n # Use indexes to grab leftmost/rightmost chars. Each may be a bar, may be a\n # space.\n str = str[0,1] + ' ' * (size) + str[-1,1]\n else\n # Blank strings are always lines that would have dashes (line 0, 2, or 4)\n str = ' ' * (size + 2)\n end\n return str\nend",
"def remove_whitespace(dirty_name)\n \n return dirty_name.split(' ').join(\" \") \n \n end",
"def tighten\n gsub(/[\\t ]+/,' ').strip\n end",
"def spaces(string1, string2, string3)\n return string1 + \" \" + string2 + \" \" + string3\nend",
"def space_in number\n number.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1 ').reverse\nend",
"def cleanup(str)\r\n str.gsub!(/[^a-z]/, ' ').squeeze(' ')\r\nend",
"def grep_spaces(str)\n str.gsub(/\\s+/, \"_\")\n end",
"def cleanup(str)\n output = [] \n no_go = false\n str = str.gsub(/[^A-Za-z0-9 ]/, ' ').split(\"\")\n str.each_index do |i|\n if str[i]==\" \"\n output.push(str[i]) unless no_go == true\n no_go = true\n else\n output.push(str[i]) \n no_go = false\n end\n end\n output.join\nend",
"def evaporate\n self.gsub(/\\s/, '')\n end",
"def whitespace_to!(separator)\n substitute!(/[[:space:]]+/, separator)\n end",
"def cleanup(string)\n string = string.gsub(/[^a-z]/i, ' ')\n until !string.include?(' ')\n string.gsub!(' ', ' ')\n end\n string\nend",
"def cleanup(string)\n string.gsub(/[^a-z]/, ' ').squeeze(' ')\nend",
"def to_s\n self.word_form + self.space\n end",
"def normalize_spacing(string_sequence)\n string_sequence.gsub(/,[^\\S\\n]*\\n\\s*/, \",\\n\")\n end",
"def _space\n\n begin # choice\n _tmp = match_string(\" \")\n break if _tmp\n _tmp = match_string(\"\\t\")\n break if _tmp\n _tmp = apply(:_eol)\n end while false # end choice\n\n set_failed_rule :_space unless _tmp\n return _tmp\n end",
"def custom_squeeze(string, chars)\n new_string = \"\"\n new_string = string.squeeze(chars)\n return new_string\nend",
"def spaces; end",
"def spaces; end",
"def cleanup(str)\n str.gsub(/\\W/, ' ').squeeze(' ')\nend",
"def cleanup(str)\n str.gsub(/[^a-z]/,\" \").squeeze(\" \")\nend",
"def cleanup(string)\n string.gsub!(/\\W/, ' ').squeeze(' ')\nend",
"def truncate(str)\n str ||= \"\"\n return str.gsub(/\\s+/, ' ').strip\n end",
"def normalize_whitespace(input); end",
"def to_s_without_spaces\n to_s.gsub(\" \",\"\").gsub(\"\\n\",\"\").gsub(\"\\r\",\"\")\n end",
"def squish!\n strip!\n gsub!(/\\s+/, ' ')\n self\n end",
"def squish\n self.gsub(/[\\n\\t]/, '').squeeze(' ').strip\n end",
"def to_s_without_spaces\n to_s.gsub(\" \",\"\").gsub(\"\\n\",\"\").gsub(\"\\r\",\"\")\n end",
"def whitespace_escape(str)\n str = str.to_s.gsub(/\\s/) do |match|\n case match\n when \"\\n\" then \"\\\\n\\n\"\n when \"\\t\" then \"\\\\t\"\n when \"\\r\" then \"\\\\r\"\n when \"\\f\" then \"\\\\f\"\n else match\n end\n end\n str.gsub!(\"\\b\", \"\\\\b\")\n str.gsub!(\"\\a\", \"\\\\a\")\n str.split(\"\\0\").join('\\\\0')\n end",
"def cleanup(string)\n string.gsub(/[^a-z]/i, ' ').squeeze(' ')\nend",
"def convert_plus_to_space(str)\n str.gsub(/[+]/, ' ')\n end",
"def custom_squeeze(string)\n final = \"\"\n chars = string.split(\"\")\n chars.each_with_index { |char, index| char == chars[index + 1] ? next : final << char }\n final\nend",
"def cleanup(string)\n string.gsub(/[^a-z]/i, \" \").squeeze(' ')\nend",
"def to_s()\n str = \"\"\n @ingame_word.each do |letter|\n if(letter == \" \")\n str << \"_\"\n else\n str << letter\n end\n str << \" \"\n end\n return str\n end",
"def add_spacing( seq, cs = cut_symbol )\n str = ''\n flag = false\n seq.each_byte do |c|\n c = c.chr\n if c == cs\n str += c\n flag = false\n elsif flag\n str += ' ' + c\n else\n str += c\n flag = true\n end\n end\n str\n end",
"def cleanup(string)\n i = 0\n final = ''\n while i < string.length\n final << (('a'..'z').cover?(string[i]) ? string[i] : ' ')\n i += 1\n end\n final.squeeze(' ')\nend",
"def cleanup(str)\n str.gsub!(/[^0-9a-z ]/i, ' ')\n str.gsub!(/\\s+/, ' ')\nend",
"def to_s_without_spaces\n to_s.gsub(/\\s/, '')\n end",
"def cleanup(input)\n input.gsub(/[^a-zA-Z]/, ' ').squeeze(' ')\nend",
"def custom_squeeze(string)\n final = \"\"\n chars = string.split(\"\")\n chars.each_with_index { |char, index| char == chars[index + 1] ? next : final << char }\n final\nend",
"def cleanup(string)\n characters = string.chars\n characters.each_with_index do |char, index|\n if !('a'..'z').include?(char.downcase)\n if characters[index - 1] == ' '\n characters[index - 1] = ''\n characters[index] = ' '\n else\n characters[index] = ' '\n end\n end\n end\n characters.join\nend",
"def space; txt ' ','' end",
"def chop(word)\n word.chop\nend",
"def outdent( str )\n\t\t\tstr.gsub( /^(\\t|[ ]{1,#{TabWidth}})/, '')\n\t\tend",
"def indent_string(string, *args)\n string = string.dup\n indent_string!(string, *args)\n string\n end",
"def right_strip(string)\n i = string.length-1\n output = \"\"\n new_line = \"\\n\"\n tab = \"\\t\"\n space = \" \"\n while 0 < i\n if string[i] == new_line || string[i] == tab || string[i] == space \n i -= 1\n else\n j = 0\n while j <= i\n output += string[j]\n j += 1\n end\n if j == i + 1\n return output\n end\n end\n end\nend",
"def cust_squeeze(str)\n final = []\n arr = str.chars\n arr.each { |char| final << char unless final.last == char }\n final.join\nend"
] | [
"0.70761573",
"0.7055404",
"0.6787125",
"0.6678213",
"0.6562428",
"0.6546508",
"0.6542062",
"0.6527542",
"0.6513802",
"0.64942694",
"0.6360922",
"0.6357714",
"0.6329139",
"0.6320897",
"0.63141966",
"0.6284409",
"0.6282641",
"0.6272445",
"0.6261222",
"0.6232203",
"0.62137234",
"0.61933255",
"0.61860836",
"0.61552423",
"0.615049",
"0.612774",
"0.61249524",
"0.61238235",
"0.61073864",
"0.6098082",
"0.60914385",
"0.60901636",
"0.60766184",
"0.6056559",
"0.60542595",
"0.60535395",
"0.6053291",
"0.6053084",
"0.6034364",
"0.60094887",
"0.6002824",
"0.60010624",
"0.5980459",
"0.59763575",
"0.59763575",
"0.59703386",
"0.5956902",
"0.59362775",
"0.59221685",
"0.5916341",
"0.5911696",
"0.5903677",
"0.58961004",
"0.58927053",
"0.5890883",
"0.58847827",
"0.58652276",
"0.5862782",
"0.58588",
"0.5858786",
"0.5851436",
"0.5838937",
"0.58387965",
"0.58345",
"0.58269495",
"0.5825075",
"0.5823936",
"0.5815722",
"0.5813613",
"0.58133775",
"0.5810813",
"0.5810813",
"0.580972",
"0.5787326",
"0.57847476",
"0.5778755",
"0.5776957",
"0.57689196",
"0.5768208",
"0.5767768",
"0.57670313",
"0.57669705",
"0.5742408",
"0.5742129",
"0.5732323",
"0.57299757",
"0.57283777",
"0.5726135",
"0.5722281",
"0.57167745",
"0.5712249",
"0.5689856",
"0.5689457",
"0.5686665",
"0.56866425",
"0.5684506",
"0.56815714",
"0.5676749",
"0.56766206",
"0.56735677"
] | 0.69937533 | 2 |
word_search.add_line(line) Add the String to the current word search puzzle object. | def add_line(line)
@text_lines << line.upcase_trim
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_line(line)\n @lines << line\n line\n end",
"def add_line(line)\n\t\t@lines << line\n\tend",
"def add_line(line)\n @entries << line\n end",
"def add_comment_line line\n @strings << line\n end",
"def add_word(word)\n \n end",
"def add_word(word)\r\n \r\n end",
"def add(word)\n end",
"def append_line(line)\n @lines.push(line)\n @current = false\n @current_pos = 0\n end",
"def add(word)\n Hunspell.Hunspell_add(self,word.to_s)\n end",
"def add_word_to_result(word, line_num)\n return if word == ''\n if @result[word].nil?\n h = Hash.new\n h[:count] = 1\n h[:line_nums] = [line_num]\n @result[word] = h\n else\n @result[word][:count] += 1\n @result[word][:line_nums] << line_num\n end\n end",
"def add(word)\n return if word.nil? || word.strip == ''\n\n @words.push(word)\n end",
"def add(word, w)\n if word != \"\" \n cur = self\n word.downcase.each_char do |character|\n modified_char = @@vowels.include?(character) ? '*' : character\n cur.kids[modified_char] = SpellingTrie.new if not cur.kids.has_key? modified_char\n cur = cur.kids[modified_char]\n end\n cur.words_here.add(w)\n end\n end",
"def append_line(line)\n @entries.last.line << line\n end",
"def add_line(line)\n @tip.string_content += line.slice(@offset, line.length) + '\\n'\n end",
"def add_location(path, line); end",
"def add_word(word)\n @word_counts[word] ||= 0\n current_count = @word_counts[word] += 1\n @total_word_count += 1\n # If this word is new for this Group, it might be new for the entire Groupie\n @groupie.add_word(word) if current_count == 1\n nil\n end",
"def add(context, line)\n\t\t\t@lines << @line.new(context, line)\n\t\tend",
"def add(word)\n change_wordlist(@words + [ Word.new(word) ] )\n end",
"def add_word(word)\n word_hash = Digest::SHA1.hexdigest(word)\n word_file_path = ROOT_DATA_FOLDER + word_hash\n word_file = File.open(word_file_path, 'a+')\n words = word_file.readlines\n words.each {|word| word.sub! \"\\n\", ''} # remove trailing \\n\n word_index = words.index(word)\n\n if word_index.nil? # add new word to end of file with count = 1\n add_line_to_file(word_file_path, word)\n add_line_to_file(word_file_path, '1')\n else # add count to existing word by replacing count line in file\n word_count = words[word_index + 1].to_i\n add_line_to_file(word_file_path, (word_count + 1).to_s, word_index + 1)\n end\n word_file.close\n end",
"def add_word word #Function shovels individual strings into the dictionary array\n @dictionary << word\n end",
"def process!(line)\n index!(get_words(clean(line)))\n end",
"def write text\n\t\t@search_text = @line.text = text\n\tend",
"def <<(line)\n line.blank? ? (@lines << line) : (self[line.key] = line) ; self\n end",
"def <<(word)\n @words << word\n end",
"def add(word)\n @root.create_final_path(word.chars.reverse + [Path::DELIMITER])\n\n Word.new(word.chars).to_delimited_paths.each do |path|\n @root.create_final_path(path.letters)\n end\n\n self\n end",
"def <<(word)\n @words << word\n end",
"def <<(word)\n @words << word\n end",
"def add(text)\n @lines ||= []\n @lines.push text\n end",
"def add word\n super word.clone\n end",
"def <<(line)\n @extra << line\n end",
"def add(word)\n build(@tree, word)\n end",
"def add_instant_text(text)\n @lines.push(text)\n refresh\n end",
"def add_example_line line\r\n if /#{regex_new_example}/.match(line)\r\n # start a new loop example with a placeholder nil \r\n @loop_examples << nil\r\n else\r\n raise \"you need use '#{regex_new_example}' to start a loop example\" unless @loop_examples.size > 0\r\n line.gsub!(/#{regex_example_head}/, '')\r\n @loop_examples[-1] = @loop_examples[-1] ? @loop_examples[-1] + \"\\n\" + line : line\r\n end\r\n end",
"def push(line)\n line_number = @lines.any? ? @lines.last.lineno + 1 : 1\n @lines.push(LOC.new(line, line_number))\n end",
"def add(station, line)\n # add station to line\n l = @lines.fetch(line) do\n @lines[line] = line\n end\n\n l.stations << station unless l.stations.include?(station)\n\n # add line to station\n s = @stations.fetch(station) do\n @stations[station] = station\n end\n\n s.lines << l unless s.lines.include?(l)\n end",
"def add_word(word, definition)\r\n @word << {Word: word, Definition: definition}\r\n # puts \"This is @word: #{@word}\"\r\n end",
"def add(word)\n @words[@words.size] = word\n end",
"def add_example_line line\r\n if /#{regex_new_example}/.match(line)\r\n # start a new loop example with a placeholder nil \r\n @loop_examples << nil\r\n else\r\n raise \"you need use '#{regex_new_example}' to start a loop example\" unless @loop_examples.size > 0\r\n line.gsub!(/#{regex_example_head}/, '')\r\n @loop_examples[-1] = @loop_examples[-1] ? @loop_examples[-1] + \"\\n\" + line : line\r\n end\r\n end",
"def index!(words)\n ### FILL IN YOUR CODE HERE\n @line += 1\n if words == nil\n else\n words.each { |word|\n if !@hash[word].include?(@line)\n @hash[word].push(@line)\n else\n\n end\n }\n end\n end",
"def add(entry, lines)\n # this assumes that entry is unique\n @entries << entry\n @entries_with_lines[entry] = lines\n @lines += lines\n self\n end",
"def <<(line)\n case line\n when /^\\-\\-\\-/\n handle #@doc\n @doc << line\n when /^\\.\\.\\./\n handle #@doc\n stop\n else\n @doc << line\n end\n end",
"def addline(line, order)\n\t\t#steps.create(installation_id: self, line_id: line.id, order: order)\n\t\tactive_steps.create(line_id: line.id, order: order)\n\tend",
"def add(text)\n @text << text\n end",
"def add(word)\n\t\tif word.class == String\n\t\t\tword = {word => nil}\n\t\tend\n\n\t\tword.each do |key, value|\n\t\t\t@entries[key] = value\n\t\tend\n\tend",
"def add_word(word)\n node = @root\n word.each_char do |c|\n node.children[c] ||= TrieNode.new\n node = node.children[c]\n end\n node.is_end = true\n end",
"def add_word(word)\n sym = word.to_sym\n wdup = word.dup\n for i in 0...word.length\n wdup[i] = 0\n @steps[wdup] << sym\n wdup[i] = word[i]\n end\n @words[word] = sym # for allow_shorter and each_word\n end",
"def add(entry) \r\n if entry.is_a? String\r\n @@words[entry] = nil\r\n else \r\n learn = entry.to_a \r\n learnit = learn[0]\r\n @@words[learnit[0]] = learnit[1]\t\r\n end\r\nend",
"def add_text(text); end",
"def write_line(line)\n text = line\n text.gsub!('~~~~{.cpp}', '```cpp')\n text.gsub!(\"~~~~\",\"```\")\n\n if text.include? \"![\"\n puts \"Image found in #{@current_content_block}.\\n...please fix #{text}\\n\"\n end\n\n @content << text\nend",
"def add_word(word)\n chars = word.chars\n current = @root\n\n chars.each do |c|\n current = add_character(c, current)\n current.word_count += 1\n end\n current.is_word = true\n end",
"def add_word(word)\n if word.length == 0\n @isend = true\n else\n @childs[word[0]] ||= WordDictionary.new\n @childs[word[0]].add_word(word[1..-1])\n end\n nil\n end",
"def add_line(line)\n unless @parsing\n if line =~ /^(---|\\+\\+\\+) (.*)$/\n self.file_name = $2\n elsif line =~ /^@@ (\\+|\\-)(\\d+)(,\\d+)? (\\+|\\-)(\\d+)(,\\d+)? @@/\n @line_num_l = $2.to_i\n @line_num_r = $5.to_i\n @parsing = true\n end\n else\n if %r{^[^\\+\\-\\s@\\\\]}.match?(line)\n @parsing = false\n return false\n elsif line =~ /^@@ (\\+|\\-)(\\d+)(,\\d+)? (\\+|\\-)(\\d+)(,\\d+)? @@/\n @line_num_l = $2.to_i\n @line_num_r = $5.to_i\n else\n parse_line(line, @type)\n end\n end\n return true\n end",
"def insert_line\n down\n\n @lines = lines.insert_line(Vedeu::Editor::Line.new, y)\n\n bol\n\n refresh\n end",
"def add(word, coordinates, direction)\n constant_coordinate = direction_other_than(direction)\n word.chars.with_index do |char, word_position|\n @grid[direction][coordinates[constant_coordinate]][coordinates[direction]+word_position] = char\n @grid[constant_coordinate][coordinates[direction]+word_position][coordinates[constant_coordinate]] = char\n end\n grid_modified!\n true\n end",
"def add_letter(letter, locations)\n # for each occurrence of a letter, add the letter to the correct location in $build-word\n locations.each { |location| $build_word[location] = letter }\n word_test() # then run word_test()\nend",
"def add_line(s=nil)\n @string << \"\\n#{@@indenation * @indentation_level}#{s}\"\n end",
"def add(term)\n root.add Buffer.new(normalize(term) + delimiter), term\n end",
"def append_new_line(new_line)\n # Append 'line' into position 'line_number'\n puts ' append_new_line ...' if $verbose > 1\n @lines << new_line\n @line_count += 1\n end",
"def add_word(word)\n sorted_word = word.lsort\n @data[sorted_word] ||= []\n @data[sorted_word] << word\n if (@max_word_size==nil) || (word.size > @max_word_size)\n @max_word_size = word.size\n end\n end",
"def add(word)\n word.scan(/./) do |l|\n if ('a'..'z') === l\n @map[l] = Array.new unless @map.has_key? l\n @map[l] = @map[l] << word\n end\n end \n end",
"def process_line line\n if line.include?(\"@\") && @add_tags_to_main\n @nd[:main_tags] << line \n elsif line.include?(\"Feature:\")\n @nd[:feature] = line.sub(\"Feature:\",\"\")\n @add_tags_to_main = false\n elsif line.include?(\"Scenario:\")\n @nd[:scenarios].push({:name => line.sub(\"Scenario:\",\"\"), :steps => []})\n @add_to_s = true\n elsif\n begin\n @nd[:scenarios].last[:steps].push(line) if @add_to_s\n @add_to_s = true \n rescue\n end\n end\n end",
"def add_word(word)\n node = root\n word.chars.each do |c|\n node.children[c] = TrieNode.new unless node.children.key?(c)\n node = node.children[c]\n end\n node.word = true\n end",
"def add_target(string)\n clean_string = string.downcase.gsub(/[^a-z ]/i, ' ')\n clean_string.split(' ').each { |word| @word_counter.add_word(word) }\n end",
"def insert_text(line, col, text) \n\t\tindex = index_of_position(line, col)\n\t\[email protected](index, text)\n\t\ti = 0\n\t\ti += 1 while i < @line_indices.length and @line_indices[i] < index\n\t\t(0...text.length).each do |c|\n\t\t\tif text[c,1] == \"\\n\"\n\t\t\t\t@line_indices.insert(i, index + c)\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\t\t(i ... @line_indices.length).each { |i| @line_indices[i] += text.length }\n\tend",
"def push_in_the_results(test_line)\n if end_of_line?(test_line)\n @results.push((ree? or mri?) ? @line.pack('c*') : @line.join)\n @line.clear\n end\n end",
"def add_word(word)\r\n if word.length == 0\r\n # handle separately\r\n @empty_string_exist = true\r\n end\r\n\r\n prev = nil\r\n n = @root\r\n\r\n word.chars.each_with_index do |chr, i|\r\n node = search_node_or_insert_node(n, chr)\r\n #puts \"chr=#{chr}, node=#{node}, letter=#{node.nil? ? '' : node.letter}\"\r\n\r\n if node.nil?\r\n #n is nil, otherwise it will return \r\n if prev.nil?\r\n # root is nil\r\n @root = Node.new(chr)\r\n\r\n prev = @root\r\n n = @root.next\r\n #if i == word.length - 1\r\n # prev.is_end = true\r\n #end\r\n else\r\n prev.next = Node.new(chr)\r\n prev = prev.next\r\n n = prev.next\r\n #if i == word.length - 1\r\n # prev.is_end = true\r\n #end\r\n end\r\n elsif node.letter == chr\r\n # I found it\r\n prev = node\r\n n = prev.next\r\n\r\n #if i == word.length - 1\r\n # prev.is_end = true\r\n #end\r\n else\r\n # I found the insert position\r\n if chr.ord < node.letter.ord\r\n # insert to left\r\n node.left = Node.new(chr)\r\n prev = node.left\r\n n = prev.next\r\n else\r\n # insert to right\r\n node.right = Node.new(chr)\r\n prev = node.right\r\n n = prev.right\r\n end\r\n\r\n end\r\n\r\n if i == word.length - 1\r\n prev.is_end = true\r\n end\r\n end\r\n end",
"def add_line(line_index, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, dx: 0)\n sprite_stack.add_line(line_index, str, align, outlinesize, type: type, color: color, dx: dx)\n end",
"def find_or_add_node(id, word)\n node = find_node(id: id)\n if node\n node.words << word unless node.words.include?(word)\n node\n else\n nodes << Node.new(id: id, words: [word])\n nodes.last\n end\n end",
"def insert(word)\n tmp = self\n word.split(\"\").each do |char|\n tmp.childs[char] ||= Trie.new\n tmp = tmp.childs[char]\n end\n tmp.isend = true\n nil\n end",
"def setLine (line)\n @line = line\n end",
"def add_line_item_from_string(input_line)\n parsed_line = /(?<quantity>\\d+) (?<item>.+) at (?<price>\\d*\\.\\d{2})?/.match(input_line)\n new_line_item = LineItem.new(parsed_line['quantity'],parsed_line['item'],parsed_line['price'])\n @line_items << new_line_item\n end",
"def add_at!(word)\n new_word = \"#{Unicode.downcase(word)}а\"\n @redis.rpush(\"store:ats\", new_word)\n end",
"def is_orig_word_line(line)\n line.match(@orig_word_regex)\n end",
"def addword(word)\n if @graph.words[word].nil? then\n @graph.words[word] = {}\n end\n end",
"def add_string(string)\n @strings << string\n end",
"def add(word)\n \t\tif word.length > 0 # there was a zero length char after this, idk\n if @children[word[0,1]] # if current letter exists in hash, add to it\n\t @children[word[0,1]].add(word[1, word.length])\n\t\t\t\t@children[word[0,1]].word = true if (word.length == 1)\n\t else # if the letter doesn't exist, create it\n\t @children[word[0,1]] = LetterTree.new(word[1, word.length])\n\t\t\t\t@children[word[0,1]].word = true if (word.length == 1)\n\t end\n\t\tend\n\tend",
"def <<(line)\n add(UnorderedListItem.new(line))\n end",
"def <<(obj)\n @words << obj\n end",
"def text_file_scan_and_rewrite(my_file_name)\n\n textfile = File.open(my_file_name, 'r+') #open file for read/write\n\n all_lines_from_file = textfile.read #read all the records in the file\n\n if word_position = all_lines_from_file =~ /word/ #check for \"word\" and if found note position in string\n all_lines_from_file.insert(word_position, 'inserted ') #put \"inserted \" in front of \"word\"\n textfile.rewind #reset to beginning of file\n textfile.puts all_lines_from_file #write new data to file\n end\n textfile.close\nend",
"def replace_line(line)\n cursor = text_cursor\n\n cursor.position = document.character_count - 1\n cursor.set_position(@min_position, Qt::TextCursor::KeepAnchor)\n\n cursor.insert_text line\n\n change_cursor { |c| c.position = document.character_count - 1 }\n\n highlight\n end",
"def insert_word(word)\n word = word.clone\n word_id = word.id\n\n @index_sense ||= @database.prepare('insert into senses_fts values (?, ?)')\n @index_literal ||= @database.prepare('insert into literals_fts values (?, ?, ?)')\n @insert_word ||= @database.prepare('insert into words values (?, ?)')\n\n word.literals.each do |literal| \n @index_literal.execute(literal.text, word_id, literal.priority)\n end\n\n word.readings.each do |reading| \n @index_literal.execute(reading.text, word_id, reading.priority) \n end\n\n word.senses.each do |sense|\n @index_sense.execute(sense.texts.join(';'), word_id)\n end\n\n # We can derive ID from table ID.\n word.id = 0\n\n @insert_word.execute(word_id, Word.encode(word))\n end",
"def new_line\n @source_lines << []\n end",
"def add(*words)\n words.flatten.each do |word|\n add_word(word)\n end\n nil\n end",
"def insert_line lineno=@current_index\n prompt = \"Insert: \"\n maxlen = 80\n #config={}; \n #config[:default] = line\n #ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)\n ret, str = input_string prompt\n #ret, str = rb_getstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config)\n $log.debug \" rb_getstr returned #{ret} , #{str} \"\n return if ret != 0\n\n # pad based expect @content not list\n # remove list after a while FIXME\n @list ||= @content\n @list.insert lineno, str\n ## added handler on 2010-05-23 11:46 - undo works - tested in testlistbox.rb\n fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str)\n fire_dimension_changed\n end",
"def add(word)\n node = @root\n word.downcase!\n word.each_char do |letter|\n node[letter] ||= Hash.new\n node = node[letter]\n end\n node[:end] = true\n end",
"def add_line\n @layout.add_widget(HLine.new)\n end",
"def update\n\t\told_lyric = LyricLine.find params[:id]\n\t\ttext = params[:lyric_line][:text]\n\t\tp text\n\t\tif text.length < 1 || text == old_lyric.text || !/\\w/.match(text)\n\t\t\t# don't save, add line back\n\t\t\t@placeholder = 'please enter a line'\n\t\t\tdump_line old_lyric\t\n\t\telse\n\t\t\tlyric_line = LyricLine.new params[:lyric_line]\n\t\t\tlyric_line.version_number = get_next_version( lyric_line )\n\t\t\tlyric_line.save\n\t\t\t@first = params[:first]\n\t\t\tdump_line lyric_line\n\t\tend\n\tend",
"def insert_from_line( line )\n begin\n row = line.chomp.parse_csv\n @cached << record( row )\n rescue\n print '#'\n end\n\n flush_inserts if @cached.size >= CACHE_SIZE\n end",
"def store_valid_word(word)\n @words << word\n @word_index[word] = @last_letter\n end",
"def add_search_term(term)\n @search_terms.push term\n end",
"def line=(line)\n @parsed_rules.line = line if @parsed_rules\n super\n end",
"def insert_word(word, x, y)\n for i in 0...word.length\n @grid[x][y+i] = word[i]\n end\n end",
"def insert_line_after_match(regex, newline)\n search_match(regex, newline, 'i', 1)\n end",
"def add(string)\n \tstring + \"only in America!\"\n end",
"def add_to_index(url, doc)\n unless is_indexed(url)\n # FIXME: replace with logging\n puts \"Indexing #{url}...\"\n \n # Get the individual words\n text = get_text_only(doc)\n words = separate_words(text)\n \n u = Url.find_by_url(url)\n if u.nil?\n u = Url.create!(:url => url)\n end\n \n # Link each word to this url\n words.each_with_index do |word, i|\n unless IGNORE_WORDS.member?(word)\n w = Word.find_by_word(word)\n if w.nil?\n w = Word.create!(:word => word)\n end\n w.word_locations.create!(:url_id => u.id, :location => i)\n end\n end\n end\n end",
"def add_segment(position, segment)\n @min_count += 1\n @min_solution[position] = true\n cover_line(segment)\n end",
"def check_line(line, line_number)\n line_words = self.class.word_splitter(line)\n line_words.each do |word|\n word_is_right, spell_checked_word = check_word(word, line_number)\n next if word_is_right.is_a?(TrueClass)\n @incorrect_words << spell_checked_word\n end\n end",
"def processLine (docNumber, line)\n line = line.to_s\n # Cleans line of white space\n line.chomp!\n #checks for punctuation and numbers\n line.gsub!($remove_punctuation, '')\n line.gsub!($numbers, \"\")\n line.gsub!(/-/, ' ')\n line.downcase!\n #splits the line into words\n words = line.split(' ').to_a\n # Handles each word\n words.each do |word|\n # Check if in hash\n if $index.has_key? word\n if $index[word].has_key? docNumber\n $index[word][docNumber] += 1\n else\n $index[word][docNumber] = 1\n end\n # Make new internal hash\n else\n $index[word] = Hash.new\n $index[word][docNumber] = 1\n end\n end\nend",
"def add(_, working_set = nil)\n return unless working_set\n entries.insert(position + 1, working_set)\n go_forward_history(nil)\n end",
"def add_ata!(word)\n @redis.rpush(\"store:atas\", Unicode.downcase(word))\n end"
] | [
"0.68505514",
"0.6775949",
"0.67582613",
"0.66004676",
"0.65298796",
"0.64221686",
"0.6354047",
"0.63225424",
"0.63010395",
"0.62856686",
"0.6236654",
"0.62097275",
"0.6178971",
"0.6123173",
"0.61008024",
"0.6077652",
"0.60291904",
"0.59757316",
"0.59376353",
"0.59094167",
"0.5855249",
"0.58189",
"0.5810672",
"0.580904",
"0.5788377",
"0.57692903",
"0.57692903",
"0.5764133",
"0.57484686",
"0.5741877",
"0.5711255",
"0.56520975",
"0.5651603",
"0.5629409",
"0.56225127",
"0.561527",
"0.5611384",
"0.5578614",
"0.5555849",
"0.55548364",
"0.5515651",
"0.5507985",
"0.54969096",
"0.54941356",
"0.54934394",
"0.5486662",
"0.54650927",
"0.5462325",
"0.5419086",
"0.5414222",
"0.54120755",
"0.5395097",
"0.53469133",
"0.5344119",
"0.5337488",
"0.53370017",
"0.5334875",
"0.53208894",
"0.531141",
"0.5302102",
"0.52994984",
"0.5276787",
"0.5274786",
"0.5257514",
"0.5254681",
"0.5248165",
"0.5244161",
"0.52391434",
"0.52371776",
"0.5228859",
"0.5223042",
"0.52186",
"0.5205171",
"0.51987416",
"0.51983106",
"0.5187549",
"0.51798666",
"0.5170918",
"0.5164388",
"0.51476574",
"0.5134345",
"0.51302016",
"0.51083714",
"0.5107301",
"0.50968844",
"0.5091084",
"0.5088983",
"0.50886226",
"0.50845873",
"0.50780517",
"0.5074954",
"0.50693274",
"0.5068918",
"0.505334",
"0.50340796",
"0.5025603",
"0.50146526",
"0.5013968",
"0.5010457",
"0.50098425"
] | 0.70044994 | 0 |
word_search.solve(words) Solve the current word search object for the words . The solution is returned, which is an Array of Strings in the same shape as the original puzzle, where the solution word letters are kept intact, but the nonsolution word letters replaced with the character '+'. We tackle this problem by doing simple string matches of over repeated transformations of the puzzle text lines: ABCD hflip DCBA diag D hflip D undiag DHL EFGH > HGFE > CH > HC > CGK IJKL LKJI BGL LGB BFJ (L>R) (R>L) AFK KFA AEI ^ EJ JE (T>B) | I I | | undiag (TL>BR) (BR>TL) | hflip | v A hflip A diag AEI hflip IEA vflip LHD BE T) L L (TR>BL) (BL>TR) Other types of transformations (such as straight transpose) would be easier (by simply undoing some transformation steps), but would require more steps. | def solve(*words)
words = words.collect { |word| word.upcase_trim }
#
# Make the various transformations, checking for matches along the
# way.
#
normalize ; replicate_match(words) # match L->R
flip_horizontal ; replicate_match(words) # match R->L
diagonalize ; replicate_match(words) # match TL->BR
flip_horizontal ; replicate_match(words) # match BR->TL
undiagonalize(true) ; replicate_match(words) # match T->B
flip_horizontal ; replicate_match(words) # match B->T
flip_vertical ; flip_horizontal
diagonalize ; replicate_match(words) # match BL->TR
flip_horizontal ; replicate_match(words) # match TR->BL
undiagonalize(false)
#
# And return the solution.
#
@sltn_lines
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve\n\t\t# Attempt to find a mismatch in start/end\n\t\t# letters in the maps. This signifies first\n\t\t# and last words of the solution\n\t\tdiff_list = []\n\t\t@start_map.each {|k,v|\n\t\t\tr = @end_map[k]\n\t\t\tdiff = r-v\n\t\t\tputs \"#{k} => #{v} | #{r} diff #{diff}\"\n\t\t\t\n\t\t\t# If values in map don't match, remember this\n\t\t\tif diff != 0\n\t\t\t\tdiff_list << diff\n\t\t\tend\n\t\t}\n\n\t\t# Ensure the matchings satisfy the properties of\n\t\t# and solvable puzzle. If there are \n\t\tputs diff_list\n\t\tif diff_list.size == 0\n\t\t\t# This means there are cycles (multiple\n\t\t\t# choices for the first word).\n\t\telsif diff_list.size == 2\n\t\t\t# Ensure there is exactly one starting\n\t\t\t# word and exactly one ending word\n\t\t\treturn [] if !diff_list.include?( 1 )\n\t\t\treturn [] if !diff_list.include?( -1 )\n\t\telse\n\t\t\t# This signifies an unsolvable puzzle\n\t\t\tputs \"Not Solvable\"\n\t\t\treturn []\n\t\tend\n\n\t\t# The characteristics of this word list look\n\t\t# good so far. Let's now try to enumerate the\n\t\t# solution array\n\t\treturn enumerate_solution\n end",
"def solver (seed_char, blanks_words_sizes, matrix)\n\t# Set numerical target\n\ttarget = magic_num(seed_char)\t\n\t# Find magic number sum buckets\n\tskynet(target, blanks_words_sizes, blanks_words_sizes.length - 1, 0, [])\n\t# Alphabetical sort input matrix\n\tsorted_seed_char = seed_char.chars.sort.join\t\n\n\t# Find unique sets from skynet solutions\n\t$answer[:trace].each do |arrOarr|\n\t\tarrOarr.sort!\n\tend \n\n\t$answer[:trace].uniq!\t\n\t\n\t# Finds match for complete set of words from skynet solutions\n\t$answer[:trace].each do |answer_arr_el|\t\t\t\t\n\t\tunordered_match(sorted_seed_char, matrix, answer_arr_el, answer_arr_el.length - 1, \"\", [])\n\t\t# Can be ignored\n\t\t$ops += $seed[answer_arr_el[0][0]][:num_groups][answer_arr_el[0][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length\t\t\n\tend\n\t\n\treturn $answer[:words]\nend",
"def solve(dictionary)\n\t\n\t\tunique_word_lengths = (@@word_lengths).uniq\n\t\tunique_word_lengths.sort!\n\t\t\n\t\ti = 1\n\t\t\n\t\tunique_word_lengths.each { |len|\n\t\t\n\t\t\tputs \"\\nSearching for words of length \" << unique_word_lengths[i-1].to_s << \"...\"\n\t\t\t\n\t\t\tconstruct_word(\"\", len, dictionary)\n\t\t\t\n\t\t\ti = i + 1\n\t\t\t\n\t\t}\n\t\t\n\tend",
"def correct(word)\n if @dictionary.has_key?(word)\n return [word]\n end\n \n dist1_replacements = known(edits1(word))\n if dist1_replacements.length != 0\n \treturn dist1_replacements.sort_by{|value| @dictionary[value]}.reverse\n end\n \n dist2_replacements = known_edits2(word)\n if dist2_replacements.length != 0\n \treturn dist2_replacements.sort_by{|value| @dictionary[value]}.reverse\n end\n return nil\n end",
"def find_words(words)\n search_results = SearchResults.new\n \n general = Vector.new\n must_match = Vector.new\n must_not_match = Vector.new\n not_found = false\n \n extract_words_for_searcher(words.join(' ')) do |word|\n case word[0]\n when ?+\n word = word[1,99]\n vector = must_match\n when ?-\n \t word = word[1,99]\n vector = must_not_match\n else\n \t vector = general\n end\n \n index = @dict.find(word.downcase)\n if index\n vector.add_word_index(index)\n else\n not_found = true\n \t search_results.add_warning \"'#{word}' does not occur in the documents\"\n end\n end\n \n if (general.num_bits + must_match.num_bits).zero? \n search_results.add_warning \"No valid search terms given\"\n elsif not not_found\n res = []\n @document_vectors.each do |entry, (dvec, mtime)|\n score = dvec.score_against(must_match, must_not_match, general)\n res << [ entry, score ] if score > 0\n end\n \n res.sort {|a,b| b[1] <=> a[1] }.each {|name, score|\n search_results.add_result(name, score)\n }\n \n search_results.add_warning \"No matches\" unless search_results.contains_matches\n end\n search_results\n end",
"def solve(words)\n x = 0\n while x < words.max.length\n equal = words.all? do |word|\n word[0..x] == words[0][0..x]\n end\n if equal == false\n return words[0][0...x]\n end\n x += 1\n end\nend",
"def solved? (guesses, word)\n\tsolved = true\n\thits = []\n\tword.length.times do |i|\n\t\thits << word[i]\n\tend\n\thits.each do |hit|\n\t\tunless guesses.include? hit\n\t\t\tsolved = false\n\t\tend\n\tend\n\tsolved\n\n\n\t\nend",
"def solve\n loop { break if !shift }\n return @solutions\n end",
"def corrections\n #For each word to be looked at\n $words.each do |word_array|\n #If the word is misspelled attempt corrections\n possible_matches = Array.new\n if word_array[1] == false\n #Sets word to the actual word, instead of array pair\n word = word_array[0]\n # Get lexicon searching vars\n first_char = word[0]\n len = word.length\n\n ##Find words with similar letters\n #Saves the length of the word for eaiser access\n size = word.length\n #Iterates over words with matching starting letter and length +- 1\n $lexicon[first_char][len].each do |word_compare|\n possible_matches << word_compare[0]\n end\n\n # only check shorter words if length is greater than 1\n if len > 1\n $lexicon[first_char][len-1].each do |word_compare|\n possible_matches << word_compare[0]\n end\n end\n\n $lexicon[first_char][len+1].each do |word_compare|\n possible_matches << word_compare[0]\n end\n\n #Iterate over the possible matches, taking the match with the highest percentage\n #Hash to hold similarity\n similarity = Hash.new(0.0)\n possible_matches.each do |word_to_compare|\n similarity[word_to_compare] = match_percentage word, word_to_compare\n end\n\n best_match = ''\n similarity.each do |match|\n if match[1] > similarity[best_match]\n best_match = match[0]\n end\n end\n $correction[word] = best_match\n end\n end\nend",
"def find_words(words)\n @words = words.map { |w| MatrixWord.new(w) }\n @words.each { |mw| place mw if (!mw.word.nil? && mw.word.size <= @width) }\n @words.select { |w| !w.place.nil? }\n end",
"def translate(words)\n split_words = words.split\n split_words.each_with_index do |word, i|\n # check if first letter is a vowel\n if word[0].include? VOWELS.join\n word = add_ay(word) # add ay to the back of the word\n split_words[i] = word\n\n elsif word[0].include? CONSONANTS\n find_phoneme(word)\n elsif (word[0].include? CONSONANTS) && (word[1].include? CONSONANTS)\n find_phoneme(word)\n elsif (word[0].include? CONSONANTS) && (word[1].include? CONSONANTS) && (word[2].include? CONSONANTS)\n\n # the word has a consonant at the beginning with\n # no special conditions\n else\n word = one_cons_at_beginning(word)\n word = add_ay(word)\n split_words[i] = word\n end\n end\n split_words.join\nend",
"def boardSolver2(index1, index2, prefix1)\n @possible_directions.each do |x,y|\n #making sure that the movement doesn't take you off the board\n if (0..3) === (x + index1) && (0..3) === (y + index2) \n prefix = prefix1 + @board[x + index1][y + index2]\n if find_prefix(prefix) == true\n @prefix[prefix] = \"#{x + index1}-#{y + index2}\"\n end\n end \n end\n prefixArray = []\n indexes = []\n @prefix.each do |pre, index|\n indexes << index\n prefixArray << pre\n end\n\n i = 0\n while i < prefixArray.length\n index = indexes[i].split(\"-\")\n if is_word(prefixArray[i]) == true\n @words << prefixArray[i]\n end\n @prefix = {}\n #if there were prefixes that can become words, it will continue going\n boardSolver2(index[0].to_i, index[1].to_i, prefixArray[i])\n i += 1\n end\nend",
"def translate(input)\n\tinputArray = input.downcase.split(\" \")\n\tanswerArray = []\n\tvowelList = [\"a\", \"e\", \"i\", \"o\", \"u\", \"y\"]\n\tcurrentWordNum = 0\n\tcurrentLetterNum = 0\n\tnumberOfWords = inputArray.length - 1\n\tcurrentWordStr = inputArray[currentWordNum].to_s\n\tcurrentWordLength = currentWordStr.length - 1\n\tcurrentLetterStr = inputArray[currentWordNum][currentLetterNum].to_s\n\n\twhile currentWordNum <= numberOfWords\n\n\t\twhile currentLetterNum <= currentWordLength\n\n\t\t\t#if vowelList.include? currentLetterStr == true\n\t\t\tif currentLetterStr.among?vowelList\n\n\t\t\t\tpreviousLetterNum = currentLetterNum - 1\n\t\t\t\tpreviousLetterStr = inputArray[currentWordNum][previousLetterNum].to_s\n\n\t\t\t\tif currentLetterNum == 0\n\t\t\t\t\tcurrentWordStr = inputArray[currentWordNum].to_s\n\t\t\t\t\t\n\t\t\t\t\tnewWordStr = currentWordStr + \"ay\"\n\t\t\t\t\tputs \"newWordStr = \" + newWordStr\n\t\t\t\t\t\n\t\t\t\t\tanswerArray = answerArray.push newWordStr\n\t\t\t\t\tputs \"answerArray = \" + answerArray.to_s\n\n\t\t\t\t\tcurrentLetterNum = currentWordLength + 1\n\n\t\t\t\telsif previousLetterStr == \"q\"\n\t\t\t\t\t#quiet = ietquay\n\t\t\t\t\tcurrentWordStr = inputArray[currentWordNum].to_s\n\t\t\t\t\t\n\t\t\t\t\ttempLetterNum = currentLetterNum + 1\n\t\t\t\t\tnewWordPrefix = currentWordStr[tempLetterNum..currentWordLength]\n\t\t\t\t\t\n\t\t\t\t\tnewWordSuffix = currentWordStr[0..currentLetterNum]\n\n\t\t\t\t\tputs \"newWordPrefix = \" + newWordPrefix\n\t\t\t\t\tputs \"newWordSuffix = \" + newWordSuffix\n\t\t\t\t\t\n\t\t\t\t\tnewWordStr = newWordPrefix + newWordSuffix + \"ay\"\n\t\t\t\t\tputs \"newWordStr = \" + newWordStr\n\t\t\t\t\t\n\t\t\t\t\tanswerArray = answerArray.push newWordStr\n\t\t\t\t\tputs \"answerArray = \" + answerArray.to_s\n\n\t\t\t\t\tcurrentLetterNum = currentWordLength + 1\n\n\t\t\t\telse\n\t\t\t\t\tcurrentWordStr = inputArray[currentWordNum].to_s\n\t\t\t\t\t\n\t\t\t\t\tnewWordPrefix = currentWordStr[currentLetterNum..currentWordLength]\n\t\t\t\t\ttempLetterNum = currentLetterNum - 1\n\t\t\t\t\tnewWordSuffix = currentWordStr[0..tempLetterNum]\n\t\t\t\t\t\n\t\t\t\t\tnewWordStr = newWordPrefix + newWordSuffix + \"ay\"\n\t\t\t\t\tputs \"newWordStr = \" + newWordStr\n\t\t\t\t\t\n\t\t\t\t\tanswerArray = answerArray.push newWordStr\n\t\t\t\t\tputs \"answerArray = \" + answerArray.to_s\n\n\t\t\t\t\tcurrentLetterNum = currentWordLength + 1\n\t\t\t\tend\n\n\t\t\telse\n\n\t\t\t\tcurrentLetterNum = currentLetterNum + 1\n\t\t\t\tcurrentLetterStr = inputArray[currentWordNum][currentLetterNum].to_s\n\n\t\t\tend\n\n\t\tend\n\n\t\tcurrentWordNum = currentWordNum + 1\n\n\t\tif currentWordNum > numberOfWords\n\t\t\tbreak\n\t\tend\n\n\t\tcurrentWordStr = inputArray[currentWordNum].to_s\n\t\t# puts \"currentWordStr = \" + currentWordStr.to_s\n\n\t\tcurrentWordLength = currentWordStr.length - 1\n\t\t# puts \"currentWordLength = \" + currentWordLength.to_s\n\t\tcurrentLetterNum = 0\n\t\tcurrentLetterStr = inputArray[currentWordNum][currentLetterNum].to_s\n\n\tend\n\n\tanswer = answerArray.join(' ')\n\tputs answer\n\treturn answer\nend",
"def solve(w, g, v)\n\n\tif $words[g] == -1\n\t\treturn v\n\telsif $words[g] == 1\n\t\treturn v + 1\n\tend\n\t#else $words[g] == 0\n\n\ttkn = next_token(w)\t\n\tfor char in tkn.chars\n\t\tv = solve(String.new(w), g + char, v)\n\tend\n\n\treturn v\nend",
"def solve\n return [] if @current_state.achieved?(@objective)\n return nil if @remaining_rounds <= 0\n\n possible_transformations = @transformations.select { |transformation| @current_state.can_apply?(transformation) }\n\n sorted_transformations = possible_transformations.sort_by do |transformation|\n future_state = @current_state.dup.apply(transformation)\n future_state.distance_of(@objective)\n end\n return nil if sorted_transformations.empty?\n\n sorted_transformations.lazy.map do |transformation|\n elapsed_rounds = @opts[:max_rounds] - @remaining_rounds - 1\n future_state = apply(transformation, elapsed_rounds)\n return nil unless future_state # apply can returns nil in case of error\n\n world = World.new(@transformations, @objective, @remaining_rounds - 1, future_state, @opts)\n res = world.solve\n [transformation] + res if res\n end.select(&:itself).first\n end",
"def moves(words)\n # words is an array of words/letters on the board e.g. [\"RATE\",\"ENCOUNTERED\",\"T\"]\n # Returns all possible moves\n words = words.collect{|word|word.upcase}\n\n moves = _moves([],words)\n\n # Apply the no-substring rule\n moves.delete_if do |move|\n reject = false\n move[1].each do |from_word|\n if ((from_word.size > 1) && (move[0].index(from_word) != nil)) then\n reject = true\n end\n end\n reject\n end\n\n return moves\n end",
"def solve map\n\n\t# Ridic. work around to get a 'deep copy' of the array\n\tsolution = Marshal.load( Marshal.dump(map) )\n\tletter = 'a'\n\n\twhile !solved solution\n\t\tx,y = next_point solution\n\t\ttraverse map, solution, x, y, letter\n\t\tletter = next_unused_letter solution\n\tend\n\n\treturn solution\nend",
"def find_words words\n # We will work with \"DictWord\" objects rather than with raw strings\n @words = words.map{|w| DictWord.new(w)}\n # It tries to find every single word (as long as it's possible because of size of grid) in the grid \n # If running on a UNIX system, we could use fork to improve the performance\n # Process.fork {\n @words.each{|dw| place dw if (dw.word != nil && dw.word.size <= @w )}\n # }\n # We return only the words that were found in the grid \n return @words.select{|w|w.place != nil} \n end",
"def translate(word)\r\n vowels = \"aeio\".split('').to_a\r\n consonant = \"bcdfghjklmnpqrstuvwxyz\".split('').to_a \r\n answer = []\r\n \r\n while word.split(' ').length == 1 \r\n words = word.split('')\r\n until vowels.include?(words[0])\r\n words = words.rotate(1)\r\n end\r\n words << \"ay\"\r\n return words.join('')\r\n end # one word ^^\r\n \r\n if word.split(' ').length > 1 \r\n words = word.split(' ')\r\n end \r\n words.each do |i|\r\n if vowels.include?(i[0])\r\n i << \"ay\"\r\n answer << i\r\n #return answer\r\n end\r\n end\r\n \r\n words.each do |j|\r\n if consonant.include?(j[0])\r\n j = j.split('').rotate(1).join('') until vowels.include?(j[0])\r\n j = j + \"ay\"\r\n #return j\r\n #j << j #correct format for 1 consonant but it doesnt add to array\r\n answer << j\r\n end\r\n end\r\n \r\n return answer.join(' ')\r\n end",
"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",
"def translate\n words\n words_array = []\n pig_latin_words_array = []\n @words_array.each do |word|\n if starts_with_vowel?(word)\n word += 'way'\n elsif !starts_with_vowel?(word[1..-1])\n word = word[2..-1] + word[0] + word[1] + 'ay'\n else\n word = word[1..-1] + word[0] + 'ay'\n end\n pig_latin_words_array << word\n end\n return pig_latin_words_array\n end",
"def possibilities(words)\n words.each do |word, translations|\n sorted = translations.sort\n words[word] = sorted.each_index.map {|i|\n sorted.combination(i+1).to_a\n }.flatten(1).sort\n end\nend",
"def solve\n end",
"def solve(from_word, to_word)\n return @word_graph.shortest_path(from_word, to_word)\n end",
"def solve(words, letters)\n hash = Hash.new(0)\n hash2 = Hash.new(0)\n letters.each_char do |char|\n hash[char] += 1\n end\n \n longest = 0\n \n words.each_with_index do |word, idx|\n word.each_char.with_index do |char, idx|\n if !hash[char] || hash[char] <= 0\n next\n end\n if hash[char] > 0\n hash[char] -= 1\n end\n end\n \n end\n return longest\nend",
"def translate(word)\n\n @word_to_translate = word.split(/ /)\n @whole_sentence = []\n @vowels = \"aeiouy\"\n @output = \"\"\n\n#Première boucle pour récupérer tous les mots dans un array\n @word_to_translate.each do |x|\n @whole_sentence << x\n end\n\n#Ensuite je boucle sur chaque mot de cet array\n#Et j'effectue des tests sur les premières lettres\n\n# Plusieurs cas\n# 1- le mot commence par une voyelle donc\n# on rajoute juste ay à la fin\n# 2 - La 1ère lettre est un Q suivi de U\n#2bis ou SQU alors je considère également le tout comme une consonne\n# 3 - Trois consonnes\n# 4 - Deux consonnes\n# 5 - Une consonne\n\n#C'est très compliqué pour rien\n#Il aurait mieux fallu faire des cas\n\n\n@whole_sentence.each do |word_to_translate|\n\n @first_char = word_to_translate[0]\n @second_char = word_to_translate[1]\n @third_char = word_to_translate[2]\n @text_length = word_to_translate.length\n @new_word = word_to_translate\n @qu = @first_char + @second_char + @third_char\n if @vowels.include?(@first_char)\n #Ici on commence par une voyelle\n\n elsif @qu.include?(\"qu\")\n @new_word[@text_length] = @first_char\n @new_word[@text_length+1] = @second_char\n\n @index = @new_word.index(\"q\")\n if @index >=1\n @new_word[@text_length+2] = @third_char\n @new_word = @new_word[@index+2..-1]\n else\n @new_word = @new_word[@index+2..-1]\n end\n\n\n elsif !(@vowels.include?(@first_char) || @vowels.include?(@second_char)|| @vowels.include?(@third_char))\n\n#Ici on commence par trois consonnes\n @new_word[@text_length] = @first_char\n @new_word[@text_length+1] = @second_char\n @new_word[@text_length+2] = @third_char\n @new_word = @new_word[3..-1]\n\n elsif !(@vowels.include?(@first_char) || @vowels.include?(@second_char))\n\n#Ici on commence par deux consonnes\n @new_word[@text_length] = @first_char\n @new_word[@text_length+1] = @second_char\n @new_word = @new_word[2..-1]\n\n\nelse\n @new_word[@text_length] = @first_char\n @new_word = @new_word[1..-1]\n #Ici on commence par une consonne\n\nend\n\n@new_word += \"ay\"\n@output += @new_word + \" \"\nend\n\nreturn @output.chomp(\" \")\n#return @index\nend",
"def correct(word)\n if (known([word]).count>0)\n return known([word])\n elsif (known(edits1(word)).count>0)\n return known(edits1(word))\n elsif (known_edits2(word).count>0)\n return known_edits2(word)\n else\n return nil\n end\n\n end",
"def edits1(word) \n deletes = [] \n #all strings obtained by deleting a letter (each letter) \n for i in 0..word.length-1\n\ttemp = word.dup\n\ttemp.slice!(i)\n\tdeletes.push(temp)\n end \n\n transposes = []\n #all strings obtained by switching two consecutive letters\n loop_count = word.length-2\n if loop_count > 0\n for i in 0..loop_count\n\ttemp = word.dup\n \ttemp[i+1] = word[i]\t\n\ttemp[i] = word[i+1]\n\ttransposes.push(temp)\n end\n end \n\n inserts = []\n # all strings obtained by inserting letters (all possible letters in all possible positions)\n for i in 0..word.length\n ALPHABET.each_char do |c|\n temp = word.dup\n temp = temp.insert(i,c)\n inserts.push(temp)\n end\n end\n\n replaces = []\n #all strings obtained by replacing letters (all possible letters in all possible positions)\n for i in 0..word.length-1\n ALPHABET.each_char do |c|\n temp = word.dup\n temp[i] = c\n replaces.push(temp)\n end\n end\n\n return (deletes + transposes + replaces + inserts).to_set.to_a #eliminate duplicates, then convert back to array\n end",
"def find_replacement_translations(locale, variant_words, translations)\n pp \"Processing #{locale} strings\"\n unchanged = []\n to_be_replaced = []\n variant_words.each do |dict|\n current = dict[:source]\n origin = dict[:origin]\n replacement = dict[:target]\n # keeping a tally of how many will not change due to both current\n # and replacement being the same\n if current == replacement\n unchanged << { current: current, replacement: replacement }\n next\n end\n if current == '--'\n t = translations.where('copy LIKE ?', \"%#{origin}%\")\n puts \"#{t.count} strings found in #{locale} for #{origin}\"\n else\n t = translations.where('copy LIKE ?', \"%#{current}%\")\n puts \"#{t.count} strings found in #{locale} for #{current}\"\n end\n # t = translations.where(source_copy: source)\n # count = t.count\n # t = t.concat(fuzzy_match)\n unless (t.nil? or t.empty?) && current[0] != replacement[0]\n # pp \"#{current[0]} matched #{replacement[0]}\"\n t.each do |row|\n # exact match with word boundaries around the word\n # this will prevent words being part of ids/classes\n # and it will also prevent words like \"Unenroll\"\n # it's looking for \"enroll\"\n unless row.copy.match(/#{current}\\b/)\n next\n end\n if current[0] == replacement[0]\n pp \"#{current} will be replaced with #{replacement}\"\n end\n rep = {\n locale: locale,\n source: row.source_copy,\n current: row.copy,\n replacement: row.copy && row.copy.gsub(current, replacement),\n id: row.id,\n word: replacement,\n }\n if rep[:current] != rep[:replacement]\n puts \"Current and replacmeent match: #{rep[:current]} == #{rep[:replacement]}\"\n begin\n if rep[:replacement].strip_html_tags == rep[:replacement]\n to_be_replaced << rep\n else\n pp \"Stripped #{rep[:replacement]} and didn't add to list\"\n end\n end\n end\n end\n end\n end\n puts \"Ignoring: #{unchanged.size} strings\"\n puts \"Changing: #{to_be_replaced.size} strings\"\n to_be_replaced\nend",
"def words\n words = @phrase.split(\" \")\n words.each do |word|\n translate(word)\n end\n end",
"def solve\n solution_candidate(intersections.next_people_with_similar_tastes)\n end",
"def make_word_from_board?(letters, word, i, j)\n matched_dices = []\n unmatched_dices = []\n letter_used = letters.map {|column| column.map { false }}\n letter_used[i][j] = true\n matched_dices.push([i, j])\n word_pos = 1\n while word_pos < word.size\n letter_matched = false\n # move a step next to the current letter to check if we can form the word\n (i-1..i+1).each do |m|\n # ignore if our matching window is outside the dices\n if m == -1 || m == letters.size\n next\n end\n (j-1..j+1).each do |n|\n # ignore if our matching window is outside the dices\n if n == -1 || n == letters[0].size\n next\n end\n # ignore for the central dice\n if m == i && n == j\n next\n end\n # ignore if letter at the position has already been used\n if letter_used[m][n]\n next\n end\n # skip if the dice is already unmatched\n if unmatched_dices.find{|dice| dice[0] == m && dice[1] == n}\n next\n end\n if letters[m][n] == word[word_pos]\n i = m\n j = n\n letter_matched = true\n letter_used[i][j] = true\n matched_dices.push([i, j])\n break\n end\n end\n if letter_matched\n word_pos += 1\n break\n end\n end\n unless letter_matched\n # return false when only a single letter is matching\n if word_pos == 1\n return false\n end\n word_pos -= 1\n # get the last matched dice\n i, j = matched_dices.pop\n letter_used[i][j] = false\n unmatched_dices.push([i, j])\n end\n end\n true\n end",
"def get_board(solution=false, title=\"Words to find\")\n result = \"\" ; i = 0\n sempty = ' '*(DISPLAY_COLUMNS*(MAXCHARACTERS+2))\n s = String.new(sempty)\n result << title << \":\\n\"\n\n @found_candidates.each_index do |idx|\n f = @found_candidates[idx] || solution\n s[i.modulo(DISPLAY_COLUMNS)*(MAXCHARACTERS+2)] = f ? \"[#{@candidates[idx]}]\" : \"[\"+(' '*@candidates[idx].length)+\"]\"\n if i.modulo(DISPLAY_COLUMNS) == DISPLAY_COLUMNS-1 then\n result << (s + \"\\n\")\n s = String.new(sempty)\n end\n i+=1\n end\n result << s if s.include?('[')\n result << \"\\n\"\n end",
"def translate(text)\n\nvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"] #create array of vowels\nwords = text.split(\" \") #create array of individual words from text \ntranslation = [] #create empty array to receive the individually translated words\n\n words.each do |word| #for each individual word in the array\n \n #create loop to continue while first letter is not a vowel.\n while vowels.include?(word[0].downcase) == false #check index 0 (first letter) in word is NOT a vowel\n \n if word[0..1] == \"qu\" #create exceptional case for 'qu'\n word = word [2..-1] + word[0..1] #splice the first two letters to the end of the word\n else\n word = word [1..-1] + word[0] #push the first letter in the word (index [0]) to the end of the array\n end \n \n end\n \n word = word + \"ay\"\n translation.push(word) #push the word to the end of the final array\n\n end\n \ntranslation.join(\" \")\n \nend",
"def translate s\n \n words = s.split.map{|word|\n if %w(a e i o u).include?(word[0])\n word << \"ay\"\n elsif %w(thr sch squ).include?(word[0..2])\n word[3..-1] << (word[0..2] << \"ay\")\n elsif %w(ch qu br th).include?(word[0..1])\n word[2..-1] << word[0..1] << \"ay\" \n else\n word[1..-1] << (word[0] << \"ay\") \n end\n }\n words.join(\" \")\n\nend",
"def translate(word)\n split_words = word.split(' ')\n words = []\n vowels = %w[a e i o u]\n split_words.each do |word|\n word = qu_in_word(word)\n if vowels.include?(word[0])\n words.push(word + 'ay')\n else\n count = 0\n word.length.times do |number|\n vowels.include?(word[number]) ? break : count += 1\n end\n words.push(word[count..-1] + word[0..(count - 1)] + 'ay')\n end\n end\n words.join(' ')\nend",
"def match_letters #handle_guess\n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = guess\n\t\tend\n\n\t\tputs @result_array\n\tend",
"def match_letters #handle_guess\n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = guess\n\t\tend\n\n\t\tputs @result_array\n\tend",
"def edits1(word)\n \n deletes = []\n i = 0\n while i < word.length\n deletes_word = word\n deletes << deletes_word.slice(0,i) + deletes_word.slice(i+1, word.length)\n i+=1\n end\n #all strings obtained by deleting a letter (each letter)\n transposes = []\n i = 0\n while i < word.length\n transpose_word = word\n letter_to_replace = transpose_word[i]\n\n transpose_word[i] = transpose_word[i-1]\n transpose_word[i-1] = letter_to_replace\n transposes << transpose_word\n\n transpose_word = word\n letter_to_replace = transpose_word[i]\n\n if(transpose_word[i+1] != nil)\n transpose_word[i] = transpose_word[i+1]\n transpose_word[i+1] = letter_to_replace\n transposes << transpose_word\n end\n\n i+=1\n end\n #all strings obtained by switching two consecutive letters\n inserts = []\n word\n inserts(word)\n\n # all strings obtained by inserting letters (all possible letters in all possible positions)\n replaces = []\n #all strings obtained by replacing letters (all possible letters in all possible positions)\n\n #return (deletes + transposes + replaces + inserts).to_set.to_a #eliminate duplicates, then convert back to array\n end",
"def find_potential_matches\n comp_words.each_with_object([]) do |comp_word, collection|\n next if comp_word == word\n\n tokenized_comp_word = tokenize_string(comp_word)\n common_token_count = (tokenized_word & tokenized_comp_word).count\n similarity = (2 * common_token_count) / (word.length + comp_word.length).to_f\n collection << comp_word if similarity > PRECISION\n end\n end",
"def solution\n solve unless solved?\n @solution\n end",
"def translate text\n split_arr = text.split(\" \")\n split_arr_trans = split_arr.map { |word| \n (@@found_dict.key? word) ? @@found_dict[word] : (@@found_dict[word]=process_word(word); @@found_dict[word])\n }\n return split_arr_trans.join(\" \")\n end",
"def find_words(lines, words, sec, point_map)\n found = {}\n max = @letters.length\n lines.each_with_index do |s, i|\n start = 0\n while start < 15\n pattern = ''\n match_regex = ''\n j = start\n while j <= 14 do\n break if s[j] == '!'\n #puts \"** #{i},#{j}\"\n match_regex << (s[j] == '?' ? \"(#{sec[i][j].keys.join('|')})\" : (s[j] == '*' ? '.' : s[j]))\n pattern << s[j]\n break if pattern.count(\".?\") >= max\n j += 1\n end\n if j && j < 14 && s[j] != '!' && words[i][j+1]\n pattern += words[i][j+1]\n match_regex += words[i][j+1]\n end\n\n\n #puts \"regex: #{match_regex}\"\n found.merge!(match(pattern, start, i, words[i], sec[i], point_map[i], match_regex)) unless pattern == ''\n\n if '.?!*'.include?(s[start])\n start += 1\n else\n start += words[i][start].length + 1\n end\n\n end\n end\n #puts \"found: #{found.inspect}\"\n found\n end",
"def existing_words\n draw_current = draw\n p \"The 7 letters drawn are:\"\n p draw_current\n p \"-\"*70\n\n combinations = combine(draw_current).flat_map{ |w| w.permutation.to_a}.uniq.map { |e| e.join }\n combinations.map{|i| search(i, UPPER_BOUND_INI, LOWER_BOUND_INI, NO_ITERATION_INI)}.flatten.reject{|x| x==nil}\nend",
"def translate string\n\n\t#This splits the string into an array of words\n\twords = string.split(\" \")\n\t\n\t#Goes through each word in array words\n\tfor i in 0...words.length\n\n\t\t#This splits each word into an array of characters\n\t\tcharacters = words[i].chars\n\n\t\t#If a word begins with a vowel, add \"ay\" to the end of the word\n\t\tif isVowel characters[0]\n\n\t\t\tcharacters.push(\"a\", \"y\")\n\t\t\twords[i] = characters.join(\"\")\n\n\t\t#If a word does not begin with a vowel...\n\t\telse\n\n\t\t\t#While the first character is not a vowel, move it to the back of the word\n\t\t\twhile !(isVowel characters[0])\n\n\t\t\t\t#If the first character is a \"q,\"\n\t\t\t\tif characters[0] == \"q\"\n\n\t\t\t\t\t#and the next character is a \"u,\" push both the \"qu\" to the end\n\t\t\t\t\tif characters[1] == \"u\"\n\n\t\t\t\t\t\tconsonant = characters.shift\n\t\t\t\t\t\tcharacters.push(consonant)\n\t\t\t\t\t\tu = characters.shift\n\t\t\t\t\t\tcharacters.push(u)\n\n\t\t\t\t\tend\n\n\t\t\t\t#Otherwise, just push the first letter to the end\n\t\t\t\telse\n\n\t\t\t\t\tconsonant = characters.shift\n\t\t\t\t\tcharacters.push(consonant)\n\n\t\t\t\tend\n\n\t\t\tend\n\n\t\t\t#Then add \"ay\" to the end of the word\n\t\t\tcharacters.push(\"a\", \"y\")\n\t\t\twords[i] = characters.join(\"\")\n\n\t\tend\n\t\t\n\tend\n\n\t#Joins together all the words with a space in between them and returns the modified string as an answer\n\tanswer = words.join(\" \")\n\treturn answer\n\nend",
"def find_solution(first_word, second_word)\n\tif first_word.length != second_word.length\n\t\treturn \"bad input, words must be the same length\"\n\tend\n\n\tcurrent_word = first_word\n\t$chain << first_word\n\n\twhile true\n\t\tpossible = words_1_letter_diff(current_word)\n\t\tpossible = possible - $seen\n\t\tif possible.include?(second_word)\n\t\t\treturn $chain << second_word\n\t\tend\n\n\t\tif possible != []\n\t\t\t$chain << possible.last\n\t\t\t$seen << possible.last\n\t\t\tcurrent_word = $chain.last\n\t\telse\n\t\t\tbacktrack()\n\t\t\tcurrent_word = $chain.last\n\t\tend\n\n\t\tif $chain == []\n\t\t\treturn \"impossible\"\n\t\tend\n\n\t\tif $chain.last == second_word\n\t\t\treturn $chain\n\t\tend\n\tend\nend",
"def solve!\n end",
"def unordered_match (target_word, matrix, ans_arr_el, index, track, trace)\t\n\tif index == 0 \n\t\t$seed[ans_arr_el[0][0]][:num_groups][ans_arr_el[0][1]].each do |word|\n\t\t\ttemp_word = track + word \n\t\t\tif(target_word == temp_word.chars.sort.join)\t\t\t\t\n\t\t\t\ttemp_answer = trace.dup\n\t\t\t\ttemp_answer.push(word)\n\t\t\t\t$answer[:words].push(temp_answer)\t\t\t\t\n\t\t\tend\n\t\tend\n\telsif index > 0\n\t\t$seed[ans_arr_el[index][0]][:num_groups][ans_arr_el[index][1]].each do |word|\n\t\t\tc = trace.dup\n\t\t\tc.push(word)\n\t\t\tunordered_match(target_word, matrix, ans_arr_el, index - 1, track + word, c)\t\t\t\t\t\t\n\t\tend\t\t\n\tend\t\nend",
"def run\n\n\tthreads = Array.new \t# a place to store threads\n\n\t# Use 4 threads when the word list is larger than 10\n\tnumber_of_threads = (@words_to_check.size < 10)? 1 : 4\n\t\n\t# Size of partisans \n\tpart = @words_to_check.size / number_of_threads\n\n\t# For each thread\n\tnumber_of_threads.times do |i|\n\n\t\t# Create a new Thread, add it to array\n\t\tthreads << Thread.new {\n\t\t\t\n\t\t\t# To make sure the partitioning is complete, calculate the upper bound\n\t\t\tif i == number_of_threads - 1\n\t\t\t\tlast = @words_to_check.size\n\t\t\telse\n\t\t\t\tlast = ((i+1) * part) - 1\n\t\t\tend\n\n\t\t\t# For each word in partitioned section of words to check\n\t\t\t@words_to_check[(i * part)..last].each do |word|\n\n\t\t\t\t# Retrieve the correct Hash for the corresponding word\n\t\t\t\tsection = (@dictionary[word[0]].nil?)? @dictionary['0'] : @dictionary[word[0]]\n\n\t\t\t\t# If direct match is found, return correct\n\t\t\t\tif section[word]\n\t\t\t\t\tputs \"CORRECT [#{word}]\"\n\t\t\t\t\n\t\t\t\t# Word is not a match\n\t\t\t\telse\n\t\t\t\t\tsuggestion = nil \t# initialize a suggestion\n\n\t\t\t\t\t# First try to find the fast solutions\n\t\t\t\t\t# For each word in the section, test for flipped, extra, and missing letters\n\t\t\t\t\tsection.each_key do |key|\n\n\t\t\t\t\t\tif flipped_letter(key, word)\n\t\t\t\t\t\t\tsuggestion = key\n\n\t\t\t\t\t\telsif extra_letter(key, word)\n\t\t\t\t\t\t\tsuggestion = key\n\n\t\t\t\t\t\telsif key.length > word.length # required comparison to avoid error\n\t\t\t\t\t\t\tsuggestion = key if missing_letter(key, word)\n\t\t\t\t\t\t\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\t# Still no suggestion found, resort to a more expensive route\n\t\t\t\t\tif suggestion.nil?\n\t\t\t\t\t\t\n\t\t\t\t\t\t# suggestion value works as a tolerance for an INCORRECT output\n\t\t\t\t\t\tsuggestion_value = 7\n\n\t\t\t\t\t\t# For each word in section\n\t\t\t\t\t\tsection.each_key do |key|\n\n\t\t\t\t\t\t\t# Get the defect count\n\t\t\t\t\t\t\tcount = defect_count(key, word)\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t# if the defect count is better, add a suggestion and associated cost\n\t\t\t\t\t\t\tif count < suggestion_value\n\n\t\t\t\t\t\t\t\tsuggestion_value = count\n\t\t\t\t\t\t\t\tsuggestion = key\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\t# No suggestion can be made\n\t\t\t\t\tif suggestion.nil?\n\t\t\t\t\t\tputs \"INCORRECT [#{word}]\"\n\t\t\t\t\t\n\t\t\t\t\t# Else, output the suggestion\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"#{suggestion} suggested for [#{word}]\"\n\t\t\t\t\t\t\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t}\n\tend\n\n\t# Run the Thread(s)\n\tthreads.each {|t| t.join}\t\nend",
"def translate(str)\n\n\n\n # Vowels to consider\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n \n # Special cases to consider\n two_letter_consonants = [\"ch\", \"sh\", \"qu\", \"th\", \"br\"]\n three_letter_consonants = [\"thr\", \"sch\", \"squ\"]\n\n words = str.split(\" \")\n result = []\n\n words.each do |word|\n if vowels.include?(word[0])\n result.push word << \"ay\"\n else \n if three_letter_consonants.include? (word[0] + word[1] + word[2])\n first_three_letters = word.slice!(0,3)\n \n # Add letters to end of word with 'ay'\n result.push word << first_three_letters << 'ay'\n elsif two_letter_consonants.include?(word[0] + word[1])\n first_two_letters = word.slice!(0,2)\n result.push word << first_two_letters << \"ay\"\n else \n first_letter = word.slice!(0)\n \n # Add first letter to end of word with 'ay'\n result.push word << first_letter << 'ay'\n end #End of special consonant check\n end \n end \n return result.join(\" \")\nend",
"def match_letters \n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = @guess\n\t\tend\n\tend",
"def solve(puzzle = @puzzle)\n #make sure we have unknown spaces\n puts \"SOLVE CALLED\"\n puzzle.propogate_constraints\n puts puzzle.present\n if puzzle.solved?\n puts \"SOLVED\"\n return puzzle\n elsif puzzle.invalid?\n puts \"INVALID\"\n return false\n else\n puts \"PUZZLE NOT SOLVED AND PUZZLE NOT INVALID\"\n new_copy = copy(puzzle)\n puts new_copy.present\n\n unknown = new_copy.spaces.select { |space| !space.known? }\n space_to_guess = unknown.sort { |a, b| a.possibilities.size <=> b.possibilities.size } [0]\n puts \"#{space_to_guess}\"\n guess = space_to_guess.possibilities.to_a[0]\n puts \"Assigning #{guess} to #{space_to_guess.coords}\"\n new_copy.assign(space_to_guess, guess)\n puts new_copy.present\n if(solve(new_copy))\n return new_copy\n else\n puts \"eliminating #{guess} from #{space_to_guess.coords}\"\n puzzle.eliminate(puzzle.get_space(space_to_guess.coords), guess)\n puzzle.propogate_constraints\n solve(puzzle)\n end\n end\n end",
"def translate words\n\tarray = words.split \n\ti = 0\n\ttotal = \"\"\n\twhile i < array.length\n\t\tstring = array[i]\n\t\tif string[0] =~ /[aeiou]/\n\t\t\tresult = string + \"ay\"\n\t\telse\n\t\t\tletters = \"\"\n\t\t\tcounter = 0\n\t\t\tnumberConsanants = 0\n\t\t\twhile counter < string.length\n\t\t\t\tif string[counter] =~ /[aeiou]/\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tletters = letters + string[counter]\n\t\t\t\t\tif string[counter] == 'q' && string[counter+1] == 'u'\n\t\t\t\t\t\tletters = letters + 'u'\n\t\t\t\t\t\tnumberConsanants = numberConsanants + 1\n\t\t\t\t\tend\n\t\t\t\t\tnumberConsanants = numberConsanants + 1\n\t\t\t\tend\n\t\t\t\tcounter = counter + 1\n\t\t\tend\n\t\t\tresult = string.slice(numberConsanants, string.length) + letters + \"ay\"\n\t\tend\n\t\ttotal = total + result\n\t\tif i != array.length - 1\n\t\t\ttotal = total + \" \"\n\t\tend\n\t\ti = i + 1\n\tend\n\ttotal\nend",
"def edits1(word)\n deletes = []\n letters = word.split(\"\")\n letters.each do |c|\n word2 = word\n deletes.push(word2.delete(c))\n end\n\n transposes = []\n for i in 0..word.length-1\n letters = word.split(\"\")\n letters2 = letters\n letters2.insert(i+1 , letters2.delete_at(i))\n transposes.push(letters2.join())\n end\n\n inserts = []\n ALPHABET.split(\"\").each do |c|\n for i in 0..word.length\n letters = word.split(\"\")\n letters2 = letters\n letters2.insert(i,c)\n inserts.push(letters2.join())\n end\n end\n\n replaces = []\n ALPHABET.split(\"\").each do |c|\n\tfor i in 0..word.length-1\n letters = word.split(\"\")\n letters2 = letters\n letters2.delete_at(i)\n letters2.insert(i,c)\n replaces.push(letters2.join())\n end\n end\n\n return (deletes + transposes + replaces + inserts).to_set.to_a #eliminate duplicates, then convert back to array\n end",
"def solution\n answer = self.clone.solve\n answer.nil? ? nil : answer.grid.map {|row| row.map {|cell| cell.first}}\n end",
"def guess(word_pattern, possible_words)\n all_words = possible_words.flatten\n guess = $avail_letters.sort_by {|c|\n all_words.select{|w|w.index c}.length}.last\n $avail_letters -= [guess]\n $guess = guess\nend",
"def find_word(letters, unused, mask, target_word, idx, adj_matrix)\n 0.upto mask.length do |letter_idx|\n if (mask[letter_idx] and\n unused[letter_idx] and\n (letters[letter_idx] == target_word[idx]))\n if idx == target_word.length - 1\n return true\n else\n unused[letter_idx] = false\n return find_word(letters, unused, adj_matrix[letter_idx],\n target_word, idx + 1, adj_matrix)\n end\n end\n end\n return false\nend",
"def translate(phrase)\n #split phrase into words\n word_array = phrase.split ' '\n #to_pig each word\n answer_array = word_array.map {|word| to_pig(word)}\n #join words back together\n answer = answer_array.join ' '\nend",
"def translate(a)\n\tvoyel = [\"a\",\"e\",\"i\",\"o\",\"u\"]\ncheck = 0\nn = 0\nx = a \n words = a.split(/\\W+/)\n words.each do |a|\n\tok = voyel.include?(a[0])\n\tif ok == true \n\t\ta = a + \"ay\"\n\t\treturn a \n\tend\n while check <= 4\n\tb = a.slice(0..check)\n\n\tcheck = check + 1\n \n\tok = voyel.include?(x[check])\n\ttest1 = \"qu\".include?(x[check])\n\tif test1 == true \n\t\tif check == 1\n\t\t\tb = a.slice(0..check)\n\t\t\ta = a + b + \"ay\"\n\t\treturn a[2..-1]\n\t elsif check == 2\n\t \tb = a.slice(1..check)\n\t \t\ta = a + b + \"ay\"\n\t \treturn a[3..-1]\n\t elsif check == 3 \n\t \t\ta = a + b + \"ay\"\n\t \treturn a[4..-1]\n\t end\n\tend\n\n\tif ok == true \n\t\tif check == 1\n\t\t\ta = a + b + \"ay\"\n\t\treturn a[1..-1]\n\t elsif check == 2\n\t \t\ta = a + b + \"ay\"\n\t \treturn a[2..-1]\n\t elsif check == 3 \n\t \t\ta = a + b + \"ay\"\n\t \treturn a[3..-1]\n\t end\n\tend\nend\nend\nend",
"def translate_word word\n # Don't translate short words\n return word if word.size == 1\n\n # Handle specific words\n dictionary = {\n 'AWESOME' => 'ERSUM',\n 'BANANA' => 'BERNERNER',\n 'BAYOU' => 'BERU',\n 'FAVORITE' => 'FRAVRIT',\n 'FAVOURITE' => 'FRAVRIT',\n 'GOOSEBUMPS' => 'GERSBERMS',\n 'LONG' => 'LERNG',\n 'MY' => 'MAH',\n 'THE' => 'DA',\n 'THEY' => 'DEY',\n 'WE\\'RE' => 'WER',\n 'YOU' => 'U',\n 'YOU\\'RE' => 'YER',\n\n 'awesome' => 'ersum',\n 'banana' => 'bernerner',\n 'bayou' => 'beru',\n 'favorite' => 'fravrit',\n 'favourite' => 'fravrit',\n 'goosebumps' => 'gersberms',\n 'long' => 'lerng',\n 'my' => 'mah',\n 'the' => 'da',\n 'they' => 'dey',\n 'we\\'re' => 'wer',\n 'you' => 'u',\n 'you\\'re' => 'yer',\n\n 'Awesome' => 'Ersum',\n 'Banana' => 'Bernerner',\n 'Bayou' => 'Beru',\n 'Favorite' => 'Fravrit',\n 'Favourite' => 'Fravrit',\n 'Goosebumps' => 'Gersberms',\n 'Long' => 'Lerng',\n 'My' => 'Mah',\n 'The' => 'Da',\n 'They' => 'Dey',\n 'We\\'re' => 'Wer',\n 'You' => 'U',\n 'You\\'re' => 'Yer',\n }\n\n return dictionary[word] if dictionary.key? word\n \n # Before translating, keep a reference of the original word\n original_word = \"\"\n original_word << word\n\n word.upcase!\n\n # Drop vowel from end of words. Keep it for short words, like \"WE\"\n word.sub!(/[AEIOU]$/, '') if original_word.size > 2\n\n # Reduce duplicate letters\n word.gsub!(/[^\\w]|(.)(?=\\1)/, '')\n\n # Reduce adjacent vowels to one\n word.gsub!(/[AEIOUY]{2,}/, 'E') # TODO: Keep Y as first letter\n\n # DOWN -> DERN\n word.gsub!(/OW/, 'ER')\n\n # PANCAKES -> PERNKERKS\n word.gsub!(/AKES/, 'ERKS')\n\n # The mean and potatoes: replace vowels with ER\n word.gsub!(/[AEIOUY]/, 'ER') # TODO: Keep Y as first letter\n\n # OH -> ER\n word.gsub!(/ERH/, 'ER')\n\n #MY -> MAH\n word.gsub!(/MER/, 'MAH')\n\n #FALLING -> FERLIN\n word.gsub!('ERNG', 'IN')\n\n #POOPED -> PERPERD -> PERPED\n word.gsub!('ERPERD', 'ERPED')\n\n #MEME -> MAHM -> MERM\n word.gsub!('MAHM', 'MERM')\n\n # Keep Y as first character\n # YES -> ERS -> YERS\n word = 'Y' + word if original_word[0] == 'Y'\n\n # Reduce duplicate letters\n word.gsub!(/[^\\w]|(.)(?=\\1)/, '')\n\n # YELLOW -> YERLER -> YERLO\n if original_word.end_with?('LOW') && word.end_with?('LER')\n word.sub!(/LER$/, 'LO')\n end\n\n # Resolve case\n return word.downcase if original_word[0] >= 'a' and original_word[0] <= 'z' and original_word[-1] >= 'a' and original_word[-1] <= 'z'\n return word[0] + word[1..-1].downcase if original_word[0] >= 'A' and original_word[0] <= 'Z' and original_word[-1] >= 'a' and original_word[-1] <= 'z'\n\n return word\n\nend",
"def main()\n rules = { # a/bc/bcd/bcdd/bcda/bcdbc/bcbc/cbc/aa/\n 'abcd' => [''],\n 'a' => ['bc'],\n 'bc' => ['bcd', 'c'],\n 'd' => ['a', 'db'],\n 'db' => ['b'],\n 'cbc' => ['ab'],\n '...' => ['a']\n }\n rows= [\n 'bd',\n ]\n moves = 10\n width = 7\n solver = Solver.new(rules, moves, width)\n game_data = GameState.new(rules, rows[0], width)\n solution = solver.find_solution(game_data)\n\n if !solution.nil?\n solution.each do |move|\n puts(move.to_s)\n end\n else\n puts 'No solution found'\n end\nend",
"def hack(words)\n candidates = words.clone\n word_to_guess = candidates.pop\n\n while !candidates.empty?\n puts \"Try the word: #{word_to_guess}\"\n puts \"What was the likeness?\"\n\n key_likeness = gets.to_i\n if key_likeness == word_to_guess.length\n puts \"Nicee hackeeer!!\"\n break\n end\n\n words.each do |word|\n next if !candidates.include?(word)\n\n likeness = get_likeness(word_to_guess, word)\n\n if key_likeness == 0\n candidates -= [word] if likeness > 0\n else\n candidates -= [word] if likeness < key_likeness\n end\n end\n\n puts \"Candidates left: #{candidates.join(', ')}\"\n word_to_guess = candidates.pop\n end\nend",
"def get_words(text) #no!, two methods named get_words, see word_search.rb\n \twords = text.split('')\n \twords.each do |word|\n \t\t#how to check if word is correct or not?\n \t\tWord.new(name: word, ngsl: false, list: self.id )\n \t\t# example = Wordnik.word.get_top_example(word)['text']\n \tend\n end",
"def verify_word_on_board(w, hash_table)\n w = w.upcase # Since the letters on board is in capital letter\n\n p hash_table\n i = 0\n searched_index = {} # Hash table to keep track what has been searched\n (0...w.length).each { |i| searched_index.store(i, -1)} # Initiate values to indicate that no letters have been searched\n\n while i >= 0 && i < w.length\n # puts \"\\nStart of while loop, i = #{i}, searching letter #{w[i]}...\" ###\n move = false\n\n unless hash_table[w[i]].empty?\n # print \"Letter #{w[i]} exist at #{hash_table[w[i]]}\\n\" ###\n hash_table[w[i]].each_with_index do | value , index |\n # puts \"Scanning through #{w[i]} at position #{value}\" ###\n \n # This unmark the position that was used previously during backtracking.\n if value + @total_letters < 0\n # puts \"Position #{hash_table[w[i]][index]} of #{w[i]} is restored...\" ###\n hash_table[w[i]][index] += (@total_letters * 2)\n # puts \"Position of #{w[i]} is now #{hash_table[w[i]][index]}.\" ###\n end\n\n if index <= searched_index[i] # This skips letters that are already searched\n # puts \"#{w[i]} at #{hash_table[w[i]][index]} is already searched.\" ###\n next\n end\n\n if value >= 0\n \n # The position is subtrated by no of total letters to indicate that it has been searched.\n # No of total letters is used so that duplicate of hash table is not required.\n \n if i == 0 || is_adjacent(hash_table[w[i]][index],(@total_letters + hash_table[w[i-1]][searched_index[i-1]]))\n hash_table[w[i]][index] -= @total_letters\n # puts \"#{value} has been subracted by @total_letters to #{hash_table[w[i]][index]}\" ###\n \n \n searched_index[i] = index\n # puts \"Moving to next letter, searched_index[#{i}] now has been updated to #{searched_index[i]}\" ###\n move = true\n i += 1\n break\n end\n\n end\n end\n\n end\n\n # i -= 1 if move == false\n if move == false\n if i > 0\n # puts \"Previously used #{w[i-1]} position of #{hash_table[w[i-1]][searched_index[i-1]]} is being marked for restoration.\" ###\n \n hash_table[w[i-1]][searched_index[i-1]] -= @total_letters # To mark position to be restored to original value as it will not be used anymore\n # puts \"Current position of #{w[i-1]} is #{hash_table[w[i-1]][searched_index[i-1]]}.\" ###\n searched_index[i] = -1\n end\n\n\n # puts \"Letter #{w[i]} is not available/not adjacent and i will be subtracted\" ###\n i -= 1\n end\n\n end\n\n # Restore back all coordinates for next word\n\n\n restore_hash_table(hash_table)\n\n # Check whether word exists.\n if i >= 0 \n puts \"#{w} exists!\"\n return true\n else\n puts \"#{w} is not available.\"\n return false\n end\n \n end",
"def word_map(lines)\n words = []\n lines.each_with_index do |s, i|\n words[i] = []\n start = -1\n word = ''\n in_word = false\n (s + '|').each_char.each_with_index do |c, j|\n if in_word\n if '.?!*|'.include?(c)\n words[i][start] = word\n words[i][j-1] = word\n in_word = false\n else\n word << c\n end\n else\n unless '.?!*|'.include?(c)\n in_word = true\n word = c\n start = j\n end\n end\n end\n end\n words\n end",
"def find_solution_dynamic\n if @game_data.solved?\n update_best_maybe(nil)\n return\n end\n\n prev_move_num = @visited[@game_data.cur_row]\n if !prev_move_num.nil? && (prev_move_num <= @move_number)\n return\n end\n\n @visited[@game_data.cur_row] = @move_number\n\n moves = @game_data.possible_plays\n moves.each do |move|\n next unless @game_data.make_move(move)\n\n raw_pat, raw_repl = @game_data.get_raw_rule_and_repl_for_move(move)\n cur_pos = @game_data.cur_row.dup\n if raw_pat.include?('.')\n # replace the replaced chars with the raw (wildcard) pattern\n # this makes it able to hook into the set of pre-computed positions.\n cur_pos[move[GS_PLAY_IDX]...raw_repl.size] = raw_pat\n end\n\n # did our two solver techniques connect? (Brute force ran into a\n # pre-populated static answer if 'pos' exists)\n pos = @positions[cur_pos]\n unless pos.nil?\n # Success! Limited brute force search with wildcards was able to\n # find a solution in the precomputed set of positions!\n # DON'T BREAK because the first found solution may not be the best.\n update_best_maybe(pos)\n end\n\n @move_number += 1\n find_solution_dynamic\n @move_number -= 1\n @game_data.undo_move\n end\n nil\n end",
"def guess(word_pattern, possible_words)\r\n all_words = possible_words.flatten\r\n guess = $avail_letters.sort_by {|c|\r\n all_words.select{|w|w.index c}.length}.last\r\n $avail_letters -= [guess]\r\n $guess = guess\r\nend",
"def solve\n BruteForceSolver.new(self).solve\n end",
"def solve\n\t\t\n\t\tcell_index = 0\n\t\t# move to the right position..\n\t\t# puts @unsolved.length.to_s + \" unknown cells!\"\n\n\t\twhile cell_index >= 0 && cell_index < @unsolved.length do\n\t\t\tcell = @unsolved[cell_index];\n\t\t\t\n\t\t\tpossible = cell.nextPossible()\t\n\n\t\t\tif possible > 9 || possible <= 0\n\t\t\t\tcell.set(0)\n\t\t\t\tcell_index -= 1\n\t\t\telse\n\t\t\t\tcell.set(possible)\n\t\t\t\tcell_index += 1\n\t\t\tend\t\t\t\t\t\t\t\n\t\tend\n\n\t\tif cell_index < 0\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend",
"def translate(sentence)\r\n words = sentence.split(\" \")\r\n words.collect! do |a|\r\n if(a =~ /\\w\\.\\.\\.\\w/) #matching e.g \"yes...no\"\r\n morewords = a.split(\"...\")\r\n ##\r\n #alternative: allows for recursion, but loses accuracy since \"a...b\" becomes \"a ... b\"\r\n #probably some non-messy way to make it work, and be less redundant too\r\n #\r\n #morewords.insert(1, \"...\")\r\n #translate(morewords.join(\" \"))\r\n pig(morewords[0], 1) + \"...\" + pig(morewords[1], 1)\r\n elsif(a =~ /\\w\\W\\w/ and !(a =~ /'/)) #matching e.g. \"steins;gate\", \"ninety-nine\", but not \"it's\"\r\n nonletter = a.scan(/\\W/)[0]\r\n morewords = a.split(/\\W/)\r\n #morewords.insert(1, nonletter)\r\n #translate(morewords.join(\" \"))\r\n pig(morewords[0], 1) + nonletter + pig(morewords[1], 1)\r\n elsif(a[0..1].match(/qu/)) #quiet = ietquay\r\n pig(a, 2)\r\n elsif(a[0..2].match(/sch|.qu/)) #school = oolschay, square = aresquay\r\n pig(a, 3)\r\n else\r\n x = a.index(/[AaEeIiOoUu]/) #starts with other consonant(s) or a vowel; find the first vowel\r\n if(!(x.nil?)) #found at least one vowel\r\n pig(a, x) \r\n else #x is nil, no vowels found\r\n a.index(/[[:alpha:]]/) ? pig(a, 1) : a #if it contains letters, attempt to process; otherwise, do nothing\r\n end\r\n end\r\n end\r\n return words.join(\" \")\r\nend",
"def solve!\n solve\n self\n end",
"def string_matching(words)\n result_words = []\n\n words.each_with_index do |possible_substring, index|\n (0..words.size - 1).each do |index_w|\n next if index_w == index || words[index_w].size < possible_substring.size\n \n result_words << possible_substring if words[index_w].index(possible_substring)\n end\n end\n \n result_words.uniq\nend",
"def translate_word(word)\n split_array = split_into_array(word)\n rotated_array = rotate_at_vindex(split_array)\n ay_array = add_ay(rotated_array)\n final_array = back_to_s(ay_array)\nend",
"def translate(your_string)\n words = your_string.split(/\\s+/)\n vowels = %w{a e i o u}\n th_ch = %q{th ch sh sc qu }\n three_letter = %q{sch}\n translated_words=[]\n words.each do |word|\n letters = word.scan(/\\w/)\n word_length = letters.length\n \n if vowels.include?(letters[0])\n #word begins with a vowel\n word += \"ay\"\n \n elsif th_ch.include?(letters[0]+letters[1]) && !vowels.include?(letters[2])\n # word begins with three consonants\n word = (letters[3..word_length-1]<<letters[0]<<letters[1]<<letters[2]).join.to_s+\"ay\"\n \n elsif th_ch.include?(letters[0]+letters[1]) && vowels.include?(letters[2])\n #word begins with two defined consonants followed by a vowel\n word = (letters[2..word_length-1]<<letters[0]<<letters[1]).join.to_s+\"ay\"\n \n elsif (letters[1]+letters[2]) == \"qu\"\n # word starts with a <consonant + \"qu\">\n word = (letters[3..word_length-1]<<letters[0]<<letters[1]<<letters[2]).join.to_s+\"ay\"\n \n elsif !vowels.include?(letters[0]) && !vowels.include?(letters[1])\n #word begins with two not_defined consonants followed by a vowel\n word = (letters[2..word_length-1]<<letters[0]<<letters[1]).join.to_s+\"ay\"\n \n else\n # only one consonant begins the word\n word = (letters[1..word_length-1]<<letters[0]).join.to_s+\"ay\"\n end\n translated_words << word\n end\n translated_words.join(\" \").to_s\nend",
"def translate(arr)\n vowels = %w{a e i o u y}\n consonants = %w{b c d f g h j k l m n p q r s t v w x y z}\n\n a = arr.split.map do |word| \n if vowels.include?(word[0])\n word + \"ay\"\n elsif word[0..1] == \"qu\"\n word[2..-1] + \"quay\"\n elsif word[0..2] == \"sch\"\n word[3..-1] + \"schay\"\n elsif word[0..2] == \"squ\"\n word[3..-1] + \"squay\"\n elsif consonants.include?(word[0]) && consonants.include?(word[1]) && consonants.include?(word[2])\n word[3..-1] + word[0..2] + \"ay\"\n elsif consonants.include?(word[0]) && consonants.include?(word[1])\n word[2..-1] + word[0..1] + \"ay\"\n elsif consonants.include?(word[0])\n word[1..-1] + word[0] + \"ay\"\n end\n end\n\n a.join(\" \")\nend",
"def solution(sentence)\n return sentence.split.reverse.join(\" \")\nend",
"def neighbors_by_substitution(word)\n word.split_around_each_char.lazy\n .flat_map do |prefix, char_to_substitute, suffix|\n get(prefix).lazy\n .reject do |substitution_possibility, _|\n substitution_possibility == char_to_substitute\n end\n .select do |_, substitution_possibility_subtree|\n # I'd usually use #try here but the instructions specify that I\n # can't include ant ActiveSupport functions.\n substitution_possibility_subtree &&\n substitution_possibility_subtree.contains?(suffix)\n end\n .map do |substitution_possibility, _|\n prefix + substitution_possibility + suffix\n end\n end\n end",
"def input_evaluation(guess, correct_word)\n if correct_word.word.include?(guess)\n # We learned that .each_with_index can be used to locate each letter corresponding with each spacific index\n # Then if the letter matches it will subsitue the \"_\", at the correct index, with the corresponding letter\n correct_word.word.each_with_index do |letter, index|\n if letter == guess\n correct_word.progress[index] = guess\n end\n end\n else\n # Storing wrong letters into an array and updating max_guesses\n correct_word.wrong_guesses << guess\n correct_word.max_guesses -= 3\n end\nend",
"def match(array_possible_anagrams)\n matching_words=[]\n word_broken=self.word.split(\"\").sort\n array_possible_anagrams.each do |possible_match|\n #possible_match=possible.word\n possible_match_broken=possible_match.split(\"\").sort\n if possible_match_broken == word_broken\n matching_words << possible_match\n else\n end #end of if\n end #end of do\n matching_words\n end",
"def analogy(a, b, c, word_to_id, id_to_word, word_matrix, top: 5, answer: nil)\n all_found = true\n [a, b, c].each do |word|\n unless word_to_id.include?(word)\n puts(\"#{word} not found.\")\n all_found = false\n end\n end\n\n return unless all_found\n\n puts(\"\\n[analogy] #{a}:#{b} = #{c}:?\")\n a_vec = word_matrix[word_to_id[a], true]\n b_vec = word_matrix[word_to_id[b], true]\n c_vec = word_matrix[word_to_id[c], true]\n query_vec = b_vec - a_vec + c_vec\n query_vec = normalize(query_vec)\n\n similarity = word_matrix.dot(query_vec).to_a\n\n if answer\n puts(\"===>#{answer}:#{word_matrix[word_to_id[answer]].dot(query_vec)}\")\n end\n\n count = 0\n\n sorted_indexes = similarity.map.with_index.sort.map(&:last).reverse\n\n sorted_indexes.each do |i|\n # TODO: Deal with NaNs\n next if [a, b, c].include?(id_to_word[i])\n\n puts(\" #{id_to_word[i]}: #{similarity[i]}\")\n\n count += 1\n break if count >= top\n end\nend",
"def solve(board_string)\n board_array = []\n separated_board_string = board_string.split('')\n board_array << (separated_board_string[0..8])\n board_array << (separated_board_string[9..17])\n board_array << (separated_board_string[18..26])\n board_array << (separated_board_string[27..35])\n board_array << (separated_board_string[36..44])\n board_array << (separated_board_string[45..53])\n board_array << (separated_board_string[54..62])\n board_array << (separated_board_string[63..71])\n board_array << (separated_board_string[72..80])\n board_array\n\n# temp_array = board_array.join\n# while board_array.include?(\"-\")\n 50.times { sudoku_solver(board_array) }\n # end\n board_array\nend",
"def translated_words\n translated_words_list = []\n\n words.each do |word|\n translation_for_this_word = TranslatedWord.find_by_word_id(word.id)\n\n if translation_for_this_word.nil?\n translated_words_list << word.text # the original word text\n else\n translated_words_list << translation_for_this_word.translation\n end\n end\n\n translated_words_list\n end",
"def translate code, translation = \"\"\n\n # recursion base case:\n #\n # return an array containing the translation if the code has\n # a size of 0\n return [translation.downcase] if code.size.zero?\n\n words = []\n\n # check all possible matches to the code\n LETTERS.each do |letter|\n if code[letter.pattern]\n\n # recurse on untranslated portion of the code\n # and new translation\n # add results to our array at this level of recursion\n words += translate code.sub(letter.pattern,''),translation+letter.letter\n end\n end\n\n return words\n\nend",
"def get_words\n @sentences.each_index do |i|\n s = @sentences[i]\n words = s.split(' ')\n words.each do |w|\n word = w.gsub(WORD_SANITIZE, '').downcase\n if belongs_to_known_abbreviations? word\n add_word_to_result(word, i)\n else\n add_word_to_result(word.gsub(DOT_SANITIZE, ''), i)\n end\n end\n end\n end",
"def translate(string)\n newArr = []\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n \n # * Split it into words\n words = string.split()\n\n # * For every word in the sentence...\n words.each do |word|\n # * If the word has 'qu'\n if word[1..2].downcase == \"qu\"\n newArr << word[3..-1] + word[0..2] + \"ay\"\n\n elsif word[0..1].downcase == \"qu\"\n newArr << word[2..-1] + word[0..1] + \"ay\"\n\n # * If it starts with a vowel\n elsif vowels.include?(word[0].downcase)\n newArr << word + \"ay\"\n\n # * If the first three consonants aren't vowels\n elsif not vowels.include?(word[0].downcase) and not vowels.include?(word[1]) and not vowels.include?(word[2])\n newArr << word[3..-1] + word[0..2] + \"ay\" \n # * ...or if the first two consonants aren't vowels\n elsif not vowels.include?(word[0].downcase) and not vowels.include?(word[1])\n newArr << word[2..-1] + word[0..1] + \"ay\" \n \n # * After all that, if it starts with one consonant\n else\n newArr << word[1..-1] + word[0] + \"ay\"\n end\n end\n\n newArr.join(\" \")\nend",
"def make_word_candidates\n while @e <= l \n @word = str[@s..@e]#.join\n end\n end",
"def translate\n @new_phrase = []\n words\n @phrase.each do |word|\n @new_phrase << changer(word)\n end\n end",
"def translate word\n\n\tsplit = word.split(\" \")\n\tlatin = \"\"\n\tvowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\t\n\n\n\tsplit.each do |string|\n\n\t\ta = 0\n\t\tconsts = 0\n\n\t\twhile vowels.include?(string[a]) === false\n\t\t\tconsts = consts + 1\n\t\t\ta = a + 1\n\t\tend\n\n\t\tif string[consts -1] === \"q\"\n\t\t\tif string[consts] === \"u\"\n\t\t\t\tconsts = consts + 1\n\t\t\tend\n\t\tend\n\n\t\tb = string[0, consts]\n\n\t\t\n\t\tif consts === 1\n\t\t\tlatin = latin + string[consts, string.length-1] + string[0] + \"ay\"\n\t\telsif\tconsts > 1\n\t\t\tlatin = latin + string[consts, string.length-1] + b + \"ay\"\n\t\telse\n\t\t\tlatin = latin + string + \"ay\"\n\t\tend\n\n\tlatin = latin + \" \"\n\n\tend\n\n\tlatin.strip\n\t\nend",
"def good_guess(pattern)\n merge(pattern)\n @dictionary.keep_only_words_that_match(@solution)\n @possible_letters.delete(letter_in(pattern))\n end",
"def solution(sentence)\n sentence.split.reverse.join(\" \")\nend",
"def translate(word)\n if starts_with_vowel?(word) == true\n @translated_phrase << (word + \"way\")\n elsif consonant_letter?(word) == true\n letter = word.split('')\n letters = []\n @count.times do\n letters << letter.shift\n end\n new_word = letters.join('') + \"ay\"\n @translated_phrase << (letter.join('') + new_word)\n end\n end",
"def optimal_words_back(current, target)\n output = []\n (1..short_word_len(current, target)+1).each do |index|\n next if current[-index] == target[-index]\n test_word = current.clone\n test_word[-index] = target[-index]\n output << test_word if legal_word?(test_word)\n end\n output\nend",
"def CompareWords(codeWord, guess, contains, hit, used)\n array = Array.new\n letters = \"abcdefghijklmnopqrstuvwxyz\"\n (0..4).each do |i| # Iterates through 5 times, once for each letter of the words\n if (guess[i] == codeWord[i]) # Checks if the string in guess \n array[i] = \" Hit\"\n hit[i] = guess[i]\n if(contains.include?(guess[i]) == false)\n contains[' '] = guess[i]\n end\n if(used.include?(guess[i]) == false)\n index = letters.index(guess[i])\n used[index] = guess[i]\n end\n elsif (codeWord.include?(guess[i])) # Checks if \"codeWord\" includes the letter\n array[i] = \"Near\"\n if(contains.include?(guess[i]) == false)\n contains[' '] = guess[i]\n end\n if(used.include?(guess[i]) == false)\n index = letters.index(guess[i])\n used[index] = guess[i]\n end\n else\n array[i] = \"Miss\"\n if(used.include?(guess[i]) == false)\n index = letters.index(guess[i])\n used[index] = guess[i]\n end\n end\n end\n return array, contains, hit, used # Returns an array contains 5 values of \" Hit\", \"Near\", \"Miss\" or any combination of the three\nend",
"def fulltextsearch(query, text, words=2)\n result = \"\"\n if text =~ /.*#{query}.*/i\n text_words = text.scan(/\\w*/)\n indexes = []\n text_words.each_with_index do |word,index|\n if word =~ /.*#{query}.*/i\n i = []\n i << index - words unless words == 0 || index - words < 0\n i << index\n i << index + words unless words == 0 || index + words > text_words.length\n indexes << i\n end\n end\n indexes.each do |i|\n result += \"... \" unless i.length == 1\n i.each {|j| result += \"#{text_words[j]} \"}\n result += \" ...\" unless i.length == 1\n end\n end\n result\n end",
"def get_all_matched_words(combination, dictionary)\n all_matched_words = []\n combination.map { |pattern| all_matched_words.push(find_matches(pattern, dictionary)) unless pattern.empty? }\n all_matched_words\n end",
"def _moves(yes_words, maybe_words)\n\n # Avoid variable scope problems\n maybe_words = maybe_words.dup\n\n # COMPUTE yes_words_sum\n yes_words_sum = \"\"; yes_words.each{|word| yes_words_sum += word}\n\n # how close are we to reaching the size limit?\n free_size = self.max_word_size - yes_words_sum.size\n\n # delete the maybe_words that won't fit inside that space.\n # THIS IS THE HEART OF MAX_WORD_SIZE OPTIMIZATION!\n maybe_words.delete_if { |word| word.size > free_size }\n\n # Base case: no maybe_words\n if (maybe_words.size == 0) then\n if yes_words.size > 1 then\n #puts \"Considering #{yes_words.inspect}\"\n valid_moves = @data[yes_words_sum.lsort]\n if (valid_moves) then\n return valid_moves.collect{|word| [word,yes_words]}\n end\n end\n return [] \n end\n\n # Recursive case: call two copies of _moves\n\n moves = []\n\n first_maybe_word = maybe_words.shift # changes maybe_words!\n\n # Case 1: Find moves that don't contain the first maybe word\n moves += _moves(yes_words, maybe_words)\n\n # Case 2: Find moves that contain the first maybe words\n moves += _moves(yes_words+[first_maybe_word], maybe_words)\n\n return moves\n end",
"def check_parallel player, board, word_list\n\t\t\tbest = [ScrabbleWord.new('',0,0,0,0), 0]\n\t\t\twords = DICTIONARY.get_all(player.tiles)\n\t\t\tword_list.each do |played_word|\n\t\t\t\twords.each do |new_word|\n\t\t\t\t\tif played_word.dir == :across\n\t\t\t\t\t\trow_1 = played_word.row-1\n\t\t\t\t\t\trow_2 = played_word.row+1\n\t\t\t\t\t\tcol_1 = played_word.col - new_word.length + 1\n\t\t\t\t\t\tcol_1 = col_1 >= 0 ? col_1 : 0\n\t\t\t\t\t\tcol_2 = played_word.length + 2*new_word.length - 2\n\t\t\t\t\t\tcol_2 = (0..14).cover?(col_2) ? col_2 : 14\n\t\t\t\t\t\tcol_1.upto(col_2) do |col|\n\t\t\t\t\t\t\tbest = parallel_helper(new_word, board, row_1, row_2, col, col, :across, best)\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tcol_1 = played_word.col-1\n\t\t\t\t\t\tcol_2 = played_word.col+1\n\t\t\t\t\t\trow_1 = played_word.row - new_word.length + 1\n\t\t\t\t\t\trow_1 = row_1 >= 0 ? row_1 : 0\n\t\t\t\t\t\trow_2 = played_word.length + 2*new_word.length - 2\n\t\t\t\t\t\trow_2 = (0..14).cover?(row_2) ? row_2 : 14\n\t\t\t\t\t\trow_1.upto(row_2) do |row|\n\t\t\t\t\t\t\tbest = parallel_helper(new_word, board, row, row, col_1, col_2, :down, best)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tbest\n\t\tend",
"def computing_patterns words\n PATTERNS.map do |pattern|\n index = 0\n is_blank = true\n pattern.each do |element|\n break if (is_blank = words[\"#{index}_#{index + element - 1}\"].empty?)\n index += element\n end\n if !is_blank\n computing_combinations(pattern, words)\n end\n end.compact\n end",
"def words\n @words ||= (\n word_suggestions = []\n spellcheck = self.response[:spellcheck]\n if spellcheck && spellcheck[:suggestions]\n suggestions = spellcheck[:suggestions]\n unless suggestions.nil?\n # suggestions is an array: \n # (query term)\n # (hash of term info and term suggestion) \n # ...\n # (query term)\n # (hash of term info and term suggestion) \n # 'correctlySpelled'\n # true/false\n # collation\n # (suggestion for collation)\n i_stop = suggestions.index(\"correctlySpelled\")\n # step through array in 2s to get info for each term\n 0.step(i_stop-1, 2) do |i| \n term = suggestions[i]\n term_info = suggestions[i+1]\n # term_info is a hash:\n # numFound =>\n # startOffset =>\n # endOffset =>\n # origFreq =>\n # suggestion => { frequency =>, word => }\n origFreq = term_info['origFreq']\n suggFreq = term_info['suggestion']['frequency'] \n word_suggestions << term_info['suggestion']['word'] if suggFreq > origFreq\n end\n end\n end\n word_suggestions.uniq\n )\n end",
"def solve(notes)\n ############################################\n # Preprocessing\n notes = uniq(notes).sort.select{|n| !n.is_rest?}\n return [[]] if notes.length == 0\n raise ArgumentError, \"There are more unique notes than strings!\" if notes.length > @guitar.nstrings\n # Separate the notes to be solved into two categories: open notes vs non-open notes\n open_notes = notes.select{|note| @open_notes.key?(note.val)}\n non_open_notes = notes.select{|note| !@open_notes.key?(note.val)}.sort\n\n # If there are zero non-open notes, then all the notes can be played with no fingers.\n return [open_notes.map{|note| [note.name, @open_notes[note.val].first, 0]}] if non_open_notes.length == 0\n\n # Note we can arbitrarily choose any note as our point of reference for spatial locality for a given string.\n # However, notes that can utilize open strings may reduce cost but negatively affect the premise of spatial locality of note-string assignment.\n # Therefore, use lowest note that cannot be an open string note to preserve spatial locality.\n # With this, there is no need to choose between an open string or non-open string for a potential open string note.\n base_note = non_open_notes.first\n base_note_task = notes.each_with_index.select{|n,i| n == base_note}.first[1]\n note_offsets = notes.map{|note| note.num_steps_from(base_note)}\n\n # Initialize basic cost matrix\n cost_matrix = init_cost_matrix(notes)\n\n if !AssignmentSolver::solvable?(cost_matrix)\n warn [notes.join(\",\"), \"is unsolvable\"].join(\" \")\n return []\n end\n \n ############################################\n # String-Note Optimal Assignment\n # Use as many strings needed from highest (right) to lowest (left)\n solutions = Set.new\n ([email protected]).to_a.reverse.each {|from|\n used_strings = @sorted_tuning[[email protected]]\n string_offsets = @offsets_grid[from][[email protected]]\n # Grab the submatrix of partially filled cost_matrix\n base = ([email protected]).map{|r|\n cost_matrix[r]\n }\n \n # Fill in the nil elements of the submatrix with relative offsets\n layer = string_offsets.map{|s_offset| note_offsets.map{|n_offset| (n_offset - s_offset)}}\n layer_abs = layer.map{|row| row.map{|e| e.abs}}\n\n # Relative positions\n relative_pos = overlay(base, layer)\n # Euclidean distance conversion\n costs = overlay(base, layer_abs)\n costs = Matrix.new(costs, used_strings, notes)\n \n # Compute best assignment solution\n solver = HungarianSolver.new(costs)\n solution = solver.run()\n next if solution.length == 0\n\n # Find the offset on the string being used as a point of reference for the base_note\n base_str, note_idx = solution.select{|w,t| t == base_note_task}.first\n base_note_offset = base_note.num_steps_from(used_strings[base_str])\n\n # Adjust relative offsets to center around the designated base note position.\n adjustment = layer[base_str][note_idx] * -1\n layer.each{|row| row.map!{|e| e += adjustment}}\n\n solution = solution.select{|w,t| layer[w][t]}.map{|w,t|\n relative_offset = layer[w][t]\n # Check if this is an open string note\n offset_from_capo = if base[w][t] == 0\n # Open note string since base element is 0\n 0\n else\n # Compute offset from capo for this string\n base_note_offset + relative_offset\n end\n [used_strings[w].name, from+w, offset_from_capo]\n }\n solutions << solution\n }\n\n return solutions.to_a\n end"
] | [
"0.7192096",
"0.64427555",
"0.643621",
"0.62722427",
"0.6263551",
"0.6248918",
"0.613598",
"0.6079689",
"0.60723",
"0.6040596",
"0.60265505",
"0.59671587",
"0.5939894",
"0.5883247",
"0.5874109",
"0.58453125",
"0.5811993",
"0.5783038",
"0.57828397",
"0.5780384",
"0.5756658",
"0.5728658",
"0.5722488",
"0.5704966",
"0.5701275",
"0.5690113",
"0.5670067",
"0.5659236",
"0.5643697",
"0.5631496",
"0.5624081",
"0.5623165",
"0.56205744",
"0.5600921",
"0.5593379",
"0.55842626",
"0.55805546",
"0.55805546",
"0.557107",
"0.5560326",
"0.55486846",
"0.5545528",
"0.55439365",
"0.55432856",
"0.55376285",
"0.55371845",
"0.5523859",
"0.5506725",
"0.5495051",
"0.5488798",
"0.548564",
"0.54853624",
"0.5485072",
"0.54587144",
"0.54518485",
"0.54504067",
"0.544296",
"0.5441084",
"0.5437874",
"0.54260314",
"0.54254985",
"0.5420613",
"0.5419487",
"0.5416659",
"0.5411478",
"0.54002416",
"0.53992313",
"0.53989804",
"0.53878474",
"0.5385379",
"0.53758323",
"0.53738403",
"0.5371188",
"0.5362298",
"0.53614974",
"0.53565407",
"0.53446484",
"0.53374267",
"0.53348494",
"0.5313323",
"0.5309706",
"0.53090715",
"0.53053886",
"0.5299952",
"0.529946",
"0.5296385",
"0.5290641",
"0.5281349",
"0.52789646",
"0.52776766",
"0.52769184",
"0.52720606",
"0.5271928",
"0.52687526",
"0.5253608",
"0.5253071",
"0.52494127",
"0.52478594",
"0.52472717",
"0.52388996"
] | 0.72635674 | 0 |
word_search.normalize Undiagonalizing is somewhat tricky, as we need to recover its original (or transposed) shape. Set the internal state of this object for suitable shape information. Also, (un)diagonalizing will be screwed up if this shape is not a nice, full rectangle. Pad it if necessary. And, clear out the solution array (and give it the same shape). | def normalize
@height = @text_lines.size
@width = 0
@sltn_lines = [ ]
@text_lines.each do |line|
len = line.length
@width = len if (len > @width)
@sltn_lines << '+' * len
end
(0...@text_lines.size).each do |i|
no_pad_chars = @width - @text_lines[i].length
1.upto(no_pad_chars) do
@text_lines[i] << '+'
@sltn_lines[i] << '+'
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize\n resize(1.0)\n end",
"def normalize!\n self.replace self.normalize\n end",
"def undiagonalize(transposed)\n text_lines = @text_lines\n @text_lines = Array.new(transposed ? @width : @height) { String.new }\n sltn_lines = @sltn_lines\n @sltn_lines = Array.new(transposed ? @width : @height) { String.new }\n text_lines.each_with_index do |line, i|\n if (transposed)\n o = (i + 1 < @height)? 0 : i + 1 - @height\n else\n o = (i + 1 < @width)? 0 : i + 1 - @width\n end\n line.split('').each_with_index do |char, j|\n @text_lines[j+o] << char\n @sltn_lines[j+o] << sltn_lines[i][j]\n end\n end\n end",
"def normalized!\n self\n end",
"def unnormalized; end",
"def normalize!\n spaces = plain.map { |line| ' ' * (max_width - line.length) }\n self.class.new zip(spaces).map(&:join), max_width\n end",
"def normalize; self.dup.normalize!; end",
"def normalize\n self.dup.normalize!()\n end",
"def normalize!\n end",
"def normalize!; end",
"def normalize\n self.dup.normalize!\n end",
"def normalize\n self.dup.normalize!\n end",
"def normalize!\n normalize self\n end",
"def normalize\n\t\t\tself.dup.normalize!\n\t\tend",
"def normalize!\n self.length = 1.0\n self\n end",
"def normalized_words\n self.split(/\\s+/).map { |word|\n Iconv.iconv('ascii//translit//ignore', 'utf-8', word).first.downcase.gsub(/\\W/,'')\n }.\n delete_if(&:empty?).\n map { |word|\n \"**#{word}\"\n }\n end",
"def find_words(words)\n @words = words.map { |w| MatrixWord.new(w) }\n @words.each { |mw| place mw if (!mw.word.nil? && mw.word.size <= @width) }\n @words.select { |w| !w.place.nil? }\n end",
"def normalize!\n end",
"def normalize\n\t\t\treturn self.dup.normalize!\n\t\tend",
"def pre_normalize(text); end",
"def normalize; end",
"def diagonalize\n text_lines = @text_lines ; @text_lines = [ ]\n sltn_lines = @sltn_lines ; @sltn_lines = [ ]\n text_lines.each_with_index do |line, i|\n line.split('').each_with_index do |char, j|\n (@text_lines[i+j] ||= '') << char\n (@sltn_lines[i+j] ||= '') << sltn_lines[i][j]\n end\n end\n end",
"def normalize!\n nil\n end",
"def normalize_whitespace!\n @raw.gsub!(/\\s+/, ' ')\n end",
"def normalized; end",
"def normalize(body)\n lines = body.split(\"\\n\")\n width = lines.first.length\n number_of_syms_to_wrap = (Dimensions::WIDTH - width) / 2\n syms_string = Citizen::DEAD * number_of_syms_to_wrap\n horiz_wrapped = lines.map { |line| syms_string + line + syms_string }\n\n matrix = horiz_wrapped.map { |row| row.split(\"\") }\n height = matrix.size\n\n number_of_row_wraps = (Dimensions::HEIGHT - height) / 2\n dead_row = (Citizen::DEAD * Dimensions::WIDTH).split(\"\")\n number_of_row_wraps.times do\n matrix = [dead_row] + matrix + [dead_row]\n end\n matrix.map(&:join).join(\"\\n\")\n end",
"def normalize\n self / self.norm\n end",
"def normalize!\n reverse! if !normal?\n end",
"def singular(word)\n if result = singular_of[word]\n return result.dup\n end\n result = word.dup\n regex, hash = singularization_rules\n result.sub!(regex) {|m| hash[m]}\n singular_of[word] = result\n return result\n end",
"def normalize\n end",
"def if_dangler_situation\n if(@i == @len) && !valid_word?(@prefix)\n @last_word_index = @words.keys.sort.last\n @words.delete(@last_word_index)\n end\n end",
"def normalize!; length = 1.0; self; end",
"def normalize_matrix(matrix)\n matrix_width = 0\n\n matrix.each do |line|\n matrix_width = line.length if line.length > matrix_width\n end\n\n matrix.each do |line|\n if line.length < matrix_width\n line[line.length, matrix_width - line.length] = '.'\n end\n end\nend",
"def normalize!\n\t\t\tmag = self.mag\n\t\t\t@elements = @elements.collect {|elem| elem / mag }\n\t\t\treturn self\n\t\tend",
"def normalize_whitespace(input); end",
"def normalize1(text, analyzer = nil)\n\t\tEntry.normalize(text, normalizer1, analyzer)\n\tend",
"def normalize!\n normalize\n save\n end",
"def normalize!\n normalize\n save\n end",
"def normalizer; end",
"def normalize_text(text)\n letters = text.upcase.split ''\n letters.delete_if { |x| ! @table[0].include?(x) }\n letters.join ''\n end",
"def singularize\n self[-1] == 's'[0] ? self[0,self.length-1] : self.dup\n end",
"def normalize\n replace(Rope.new(*flat_strings.reject(&:empty?)))\n end",
"def normalize_boundaries\n unless empty?\n self.explicit_boundaries = explicit_boundaries.uniq.sort\n end\n explicit_boundaries\n end",
"def normalize_spacing(text)\n text\n .delete(REMOVED_CHARACTERS)\n .tr(SQUEEZED_SPACES, ' ')\n .squeeze(' ')\n .sub(LEADING_SPACES, '')\n .sub(TRAILING_SPACES, '')\n .tr(NON_BREAKING_SPACE, ' ')\n end",
"def normalize!\n\t\t\tmagnitude = self.mag\n\t\t\[email protected]! {|elem| elem / magnitude}\n\t\t\treturn self\n\t\tend",
"def solve(*words)\n words = words.collect { |word| word.upcase_trim }\n\n #\n # Make the various transformations, checking for matches along the\n # way.\n #\n normalize ; replicate_match(words) # match L->R\n flip_horizontal ; replicate_match(words) # match R->L\n diagonalize ; replicate_match(words) # match TL->BR\n flip_horizontal ; replicate_match(words) # match BR->TL\n undiagonalize(true) ; replicate_match(words) # match T->B\n flip_horizontal ; replicate_match(words) # match B->T\n flip_vertical ; flip_horizontal\n diagonalize ; replicate_match(words) # match BL->TR\n flip_horizontal ; replicate_match(words) # match TR->BL\n undiagonalize(false)\n\n #\n # And return the solution.\n #\n @sltn_lines\n end",
"def normalize(word)\n UnicodeUtils.downcase(word.strip)\n end",
"def normalize2(text, analyzer = nil)\n\t\tEntry.normalize(text, normalizer2, analyzer)\n\tend",
"def redesign\n x = @mat[0].length\n y = @mat.size\n (1..y-2).each do |i|\n (1..x-2).each do |j|\n @mat[i][j] = \"0\"\n end\n end\n\n divide(1,x-2,1,y-2)\n end",
"def horizontal_words\n word_vectors = []\n \n @grid.each_with_index do |line, index|\n words = discover_words(line)\n words.each do |word|\n #Set the direction as 'discover_words' is direction agnostic\n word.direction = :horizontal\n word.y_pos = index\n end\n word_vectors << words\n end\n \n word_vectors.flatten\n end",
"def morphword\n input.morphword\n end",
"def clean_up_input(word, start_position, direction)\n position_array = []\n if start_position.length > 2\n letter = start_position[2]\n position_array[0] = start_position[0,2]\n else\n letter = start_position[1]\n position_array[0] = start_position[0]\n end\n\n case letter #start_position[1]\n when \"A\"\n position_array[1] = \"0\"\n when \"B\"\n position_array[1] = \"1\"\n when \"C\"\n position_array[1] = \"2\"\n when \"D\"\n position_array[1] = \"3\"\n when \"E\"\n position_array[1] = \"4\"\n when \"F\"\n position_array[1] = \"5\"\n when \"G\"\n position_array[1] = \"6\"\n when \"H\"\n position_array[1] = \"7\"\n when \"I\"\n position_array[1] = \"8\"\n when \"J\"\n position_array[1] = \"9\"\n when \"K\"\n position_array[1] = \"10\"\n when \"L\"\n position_array[1] = \"11\"\n when \"M\"\n position_array[1] = \"12\"\n when \"N\"\n position_array[1] = \"13\"\n when \"O\"\n position_array[1] = \"14\"\n end\n\n\n v = position_array[0].to_i\n h = position_array[1].to_i\n\n word = word.upcase #changes all letters to uppercase\n direction = direction.downcase\n\n return [word, v, h]\n end",
"def clean_phrase\n clean_phrase = @phrase.dup\n clean_phrase.downcase!\n clean_phrase.squeeze!\n clean_phrase.gsub!(/[[:space:]]/, '')\n clean_phrase = clean_phrase.split(//)\n end",
"def solve(dictionary)\n\t\n\t\tunique_word_lengths = (@@word_lengths).uniq\n\t\tunique_word_lengths.sort!\n\t\t\n\t\ti = 1\n\t\t\n\t\tunique_word_lengths.each { |len|\n\t\t\n\t\t\tputs \"\\nSearching for words of length \" << unique_word_lengths[i-1].to_s << \"...\"\n\t\t\t\n\t\t\tconstruct_word(\"\", len, dictionary)\n\t\t\t\n\t\t\ti = i + 1\n\t\t\t\n\t\t}\n\t\t\n\tend",
"def singularize(word)\n result = word.to_s.dup\n\n if inflections.uncountables.any? { |inflection| result =~ /\\b(#{inflection})\\Z/i }\n result\n else\n inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n result\n end\n end",
"def normalize()\n merge(normalize: 'true')\n end",
"def normalize\n self.clean_extra_spaces.split.map{|w| w.size>2 ? w.capitalize : w.downcase}.join(' ')\n end",
"def singularize(word)\n result = word.to_s.dup\n\n if inflections.uncountables.any? { |inflection| result =~ /#{inflection}\\Z/i }\n result\n else\n inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }\n result\n end\n end",
"def tighten_search_area\n @search_cols = search_image.columns - template_image.columns\n @search_rows = search_image.rows - template_image.rows\n end",
"def reanalyze_words(morpheme_hypotheses)\n # Create a table of morpheme hypotheses indexed by word.\n word_table = {}\n morpheme_hypotheses.each do |hyp|\n # TODO Check for overlapping morpheme ranges with asserts.\n if not word_table.has_key?(hyp.original_word)\n word_table[hyp.original_word] = []\n end\n word_table[hyp.original_word] <<= hyp\n end\n # Insert the new morphemes into the phonetic components of the original\n # words.\n changed_word_indexes = []\n word_table.each do |word, hyps|\n # Don't insert a morpheme at the same location more than once.\n hyps.uniq!\n # Sort the morphemes in reverse order. That way inserting the first\n # one doesn't change the offsets of the subsequent ones.\n hyps = hyps.sort_by {|hyp| -hyp.original_word_offsets[0] }\n # Insert the new morphemes into the specified positions in the words'\n # phonetic components. Make the changes to the word stored in this\n # analysis' word list so that we may maintain multiple independent\n # analyses.\n hyps.each do |hyp|\n source_index, dest_index = @alignment_table.indexes[hyp.alignment]\n word_index = case hyp.word\n when :source\n source_index\n when :dest\n dest_index\n else\n raise RuntimeError.new(\"Invalid word value #{word}\")\n end\n original_word = word_list[word_index]\n from, to = hyp.original_word_offsets\n LOGGER.debug(\"Insert #{hyp.morpheme} into \" +\n \"#{original_word.transcription}[#{from}..#{to}]\")\n original_word.phonetic_component[from..to] = hyp.morpheme\n changed_word_indexes << word_index\n end\n end\n # Delete alignments involving words that changed.\n changed_word_indexes.uniq!\n changed_word_indexes.each { |index| @alignment_table.delete(index) }\n # Rerun alignments for the words that changed.\n changed_word_indexes.each do |word_index|\n # The alignments are done so that source words always have larger\n # indexes than dest words.\n 0.upto(word_index - 1) do |dest_index|\n source_word = self[word_index]\n dest_word = self[dest_index]\n alignment = Alignment.new(source_word, dest_word)\n @alignment_table.add(alignment, word_index, dest_index)\n end\n (word_index + 1).upto(word_list.length - 1) do |source_index|\n source_word = self[source_index]\n dest_word = self[word_index]\n alignment = Alignment.new(source_word, dest_word)\n @alignment_table.add(alignment, source_index, word_index)\n end\n end\n end",
"def normalize\n x_alize(true)\n end",
"def diagonalize floor = 0\n raise 'err: not 2d' unless self[0].class == Array\n size = self.length + self[0].length - 1\n array = Array.new(size) {Array.new}\n # acquire top and main diagonal\n self.length.times do |row|\n (0 .. row).each do |col|\n array[row] << self[row-col][col]\n end\n end\n # now cover the additional bottom diagonals\n sides_difference = self.length[0] - self.length\n if sides_difference == 0\n (1 .. self.length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self.length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self.length - 1 + row] = temp_arr\n end\n else\n (1 .. self[0].length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self[0].length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self[0].length - 2 + row] = temp_arr\n end\n end\n\n # phew... now to trim and format\n unless floor == 0\n index = 0\n while index < size\n if array[index].length < floor\n array.slice! index\n size -= 1\n index -= 1\n end\n index += 1\n end\n end\n\n (0..size-1).each do |index|\n while array[index].length < self.length\n array[index] << nil\n end\n end\n array\n end",
"def normalize(text)\n text.downcase.split(\"\").map! {|i| i if ('a'..'z').include?(i) || i == \" \"}.join.split(\" \")\nend",
"def apply_solution array\n\n # Reverse the String to iterate right to left JUST because is easier :P\n index = find_small_neighbors array.reverse!\n \n return \"no answer\" unless index\n\n # Find rightmost successor to pivot in the suffix\n sec_index = array.index(array.slice(0..index).select{ |num| num > array[index] }.sort.first)\n # Swap with pivot\n array[index], array[sec_index] = array[sec_index], array[index]\n\n # Reverse the suffix REVERT rathern than sort\n solution = array.slice!(0..index-1).sort.join.reverse\n solution << array.join\n return solution.reverse\nend",
"def normalize_phrase phrase\n\t\tphrase.to_s.downcase\n\tend",
"def show_blanks\n\t\t@result_array = \"_\"*@word_array.length\n\t\tputs @result_array\n\tend",
"def show_blanks\n\t\t@result_array = \"_\"*@word_array.length\n\t\tputs @result_array\n\tend",
"def norm w\n 0.5 * Math.sqrt(w.keys.inject(0.0) {|u,k| u += w[k] ** 2.0})\nend",
"def reciprocalize\n Dimensions.new(self.to_hash).reciprocalize!\n end",
"def morph_words\n words = @query.split(/[^a-zA-Z0-9]/)\n morphed_words = words.map{|word| [word,Text::Metaphone.double_metaphone(word)]}\n morphed_words\n end",
"def normalize(word)\n return word.downcase.split(//).sort.to_s\nend",
"def normalize_whitespace(input)\n input.to_s.gsub(%r!\\s+!, \" \").tap(&:strip!)\n end",
"def normalize_whitespace(string)\n # in most cases there is nothing to do, then leave immediately\n return string unless string.match(/\\s\"\\s/)\n\n scanner = StringScanner.new(string)\n reset_direct_speech_status\n string_with_normalized_whitespace(scanner)\n end",
"def normalize\n divide(magnitude)\n end",
"def analyze phrase\n\t\t@meaningful_words = meaningful_words(phrase, \" \")\n\tend",
"def unnormalized\n document.record_entity_expansion unless document.nil?\n v = value()\n return nil if v.nil?\n @unnormalized = Text::unnormalize(v, parent)\n @unnormalized\n end",
"def word_mesh(arr)\n \"\".tap do |m|\n arr.each_cons(2) do |a,b|\n until a.end_with?(b)\n b = b.chop\n return \"failed to mesh\" if b.empty?\n end\n m << b\n end\n end\nend",
"def transposed_search_vector\n @transposed_search_vector ||= super\n end",
"def normalize(domain); end",
"def dup\n copy = Word.new(@system)\n # Make local references to reduce number of method calls\n c_input = copy.input\n c_output = copy.output\n c_io_corr = copy.io_corr\n # dup the morphological word for the copy's input and output\n unless input.morphword.nil?\n c_morphword = input.morphword.dup\n c_input.morphword = c_morphword\n c_output.morphword = c_morphword\n end\n # Make copies of the old input's elements, creating a map from each\n # old element to its copy.\n input_dup_map = {}\n input.each { |old| input_dup_map[old] = old.dup }\n # Fill the copy input with copies of the input elements, and fill the\n # copy's UI correspondence using the copy input elements.\n input.each do |old_in_el|\n new_in_el = input_dup_map[old_in_el]\n c_input << new_in_el # add the element copy to the input copy\n under_el = ui_under_corr(old_in_el) # UF correspondent\n c_input.ui_corr.add_corr(under_el, new_in_el) unless under_el.nil?\n end\n # Fill the copy output with copies of the output elements, and fill the\n # copy's IO correspondence using the copy input and output elements.\n output.each do |old_out_el|\n new_out_el = old_out_el.dup # duplicate the old output element\n c_output << new_out_el # add the element copy to the output copy\n old_in_el = io_in_corr(old_out_el) # old input correspondent\n unless old_in_el.nil?\n new_in_el = input_dup_map[old_in_el]\n c_io_corr.add_corr(new_in_el, new_out_el)\n end\n end\n copy.eval # set the constraint violations\n copy\n end",
"def normalize(string); end",
"def normalize(incoming_str)\n if normalizer\n return normalizer.call(incoming_str)\n end\n\n str = incoming_str\n str = str.downcase\n str = str.gsub(/[^a-z0-9]/, \" \")\n # squish whitespace\n str = str.gsub(/\\s+/, \" \").strip\n str\n end",
"def word_unscrambler(arr, word)\n \n # get a helper function anangram or not\n \n # fileter out diff lengths\n same_length = arr.select{|dict_word| dict_word.length == word.length}\n \n matches = same_length.select{|string| anagram?(string, word)}\n \n matches\n \n #filter out non anagram words\n \n #\n\nend",
"def normalize\n\t\t@grammar_string.each_index do |i|\n\t\t\ttemp = @grammar_string[i]\n\t\t\tif temp.empty?\n\t\t\t\t@grammar_string[i] = nil\n\t\t\telsif temp[0] == \"#\"\n\t\t\t\t#continue \n\t\t\t\tnext\n\t\t\telsif temp[0] == \"|\"\n\t\t\t\tlast = i\n\t\t\t\tbegin\n\t\t\t\t\tlast -= 1\n\t\t\t\tend while @grammar_string[last].nil?\n\n\t\t\t\t@grammar_string[last] += \" #{temp}\"\n\t\t\t\t@grammar_string[i] = nil\n\t\t\tend\n\t\tend\n\n\t\t@grammar_string.compact!\n\tend",
"def remove_w_words(sentence)\n \nend",
"def normalize(tag)\n prenormalized = prenormalize(tag)\n @extra_normalizer ? @extra_normalizer.call(prenormalized) : prenormalized\n end",
"def normalize(x)\n if x.ndim == 2\n s = Numo::SFloat::Math.sqrt((x**2).sum(axis: 1))\n x / s.reshape(s.shape[0], 1)\n elsif x.ndim == 1\n s = Numo::SFloat::Math.sqrt((x**2).sum)\n x / s\n end\nend",
"def set_masked_word(master_word)\n \n counter = 0 # This counter is used for the each loop Used Locally!\n \n @randomWordArray = @master_word.scan(/./) # split the random word so each letter is in its own spot in an array\n # .scan is slightly faster than .split, but both do the same thing\n \n @masterWordArray = @master_word.scan(/./) # masterWordArray holds the split up word but in an array with no _\n \n # The .each method is tailor made for arrays. When an array is made and the .each method is used the each loop \n # automatically walks through each item in the array performing commands between cycles\n # Every time the loop passes through the array the current item is assigned the letter variable\n # and then the current letter is replaced by an underscore\n @randomWordArray.each do |letter|\n @randomWordArray[counter] = \"_ \" #ex: prints \"_ _ _ _ _ \" assigns _ in place of a letter\n #print randomWordArray\n counter += 1 # increments the counter to move to the next spot in the array\n end\t# end each loop\n \n # This statement takes @random_word that we split up and joins the array back into one string\n @masked_word = @randomWordArray.join(\"\")\n\n\t\n end",
"def normalize! page\n mediawiki = text page\n html = text_wikimedia_html page\n norm_mediawiki = normalize_text mediawiki, html, page\n if mediawiki != norm_mediawiki\n write! page, norm_mediawiki\n else\n pp %Q{normalize! page #{page} already normalized}\n end\n norm_mediawiki\n end",
"def normalized\n @original.downcase\n end",
"def normalize search\n if search.is_a? Search\n search\n else\n Search.new :query => search\n end\n end",
"def neutralize(sentence)\n words = sentence.split(' ')\n words.each_with_index do |word, index|\n p index\n p word\n p words\n words.delete(word) if negative?(word)\n p words\n end\n\n words.join(' ')\nend",
"def word_break(s, word_dict)\n wb = Array.new(s.size + 1) { false }\n wb[0] = true\n 0.upto(s.size - 1).each { |i|\n next if !wb[i]\n 1.upto(s.size - i).each { |j|\n next if wb[i + j]\n wb[i + j] = word_dict.include?(s[i, j])\n }\n }\n\n wb[s.size]\nend",
"def solver (seed_char, blanks_words_sizes, matrix)\n\t# Set numerical target\n\ttarget = magic_num(seed_char)\t\n\t# Find magic number sum buckets\n\tskynet(target, blanks_words_sizes, blanks_words_sizes.length - 1, 0, [])\n\t# Alphabetical sort input matrix\n\tsorted_seed_char = seed_char.chars.sort.join\t\n\n\t# Find unique sets from skynet solutions\n\t$answer[:trace].each do |arrOarr|\n\t\tarrOarr.sort!\n\tend \n\n\t$answer[:trace].uniq!\t\n\t\n\t# Finds match for complete set of words from skynet solutions\n\t$answer[:trace].each do |answer_arr_el|\t\t\t\t\n\t\tunordered_match(sorted_seed_char, matrix, answer_arr_el, answer_arr_el.length - 1, \"\", [])\n\t\t# Can be ignored\n\t\t$ops += $seed[answer_arr_el[0][0]][:num_groups][answer_arr_el[0][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length\t\t\n\tend\n\t\n\treturn $answer[:words]\nend",
"def normalize\n puts \"[debug] [normalize] node weight: #{@weight.class}\"\n if @is_leaf == 1\n @@validations.each do |validation|\n puts \"[debug] [normalize] current validation: |#{validation[0].class}|#{validation[1]}|#{validation[2]}|\"\n if (validation[0]...validation[1]) === @weight\n puts \"Bang!\"\n @weight=validation[2]\n break\n end\n end\n 1\n else\n 0\n end\n end",
"def normalize(data)\n normalize_players data\n normalize_board data\n normalize_deals data\n data\n end",
"def untrain(words)\n decreases = @categories.filter(@name).eject(words)\n @size -= decreases[@name]\n end",
"def diagonal_search \n diagonal = []\n diagonal_words = []\n search = @@boards_templates[1].to_s.scan(/./).each_slice(5).to_a\n for ca in 2..7 \n down = ca \n for row in 0..ca\n if row <= 4 \n diagonal << search[down][row]\n down -= 1 \n end \n end \n end\n diagonal = diagonal.join \n @@boards_templates[0].each { |x| diagonal.include?(x) ? diagonal_words << x : diagonal_words.reverse.include?(x) ? diagonal_words << x : \"No hay palabras en dirección diagonal\" }\n #diagonal_words \n end",
"def normalize_whitespace(text)\n text.to_s.gsub(/[[:space:]]+/, ' ').strip\n end",
"def build_hierarchy\n root = LetterNode.new(nil)\n\n # TODO: Limit word table to 50,000 highest ranking words\n\n words.each do |word|\n wl = root\n word.spelling.each_char do |letter|\n wl = wl.add(letter, word.count)\n end\n wl.word!(word.count)\n end\n\n root\n end"
] | [
"0.54442054",
"0.52825314",
"0.5265053",
"0.5262985",
"0.52268296",
"0.5157169",
"0.5111925",
"0.5092437",
"0.5038435",
"0.50008994",
"0.49940658",
"0.49940658",
"0.49826562",
"0.49511987",
"0.49263614",
"0.49138594",
"0.48995504",
"0.4883798",
"0.4831838",
"0.48219055",
"0.48204577",
"0.48101366",
"0.47677633",
"0.4755909",
"0.47542575",
"0.47469333",
"0.47308958",
"0.47264928",
"0.4712683",
"0.4702746",
"0.4697414",
"0.46916488",
"0.46901888",
"0.46853516",
"0.4680775",
"0.46763366",
"0.4663034",
"0.4663034",
"0.4654529",
"0.46466714",
"0.46340027",
"0.4633605",
"0.4625946",
"0.46255696",
"0.46123922",
"0.46095556",
"0.46090096",
"0.46075207",
"0.45875236",
"0.4581993",
"0.45815066",
"0.4572192",
"0.4569179",
"0.45600578",
"0.45599887",
"0.45569947",
"0.45471916",
"0.45439133",
"0.45408776",
"0.4537562",
"0.4530904",
"0.4522759",
"0.452194",
"0.45140272",
"0.44589812",
"0.44331414",
"0.44331414",
"0.442079",
"0.44062424",
"0.44035554",
"0.44029102",
"0.43906143",
"0.4372645",
"0.43680173",
"0.4356719",
"0.43564042",
"0.4353932",
"0.43511698",
"0.43478724",
"0.43385142",
"0.4330153",
"0.43181533",
"0.4316625",
"0.4316425",
"0.43122232",
"0.43091437",
"0.43091103",
"0.43042645",
"0.43041727",
"0.42923528",
"0.4292205",
"0.42892462",
"0.42855334",
"0.42830148",
"0.4280613",
"0.42694274",
"0.42667168",
"0.4266657",
"0.42608276",
"0.42594013"
] | 0.4693709 | 31 |
word_search.flip_horizontal() Flip all the lines of the current word search puzzle object horizontally. (Note: this and all similar methods should more appropriately be named in their bang (!) forms, but I don't do that for this quiz, nor do I do other normal things here like returning self.) | def flip_horizontal
(0...@text_lines.size).each do |i|
@text_lines[i].reverse!
@sltn_lines[i].reverse!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flip_horizontally!\n for y in 0..((height - 1) >> 1) do\n other_y = height - (y + 1)\n other_row = row(other_y)\n replace_row!(other_y, row(y))\n replace_row!(y, other_row)\n end\n self\n end",
"def flip_horizontally\n dup.flip_horizontally!\n end",
"def flip_vertically!\n for y in 0...height do\n replace_row!(y, row(y).reverse)\n end\n self\n end",
"def flip_horizontal(matrix)\n matrix.map(&:reverse)\n end",
"def horizontal_words\n word_vectors = []\n \n @grid.each_with_index do |line, index|\n words = discover_words(line)\n words.each do |word|\n #Set the direction as 'discover_words' is direction agnostic\n word.direction = :horizontal\n word.y_pos = index\n end\n word_vectors << words\n end\n \n word_vectors.flatten\n end",
"def flip_horizontally!\n @picture.flip_horizontally!\n end",
"def flip_vertical\n @text_lines.reverse!\n @sltn_lines.reverse!\n end",
"def spoonerize\n raise JakPibError, \"Not enough words to flip\" unless enough_flippable_words?\n\n words.map.with_index { |word, idx| flip_words(word, idx) }\n end",
"def flip_vertically\n dup.flip_vertically!\n end",
"def reflect_horizontal\r\n self.v[:x] = -self.v[:x]\r\n end",
"def vertical_words\n word_vectors = []\n inverted_grid = Matrix.rows(@grid.map { |line| line.split('') }).transpose.to_a.map {|line| line.join}\n \n inverted_grid.each_with_index do |line, index|\n words = discover_words(line)\n words.each do |word|\n #Set the direction as 'discover_words' is direction agnostic\n word.direction = :vertical\n #Need to set the y_pos to the x_pos as the grid is inverted\n word.y_pos = word.x_pos\n word.x_pos = index\n end\n word_vectors << words\n end\n \n word_vectors.flatten\n end",
"def reflect_horizontal\n v[:x] = -v[:x]\n end",
"def rl_transpose_words(count, key)\r\n orig_point = @rl_point\r\n\r\n return if (count==0)\r\n\r\n # Find the two words.\r\n rl_forward_word(count, key)\r\n w2_end = @rl_point\r\n rl_backward_word(1, key)\r\n w2_beg = @rl_point\r\n rl_backward_word(count, key)\r\n w1_beg = @rl_point\r\n rl_forward_word(1, key)\r\n w1_end = @rl_point\r\n\r\n # Do some check to make sure that there really are two words.\r\n if ((w1_beg == w2_beg) || (w2_beg < w1_end))\r\n rl_ding()\r\n @rl_point = orig_point\r\n return -1\r\n end\r\n\r\n # Get the text of the words.\r\n word1 = rl_copy_text(w1_beg, w1_end)\r\n word2 = rl_copy_text(w2_beg, w2_end)\r\n\r\n # We are about to do many insertions and deletions. Remember them\r\n # as one operation.\r\n rl_begin_undo_group()\r\n\r\n # Do the stuff at word2 first, so that we don't have to worry\r\n # about word1 moving.\r\n @rl_point = w2_beg\r\n rl_delete_text(w2_beg, w2_end)\r\n rl_insert_text(word1)\r\n\r\n @rl_point = w1_beg\r\n rl_delete_text(w1_beg, w1_end)\r\n rl_insert_text(word2)\r\n\r\n # This is exactly correct since the text before this point has not\r\n # changed in length.\r\n @rl_point = w2_end\r\n\r\n # I think that does it.\r\n rl_end_undo_group()\r\n word1 = nil\r\n word2 = nil\r\n\r\n 0\r\n end",
"def reverse_words(my_words)\n return if !my_words\n left = 0\n my_words_length = my_words.length\n my_words_length.times do |i|\n if my_words[i] == \" \" || i == my_words_length - 1\n right = (i == (my_words_length - 1) ? i : i - 1)\n ((right + 1 - left) / 2).times do |j|\n temp = my_words[left + j]\n my_words[left + j] = my_words[right - j]\n my_words[right - j] = temp\n end\n left = i + 1\n end\n end\n return my_words\nend",
"def flip_horizontally(params = {})\n params[:name] ||= @pictureName.gsub('.png', 'FlippedH.png')\n params[:save] ||= @picturePath\n \n flip_h = dup\n flip_h.flip_horizontally!\n \n flip_h.pictureName, picturePath = params[:name], params[:save]\n flip_h\n end",
"def flip_horizontally(array)\n\tif array[1].kind_of?(Array)\n\t\tfor item in array\n\t\t\titem.reverse!\n\t\tend\n\telse \n\t\tarray.reverse!\n\tend\n\treturn array\nend",
"def flip_words(word, idx) # :nodoc:\n return word if excluded?(idx)\n bumper = Bumper.new(idx, words.size, reverse?)\n bumper.bump while excluded?(bumper.value)\n words[bumper.value].match(consonants).to_s + word.match(vowels).to_s\n end",
"def justify(linewrap=false)\n\n\t\tif @linelength == 0 then @linelength = $screen.cols end\n\n\t\tif linewrap\n\t\t\tcols = @linelength\n\t\t\tif @text[@row].length < cols then return end\n\t\telse\n\t\t\t# ask for screen width\n\t\t\t# nil means cancel, empty means screen width\n\t\t\tans = $screen.ask(\"Justify width: \",[@linelength.to_s],true)\n\t\t\tif ans == nil\n\t\t\t\t$screen.write_message(\"Cancelled\")\n\t\t\t\treturn\n\t\t\tend\n\t\t\tif ans == \"\"\n\t\t\t\tcols = @linelength\n\t\t\telsif ans == \"0\"\n\t\t\t\tcols = $screen.cols\n\t\t\telsif ans.to_i < 0\n\t\t\t\tcols = $screen.cols + ans.to_i\n\t\t\telse\n\t\t\t\tcols = ans.to_i\n\t\t\tend\n\t\t\t@linelength = cols\n\t\tend\n\n\t\t# set start & end rows\n\t\tif @marked\n\t\t\tmark_row, row = ordered_mark_rows\n\t\telse\n\t\t\tmark_row = @row\n\t\t\trow = @row\n\t\tend\n\t\tnl = row - mark_row + 1\n\n\t\t# make one long line out of multiple lines\n\t\ttext = @text[mark_row..row].join(\" \")\n\t\tfor r in mark_row..row\n\t\t\tdelrow(mark_row)\n\t\tend\n\n\t\t# loop through words and check length\n\t\tc = 0\n\t\tr = mark_row\n\t\tloop do\n\t\t\tc2 = text.index(/([^\\s]\\s)|($)/,c) # end of next word\n\t\t\tif c2 == nil then break end # end, if no more words\n\t\t\t# if we are past the edge, then put it in the next row\n\t\t\t# Otherwise, keep going.\n\t\t\tif c2 >= (cols-1)\n\t\t\t\tif c == 0 then c = c2+1 end # careful about long words\n\t\t\t\tinsertrow(r,text[0,c])\n\t\t\t\ttext = text[c..-1]\n\t\t\t\tif text == nil then text = \"\" end\n\t\t\t\ttext.lstrip!\n\t\t\t\tr += 1\n\t\t\t\tc = 0\n\t\t\telse\n\t\t\t\tc = c2+1\n\t\t\tend\n\t\t\tif text == nil || text == \"\"\n\t\t\t\ttext = \"\"\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\tinsertrow(r,text)\n\t\t$screen.write_message(\"Justified to \"+cols.to_s+\" columns\")\n\t\tif linewrap\n\t\t\tif @col >= @text[@row].length+1\n\t\t\t\t@col = @col - @text[@row].length - 1\n\t\t\t\t@row += 1\n\t\t\tend\n\t\telse\n\t\t\t@row = r\n\t\t\t@col = 0\n\t\tend\n\t\t@marked = false\n\tend",
"def inverted; invert = true; self; end",
"def reverse_words(my_words)\n if my_words == nil\n return my_words\n end\n len = my_words.length\n i = 0\n low = nil\n high = nil\n len.times do\n if my_words[i] != \" \"\n if my_words[i - 1] == \" \" || i == 0\n low = i\n elsif my_words[i + 1] == \" \" || i + 1 == len\n high = i\n end\n if low != nil && high != nil\n j = 0\n len2 = high - low + 1\n (len2 / 2).times do\n l = my_words[low + j]\n h = my_words[high - j]\n x = l\n my_words[low + j] = h\n my_words[high - j] = x\n j += 1\n end\n high = nil\n low = nil\n end\n end\n i += 1\n end\n return my_words\nend",
"def flip_vertically!\n @picture.flip_vertically!\n end",
"def flip_vertical(matrix)\n matrix.reverse\n end",
"def transpositions\n new_words = []\n @words.each do |word|\n @word = word || '' \n new_words += (0..length-1).map { |i| \"#{@word[0...i]}#{@word[i+1, 1]}#{@word[i,1]}#{@word[i+2..-1]}\" }\n end\n new_words\n end",
"def crossword(arr, word)\n earliest_col = -1\n ans = []\n arr.each_with_index do |row, i|\n earliest_col = solve_horiz(row, word)\n ans = [i, earliest_col]\n break\n end\n\n tarr = transpose arr\n tarr.each_with_index do |col, i|\n earliest_row = solve_horiz(row, word)\n if earliest_row <= ans[0] && i <= ans[1]\n ans = [earliest_row, i]\n end\n break\n end\n\n ans\nend",
"def horizontal_traversal(horizontal_cursor=@horizontal_cursor)\n @horizontal_cursor=horizontal_cursor\n while @horizontal_cursor != nil\n horizontal_traversal_step()\n @horizontal_cursor = @horizontal_cursor.lateral\n end\n end",
"def solve(*words)\n words = words.collect { |word| word.upcase_trim }\n\n #\n # Make the various transformations, checking for matches along the\n # way.\n #\n normalize ; replicate_match(words) # match L->R\n flip_horizontal ; replicate_match(words) # match R->L\n diagonalize ; replicate_match(words) # match TL->BR\n flip_horizontal ; replicate_match(words) # match BR->TL\n undiagonalize(true) ; replicate_match(words) # match T->B\n flip_horizontal ; replicate_match(words) # match B->T\n flip_vertical ; flip_horizontal\n diagonalize ; replicate_match(words) # match BL->TR\n flip_horizontal ; replicate_match(words) # match TR->BL\n undiagonalize(false)\n\n #\n # And return the solution.\n #\n @sltn_lines\n end",
"def flip\n sentence_array = @sentence.split\n length = sentence_array.count\n flipped_sentence = length.times.map do |i|\n sentence_array[-i - 1]\n end\n flipped_sentence.join(\" \")\n end",
"def horizontals_reset\n @htop = 0\n end",
"def row_search \n horizontal_words = []\n search = @@boards_templates[1].to_s.scan(/...../).each_slice(1).to_a\n rows = search.join \n @@boards_templates[0].each { |x| rows.include?(x) ? horizontal_words << x : rows.reverse.include?(x) ? horizontal_words << x : \"No hay palabras en dirección horizontal\" }\n horizontal_words\n end",
"def flip_word(word)\n first_half = \"\"\n second_half = \"\"\n middle = \"\"\n idx = 0\n\n word.each_char do |letter|\n if (idx == word.length / 2) && (word.length % 2 != 0)\n middle << letter\n elsif idx <= (word.length / 2 - 1)\n first_half << letter\n elsif idx > (word.length / 2 - 1)\n second_half << letter\n end\n\n idx += 1\n end\n\n puts second_half + middle + first_half\nend",
"def undiagonalize(transposed)\n text_lines = @text_lines\n @text_lines = Array.new(transposed ? @width : @height) { String.new }\n sltn_lines = @sltn_lines\n @sltn_lines = Array.new(transposed ? @width : @height) { String.new }\n text_lines.each_with_index do |line, i|\n if (transposed)\n o = (i + 1 < @height)? 0 : i + 1 - @height\n else\n o = (i + 1 < @width)? 0 : i + 1 - @width\n end\n line.split('').each_with_index do |char, j|\n @text_lines[j+o] << char\n @sltn_lines[j+o] << sltn_lines[i][j]\n end\n end\n end",
"def reverse_words!\n self[0..-1] = reverse_words[0..-1]\n nil\n end",
"def swasify(word)\r\n word = word.upcase.gsub(' ','').strip\r\n width = (word.length*2 - 1)*4 - 3\r\n sc = width/2\r\n word.split('')[0..-2].each do |letter|\r\n puts \" \"*sc + letter\r\n sc -= 2\r\n end\r\n sc2 = word.length*4 - 5\r\n puts \" \"*sc + word[-1] + \" \"*sc2 + word[-1]\r\n sc3 = 3\r\n \r\n word.split('')[1..-2].reverse.each do |letter|\r\n sc += 2\r\n sc2 -= 4 \r\n puts \" \"*sc + letter + \" \"*sc2 + letter + \" \"*sc3 + letter\r\n sc3 += 4\r\n end\r\n\r\n puts (word[0] + ' '*sc3)*2 + word[0]\r\n\r\n sc = 2\r\n word.split('')[1..-2].each do |letter|\r\n sc3 -= 4\r\n puts \" \"*sc + letter + \" \"*sc3 + letter + \" \"*sc2 + letter\r\n sc += 2\r\n sc2 += 4\r\n end\r\n\r\n sc2 = word.length*4 - 5\r\n puts \" \"*sc + word[-1] + \" \"*sc2 + word[-1]\r\n sc += sc2 - 1\r\n word.split('')[0..-2].reverse.each do |letter|\r\n puts \" \"*sc + letter\r\n sc -= 2\r\n end \r\nend",
"def rightToLeftWraparound(grid, width, height)\n\n strings = rightToLeft(grid, width, height)\n\n for string in strings do\n\n string << string\n\n end\n\n return strings\n\nend",
"def transpose!\n super()\n self.flip!\n end",
"def reverser \n\twords = yield\n\twords.split.map {|word| word.reverse}.join(\" \") # figured out that map yield the result as an array.\nend",
"def word_search_board\n @grid.each do |r|\n puts r.map { |p| p }.join(\" \")\n end\n end",
"def spin_me(arr)\n arr.each do |word|\n word.reverse!\n end\nend",
"def fold!(width, number = nil, breaker = nil)\n\n # If the TextRect has no lines, just return immediately.\n\n len = @theLines.length\n return self if len == 0\n\n # Create an array of line numbers. Make sure they are right adjusted.\n # When the array is complete, make up a left fill for those broken lines\n # that will not be copied. Also remember the length of the numbering\n # header.\n\n theNums = Array.new(len, '')\n\n if not number.nil? \n 0.upto(len-1) { |i| theNums[i] = \"#{(i+number).to_s}. \" }\n numWide = theNums.last.length\n theNums.collect! { |s| s.rjust(numWide) }\n end\n\n theFill = theNums.last.tr(theNums.last, ' ')\n numLen = theNums.last.length\n\n # Now process the strings of the original TextRect one by one. The new\n # lines are collected into an initially empty Array. Each line from the\n # receiver is processed in turn.\n\n theRes = Array.new\n\n @theLines.each_index do |i|\n\n # Get a line from the receiver and split it into words. Set of an array\n # of replacement lines and initialize the first replacement line to \n # be the number for the line followed by the first word and a space. \n # Every working line will end with a space (to be removed later).\n\n theWords = @theLines[i].split\n newLines = Array.new\n newLine = theNums[i] + theWords.delete_at(0) + ' '\n \n # In this loop, process each word in turn. Notice that as the line\n # already includes the first word and has a space at the end. If the line\n # cannot take one more word, take the trailing blank off, put it into\n # the accumulating array of new lines, and initialize the next new\n # line -- which must exist because there is a word pending -- with the\n # the left fill. Then, regardless of whether a line was saved, put the\n # word and a space at the end of the current line.\n\n theWords.each do |w|\n if newLine.length + w.length > width\n newLine.chomp!(' ')\n newLines << newLine\n newLine = String.new(theFill)\n end\n newLine << w << ' '\n end\n \n # All the words from this original line have been processed. Make sure\n # the last partial line gets into the array. Then put the folded lines\n # into the result. If this isn't the last line and the breaker isn't\n # NIL, put in a breaker line.\n\n newLines << newLine \n theRes.concat(newLines)\n theRes << breaker unless breaker.nil? or i == @theLines.length - 1\n\n end\n\n @theLines = theRes\n\n return self\n\n end",
"def reverser\nwords=yield.split(\" \")\noutpt=\"\"\nwords.map do\n |w|\noutpt= outpt + w.reverse + \" \"\n end\noutpt [0...-1]\nend",
"def fold(direction)\n case direction\n when \"L\"\n left, @values = split_along_v\n flip_along_v(left)\n place_over(left)\n when \"R\"\n @values, right = split_along_v\n flip_along_v(right)\n place_over(right)\n when \"T\"\n top, @values = split_along_h\n flip_along_h(top)\n place_over(top)\n when \"B\"\n @values, bottom = split_along_h\n flip_along_h(bottom)\n place_over(bottom)\n end\n end",
"def isFlipped\n true\n end",
"def reformat\n\t\t\tif self.r < self.l\n\t\t\t\t# swap r and l\n\t\t\t\tswap = self.r\n\t\t\t\tself.r = self.l\n\t\t\t\tself.l = swap\n\t\t\tend\n\t\t\tif self.t < self.b\n\t\t\t\t# swap top and bottom\n\t\t\t\tswap = self.t\n\t\t\t\tself.t = self.b\n\t\t\t\tself.b = swap\n\t\t\tend\n\t\tend",
"def reverse_words(my_words)\n return my_words if my_words.nil?\n\n breaks = spaces(my_words) #breaks found with helper method\n \n first = 0\n breaks.each do |space|\n last = space - 1\n\n while first < last\n a = my_words[first]\n my_words[first] = my_words[last]\n my_words[last] = a\n first += 1\n last -= 1\n end\n first = space + 1\n end\nend",
"def reverse_words!(message)\n # First we reverse all the characters in the entire message.\n reverse_characters!(message, 0, message.length - 1)\n # This gives us the right word order\n # but with each word backward.\n # Now we'll make the words forward again\n # by reversing each word's characters.\n # We hold the index of the *start* of the current word\n # as we look for the *end* of the current word.\n current_word_start_index = 0\n (0..message.length).each do |i|\n # Skip unless we're at the end of the current word.\n next unless i == message.length || message[i] == ' '\n reverse_characters!(message, current_word_start_index, i - 1)\n # If we haven't exhausted the string our\n # next word's start is one character ahead.\n current_word_start_index = i + 1\n end\nend",
"def vert_mirror(strng)\n string.split(\"\\n\").map do |piece|\n piece.reverse\n end.join(\"/n\")\nend",
"def stitching(x, y)\n\t\t# Return only what's already been generated (that is, what's above and to the left).\n\t\treturn [:normal, [\n\t\t\t([x - 1, y] if x > 0),\n\t\t\t([x - 1, y - 1] if x > 0 and y > 0),\n\t\t\t([x, y - 1] if y > 0),\n\t\t\t([x + 1, y - 1] if y > 0 and x < @field_width - 1)\n\t\t].compact]\n\tend",
"def play_rules_orig\n <<~'HOWTOPLAY'\n The word to guess is represented by a row of dashes,\n representing each letter of the word.\n In most variants, proper nouns, such as names, places, and brands,\n are not allowed.\n Slang words, sometimes referred to as informal or shortened words,\n are also not allowed.\n If the guessing player suggests a letter which occurs in the word,\n the other player writes it in all its correct positions.\n If the suggested letter does not occur in the word,\n the other player draws one element of a hanged man stick figure\n as a tally mark.\n\n The player guessing the word may, at any time, attempt to guess\n the whole word.\n If the word is correct, the game is over and the guesser wins.\n Otherwise, the other player may choose to penalize the guesser by\n adding an element to the diagram.\n On the other hand, if the other player makes enough incorrect guesses\n to allow his opponent to complete the diagram, the game is also over,\n this time with the guesser losing.\n However, the guesser can also win by guessing all the letters that\n appear in the word, thereby completing the word, before the diagram\n is completed.\n HOWTOPLAY\n end",
"def inversed; end",
"def invert() end",
"def reverse_words(my_words)\r\n j = 0\r\n i = 0\r\n while j < my_words.length - 1\r\n #find the beginning of the word\r\n i += 1 while my_words[i] == \" \"\r\n #find the end of the word\r\n j += 1 while (my_words[j + 1] != \" \" && my_words[j] == \" \") && (j != my_words.length - 1)\r\n #set counters for reverse\r\n k = i\r\n l = j\r\n #reverse the word in place\r\n while k < l\r\n letter = my_words[k]\r\n my_words[k] = my_words[l]\r\n my_words[l] = letter\r\n k += 1\r\n l -= 1\r\n end\r\n i = j + 2\r\n j = i\r\n end\r\n\r\nend",
"def reverser\n words= yield.split\n for word in words\n word.reverse!\n end\n words.join(\" \")\nend",
"def rightToLeft(grid, width, height)\n\n strings = leftToRight(grid, width, height)\n\n for string in strings do\n string.reverse!\n end\n\n return strings\nend",
"def flip\n @facing_up = !@facing_up\n self\n end",
"def front_to_back(word, index, how_far)\n word = string_to_char_array(word)\n word.rotate(how_far)\nend",
"def increment!\n self.left_half += 1\n # TODO: This breaks if the length of a palindrome changes, as odd doesn't update\n self\n end",
"def find_words(words)\n @words = words.map { |w| MatrixWord.new(w) }\n @words.each { |mw| place mw if (!mw.word.nil? && mw.word.size <= @width) }\n @words.select { |w| !w.place.nil? }\n end",
"def swap(sentence)\n final = []\n reversed_copy_array = sentence.dup.split.map(&:reverse)\n sentence_array = sentence.split\n zipped = sentence_array.zip(reversed_copy_array)\n zipped.each do |word_set|\n word_set[0][0] = word_set[1][0]\n word_set[0][-1] = word_set[1][-1]\n end\n zipped.each { |word_set| final << word_set[0] }\n final.join(' ')\nend",
"def diagonalize\n text_lines = @text_lines ; @text_lines = [ ]\n sltn_lines = @sltn_lines ; @sltn_lines = [ ]\n text_lines.each_with_index do |line, i|\n line.split('').each_with_index do |char, j|\n (@text_lines[i+j] ||= '') << char\n (@sltn_lines[i+j] ||= '') << sltn_lines[i][j]\n end\n end\n end",
"def fold!\n raise \"Bad input\" if width%2 == 1\n @grid = (0 .. (width / 2 - 1)).map { |col|\n @grid[col].zip(@grid[width - col - 1]).map {|pair| pair[1].reverse + pair[0]}\n }\n end",
"def horizontalLines\n (0...@height).inject([]) { |arr, row| arr << @modified.row(row) }\n end",
"def horizontal_traversal_step(horizontal_cursor=@horizontal_cursor)\n @min_support = horizontal_cursor.support\n @current_branch = []\n @vertical_cursor = horizontal_cursor.parent\n @current_branch = down_to_top_traversal()\n @patterns << Pattern.new(@current_branch, @min_support)\n end",
"def folds\n\t\[email protected]{|l| l.folded_lines}\n\tend",
"def reverseWords(line)\n words = line.split(\" \")\n words.reverse.join(\" \")\nend",
"def flip_words (first_word, second_word)\n puts second_word + first_word\nend",
"def spin_words(string)\n if string.include? \" \"\n string = string.split(\" \")\n string.each do |word|\n word.reverse! if word.size >= 5\n end\n p string * \" \"\n else\n if string.size < 5\n p string\n else\n p string.reverse!\n end\n end\nend",
"def turn_left\n # a kind of matrix multiplication\n new_row_diff = 0 - @col_diff\n new_col_diff = @row_diff + 0\n @row_diff = new_row_diff\n @col_diff = new_col_diff\n end",
"def reverse_words(my_words)\n return if (my_words == nil || my_words.length == 0)\n\n i = 0\n total = my_words.length\n while i < total\n while my_words[i] == ' ' && i < total\n i += 1\n end\n starting = i\n\n while my_words[i] != ' ' && i < total\n i += 1\n end\n ending = i - 1\n\n partial_reverse(my_words, starting, ending)\n end\n return\nend",
"def replaceHorizontal(y, arr)\n @modified.replace_row!(y, arr)\n @modified\n end",
"def mirror_angle_horizontally!\n @angle = (-@angle) % 360\n end",
"def strip!\n acc = 0\n new_te = self.text_elements.drop_while { |te|\n te.text == ' ' && acc += 1\n }\n self.left += self.text_elements.take(acc).inject(0) { |m, te| m += te.width }\n self.text_elements = new_te\n\n self.text_elements.reverse!\n acc = 0\n new_te = self.text_elements.drop_while { |te|\n te.text == ' ' && acc += 1\n }\n self.right -= self.text_elements.take(acc).inject(0) { |m, te| m += te.width }\n self.text_elements = new_te.reverse\n self\n end",
"def horizontal\n return HORIZONTAL\n end",
"def forward_word\n $multiplier = 1 if !$multiplier or $multiplier == 0\n line = @current_index\n buff = @list[line]\n pos = @curpos\n $multiplier.times {\n found = buff.index(/[[:punct:][:space:]]/, pos)\n if !found\n # if not found, we've lost a counter\n line += 1 # unless eof\n buff = @list[line]\n pos = 0\n else\n pos = found + 1\n end\n $log.debug \" forward_word: pos #{pos} line #{line} buff: #{buff}\"\n }\n @current_index = line\n @curpos = pos\n @buffer = @list[@current_index]\n set_form_row\n set_form_col pos\n @repaint_required = true\n end",
"def reverser\n str = yield\n words = str.split(\" \")\n\n words.each do |word|\n word.reverse!\n end\n words.join(\" \")\nend",
"def invert!\n @front, @back = @back, @front\n end",
"def vflip\n g = Grid.new\n self.each do |point,v|\n g[Point.new( point.x, @height - point.y - 1 )] = v \n end\n g\n end",
"def rearrange_board\n puts \"Letters rearranged.\"\n @outer_letters = self.outer_letters.chars.shuffle.join\n end",
"def flip\n __flip__\n end",
"def reverse_each_word(sentence)\narrayed = sentence.split (\" \")\nreversed = arrayed.collect {|i| i.reverse}\nreversed.join (\" \")\nend",
"def flip(dir, boxes)\n dir == 'R' ? boxes.sort : boxes.sort.reverse\nend",
"def reverse!\n tmp = self.from\n self.from = self.to\n self.to = tmp\n tmp = self.from_orient\n self.from_orient = (self.to_orient == :+) ? :- : :+\n self.to_orient = (tmp == :+) ? :- : :+\n self.overlap = self.reverse_overlap\n return self\n end",
"def reverse_words(sentence)\n first = 0\n last = sentence.length - 1\n\n while first < last\n sentence[first], sentence[last] = sentence[last], sentence[first]\n first += 1\n last -= 1\n end\n \n beginning_of_word = 0\n\n (0..sentence.length).each do |index|\n if sentence[index] == ' ' || index == sentence.length\n first = beginning_of_word\n last = index - 1\n while first < last\n sentence[first], sentence[last] = sentence[last], sentence[first]\n first += 1\n last -= 1\n end\n beginning_of_word = index + 1\n end\n end\n\n sentence\nend",
"def reverse_words\n collection.map(&:reverse)\n end",
"def reverse\r\n # Mirror the shape by the y axis, effectively creating shape counterparts such as 'L' and 'J'\r\n center = (get_bounds[2] + get_bounds[0]) / 2.0\r\n @blocks.each do |block|\r\n\t block.x = 2*center - block.x - @game.block_width\r\n\tend\r\n end",
"def all_horizontals(columns)\n horizontals = []\n 6.times do |row_index|\n horizontals[row_index] = ''\n 7.times do |column_index|\n if columns[column_index][row_index] == nil\n horizontals[row_index] << '-'\n else\n horizontals[row_index] << columns[column_index][row_index]\n end\n end\n end\n horizontals\n end",
"def reverse_words\n\tputs \"ERROR: Please give a valid filename as an argument.\" if ARGV[0] == nil\n\tFile.readlines(ARGV[0]).each do |line|\n\t\tline.gsub!(\"\\n\", \"\") if line.include? \"\\n\"\n\t\tword_reverser(line.split(\" \")) unless line.split[0] == nil\n\tend\nend",
"def invert; end",
"def horizontals_cur\n if !@horizontals[@htop]\n @horizontals[@htop] = @layout.createParallelGroup()\n @hgroup.add(@horizontals[@htop])\n end\n\n @horizontals[@htop]\n end",
"def reverse_each_word(sentence)\n sentence.reverse.split.reverse.join(\" \")\n \nend",
"def word_swap wrd\n return wrd if wrd.length < 2\n wrd[-1] + wrd[1..-2] + wrd[0]\nend",
"def flipflop!\n\t\tif size > 1\n\t\t\ta, b = shift, pop\n\t\t\tunshift(b); push(a)\n\t\tend\n\tend",
"def shift_rows_inv(state)\n shifted_rows = state.row_vectors.map.with_index do |vec, idx|\n vec.to_a.rotate(-1*idx)\n end\n state = Matrix.rows(shifted_rows)\n print_state(state, __method__) if DEBUG\n state\n end",
"def invert\n end",
"def reverse_words!(message)\n # first we reverse the entire thing\n reverse_characters!(message, 0, message.length - 1)\n\n current_start = 0\n\n # then we reverse each word\n (0..message.length).each do |i|\n # keep going unless message is over or we found a space\n next unless i == message.length || message[i] == ' '\n\n # if we found a space reverse the word\n\n reverse_characters!(message, current_start, i - 1)\n\n # start the next word ... we already know that there can only be 1 space\n\n current_start = i + 1\n end\n\n message # don't need to return but doing this to test spec\nend",
"def all_traversals(word)\n length = word.length\n results = []\n\n results << row_up(length)\n results << up_right(length)\n results << col_right(length)\n results << down_right(length)\n results << row_down(length)\n results << down_left(length)\n results << col_left(length)\n results << up_left(length)\n\n results\n end",
"def setup\n @board = []\n @words = 1\n for i in [email protected]\n if @phrase[i] == \" \"\n @board << \" \"\n @words += 1\n else\n @board << \"_\"\n end\n end\n @phraseletters = @phrase.length + 1 - words\n @remaining = phraseletters\n @board = @board.join\n end",
"def north(i=@cursor) i-width end",
"def reverse_words(my_words)\n return my_words if my_words == nil || my_words.length == 0\n \n i = 0\n l = my_words.length\n start_char = 0\n finish_char = 0\n \n while i < l \n while my_words[i] == \" \"\n i += 1\n end\n start_char = i\n while my_words[i] != \" \" && i < l\n i += 1 \n end\n finish_char = (i -1) \n while start_char < finish_char\n temp = my_words[start]\n my_words[start_char] = my_words[finish_char]\n my_words[finish] = temp\n start_char += 1\n finish_char -= 1\n end\n end\n return my_words\nend",
"def reverse_words(my_words) #with string_reverse\r\n return my_words if my_words.length < 2\r\n return string_reverse(my_words) if !my_words.include?(\" \")\r\n\r\n first = 0\r\n\r\n my_words.length.times do |last |\r\n if my_words[last].match(/\\s/)\r\n my_words[first...last] = string_reverse(my_words[first...last])\r\n first = last + 1\r\n elsif last == (my_words.length - 1)\r\n my_words[first..last] = string_reverse(my_words[first..last])\r\n end\r\n end\r\n\r\n return my_words\r\nend",
"def reverse_sentence(my_sentence)\n if my_sentence == nil\n return my_sentence\n end\n \n length = my_sentence.length\n (length / 2).times do |i|\n my_sentence[i], my_sentence[length - 1 - i] = my_sentence[length - 1 - i], my_sentence[i]\n end\n \n prev_char = nil\n next_char = my_sentence[1]\n word_break_indexes = []\n word_start_indexes = []\n if my_sentence[0] != \" \"\n word_start_indexes << 0\n end\n \n my_sentence.each_char.with_index do |char, index|\n if char == \" \" && prev_char != \" \"\n unless prev_char == nil\n word_break_indexes << index\n end\n end\n \n if char == \" \" && next_char != \" \"\n unless next_char == nil\n word_start_indexes << index\n end\n end\n prev_char = char\n next_char = my_sentence[index + 2]\n end\n \n if my_sentence[length - 1] != \" \"\n word_break_indexes << length\n end\n \n x = 0\n word_break_indexes.each do |index|\n if x == 0\n if my_sentence[0] == \" \"\n ((index - word_start_indexes[0]) / 2).times do |i|\n my_sentence[word_start_indexes[0] + 1 + i], my_sentence[index - 1 - i] = my_sentence[index - 1 - i], my_sentence[word_start_indexes[0] + 1 + i]\n end\n else\n (index / 2).times do |i|\n my_sentence[i], my_sentence[index - 1 - i] = my_sentence[index - 1 - i], my_sentence[i]\n end\n end\n else\n ((index - word_start_indexes[x] - 1) / 2).times do |i|\n my_sentence[word_start_indexes[x] + 1 + i], my_sentence[index - 1 - i] = my_sentence[index - 1 - i], my_sentence[word_start_indexes[x] + 1 + i]\n end\n end\n x += 1\n end\n \n return my_sentence\n \nend"
] | [
"0.6792041",
"0.6417419",
"0.60523856",
"0.599958",
"0.58600897",
"0.5796757",
"0.5752684",
"0.56558865",
"0.55812234",
"0.5263736",
"0.5223522",
"0.5220052",
"0.5171433",
"0.5132745",
"0.51269615",
"0.51020294",
"0.509572",
"0.5093568",
"0.50895673",
"0.5088457",
"0.5082823",
"0.5026887",
"0.50208706",
"0.5014361",
"0.4998503",
"0.49728405",
"0.4923169",
"0.49133435",
"0.4913256",
"0.48934737",
"0.48856744",
"0.48436236",
"0.48412126",
"0.48300537",
"0.48224148",
"0.48170948",
"0.48113322",
"0.480442",
"0.48021883",
"0.48020226",
"0.47613218",
"0.47567073",
"0.4742253",
"0.47337812",
"0.4732802",
"0.4727915",
"0.4722582",
"0.47158667",
"0.46984667",
"0.46974713",
"0.46914402",
"0.46912318",
"0.469093",
"0.46866918",
"0.46846095",
"0.46757895",
"0.4675681",
"0.467372",
"0.467295",
"0.46726114",
"0.4671864",
"0.46615154",
"0.46500194",
"0.46483296",
"0.46424735",
"0.46399254",
"0.46387252",
"0.46367884",
"0.46323186",
"0.46303797",
"0.46285096",
"0.46197206",
"0.4616148",
"0.4607828",
"0.45996445",
"0.45899054",
"0.45895854",
"0.4586486",
"0.45860088",
"0.458588",
"0.45854092",
"0.45772815",
"0.45596638",
"0.45545483",
"0.4551198",
"0.4549914",
"0.4547791",
"0.45350412",
"0.453292",
"0.4528587",
"0.4521934",
"0.45217943",
"0.4518535",
"0.45185116",
"0.45105553",
"0.45095542",
"0.44940385",
"0.44896063",
"0.4489205",
"0.44881845"
] | 0.70315975 | 0 |
word_search.flip_vertical() Flip all the lines of the current word search puzzle object vertically. | def flip_vertical
@text_lines.reverse!
@sltn_lines.reverse!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flip_vertically!\n for y in 0...height do\n replace_row!(y, row(y).reverse)\n end\n self\n end",
"def vertical_words\n word_vectors = []\n inverted_grid = Matrix.rows(@grid.map { |line| line.split('') }).transpose.to_a.map {|line| line.join}\n \n inverted_grid.each_with_index do |line, index|\n words = discover_words(line)\n words.each do |word|\n #Set the direction as 'discover_words' is direction agnostic\n word.direction = :vertical\n #Need to set the y_pos to the x_pos as the grid is inverted\n word.y_pos = word.x_pos\n word.x_pos = index\n end\n word_vectors << words\n end\n \n word_vectors.flatten\n end",
"def flip_vertically\n dup.flip_vertically!\n end",
"def flip_vertical(matrix)\n matrix.reverse\n end",
"def flip_vertically!\n @picture.flip_vertically!\n end",
"def flip_horizontal\n (0...@text_lines.size).each do |i|\n @text_lines[i].reverse!\n @sltn_lines[i].reverse!\n end\n end",
"def vert_mirror(strng)\n string.split(\"\\n\").map do |piece|\n piece.reverse\n end.join(\"/n\")\nend",
"def reflect_vertical\r\n self.v[:y] = -self.v[:y]\r\n end",
"def flip_horizontally!\n for y in 0..((height - 1) >> 1) do\n other_y = height - (y + 1)\n other_row = row(other_y)\n replace_row!(other_y, row(y))\n replace_row!(y, other_row)\n end\n self\n end",
"def flip_vertically(params = {})\n params[:name] ||= @pictureName.gsub('.png', 'FlippedV.png')\n params[:save] ||= @picturePath\n \n flip_v = dup\n flip_v.flip_vertically!\n \n flip_v.pictureName, picturePath = params[:name], params[:save]\n flip_v\n end",
"def spoonerize\n raise JakPibError, \"Not enough words to flip\" unless enough_flippable_words?\n\n words.map.with_index { |word, idx| flip_words(word, idx) }\n end",
"def replaceVertical(y, arr)\n @modified.replace_column!(y, arr)\n @modified\n end",
"def vertically_striped(unstriped)\n output = unstriped.dup\n row_width = output[0].length\n\n # Zero out top and bottom 2 rows\n output[0] = [0] * row_width\n output[1] = [0] * row_width\n output[-1] = [0] * row_width\n output[-2] = [0] * row_width\n output\n end",
"def split_vertically!(y)\n raise \"Not Implemented\"\n end",
"def verticalLines\n (0...@width).inject([]) { |arr, column| arr << @modified.column(column) }\n end",
"def inverted; invert = true; self; end",
"def vflip\n g = Grid.new\n self.each do |point,v|\n g[Point.new( point.x, @height - point.y - 1 )] = v \n end\n g\n end",
"def flip\n sentence_array = @sentence.split\n length = sentence_array.count\n flipped_sentence = length.times.map do |i|\n sentence_array[-i - 1]\n end\n flipped_sentence.join(\" \")\n end",
"def mirror_angle_vertically!\n @angle = (180 - @angle) % 360\n end",
"def invert() end",
"def transposed_search_vector\n @transposed_search_vector ||= super\n end",
"def reverse_words(my_words)\n return if !my_words\n left = 0\n my_words_length = my_words.length\n my_words_length.times do |i|\n if my_words[i] == \" \" || i == my_words_length - 1\n right = (i == (my_words_length - 1) ? i : i - 1)\n ((right + 1 - left) / 2).times do |j|\n temp = my_words[left + j]\n my_words[left + j] = my_words[right - j]\n my_words[right - j] = temp\n end\n left = i + 1\n end\n end\n return my_words\nend",
"def reverse_words(my_words)\n if my_words == nil\n return my_words\n end\n len = my_words.length\n i = 0\n low = nil\n high = nil\n len.times do\n if my_words[i] != \" \"\n if my_words[i - 1] == \" \" || i == 0\n low = i\n elsif my_words[i + 1] == \" \" || i + 1 == len\n high = i\n end\n if low != nil && high != nil\n j = 0\n len2 = high - low + 1\n (len2 / 2).times do\n l = my_words[low + j]\n h = my_words[high - j]\n x = l\n my_words[low + j] = h\n my_words[high - j] = x\n j += 1\n end\n high = nil\n low = nil\n end\n end\n i += 1\n end\n return my_words\nend",
"def flip_words(word, idx) # :nodoc:\n return word if excluded?(idx)\n bumper = Bumper.new(idx, words.size, reverse?)\n bumper.bump while excluded?(bumper.value)\n words[bumper.value].match(consonants).to_s + word.match(vowels).to_s\n end",
"def reverse!\n low = 0\n high = self.__size - 1\n while low < high\n a = self.__at(low)\n b = self.__at(high)\n self.__at_put(high, a)\n self.__at_put(low, b)\n low = low + 1\n high = high - 1\n end\n self\n end",
"def flip_horizontal(matrix)\n matrix.map(&:reverse)\n end",
"def swap(sentence)\n final = []\n reversed_copy_array = sentence.dup.split.map(&:reverse)\n sentence_array = sentence.split\n zipped = sentence_array.zip(reversed_copy_array)\n zipped.each do |word_set|\n word_set[0][0] = word_set[1][0]\n word_set[0][-1] = word_set[1][-1]\n end\n zipped.each { |word_set| final << word_set[0] }\n final.join(' ')\nend",
"def invert; end",
"def refresh\n d = @data.dup.map{ |row| row.split(\"\") }\n @num_rotations.times { d = d.transpose.map(&:reverse) }\n d.map(&:reverse!) if @flipped\n d.map(&:join)\n end",
"def find_vertical\n\n\t\t# (x * g) + y where y = (1...g), x = (0...g-1)\n\n\t\t@grid_size.times do |y|\n\t\t\t@winner = true if\n\t\t\t\t(0..(@grid_size-1)).each do |x|\n\t\t\t\t\tvertical_hit = x * @grid_size + y + 1\n\t\t\t\t\tif [email protected]? vertical_hit\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\tend",
"def flip_vertically(array)\n\tif array[1].kind_of?(Array)\n\t\tarray.reverse!\n\tend\n\n\treturn array\nend",
"def fold_down(state)\n new_state = []\n state.column_vectors.each {|column|\n values = column.to_a.reverse\n values = @line_folder.fold(values)\n new_state << values.reverse\n }\n Matrix.columns(new_state)\n end",
"def reverse_words(my_words)\n # raise NotImplementedError\n return my_words if my_words.nil? || my_words.empty?\n\n i = 0 # starting point of sentence\n j = my_words.length # ending point of sentence\n\n while i < j\n while my_words[i] == \" \" && i < j\n i += 1\n end\n\n word_start = i # starting point of next word in sentence\n\n while my_words[i] != \" \" && i < j\n i += 1\n end\n\n word_end = i - 1 # end point of word in sentence\n\n word_reverse(my_words, word_start, word_end)\n end\n return\nend",
"def reverse_each_word(sentence)\narrayed = sentence.split (\" \")\nreversed = arrayed.collect {|i| i.reverse}\nreversed.join (\" \")\nend",
"def reverse_each_word(sentence)\n\tarray_of_words = sentence.split(' ')\n\tarray_of_words.collect do |word|\n word.reverse!\n\tend\n\tarray_of_words.join(\" \")\nend",
"def invert\n end",
"def reverse\n # Mirror the shape by the y axis, effectively creating shape counterparts such as 'L' and 'J'\n center = (get_bounds[2] + get_bounds[0]) / 2.0\n @blocks.each do |block|\n block.x = 2*center - block.x - @game.block_width\n end\n end",
"def reverse_words!\n self[0..-1] = reverse_words[0..-1]\n nil\n end",
"def invert!\n @front, @back = @back, @front\n end",
"def reverse\r\n # Mirror the shape by the y axis, effectively creating shape counterparts such as 'L' and 'J'\r\n center = (get_bounds[2] + get_bounds[0]) / 2.0\r\n @blocks.each do |block|\r\n\t block.x = 2*center - block.x - @game.block_width\r\n\tend\r\n end",
"def reverse_each_word(sentence)\r\n array1 = sentence.split(\" \")\r\n array1.collect do |x|\r\n x.reverse!\r\n end\r\n array1.join(\" \")\r\nend",
"def wordReverse(sentence) \n\tsentence = sentence.split (\" \")\n\tsentence.each do |words|\n\tend\n\tputs sentence.reverse\nend",
"def reverse!\n\t vertices.reverse!\n\t edges.reverse!.map! {|edge| edge.reverse! }\n\t self\n\tend",
"def reverse_each_word (sentence)\n array_sentence = sentence.split()\n array_reversed = array_sentence.collect do |word|\n word.reverse\n end\n array_reversed.join(\" \")\nend",
"def invert!\n @cards.values.each {|c| c.invert! }\n end",
"def reverse_each_word(sentence)\n\tsplit_up = sentence.split(\" \")\n\tsplit_up.collect do |word|\n\t\tword.reverse!\n\tend\n\tsplit_up.join(' ')\nend",
"def display_board\n # Reverse it to display the board correctly\n reverse = @board.reverse\n \n puts \"------------------------------\"\n reverse.each do |row|\n print \"|\"\n row.each do |col|\n print \" #{col} |\" if(col != -1)\n print \" |\" if(col == -1)\n end\n puts \"\\n------------------------------\"\n end\n end",
"def inversed; end",
"def reverse_each_word(sentence)\n array_of_split_string = []\n reversed_words = []\n array_of_split_string = sentence.split\n array_of_split_string.collect {|words| reversed_words << words.reverse!}\n reversed_words.join(\" \")\nend",
"def reverse_each_word(sentence)\n sentence_array = sentence.split(/ /)\n result = sentence_array.collect do |binkbutt|\n binkbutt.reverse\n end\n result.join(\" \")\nend",
"def reverse_words(my_words)\n return my_words if my_words.nil?\n\n breaks = spaces(my_words) #breaks found with helper method\n \n first = 0\n breaks.each do |space|\n last = space - 1\n\n while first < last\n a = my_words[first]\n my_words[first] = my_words[last]\n my_words[last] = a\n first += 1\n last -= 1\n end\n first = space + 1\n end\nend",
"def flip_horizontally\n dup.flip_horizontally!\n end",
"def output_lcs_blosum(backtrack, v, w, i, j)\n\n v_str = \"\"\n w_str = \"\"\n\n loop do\n # break if (i == 0 || j == 0)\n break if (i == 0)\n # puts i.to_s + \" \" + j.to_s + \" \" + backtrack[i][j]\n if backtrack[i][j] == \"down\"\n v_str += v[i-1]\n w_str += \"-\"\n i -= 1\n elsif backtrack[i][j] == \"right\"\n v_str += \"-\"\n w_str += w[j-1]\n j -= 1\n else\n v_str += v[i-1]\n w_str += w[j-1]\n i -= 1\n j -= 1\n end\n end\n\n # puts v_str.reverse\n # puts w_str.reverse\n return [v_str.reverse, w_str.reverse]\n # return [v_str, w_str]\n <<-DOC\n OUTPUTLCS(backtrack, v, i, j)\n if i = 0 or j = 0\n return\n if backtracki, j = \"↓\"\n OUTPUTLCS(backtrack, v, i - 1, j)\n else if backtracki, j = \"→\"\n OUTPUTLCS(backtrack, v, i, j - 1)\n else\n OUTPUTLCS(backtrack, v, i - 1, j - 1)\n output vi \n DOC\n\n # return if (i == 0 || j == 0)\n # if backtrack[i][j] == \"del\"\n # output_lcs_blosum(backtrack, v, w, i-1, j) \n # print \"-\"\n # elsif backtrack[i][j] == \"add\"\n # output_lcs_blosum(backtrack, v, w, i, j-1) \n # print \"-\"\n # # elsif backtrack[i][j] == \"mismatch\"\n # # output_lcs(backtrack, v, w, i-1, j-1) \n # # print \"-\"\n # else\n # output_lcs_blosum(backtrack, v, w, i-1, j-1) \n # print v[i-1]\n # print w[j-1]\n # end\n end",
"def reverse_each_word(sentence)\n\tarray= sentence.split\n\tarray.map! do |word|\n\t\tword.reverse\n\tend\n\tarray.join(\" \")\nend",
"def reverse_each_word(sentence)\n word_array = []\n rev_array = []\n word_array = sentence.split\n word_array.collect {|word| rev_array << word.reverse}\n return rev_array.join(\" \")\nend",
"def reverse_words(my_words)\n i = 0\n j = 0\n\n if my_words == nil\n return\n end\n\n loop do\n # binding.pry\n until my_words[i] != \" \"\n i += 1\n break if i >= my_words.length - 1\n end\n j = i\n until my_words[j + 1] == \" \" || j == (my_words.length - 1)\n j += 1\n end\n # binding.pry\n string_reverse(my_words, i, j)\n i = j + 2\n # binding.pry\n break if i >= my_words.length - 1\n end\n return my_words\nend",
"def reverse_each_word(sentence)\n sentence.split.collect {|word| word.reverse}.join(\" \")\n end",
"def reverse_each_word(sentence)\n sentence.split.collect {|word| word.reverse}.join(\" \")\n end",
"def spin_me(arr)\n arr.each do |word|\n word.reverse!\n end\nend",
"def reverseWords(line)\n words = line.split(\" \")\n words.reverse.join(\" \")\nend",
"def reverse_each_word(sentence)\n words_array = sentence.split(\" \") \n new_array = []\n new_array = words_array.collect {|word| word.reverse}\n new_array.join(\" \")\nend",
"def reverse_each_word(sentence)\n array = sentence.split\n new_arr = []\n array.collect do |word| \n new_arr << word.reverse\n end\n p new_arr.join(' ')\nend",
"def reverse_words(my_words)\r\n j = 0\r\n i = 0\r\n while j < my_words.length - 1\r\n #find the beginning of the word\r\n i += 1 while my_words[i] == \" \"\r\n #find the end of the word\r\n j += 1 while (my_words[j + 1] != \" \" && my_words[j] == \" \") && (j != my_words.length - 1)\r\n #set counters for reverse\r\n k = i\r\n l = j\r\n #reverse the word in place\r\n while k < l\r\n letter = my_words[k]\r\n my_words[k] = my_words[l]\r\n my_words[l] = letter\r\n k += 1\r\n l -= 1\r\n end\r\n i = j + 2\r\n j = i\r\n end\r\n\r\nend",
"def reverse_each_word(array)\n new_array = array.split(\" \") \n reversed_array = new_array.each {|x| x.reverse!} \n return reversed_array.join(\" \") \n end",
"def reverse_each_word(sentence1)\n ## sentence1.split turns the string into an array, where each word is an element of the array. No spaces.\n sentence_array = sentence1.split\n sentence_array.collect { |word|\n \n ## .reverse! reverses each word \"in place\", not creating new\n word.reverse!\n }\n ## .join(\" \") takes the elements of the array, joins them as a string with a space between each \n sentence_array.join(\" \")\nend",
"def reverse_words(my_words)\n return if (my_words == nil || my_words.length == 0)\n\n i = 0\n total = my_words.length\n while i < total\n while my_words[i] == ' ' && i < total\n i += 1\n end\n starting = i\n\n while my_words[i] != ' ' && i < total\n i += 1\n end\n ending = i - 1\n\n partial_reverse(my_words, starting, ending)\n end\n return\nend",
"def reverse_each_word(sentence)\n array = sentence.split\n array = array.collect {|word| word.reverse}\n array.join(\" \")\nend",
"def reverse_each_word_collect(sentence)\n array = sentence.split(\" \")\n return_array = []\n array.collect do|sentence|\n return_array << sentence.reverse\n end\n return_array.join(\" \")\nend",
"def transpositions\n new_words = []\n @words.each do |word|\n @word = word || '' \n new_words += (0..length-1).map { |i| \"#{@word[0...i]}#{@word[i+1, 1]}#{@word[i,1]}#{@word[i+2..-1]}\" }\n end\n new_words\n end",
"def reverse_each_word(sentence)\n array = sentence.split()\n reversed_words = array.collect do |word|\n word.reverse\n end\n reversed_words.join(\" \")\nend",
"def reverser\nwords=yield.split(\" \")\noutpt=\"\"\nwords.map do\n |w|\noutpt= outpt + w.reverse + \" \"\n end\noutpt [0...-1]\nend",
"def backwards_wording(words)\n words.select { |word| word.size >= 5 }.map { |word| word.reverse }\n end",
"def reverse_each_word(sentence1)\n sentence1.split.collect {|word| word.reverse}.join(\" \")\n# new_array = []\n# reversed_words = []\n# new_array << sentence1.split.collect(&:reverse!).join(\" \")\n #reversed_words << new_array.collect(&:reverse!)\n #new_array.collect {|word| reversed_words << word.reverse}\n# sentence1.split('').reverse.join('').reverse\n #binding.pry\n #new_array\nend",
"def reverse_sentence(my_sentence)\n \n return nil if my_sentence == nil\n \n # reverses all characters in sentence\n i = 0\n j = my_sentence.length - 1\n \n while i < my_sentence.length / 2\n temp_i = my_sentence[i]\n temp_j = my_sentence[j]\n \n my_sentence[i] = temp_j\n my_sentence[j] = temp_i\n \n i += 1 \n j -= 1\n end\n \n \n # reverses any words in the sentence\n i = 0\n word_start = 0\n word_end = 0\n in_word = true\n \n while i < my_sentence.length\n if ( my_sentence[i] == \" \" || i == my_sentence.length - 1 ) && in_word == true\n \n word_end = i \n word_end -= 1 if my_sentence[i] == \" \"\n \n word_length = word_end - word_start + 1\n count = 0\n \n while count < word_length / 2\n temp_start = my_sentence[word_start]\n temp_end = my_sentence[word_end]\n \n my_sentence[word_start] = temp_end\n my_sentence[word_end] = temp_start\n \n word_start += 1\n word_end -= 1\n count += 1\n end\n \n in_word = false\n end\n \n if my_sentence[i] != \" \" && in_word == false\n word_start = i\n in_word = true\n end\n \n i += 1\n end\n \n return my_sentence\nend",
"def reverse_each_word(sentence)\n array =[ ]\n new_sentence = \" \"\n(sentence.split).collect do |word|\n word.reverse\n array << (word.reverse)\nend\narray.join(\" \")\nend",
"def flip\n arr = Array.new(self.length)\n (0..self.length / 2).each do |index|\n arr[index] = self[self.length - 1 - index]\n arr[self.length - 1 - index] = self[index]\n end\n arr\n end",
"def isFlipped\n true\n end",
"def move_vertically\n @vy += 1\n\n # Vertical movement\n if @vy > 0 && @y < 500 # TODO set externally\n @vy.times { @y += 1 }\n end\n if @vy < 0\n (-@vy).times { @y -= 1 }\n end\n end",
"def word_search_board\n @grid.each do |r|\n puts r.map { |p| p }.join(\" \")\n end\n end",
"def reverse_each_word(sentence)\n array = sentence.split(\" \")\n array_new = []\n array_new = array.collect do |element| \n element.reverse \n end\n array_new.join(\" \")\nend",
"def reverse_each_word(sentence)\n\treversed = Array.new\n\tsentence.split(\" \").map do |word|\n\t\treversed << word.reverse.to_s\n\tend\n\treversed.join(\" \")\nend",
"def reverse_each_word(sentence)\n sentence.reverse.split.reverse.join(\" \")\n \nend",
"def flipud\n reverse(0)\n end",
"def reverse_each_word(sentence)\n new_array = sentence.split(\" \").collect do |word|\n word.reverse!\n end\n new_array.join(\" \")\nend",
"def flip(dir, boxes)\n dir == 'R' ? boxes.sort : boxes.sort.reverse\nend",
"def reverse_each_word(sentence)\n words = sentence.split(\" \")\n\n new_words = words.collect do |word|\n word.reverse()\n end\n\n new_words.join(\" \")\nend",
"def vertical_move\n @initial_pos[0] == @final_pos[0] \n end",
"def reverse_each_word(sentence2)\n sentence2.split.collect {|word| word.reverse}.join(\" \")\nend",
"def reverse_each_word(sentence)\n sentence = sentence.split(' ')\n sentence.collect do |word|\n word.reverse!\n end\n sentence = sentence.join(' ')\nend",
"def reverse_words\n collection.map(&:reverse)\n end",
"def reverse!\n tmp = self.from\n self.from = self.to\n self.to = tmp\n tmp = self.from_orient\n self.from_orient = (self.to_orient == :+) ? :- : :+\n self.to_orient = (tmp == :+) ? :- : :+\n self.overlap = self.reverse_overlap\n return self\n end",
"def reverse\n puts content.reverse\n end",
"def _rl_move_vert(to)\r\n if (@_rl_last_v_pos == to || to > @_rl_screenheight)\r\n return\r\n end\r\n\r\n if ((delta = to - @_rl_last_v_pos) > 0)\r\n @rl_outstream.write(\"\\n\"*delta)\r\n @rl_outstream.write(\"\\r\")\r\n @_rl_last_c_pos = 0\r\n else\r\n if(@_rl_term_up)\r\n @rl_outstream.write(@_rl_term_up*(-delta))\r\n end\r\n end\r\n @_rl_last_v_pos = to # Now TO is here\r\n end",
"def reverse_each_word(sentence1)\n \n reverse_array=[]\n split_sentence_array=sentence1.split(\" \")\n reversed=split_sentence_array.collect {|word| word.reverse}\n reversed.join(\" \")\n \nend",
"def invertir\n @contenido = invertirExamen(@contenido)\n end",
"def reverse_each_word(sentence)\n sentence_array = []\n split_sentence = sentence.split\n \n split_sentence.collect do |element|\n reverse = element.reverse\n sentence_array << reverse\n \n end\nreverse_sentence = sentence_array.join(\" \")\nreverse_sentence\nend",
"def reverse_words(sentence)\n arr_of_words = split_sentence(sentence)\n arr_of_reversed_words = reverse_array(arr_of_words)\n join_array(arr_of_reversed_words)\nend",
"def reverse_each_word(sentence)\n# piecesOfSentence=sentence.split(\" \")\n# reversedSentence =[]\n# piecesOfSentence.each { |word| \n# reversedSentence << word.reverse }\n# output = reversedSentence.join(\" \")\n# return output\n\npiecesOfSentence=sentence.split(\" \")\nreversedSentence = []\npiecesOfSentence.collect { |word|\nreversedSentence << word.reverse }\noutput = reversedSentence.join(\" \")\nreturn output\n\nend",
"def all_verticals(columns)\n verticals = []\n columns.each {|column, content| verticals << content.join}\n verticals\n end",
"def reverse_each_word(sentence)\n backwards = []\n sentence_array = sentence.split(/ /)\n sentence_array.collect do |word|\n backwards << word.reverse\n end\n backwards.join(\" \")\nend"
] | [
"0.72670025",
"0.67112905",
"0.66560256",
"0.66510785",
"0.5957041",
"0.592218",
"0.5773021",
"0.5727257",
"0.55526936",
"0.5523436",
"0.5486222",
"0.53519",
"0.5313064",
"0.5304981",
"0.53012145",
"0.5293072",
"0.5244131",
"0.51944715",
"0.51589257",
"0.51348245",
"0.5112165",
"0.5090616",
"0.5081302",
"0.50702727",
"0.5068367",
"0.50598603",
"0.50296134",
"0.5018855",
"0.5013902",
"0.5011259",
"0.5008604",
"0.49958178",
"0.49725637",
"0.4971854",
"0.49600062",
"0.49582866",
"0.49511307",
"0.49491236",
"0.4943755",
"0.49320546",
"0.49137416",
"0.49078736",
"0.48891726",
"0.48859692",
"0.48804918",
"0.4877513",
"0.48764938",
"0.48674282",
"0.48583406",
"0.48547342",
"0.48395917",
"0.48294264",
"0.4828528",
"0.48135757",
"0.48107225",
"0.48069498",
"0.48033485",
"0.48033485",
"0.48022574",
"0.48010024",
"0.47823706",
"0.47807372",
"0.47802132",
"0.47706565",
"0.47698098",
"0.47648215",
"0.47647995",
"0.4760028",
"0.47590703",
"0.47554785",
"0.4747704",
"0.47413245",
"0.47411588",
"0.47403514",
"0.47349504",
"0.47345686",
"0.4726057",
"0.4718505",
"0.4711324",
"0.4706341",
"0.46995583",
"0.46991736",
"0.4697336",
"0.4696684",
"0.46954557",
"0.4695394",
"0.46950722",
"0.46871787",
"0.4682692",
"0.467843",
"0.4677489",
"0.46773493",
"0.4675236",
"0.46743295",
"0.46719643",
"0.4671806",
"0.46707892",
"0.46696952",
"0.46644554",
"0.46624634"
] | 0.7439568 | 0 |
word_search.diagonalize() Convert the lines of the current word search puzzle object to a kind of diagonalized form. Note that here I don't presize the arrays, and so use the ||= trick (well, I suppose it's possible to figure out how big to make the arrays, but I didn't bother doing that). | def diagonalize
text_lines = @text_lines ; @text_lines = [ ]
sltn_lines = @sltn_lines ; @sltn_lines = [ ]
text_lines.each_with_index do |line, i|
line.split('').each_with_index do |char, j|
(@text_lines[i+j] ||= '') << char
(@sltn_lines[i+j] ||= '') << sltn_lines[i][j]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diagonalize floor = 0\n raise 'err: not 2d' unless self[0].class == Array\n size = self.length + self[0].length - 1\n array = Array.new(size) {Array.new}\n # acquire top and main diagonal\n self.length.times do |row|\n (0 .. row).each do |col|\n array[row] << self[row-col][col]\n end\n end\n # now cover the additional bottom diagonals\n sides_difference = self.length[0] - self.length\n if sides_difference == 0\n (1 .. self.length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self.length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self.length - 1 + row] = temp_arr\n end\n else\n (1 .. self[0].length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self[0].length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self[0].length - 2 + row] = temp_arr\n end\n end\n\n # phew... now to trim and format\n unless floor == 0\n index = 0\n while index < size\n if array[index].length < floor\n array.slice! index\n size -= 1\n index -= 1\n end\n index += 1\n end\n end\n\n (0..size-1).each do |index|\n while array[index].length < self.length\n array[index] << nil\n end\n end\n array\n end",
"def undiagonalize(transposed)\n text_lines = @text_lines\n @text_lines = Array.new(transposed ? @width : @height) { String.new }\n sltn_lines = @sltn_lines\n @sltn_lines = Array.new(transposed ? @width : @height) { String.new }\n text_lines.each_with_index do |line, i|\n if (transposed)\n o = (i + 1 < @height)? 0 : i + 1 - @height\n else\n o = (i + 1 < @width)? 0 : i + 1 - @width\n end\n line.split('').each_with_index do |char, j|\n @text_lines[j+o] << char\n @sltn_lines[j+o] << sltn_lines[i][j]\n end\n end\n end",
"def diagonal_search \n diagonal = []\n diagonal_words = []\n search = @@boards_templates[1].to_s.scan(/./).each_slice(5).to_a\n for ca in 2..7 \n down = ca \n for row in 0..ca\n if row <= 4 \n diagonal << search[down][row]\n down -= 1 \n end \n end \n end\n diagonal = diagonal.join \n @@boards_templates[0].each { |x| diagonal.include?(x) ? diagonal_words << x : diagonal_words.reverse.include?(x) ? diagonal_words << x : \"No hay palabras en dirección diagonal\" }\n #diagonal_words \n end",
"def get_diagonal(representation)\n diagonals = []\n for k in (0..7)\n arr = []\n arr2 = []\n for i in (0..6)\n for j in (0..5)\n if (i == (j - k))\n arr << representation[i][j]\n end\n if ((i-k) == j)\n arr2 << representation[i][j]\n end\n end\n end\n diagonals.push(arr, arr2)\n end\n\n determine_winner(diagonals)\nend",
"def diagonals\n vals = [[], []]\n (0...size).each do |i|\n vals[0].push(get_square({:column => i, :row => i}))\n vals[1].push(get_square({:column => i, :row => size - i - 1}))\n end\n vals.map {|v| Row.new(size, {:vals => v}) }\n end",
"def diagonals\n down_diag = []\n up_diag = []\n \n # push sets of coordinates that make up both diagonals\n 0.upto(@size - 1) do |idx|\n down_diag << [idx, idx]\n up_diag << [idx, @size - 1 - idx]\n end\n\n [down_diag, up_diag].map do |diag|\n diag.map { |pos| self[pos] }\n end\n end",
"def diagonalLines\n Pxlsrt::Lines.getDiagonals(horizontalLines.flatten(1), @width, @height)\n end",
"def diagonals(arr)\n \n #define slices of array where diagonal lines can be drawn \n slices = [arr[23..36],arr[43..56],arr[63..76],arr[83..96],arr[103..116],arr[123..136],arr[143..156],arr[163..176]]\n \n #define holders for results \n diagonal_ans = []\n helper_hash = {}\n\n slices.map do |slice|\n for i in slice\n #make two sets of diagonals for each index currently selected\n #because the number of elements in each diagonal is 4, so there is no center element\n key_num1 = (arr[i-19]*arr[i]*arr[i+21]*arr[i+42])\n key_num2 = (arr[i-38]*arr[i-19]*arr[i]*arr[i+21])\n val_arr1 = [arr[i-19],arr[i],arr[i+21],arr[i+42]]\n val_arr2 = [arr[i-38],arr[i-19],arr[i],arr[i+21]]\n \n #retain the larger of the two possible diagonals for a given element \n key_num1 > key_num2 ? helper_hash[key_num1] = val_arr1 : helper_hash[key_num2] = val_arr2\n \n end\n diagonal_ans = helper_hash.max_by{|k,v| v}\n end\n @@maximums << diagonal_ans\n puts \"Diagonal max is\"\n p diagonal_ans\n\n end",
"def rDiagonalLines\n Pxlsrt::Lines.getDiagonals(horizontalLines.reverse.flatten(1).reverse, @width, @height)\n end",
"def diagonal main_diagonal=true\n diag_size = [cols, rows].min\n diag = NMatrix.new [diag_size], dtype: dtype\n\n if main_diagonal\n 0.upto(diag_size-1) do |i|\n diag[i] = self[i,i]\n end\n else\n row = 0\n (diag_size-1).downto(0) do |col|\n diag[row] = self[row,col]\n row += 1\n end\n end\n\n diag\n end",
"def d; Matrix.new(RAtlas.vec2diag(@storage)); end",
"def main_diagonal\n ([email protected]).collect { |i| @game.board.board[i][i] }\n end",
"def make_diagonal\n each{|x,y,val| set x,x,x+1 if x==y}\n self\n end",
"def diagonal\n raise NonSquareException, \"Can not get diagonal of non-square matrix.\" unless square?\n\n diag = Array.new(@rows, 0)\n iter = iterator\n while iter.has_next?\n item = iter.next\n diag[item[0]] = item[2] if item[0] == item[1]\n end\n diag\n end",
"def diagonal(a)\n rows = a.length\n cols = a[0].length\n result = []\n i, j = 0, 0\n # traverse from right to left on col\n while j < cols\n i = 0\n result << diagonalAt(a, i, j, rows)\n j += 1\n end\n # start from 1 we don't want repeatation\n i = 1\n while i < rows\n j = cols - 1\n result << diagonalAt(a, i, j, rows)\n i += 1\n end\n result\n end",
"def diagonals\n container = Array.new()\n diag_array_1 = []\n diag_array_2 = []\n for i in 0..@size-1\n diag_array_1 << i * (@size+1) \n end\n for i in 0..@size-1\n diag_array_2 << (i * (@size-1)) + @size-1\n end\n container << diag_array_1\n container << diag_array_2\n return container\n end",
"def diagonals\n [board.map.with_index { |row, i| row[i] },\n board.map.with_index { |row, i| row[row.size - i - 1] }]\n end",
"def diagonals\n [\n [@board[0][0], @board[1][1], @board[2][2]],\n [@board[0][2], @board[1][1], @board[2][0]]\n ]\n end",
"def get_diagonal_moves\n northwest_moves = []\n northeast_moves = []\n southwest_moves = []\n southeast_moves = []\n (1...ChessBoardConstants::BOARD_DIMENSIONS).each do |step|\n northwest_moves << { row: @row + step, col: @col - step }\n northeast_moves << { row: @row + step, col: @col + step }\n southwest_moves << { row: @row - step, col: @col - step }\n southeast_moves << { row: @row - step, col: @col + step }\n end\n return select_legal_moves(northwest_moves) +\n select_legal_moves(northeast_moves) +\n select_legal_moves(southwest_moves) +\n select_legal_moves(southeast_moves)\n end",
"def diagonals\n down_diag = [[0, 0], [1, 1], [2, 2]]\n up_diag = [[0, 2], [1, 1], [2, 0]]\n \n [down_diag, up_diag].map do |diag|\n diag.map { |row, col| @rows[row][col] }\n end\n end",
"def diagnoal(offset=0)\n\t\tdiag = Array.new()\n\t\t\n\t\tif(offset >= 0)\n\t\t\t0.upto(width - 1 - offset) {|i| diag.push(self[i][i+offset])}\n\t\telse\n\t\t\toffset = -offset\n\t\t\t0.upto(height - 1 - offset) {|i| diag.push(self[i+offset][i])}\n\t\tend\n\t\n\t\treturn diag\n\tend",
"def diagonals\n [\n Diagonal.new(position: 0,cells: diagonal_cells(diagonal_coordinates[:diagonal_one_coordinates])),\n Diagonal.new(position: 1,cells: diagonal_cells(diagonal_coordinates[:diagonal_two_coordinates]))\n ]\n end",
"def all_diagonals(columns)\n diagonals = []\n valid_col_rows = [\n [ [0,2], [1,3], [2,4], [3,5] ],\n [ [0,1], [1,2], [2,3], [3,4], [4,5] ],\n [ [0,0], [1,1], [2,2], [3,3], [4,4], [5,5] ],\n [ [1,0], [2,1], [3,2], [4,3], [5,4], [6,5] ],\n [ [2,0], [3,1], [4,2], [5,3], [6,4] ],\n [ [3,0], [4,1], [5,2], [6,3] ],\n\n [ [0,3], [1,2], [2,1], [3,0] ],\n [ [0,4], [1,3], [2,2], [3,1], [4,0] ],\n [ [0,5], [1,4], [2,3], [3,2], [4,1], [5,0] ],\n [ [1,5], [2,4], [3,3], [4,2], [5,1], [6,0] ],\n [ [2,5], [3,4], [4,3], [5,2], [6,1] ],\n [ [3,5], [4,4], [5,3], [6,2] ],\n ]\n\n valid_col_rows.each do |diag|\n diagonal = ''\n diag.each do |coords|\n symbol = columns[coords.first][coords.last]\n symbol.nil? ? diagonal += '-' : diagonal += symbol\n end\n diagonals << diagonal\n end\n diagonals\n end",
"def check_diagonals\n diagonal_winner = nil\n # stores the markers\n backward_diagonal = ''\n forward_diagonal = ''\n\n # for a diagonal to be a winner it takes the row[n], row[n+1], row[n+2] and so on..\n @board.each_with_index do |row,index|\n\n # check if left to right diagonal is a winner\n row.each_with_index do |marker, position|\n if position == index\n backward_diagonal += marker\n end\n end\n\n # check if right to left diagonal is a winner\n reversed_row = row.reverse\n reversed_row.each_with_index do |marker, position|\n if position == index\n forward_diagonal += marker\n end\n end\n end\n\n # checks iteration count of x or o in strings to find winner\n if backward_diagonal.count('x') == @board.size || forward_diagonal.count('x') == @board.size\n diagonal_winner = 'x'\n elsif backward_diagonal.count('o') == @board.size || forward_diagonal.count('o') == @board.size\n diagonal_winner = 'o'\n end\n\n diagonal_winner\n end",
"def diagonal(entries, opts={})\n m = NMatrix.zeros(entries.size,\n {:dtype => guess_dtype(entries[0]), :capacity => entries.size + 1}.merge(opts)\n )\n entries.each_with_index do |n, i|\n m[i,i] = n\n end\n m\n end",
"def make_diagonal_array(horizontal_array, vertical, horizontal)\n diagonal_array = []\n until vertical > 19 || horizontal < 0 do\n diagonal_array << horizontal_array[vertical][horizontal]\n vertical += 1\n horizontal -= 1\n end\n diagonal_array\nend",
"def border_diagonal()\n return get_border(:diagonal)\n end",
"def change_border_diagonal(weight='thin')\n change_border(:diagonal, weight)\n end",
"def diag(k=0)\n *shp,n = shape\n n += k.abs\n a = self.class.zeros(*shp,n,n)\n a.diagonal(k).store(self)\n a\n end",
"def diagonal_slide(row, col) # oh cool try the .downto here instead of the reverse always nice to try new things even though it doesn't make for the most sensical code as per https://stackoverflow.com/questions/2070574/is-there-a-reason-that-we-cannot-iterate-on-reverse-range-in-ruby love it the last time you did reverse just because you didn't think about it until later now knowing this you can do it this way love it ah nevermind no need but would have been great to write smaller.downto(0).map oh well lol remember that for some other time love Ruby what a great language\n (row <= col) ? (smaller, larger = row, col) : (smaller, larger = col, row) # establish which number is the smaller of the two and the larger love it you have some crazy short code lol. For the nw and se diagonals\n nw = check_blocking_pieces((1..smaller).map { |offset| [row-offset, col-offset] }) # go by smaller because that's which one will hit 0 first\n ne = check_blocking_pieces((1..(7-row)).map { |offset| [row+offset, col-offset] if ((col-offset) >= 0) }.compact) # Need to use .compact to remove all the nil elements that were returned by .map since can't quite use select or reject since you *do* want to return the evaluation of the array but ah well code smells http://ruby-doc.org/core-1.9.3/Array.html#method-i-compact if you don't get rid of these nils then in the check_blocking_pieces() you'll run into an error since it'll be trying to get an index of a nil value in moves lol amaizng that even the most misleading errors you can debug with debugger and a good eye fuck byebug is so powerful # go by larger but check that the thing doesn't go out of bounds, the only bounds that it could go out if you have the row correct is col-offset being less than 0 # ahh these return nil for everything it doesn't return for so that's the error love it great catch # don't know what you would do without byebug it's literally god mode\n sw = check_blocking_pieces((1..(7-col)).map { |offset| [row-offset, col+offset] if ((row-offset) >= 0) }.compact) # go up until col == 7 as long as row is above or equal to 0, could do it the other way too, as long as col <= 7 go until row hits 0, but same thing\n se = check_blocking_pieces((1..(7-larger)).map { |offset| [row+offset, col+offset] }) # increase up until the largest one equals 7 basically there might be some nil issues with this but this should work can't wait to check it if you add them all up and there are some nils they might not add let's see, ah nope thankfully map returns an empty array fucking love it Ruby is the best\n (nw + ne + sw + se)\nend",
"def minor_diagonal\n ([email protected]).collect { |i| @game.board.board[i][-i - 1] }\n end",
"def diagonal_coordinates\n r = @size - 1\n hsh = {diagonal_one_coordinates: [],diagonal_two_coordinates: []}\n #building diagonal one\n (0...@size).each do |x|\n hsh[:diagonal_one_coordinates] << [x,x]\n end\n\n #building diagonal two\n (0...@size).each do |x|\n hsh[:diagonal_two_coordinates] << [x,r]\n r -=1\n end\n hsh\n end",
"def diagonal_dirs\n moves = []\n # Add moves toward the top left...\n moves += grow_unblocked_moves_in_dir(-1, -1)\n # ...the bottom left...\n moves += grow_unblocked_moves_in_dir(-1, 1)\n # ...the top right...\n moves += grow_unblocked_moves_in_dir( 1, -1)\n # ...and the bottom right.\n moves += grow_unblocked_moves_in_dir( 1, 1) \n moves\n end",
"def diagonals\n [\n [self.r1_c1, self.r2_c2, self.r3_c3],\n [self.r1_c3, self.r2_c2, self.r3_c1]\n ]\n end",
"def min_distance(word1, word2)\n dp = Array.new(word1.size + 1) { Array.new(word2.size + 1) }\n\n # increment values in 1st row and col\n (0...dp.size).each do |i|\n dp[i][0] = i\n end\n (0...dp[0].size).each do |j|\n dp[0][j] = j\n end\n\n (1...dp.size).each do |i|\n (1...dp[0].size).each do |j|\n dp[i][j] = if word1[i - 1] == word2[j - 1]\n # if chars are same, value will be from diagonal upward\n dp[i - 1][j - 1]\n else\n [\n dp[i - 1][j - 1],\n dp[i][j - 1],\n dp[i - 1][j]\n ].min + 1\n end\n end\n end\n dp[-1][-1]\nend",
"def gen_diagonal_up(row,col)\n array_diagonals =[]\n 0.upto(5).each do |num|\n if ( row - num < 0 || col + num > 6)\n break\n end\n\n array_diagonals << [row-num, col+num] \n end\n array_diagonals.map{|coordinates| @grid[coordinates[1]][coordinates[0]]}\n end",
"def diagonal_coords\n data_hsh = { forward: [], backward: [] }\n @width.times do |t|\n data_hsh[:forward].push([t + 1, t + 1])\n data_hsh[:backward].push([@width - t, t + 1])\n end\n data_hsh\n end",
"def diagonal_left\n end",
"def horizontal_words\n word_vectors = []\n \n @grid.each_with_index do |line, index|\n words = discover_words(line)\n words.each do |word|\n #Set the direction as 'discover_words' is direction agnostic\n word.direction = :horizontal\n word.y_pos = index\n end\n word_vectors << words\n end\n \n word_vectors.flatten\n end",
"def parse(min_size = 0)\n diagonals = []\n column = starting_column\n row = max_row_index\n while valid_column_to_parse(column) && row >= 0\n output = []\n tmp_row = row\n tmp_column = column\n loop do\n output << @grid[tmp_column][tmp_row]\n tmp_column = next_cell_column_index(tmp_column)\n tmp_row -= 1\n if column_out_of_bounds(tmp_column) || tmp_row < 0 #out of bounds\n diagonals << output if output.length >= min_size\n if column != ending_column\n column = next_column_index(column)\n else\n row -= 1\n end\n break\n end\n end\n end\n diagonals\n end",
"def diagonal(height, lenght)\n printf \"Staciakampio istrizaine: #{Math.sqrt((height * height) + (lenght * lenght))} \\n\"\n end",
"def each_diagonal( square = nil )\n\t\t\tif square\n\t\t\t\tfile = square[0] - ?a\n\t\t\t\trank = square[1, 1].to_i - 1\n\t\t\t\t[[-1, 1], [1, -1], [1, 1], [-1, -1]].each do |(x_off, y_off)|\n\t\t\t\t\tdiag = Array.new\n\t\t\t\t\tx, y = file + x_off, rank + y_off\n\t\t\t\t\twhile (0..7).include?(x) and (0..7).include?(y)\n\t\t\t\t\t\tname = \"#{(x + ?a).chr}#{y + 1}\"\n\t\t\t\t\t\tdiag << [name, @squares[name]]\n\t\t\t\t\t\tx, y = x + x_off, y + y_off\n\t\t\t\t\tend\n\t\t\t\t\tyield diag unless diag.empty?\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t# FIX ME!\n\t\t\tend\n\t\tend",
"def diagonals_checker(square_object, board, counter_max)\n diag1 = []\n diag2 = []\n diag3 = []\n diag4 = []\n counter = 1\n while counter <= counter_max\n nil_checker1 = square_object.dup.add_row(counter)\n nil_checker2 = square_object.dup.add_row(-counter)\n\n diag1 << (square_object.dup.add_row(counter).add_column(counter)) if nil_checker1.row != nil\n diag2 << (square_object.dup.add_row(-counter).add_column(-counter)) if nil_checker2.row != nil\n diag3 << (square_object.dup.add_row(-counter).add_column(counter)) if nil_checker2.row != nil\n diag4 << (square_object.dup.add_row(counter).add_column(-counter)) if nil_checker1.row != nil\n\n counter += 1\n end\n diag1 = legal_moves_delete(diag1, board)\n diag2 = legal_moves_delete(diag2, board)\n diag3 = legal_moves_delete(diag3, board)\n diag4 = legal_moves_delete(diag4, board)\n\n diag1 + diag2 + diag3 + diag4\n end",
"def diagonal_dir\n diag_or_lat(DIAGONAL_DIRS)\n end",
"def move_diagonal(horz, vert)\r\n @move_succeed = diagonal_passable?(x, y, horz, vert)\r\n if @move_succeed\r\n @x = $game_map.round_x_with_direction(@x, horz)\r\n @y = $game_map.round_y_with_direction(@y, vert)\r\n @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))\r\n @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))\r\n increase_steps\r\n end\r\n set_direction(horz) if @direction == reverse_dir(horz)\r\n set_direction(vert) if @direction == reverse_dir(vert)\r\n end",
"def lookup_diag_no(x, y)\n x, y = normalize_coords(x, y)\n # Magic formula reverse engineered from Mykolas.\n (((1 + 2 * (y - x)) ** 2 - 1) / 8.0) + 1\n end",
"def win_diagonal?(mark)\n ltr_diagonal = []\n rtl_diagonal = []\n @grid.each.with_index do |row,r|\n row.each.with_index do |col,c|\n if r == c \n ltr_diagonal << col\n end\n \n if (row.length - r - 1) == c\n rtl_diagonal << col\n end\n end\n end\n ltr = (ltr_diagonal.uniq.length == 1) && ltr_diagonal.include?(mark) \n rtl = (rtl_diagonal.uniq.length == 1) && rtl_diagonal.include?(mark)\n ltr || rtl\n\n end",
"def replaceRDiagonal(d, arr)\n d = d.to_i\n (0...arr.length).each do |i|\n xy = rDiagonalXY(d, i)\n self[xy['x'], xy['y']] = arr[i]\n end\n end",
"def diagonals\n s = board_state\n first_diagonal = s[0] + s[4] + s[8]\n second_diagonal = s[2] + s[4] + s[6]\n [first_diagonal, second_diagonal]\n end",
"def replaceDiagonal(d, arr)\n d = d.to_i\n (0...arr.length).each do |i|\n xy = diagonalXY(d, i)\n self[xy['x'], xy['y']] = arr[i]\n end\n end",
"def convert_diagonals_to_arrays_part_1(diagonals = [], start = 0)\r\n\treturn diagonals if diagonals.size == 6\r\n\tdiagonal = []; x = start; y = 0\t\t\t\r\n\tuntil x > 5\r\n\t diagonal << cell_check(x,y)\r\n\t x += 1; y += 1\r\n\tend\r\n\tdiagonals << diagonal\r\n\tstart += 1\r\n\tconvert_diagonals_to_arrays_part_1(diagonals, start)\r\n end",
"def diagonal_paths(direction)\n off_gen = DiagonalOffsetGenerator.new(coordinates, direction)\n off_gen.moves\n end",
"def diagonal_up_to_string(row_index, col_index)\n #move to edge\n until row_index == @rows - 1 || col_index == 0\n row_index += 1\n col_index -= 1\n end\n\n #form diagonal string from edge\n diagonal_string = \"\"\n while row_index > 0 && col_index < @cols\n diagonal_string += @grid[row_index][col_index]\n row_index -= 1\n col_index += 1\n end\n diagonal_string\n end",
"def solution(s)\n grid = s.split(/\\n/).map { |row| row.split(/\\s/).map(&:to_i) }\n \n search = ->(table) do\n table.map do |row|\n row.each_cons(4).map do |seg|\n seg.reduce(:*)\n end.max\n end.max\n end\n\n squeeze = ->(table, opts={inverse: false}) do\n table.map.with_index do |row,depth|\n row.rotate(opts[:inverse] ? -depth : depth)\n end.transpose\n end\n\n [\n search[grid], # horizontal\n search[grid.transpose], # vertical\n search[squeeze[grid]], # down_diagonals\n search[squeeze[grid, inverse: true]] # up_diagonals\n ].max\nend",
"def get_diagonal_elements(row, column)\n queried_diagonals = [1,-1].each_with_object([]) do |slope, diagonals|\n diagonal = get_points(column, row, slope).each_with_object([]) do |point, elements|\n elements << @cells[point[1]][point[0]]\n end\n\n diagonals << diagonal\n end\n\n queried_diagonals.reject {|diagonal| diagonal.size == 1 }\n end",
"def move_diagonal(horz, vert)\r\r\n pixelstep = CXJ::FREE_MOVEMENT::PIXELS_PER_STEP / 32.0\r\r\n @move_poll+= [[vert + (horz > 5 ? 1 : -1), true]] * (distance_per_frame / pixelstep).ceil\r\r\n end",
"def diag?(twod_arr)\n first_diag = []\n second_diag = [] # two arrays for later storage\n\n (0...twod_arr.length).each do |idx| # looping though the length of the array\n first_diag << twod_arr[idx][idx] # storeing the first diag, it's easy since its index will always be the same\n second_diag << twod_arr[idx][twod_arr.length - 1 -idx] #second diag, this is the invert of \n end\n\n first_diag.uniq.length == 1 || second_diag.uniq.length == 1\nend",
"def diagonal_dirs\n move_set = []\n move_set += grow_unblocked_moves_in_dir(1, -1)\n move_set += grow_unblocked_moves_in_dir(1, 1)\n move_set += grow_unblocked_moves_in_dir(-1, -1)\n move_set += grow_unblocked_moves_in_dir(-1, 1)\n end",
"def justify(linewrap=false)\n\n\t\tif @linelength == 0 then @linelength = $screen.cols end\n\n\t\tif linewrap\n\t\t\tcols = @linelength\n\t\t\tif @text[@row].length < cols then return end\n\t\telse\n\t\t\t# ask for screen width\n\t\t\t# nil means cancel, empty means screen width\n\t\t\tans = $screen.ask(\"Justify width: \",[@linelength.to_s],true)\n\t\t\tif ans == nil\n\t\t\t\t$screen.write_message(\"Cancelled\")\n\t\t\t\treturn\n\t\t\tend\n\t\t\tif ans == \"\"\n\t\t\t\tcols = @linelength\n\t\t\telsif ans == \"0\"\n\t\t\t\tcols = $screen.cols\n\t\t\telsif ans.to_i < 0\n\t\t\t\tcols = $screen.cols + ans.to_i\n\t\t\telse\n\t\t\t\tcols = ans.to_i\n\t\t\tend\n\t\t\t@linelength = cols\n\t\tend\n\n\t\t# set start & end rows\n\t\tif @marked\n\t\t\tmark_row, row = ordered_mark_rows\n\t\telse\n\t\t\tmark_row = @row\n\t\t\trow = @row\n\t\tend\n\t\tnl = row - mark_row + 1\n\n\t\t# make one long line out of multiple lines\n\t\ttext = @text[mark_row..row].join(\" \")\n\t\tfor r in mark_row..row\n\t\t\tdelrow(mark_row)\n\t\tend\n\n\t\t# loop through words and check length\n\t\tc = 0\n\t\tr = mark_row\n\t\tloop do\n\t\t\tc2 = text.index(/([^\\s]\\s)|($)/,c) # end of next word\n\t\t\tif c2 == nil then break end # end, if no more words\n\t\t\t# if we are past the edge, then put it in the next row\n\t\t\t# Otherwise, keep going.\n\t\t\tif c2 >= (cols-1)\n\t\t\t\tif c == 0 then c = c2+1 end # careful about long words\n\t\t\t\tinsertrow(r,text[0,c])\n\t\t\t\ttext = text[c..-1]\n\t\t\t\tif text == nil then text = \"\" end\n\t\t\t\ttext.lstrip!\n\t\t\t\tr += 1\n\t\t\t\tc = 0\n\t\t\telse\n\t\t\t\tc = c2+1\n\t\t\tend\n\t\t\tif text == nil || text == \"\"\n\t\t\t\ttext = \"\"\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\tinsertrow(r,text)\n\t\t$screen.write_message(\"Justified to \"+cols.to_s+\" columns\")\n\t\tif linewrap\n\t\t\tif @col >= @text[@row].length+1\n\t\t\t\t@col = @col - @text[@row].length - 1\n\t\t\t\t@row += 1\n\t\t\tend\n\t\telse\n\t\t\t@row = r\n\t\t\t@col = 0\n\t\tend\n\t\t@marked = false\n\tend",
"def normalize_matrix(matrix)\n matrix_width = 0\n\n matrix.each do |line|\n matrix_width = line.length if line.length > matrix_width\n end\n\n matrix.each do |line|\n if line.length < matrix_width\n line[line.length, matrix_width - line.length] = '.'\n end\n end\nend",
"def each_diagonal(&block)\n diags_coords = [[[1,1], [2,2], [3,3]],\n [[1,3], [2,2], [3,1]]]\n diags = diags_coords.map do |diag_coords|\n diag_coords.map do |l, c|\n self[l,c]\n end\n end\n\n each_for diags, &block\n end",
"def diagAve(arr, i, j) # (arr= input, i=0 , j = 0)\n \n nums = [arr[i][j]]\n\n # we iterate through matrix as long as we are inbound\n while (i+1 > 0 && j-1 >= 0)\n\n if (i+1 < arr.length && j-1 < arr[0].length)\n i+=1\n j-=1\n nums.push(arr[i][j])\n else\n break\n end\n end\n\n length = nums.length\n (nums.reduce(:+))/length\nend",
"def minor_diagnoal(offset=0)\n\t\tdiag = Array.new()\n\t\tif(offset >= 0)\n\t\t\t0.upto(height-1-offset) {|i| diag.push(self[i][width-1-offset-i])}\n\t\telse\n\t\t\toffset = -offset\n\t\t\toffset.upto(height-1) {|i| diag.push(self[i][width-i+offset-1])}\n\n\t\tend\n\t\n\t\treturn diag\n\tend",
"def diagonal_cells(koordinates)\n cells.select do |cell|\n koordinates.include?([cell.coordinate.x,cell.coordinate.y])\n end\n end",
"def vertical_words\n word_vectors = []\n inverted_grid = Matrix.rows(@grid.map { |line| line.split('') }).transpose.to_a.map {|line| line.join}\n \n inverted_grid.each_with_index do |line, index|\n words = discover_words(line)\n words.each do |word|\n #Set the direction as 'discover_words' is direction agnostic\n word.direction = :vertical\n #Need to set the y_pos to the x_pos as the grid is inverted\n word.y_pos = word.x_pos\n word.x_pos = index\n end\n word_vectors << words\n end\n \n word_vectors.flatten\n end",
"def justify(array, max_length=16)\n words_per_line = 0\n character_count = 0\n per_line = []\n\n array.each_with_index do |word, index|\n if (character_count + word.length) > max_length\n per_line << words_per_line\n character_count = 0\n words_per_line = 0\n end\n character_count += word.length + 1\n words_per_line += 1\n end\n\n per_line << array.size - per_line.inject(:+) if (array.size - per_line.inject(:+)) != 1\n\n result = []\n number_of_lines = per_line.size\n\n 0.upto(number_of_lines - 1) do |i|\n line = array.first(per_line[i])\n array = array.drop(per_line[i])\n\n num_of_chars = line.join(\" \").size\n num_of_chars_to_fill = max_length - num_of_chars\n num_of_words = per_line[i]\n num_of_words == 1 ? num_of_spaces = 1 : num_of_spaces = (num_of_words - 1)\n\n if num_of_chars_to_fill % num_of_spaces == 0\n 0.upto(num_of_spaces-1) do |space|\n line[space] << \" \" * (num_of_chars_to_fill/num_of_spaces)\n ##will only occur when number of chars to fill is less than the num of spaces.\n if num_of_chars_to_fill > 0 && num_of_chars_to_fill/num_of_spaces == 0\n ## Add the num_of_chars_to_fill to the most lefterly spaces.\n count = 0\n until count == num_of_chars_to_fill\n line[count] << \" \"\n count += 1\n end\n end\n end\n elsif num_of_chars_to_fill % num_of_spaces != 0\n if num_of_chars_to_fill == 1\n line[0] << \" \"\n elsif num_of_chars_to_fill > 1\n 0.upto(num_of_spaces-1) do |space|\n line[space] << \" \" * (num_of_chars_to_fill/num_of_spaces)\n line[0] << \" \"\n if num_of_chars_to_fill > 0 && num_of_chars_to_fill/num_of_spaces == 0\n ## Add the num_of_chars_to_fill to the most lefterly spaces.\n ## Count == as we have already placed one.\n count = 1\n until count == num_of_chars_to_fill\n line[count] << \" \"\n count += 1\n end\n end\n end\n end\n end\n line = line.join(\" \")\n result << line\n end\n\n unless array.empty?\n last_line = array[0] + (\" \" * (max_length - array[0].size))\n result << last_line\n end\n\n puts result\nend",
"def find_words(words)\n @words = words.map { |w| MatrixWord.new(w) }\n @words.each { |mw| place mw if (!mw.word.nil? && mw.word.size <= @width) }\n @words.select { |w| !w.place.nil? }\n end",
"def potential_diagonal_moves is_king=false\n moves = []\n\n # Possible moves\n # - all possible combination of increment/decrement of r_idx/c_idx\n\n r_min = is_king ? (r_idx - 1 >= 0 ? r_idx - 1 : r_idx) : 0\n c_min = is_king ? (c_idx - 1 >= 0 ? c_idx - 1 : c_idx) : 0\n r_max = is_king ? (r_idx + 1 <= 7 ? r_idx + 1 : r_idx) : Board::WIDTH - 1\n c_max = is_king ? (c_idx + 1 <= 7 ? c_idx + 1 : c_idx) : Board::WIDTH - 1\n\n # top-right: row-decrement, column-increment [4, 5] [3, 6]\n r = r_idx - 1\n c = c_idx + 1\n while (r >= r_min) && (c <= c_max)\n moves << [r, c]\n r -= 1\n c += 1\n end\n\n # bottom-right: row-increment, column-increment [4, 5] [5, 6]\n r = r_idx + 1\n c = c_idx + 1\n while (r <= r_max) && (c <= c_max)\n moves << [r, c]\n r += 1\n c += 1\n end\n\n # bottom-left: row-increment, column-decrement [4, 5] [5, 4]\n r = r_idx + 1\n c = c_idx - 1\n while (r <= r_max) && (c >= c_min)\n moves << [r, c]\n r += 1\n c -= 1\n end\n\n # top-left: row-decrement, column-decrement [4, 5] [3, 4]\n r = r_idx - 1\n c = c_idx - 1\n while (r >= r_min) && (c >= c_min)\n moves << [r, c]\n r -= 1\n c -= 1\n end\n\n # TODO\n # - refactor to avoid repeated pattern of code without compromising with runtime\n\n moves\n end",
"def sum_of_diagonals\r\n\tresult = []\r\n\tresult.push 1\r\n\twidth = 3\r\n\twhile width <= 1001\r\n\t\tresult.push width**2, width**2 - (width-1), width**2 - (width-1)*2, width**2 - (width-1)*3\r\n\t\twidth += 2\r\n\tend\r\n\treturn result.reduce(:+)\r\nend",
"def diagonally_dominant_by_row?\n @colt_property.diagonallyDominantByRow(@colt_matrix)\n end",
"def solve(*words)\n words = words.collect { |word| word.upcase_trim }\n\n #\n # Make the various transformations, checking for matches along the\n # way.\n #\n normalize ; replicate_match(words) # match L->R\n flip_horizontal ; replicate_match(words) # match R->L\n diagonalize ; replicate_match(words) # match TL->BR\n flip_horizontal ; replicate_match(words) # match BR->TL\n undiagonalize(true) ; replicate_match(words) # match T->B\n flip_horizontal ; replicate_match(words) # match B->T\n flip_vertical ; flip_horizontal\n diagonalize ; replicate_match(words) # match BL->TR\n flip_horizontal ; replicate_match(words) # match TR->BL\n undiagonalize(false)\n\n #\n # And return the solution.\n #\n @sltn_lines\n end",
"def diagonal_size\n Math.sqrt( @room_height * @room_height + @room_width * @room_width ).round(0)\n end",
"def win_lines\n\t\t(\n\t\t\t([email protected]).each_slice(@dim).to_a +\n\t\t\t([email protected]).each_slice(@dim).to_a.transpose +\n\t\t\t[ ([email protected]).step(@dim.succ).to_a ] +\n\t\t\t[ (@dim.pred..(@size-@dim)).step(@dim.pred).to_a ]\n\t\t).map { |line| line.map { |idx| @board[idx] }}\n\tend",
"def diagonal_line (board)\n if (board[0][0] == \"O\" && board[1][1] == \"O\" && board[2][2] == \"O\")\n return true\n elsif (board[2][0] == \"O\" && board[1][1] == \"O\" && board[0][2] == \"O\")\n return true\n elsif (board[0][0] == \"X\" && board[1][1] == \"X\" && board[2][2] == \"X\")\n return true\n elsif (board[2][0] == \"X\" && board[1][1] == \"X\" && board[0][2] == \"X\")\n return true\n end\n return false\n end",
"def diagonal_traversal(matrix)\n raise NotImplementedError, \"This method has not yet been implemented\"\nend",
"def diagonal_dirs \n DIAGONAL_DIRS\n end",
"def diagonal?\n @colt_property.diagonal(@colt_matrix)\n end",
"def diagonal_move\n (@initial_pos[0] - @final_pos[0]).abs == (@initial_pos[1] - @final_pos[1]).abs\n end",
"def should_check_diagonal?\n return false unless @two_dimensional_arrays[2].any? { |column| column != \".\" }\n true\n end",
"def runAlgorithm(row)\n for column in 0..@width-1\n if @columns[column] >= 0 then\n next\n end\n\n ixDiag1 = row + column\n if @diagonals1[ixDiag1] then\n next\n end\n\n ixDiag2 = @lastRow - row + column\n if @diagonals2[ixDiag2] then\n next\n end\n\n @columns[column] = row\n @diagonals1[ixDiag1] = true\n @diagonals2[ixDiag2] = true\n\n if row == @lastRow then\n @solutions.push(@columns.dup)\n else\n runAlgorithm(row + 1)\n end\n\n @columns[column] = -1\n @diagonals1[ixDiag1] = false\n @diagonals2[ixDiag2] = false\n end\n end",
"def win_diagonal?(mark)\n diag1 = []\n diag2 = []\n @grid.each_with_index do |row, idx|\n diag1 << @grid[idx][idx]\n diag2 << @grid[idx][(idx+1)*-1]\n end\n (diag1.uniq[0] == mark && diag1.uniq.length == 1) || (diag2.uniq[0] == mark && diag2.uniq.length == 1)\n end",
"def get_diag_ne_sw(n)\n\t\tprepare(@dim_i,@dim_j)\n\t\ttmpTab = Array.new\n\t\tdim = @dim_i\n\t\tif (n<0)\n\t\t\tdeb = n.abs\n\t\t\tfin = dim - 1\n\t\t\titerateur = dim - 1\n\t\tend\n\t\tif (n==0)\n\t\t\tdeb = 0\n\t\t\tfin = dim - 1\n\t\t\titerateur = dim - 1\n\t\tend\n\t\tif (n>0)\n\t\t\tdeb = 0\n\t\t\tfin = dim - 1 - n\n\t\t\titerateur = dim - 1 - n\n\t\tend\n\t\tfor i in deb..fin\n\t\t\ttmpTab.push @myTab[i][iterateur]\n\t\t\titerateur = iterateur - 1\n\t\tend\n\t\treturn tmpTab\n\tend",
"def crossword(arr, word)\n earliest_col = -1\n ans = []\n arr.each_with_index do |row, i|\n earliest_col = solve_horiz(row, word)\n ans = [i, earliest_col]\n break\n end\n\n tarr = transpose arr\n tarr.each_with_index do |col, i|\n earliest_row = solve_horiz(row, word)\n if earliest_row <= ans[0] && i <= ans[1]\n ans = [earliest_row, i]\n end\n break\n end\n\n ans\nend",
"def solution \n row_search \n columns_search \n diagonal_search\n end",
"def diagonalSum(matrix)\n # case Matrix[*matrix].column_size\n # when Matrix[*matrix].row_size\n x=0\n y=0\n p matrix.class\n while x<matrix.flatten.size do \n y=y+matrix.flatten[x]\n x=x+matrix.size+1 \n # print \"x= #{x}, y = #{y}, \"\n end\n y\nend",
"def diagonally_dominant_by_column?\n @colt_property.diagonallyDominantByColumn(@colt_matrix)\n end",
"def challenge137(input)\n # Using the built-in transpose method.\n # Could have used the 'safe transpose' method found in http://www.matthewbass.com/2009/05/02/how-to-safely-transpose-ruby-arrays/\n # but I figured I'd go the padding route to learn something (I'm new to ruby).\n transposed_array = normalize_array(input.lines).transpose\n transposed_array.each { |line| p line }\nend",
"def extent; @bounds.diagonal; end",
"def check_left_diagonal\n if @game_array[0][0] == @game_array[1][1] &&\n @game_array[0][0] == @game_array[2][2] &&\n !@game_array[0][0].nil?\n\n @game_array[0][0]\n end\n end",
"def in_ascending_diagonal?\n if @board.each_with_index.map {|row, index| row[4-index]} == @key\n true\n else\n false\n end\n end",
"def moves\n diagonal_dirs\n end",
"def diag_scode\n diag_code[0,3].rjust(3,'0') if diag_code.present?\n end",
"def board_diagonal_values(board, left_diagonal = true)\n values = []\n start_at = left_diagonal ? 1 : 3\n BOARD_HEIGHT.times do\n values << board[start_at]\n start_at += BOARD_WIDTH\n start_at = left_diagonal ? start_at + 1 : start_at - 1\n end\n values\nend",
"def diagonalCount(n)\n\n#First number saved as \"start.\"\"\nstart = n**2\n\n#Solution is the variable to which we add all elements of the diagonals.\nsolution = 0\n\n#Increment is the gap between elements of diagonals. \nincrement = n - 1\n\n#The first loop continues until start == 1.\nwhile start > 1\n\n#The number of diagonal elements for each \"increment.\"\nk = 4\n\n#The second, nested loop, which repeats four times for each increment\n#and adds the diagonal entries (stored in the \"start\" variable)\n#to solution.\nwhile k > 0\nsolution += start\nstart -= increment\nk -= 1\nend\n\n#After each sequence of 4 entries, we subtract two from the increment\n#variable to add the diagonal elements in the next \"square\" within the\n#grid.\nincrement -= 2\n\nend\n\n#After the final loop is complete, start will equal 1, but will not\n#have been added to solution. The final step is to add 1 and output\n#the solution.\n\nputs solution + 1\n\nend",
"def diagonal_left_right\n func = lambda do |arr, mark|\n return mark if arr.all? { |el| el == mark } end\n\n left = []; len = @grid.length\n (0...len).each { |i| left << @grid[i][i] }\n\n right = []; len = @grid.length - 1\n ([email protected]).each { |i| right << @grid[i][len-i] }\n\n return :X if (func.call(left, :X) == :X) || (func.call(right, :X) == :X)\n return :O if (func.call(left, :O) == :O) || (func.call(right, :O) == :O)\n end",
"def diagonal_data\n ret_hsh = {}\n diagonal_coords.each do |k, arr|\n vals = arr.map do |sub_arr|\n @grid[sub_arr[0].to_s][sub_arr[1].to_s]\n end\n ret_hsh[k] = vals\n end\n ret_hsh\n end",
"def redesign\n x = @mat[0].length\n y = @mat.size\n (1..y-2).each do |i|\n (1..x-2).each do |j|\n @mat[i][j] = \"0\"\n end\n end\n\n divide(1,x-2,1,y-2)\n end",
"def get_diagonal_difference(\n matrix:\n )\n primary_dia, secondary_dia = 0, 0\n array_length = matrix[0].length - 1\n # Calculate diagonal sum\n (0...matrix[0].length).each do |index|\n \tprimary_dia += matrix[index][index]\n \tsecondary_dia += matrix[index][array_length]\n \tarray_length -= 1\n end\n # Return absolute value of the difference between to diagonals\n (primary_dia - secondary_dia).abs\nend",
"def check_diagonals\n 0.upto(2) do |i|\n 0.upto(3) do |j|\n if (@board[j][i].to_s + @board[j + 1][i + 1].to_s + @board[j + 2][i + 2].to_s + @board[j + 3][i + 3].to_s).match(/RRRR|BBBB/) != nil\n return true\n end\n end\n 3.upto(6) do |j|\n if (@board[j][i].to_s + @board[j - 1][i + 1].to_s + @board[j - 2][i + 2].to_s + @board[j - 3][i + 3].to_s).match(/RRRR|BBBB/) != nil\n return true\n end\n end\n end\n return false\n end",
"def kill_cells_in_borders\n (0..@long - 1).each do |long|\n (0..@width - 1).each do |width|\n @matriz[long][width] = ' . ' if long.zero? || (long == @long - 1) || width.zero? || (width == @width - 1)\n end\n end\n end"
] | [
"0.67708445",
"0.6632957",
"0.6403742",
"0.6285169",
"0.621031",
"0.6162703",
"0.6037388",
"0.6034925",
"0.5980928",
"0.59733415",
"0.5965713",
"0.59457356",
"0.59091485",
"0.5899854",
"0.58809996",
"0.5859907",
"0.5839957",
"0.578601",
"0.5777867",
"0.5761868",
"0.57285726",
"0.5693651",
"0.56572187",
"0.55829567",
"0.55567604",
"0.5459954",
"0.5429611",
"0.54258364",
"0.53716695",
"0.5369264",
"0.5364304",
"0.5334893",
"0.5332418",
"0.532791",
"0.5294824",
"0.5287457",
"0.52826136",
"0.52527755",
"0.52221304",
"0.52076364",
"0.5203527",
"0.5202476",
"0.5202273",
"0.5170211",
"0.5165985",
"0.51624256",
"0.51623243",
"0.5159934",
"0.5156975",
"0.51496774",
"0.5147397",
"0.5145788",
"0.51425827",
"0.5132094",
"0.5116768",
"0.51115483",
"0.5111496",
"0.5110614",
"0.5100389",
"0.50822806",
"0.5076421",
"0.5058016",
"0.50453097",
"0.5042626",
"0.502157",
"0.49744746",
"0.49722084",
"0.49566826",
"0.49515414",
"0.4940825",
"0.493634",
"0.4930037",
"0.49284998",
"0.49101442",
"0.48825765",
"0.48802412",
"0.4873608",
"0.48634455",
"0.4860908",
"0.48603463",
"0.4859402",
"0.48489317",
"0.48357442",
"0.48345315",
"0.48262084",
"0.48251432",
"0.48244175",
"0.4818659",
"0.48133314",
"0.48088405",
"0.48046634",
"0.48025364",
"0.47950438",
"0.4790866",
"0.47889984",
"0.47805518",
"0.4776698",
"0.4769999",
"0.47593367",
"0.47571295"
] | 0.72818345 | 0 |
word_search.undiagonalize(transposed) Convert the lines of the current word search puzzle object back into a rectangular form. Because we don't do true matrixlike manipulation (we work with simple strings) and thus lose any original indexing (via simple string appending), we need original shape information in order to do the reconstruction. But this is perhaps fortuitous, because we can in fact reconstruct the lines into a transposedlike shape (saving us several transformation steps). | def undiagonalize(transposed)
text_lines = @text_lines
@text_lines = Array.new(transposed ? @width : @height) { String.new }
sltn_lines = @sltn_lines
@sltn_lines = Array.new(transposed ? @width : @height) { String.new }
text_lines.each_with_index do |line, i|
if (transposed)
o = (i + 1 < @height)? 0 : i + 1 - @height
else
o = (i + 1 < @width)? 0 : i + 1 - @width
end
line.split('').each_with_index do |char, j|
@text_lines[j+o] << char
@sltn_lines[j+o] << sltn_lines[i][j]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diagonalize\n text_lines = @text_lines ; @text_lines = [ ]\n sltn_lines = @sltn_lines ; @sltn_lines = [ ]\n text_lines.each_with_index do |line, i|\n line.split('').each_with_index do |char, j|\n (@text_lines[i+j] ||= '') << char\n (@sltn_lines[i+j] ||= '') << sltn_lines[i][j]\n end\n end\n end",
"def diagonalize floor = 0\n raise 'err: not 2d' unless self[0].class == Array\n size = self.length + self[0].length - 1\n array = Array.new(size) {Array.new}\n # acquire top and main diagonal\n self.length.times do |row|\n (0 .. row).each do |col|\n array[row] << self[row-col][col]\n end\n end\n # now cover the additional bottom diagonals\n sides_difference = self.length[0] - self.length\n if sides_difference == 0\n (1 .. self.length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self.length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self.length - 1 + row] = temp_arr\n end\n else\n (1 .. self[0].length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self[0].length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self[0].length - 2 + row] = temp_arr\n end\n end\n\n # phew... now to trim and format\n unless floor == 0\n index = 0\n while index < size\n if array[index].length < floor\n array.slice! index\n size -= 1\n index -= 1\n end\n index += 1\n end\n end\n\n (0..size-1).each do |index|\n while array[index].length < self.length\n array[index] << nil\n end\n end\n array\n end",
"def challenge137(input)\n # Using the built-in transpose method.\n # Could have used the 'safe transpose' method found in http://www.matthewbass.com/2009/05/02/how-to-safely-transpose-ruby-arrays/\n # but I figured I'd go the padding route to learn something (I'm new to ruby).\n transposed_array = normalize_array(input.lines).transpose\n transposed_array.each { |line| p line }\nend",
"def vertical_words\n word_vectors = []\n inverted_grid = Matrix.rows(@grid.map { |line| line.split('') }).transpose.to_a.map {|line| line.join}\n \n inverted_grid.each_with_index do |line, index|\n words = discover_words(line)\n words.each do |word|\n #Set the direction as 'discover_words' is direction agnostic\n word.direction = :vertical\n #Need to set the y_pos to the x_pos as the grid is inverted\n word.y_pos = word.x_pos\n word.x_pos = index\n end\n word_vectors << words\n end\n \n word_vectors.flatten\n end",
"def trans(input)\n\trows, columns = input.count, input.first.count\n\tx, y = [], []\n\ti = j = 0\n\twhile j < columns do\n\t\twhile i <= rows - 1 do\n\t\t\tx.push(input[i][j])\n\t\t\ti += 1\n\t\tend\n\t\tj += 1 #go to next column\n\t\ti = 0 #reset the inner counter to go back to 1st array\n\tend\n\tx.each_slice(rows).each.map{|e| y.push(e)}\n\treturn y\nend",
"def crossword(arr, word)\n earliest_col = -1\n ans = []\n arr.each_with_index do |row, i|\n earliest_col = solve_horiz(row, word)\n ans = [i, earliest_col]\n break\n end\n\n tarr = transpose arr\n tarr.each_with_index do |col, i|\n earliest_row = solve_horiz(row, word)\n if earliest_row <= ans[0] && i <= ans[1]\n ans = [earliest_row, i]\n end\n break\n end\n\n ans\nend",
"def solution(s)\n grid = s.split(/\\n/).map { |row| row.split(/\\s/).map(&:to_i) }\n \n search = ->(table) do\n table.map do |row|\n row.each_cons(4).map do |seg|\n seg.reduce(:*)\n end.max\n end.max\n end\n\n squeeze = ->(table, opts={inverse: false}) do\n table.map.with_index do |row,depth|\n row.rotate(opts[:inverse] ? -depth : depth)\n end.transpose\n end\n\n [\n search[grid], # horizontal\n search[grid.transpose], # vertical\n search[squeeze[grid]], # down_diagonals\n search[squeeze[grid, inverse: true]] # up_diagonals\n ].max\nend",
"def transpose(text)\n\n words = text.split(\"\\n\")\n words.shift # remove the starting number \n\n maxlen = words.map { |w| w.length }.max\n\n for i in 0..maxlen - 1 do\n\n line = \"\"\n words.each do |w|\n line << (w[i].nil? ? \" \" : w[i])\n end\n\n puts line\n end\n\n\nend",
"def to_a(newlines: false, phrases: true)\n grid[:rows]\n .reverse\n .map { |row|\n grid[:columns].map do |column|\n render(\n phrases ? words_inside(column, row) : chars_inside(column, row),\n newlines: newlines\n )\n end\n }\n end",
"def to_a(newlines: false, phrases: true)\n grid[:rows]\n .reverse\n .map { |row|\n grid[:columns].map do |column|\n render(\n phrases ? words_inside(column, row) : chars_inside(column, row),\n newlines: newlines\n )\n end\n }\n end",
"def my_transpose(matrix)\n #algorithm\n for i in 0...matrix[0].length\n for j in (i + 1)...matrix[0].length\n temp = matrix[i][j]\n matrix[i][j] = matrix[j][i]\n matrix[j][i] = temp\n end\n end\n\n #printer\n for k in (0..(matrix[0].length-1))\n puts matrix[k].join(\" \")\n end\n matrix\nend",
"def antidiagonal_starts\n result = []\n # Insert the antidiagonal starts along the bottom edge first, beginning on\n # the right side\n (1..size).each do |n|\n result.push MatrixPosition.new(size-1, size-n)\n end\n\n # Start at 2 since the last iterator covered (size-1, 0)\n (2..size).each do |n|\n result.push MatrixPosition.new(size-n, 0)\n end\n\n result\n end",
"def normalize_matrix(matrix)\n matrix_width = 0\n\n matrix.each do |line|\n matrix_width = line.length if line.length > matrix_width\n end\n\n matrix.each do |line|\n if line.length < matrix_width\n line[line.length, matrix_width - line.length] = '.'\n end\n end\nend",
"def squarocol?(array)\n outer_iterator = 0\n while outer_iterator < array.length\n first_ele = array[outer_iterator].first\n return true if array[outer_iterator].all? { |ele| ele == first_ele }\n outer_iterator += 1\n end\n\n transposed = []\n\n outer_iterator = 0\n while outer_iterator < array.length\n inner_iterator = 0\n row = []\n while inner_iterator < array.length\n row << array[inner_iterator][outer_iterator]\n inner_iterator += 1\n end\n transposed << row\n outer_iterator += 1\n end\n \n\n transposed.each do |ele|\n first = ele.first\n return true if ele.all? { |ele| ele == first}\n end\n\n false\nend",
"def solve(*words)\n words = words.collect { |word| word.upcase_trim }\n\n #\n # Make the various transformations, checking for matches along the\n # way.\n #\n normalize ; replicate_match(words) # match L->R\n flip_horizontal ; replicate_match(words) # match R->L\n diagonalize ; replicate_match(words) # match TL->BR\n flip_horizontal ; replicate_match(words) # match BR->TL\n undiagonalize(true) ; replicate_match(words) # match T->B\n flip_horizontal ; replicate_match(words) # match B->T\n flip_vertical ; flip_horizontal\n diagonalize ; replicate_match(words) # match BL->TR\n flip_horizontal ; replicate_match(words) # match TR->BL\n undiagonalize(false)\n\n #\n # And return the solution.\n #\n @sltn_lines\n end",
"def inverse_from(src)\n size = row_size - 1\n a = src.to_a\n \n my_rows = @rows\n for k in 0..size\n i = k\n akk = a[k][k].abs\n for j in (k+1)..size\n v = a[j][k].abs\n if v > akk\n i = j\n akk = v\n end\n end\n Matrix.Raise ErrNotRegular if akk == 0\n if i != k\n a[i], a[k] = a[k], a[i]\n my_rows[i], my_rows[k] = my_rows[k], my_rows[i]\n end\n akk = a[k][k]\n \n for i in 0 .. size\n next if i == k\n q = a[i][k] / akk\n a[i][k] = 0\n \n #(k + 1).upto(size) do\n j = k + 1\n while j <= size \n a[i][j] -= a[k][j] * q\n j += 1\n end\n # 0.upto(size) do\n j = 0\n while j <= size\n my_rows[i][j] -= my_rows[k][j] * q\n j += 1\n end\n end\n \n #(k + 1).upto(size) do\n j = k + 1\n while j <= size\n a[k][j] /= akk\n j += 1\n end\n # 0.upto(size) do\n j = 0\n while j <= size\n my_rows[k][j] /= akk\n j += 1\n end\n end\n self\n end",
"def transpositions\n new_words = []\n @words.each do |word|\n @word = word || '' \n new_words += (0..length-1).map { |i| \"#{@word[0...i]}#{@word[i+1, 1]}#{@word[i,1]}#{@word[i+2..-1]}\" }\n end\n new_words\n end",
"def solve\r\n\t\t\traise MatrixSizeError unless @height + 1 == @width\r\n\r\n\t\t\tinverse = []\r\n\t\t\tm = self.to_a\r\n\t\t\tn = @height\r\n\r\n\t\t\tn.times do |j|\r\n\t\t\t\t# Find non-zero entry\r\n\t\t\t\trow = nil\r\n\t\t\t\tj.upto(n - 1) do |i|\r\n\t\t\t\t\tunless m[i][j].zero?\r\n\t\t\t\t\t\trow = i\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\t\treturn nil unless row\r\n\r\n\t\t\t\t# Swap?\r\n\t\t\t\tif j < row\r\n\t\t\t\t\tm[row], m[j] = m[j], m[row]\r\n\t\t\t\tend\r\n\r\n\t\t\t\t# Eliminate\r\n\t\t\t\tinverse[j] = m[j][j].inverse\r\n\t\t\t\t(j + 1).upto(n - 1) do |i|\r\n\t\t\t\t\tc = m[i][j] * inverse[j]\r\n\r\n\t\t\t\t\t(j + 1).upto(n) do |j2|\r\n\t\t\t\t\t\tm[i][j2] -= m[j][j2] * c\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\r\n\t\t\t# Solve triangular system\r\n\t\t\tx = []\r\n\t\t\t(n - 1).downto(0) do |i|\r\n\t\t\t\ttemp = m[i][n]\r\n\t\t\t\t(i + 1).upto(n - 1) do |j|\r\n\t\t\t\t\ttemp -= m[i][j] * x[j]\r\n\t\t\t\tend\r\n\t\t\t\tx[i] = temp * inverse[i]\r\n\t\t\tend\r\n\r\n\t\t\treturn Abst::Vector(self.class.coef_class, x)\r\n\t\tend",
"def vertically_striped(unstriped)\n output = unstriped.dup\n row_width = output[0].length\n\n # Zero out top and bottom 2 rows\n output[0] = [0] * row_width\n output[1] = [0] * row_width\n output[-1] = [0] * row_width\n output[-2] = [0] * row_width\n output\n end",
"def tridiagonal?\n @colt_property.isTridiagonal(@colt_matrix)\n end",
"def transposition\n (0...length-1).map { |i|\n string[0...i] +\n string[i+1, 1] +\n string[i,1] +\n string[i+2..-1]\n }.uniq\n end",
"def fold_up(state)\n new_state = []\n state.column_vectors.each {|column|\n values = column.to_a\n values = @line_folder.fold(values)\n new_state << values\n }\n Matrix.columns(new_state)\n end",
"def normalize(body)\n lines = body.split(\"\\n\")\n width = lines.first.length\n number_of_syms_to_wrap = (Dimensions::WIDTH - width) / 2\n syms_string = Citizen::DEAD * number_of_syms_to_wrap\n horiz_wrapped = lines.map { |line| syms_string + line + syms_string }\n\n matrix = horiz_wrapped.map { |row| row.split(\"\") }\n height = matrix.size\n\n number_of_row_wraps = (Dimensions::HEIGHT - height) / 2\n dead_row = (Citizen::DEAD * Dimensions::WIDTH).split(\"\")\n number_of_row_wraps.times do\n matrix = [dead_row] + matrix + [dead_row]\n end\n matrix.map(&:join).join(\"\\n\")\n end",
"def grab_line(search, row, col, length, orientation)\n line = \"\"\n\n case orientation\n when :down\n # check boundary case\n if search.has_key?([row + length, col])\n (0..length).each do |i|\n line += search[[row + i, col]]\n end\n end\n\n when :down_right\n # check boundary case\n if search.has_key?([row + length, col + length])\n (0..length).each do |i|\n line += search[[row + i, col + i]]\n end\n end\n\n when :right\n # check boundary case\n if search.has_key?([row, col + length])\n (0..length).each do |i|\n line += search[[row, col + i]]\n end\n end\n\n when :up_right\n # check boundary case\n if search.has_key?([row - length, col + length])\n (0..length).each do |i|\n line += search[[row - i, col + i]]\n end\n end\n\n when :up\n # check boundary case\n if search.has_key?([row - length, col])\n (0..length).each do |i|\n line += search[[row - i, col]]\n end\n end\n\n when :up_left\n # check boundary case\n if search.has_key?([row - length, col - length])\n (0..length).each do |i|\n line += search[[row - i, col - i]]\n end\n end\n\n when :left\n # check boundary case\n if search.has_key?([row, col - length])\n (0..length).each do |i|\n line += search[[row, col - i]]\n end\n end\n\n when :down_left\n # check boundary case\n if search.has_key?([row + length, col - length])\n (0..length).each do |i|\n line += search[[row + i, col - i]]\n end\n end\n end\n\n return line\nend",
"def diagonals\n down_diag = []\n up_diag = []\n \n # push sets of coordinates that make up both diagonals\n 0.upto(@size - 1) do |idx|\n down_diag << [idx, idx]\n up_diag << [idx, @size - 1 - idx]\n end\n\n [down_diag, up_diag].map do |diag|\n diag.map { |pos| self[pos] }\n end\n end",
"def to_polycube_layout\n rows = []\n\n all_pieces = Piece.generate_pieces\n pieces_on_the_board = self.pieces\n codes_on_the_board = pieces_on_the_board.map {|p| p.code }.uniq\n pieces_off_the_board = all_pieces.select do |piece|\n !codes_on_the_board.include?(piece.code)\n end\n\n rows << \"D:xDim=6:yDim=6:zDim=1:oneSide\"\n if pieces_off_the_board.size > 0\n rows << \"L\"\n rows << \" \"\n pieces_off_the_board.each do |piece|\n rows << piece.to_polycube_layout\n rows << \" \"\n end\n rows << \"~L\"\n end\n rows << \" \"\n\n if codes_on_the_board.size > 0\n rows << \"L:stationary=#{codes_on_the_board.join(' ')}\"\n else\n rows << \"L\"\n end\n\n (1..DEFAULT_WIDTH).each do |y|\n row = []\n\n (1..DEFAULT_WIDTH).each do |x|\n row << (cell(x, y).piece&.code || \".\")\n end\n rows << row.join(\" \")\n end\n rows << \"~L\"\n rows << \" \"\n rows << \"~D\"\n\n rows.join(\"\\n\")\n end",
"def diagonal_up_to_string(row_index, col_index)\n #move to edge\n until row_index == @rows - 1 || col_index == 0\n row_index += 1\n col_index -= 1\n end\n\n #form diagonal string from edge\n diagonal_string = \"\"\n while row_index > 0 && col_index < @cols\n diagonal_string += @grid[row_index][col_index]\n row_index -= 1\n col_index += 1\n end\n diagonal_string\n end",
"def vert_mirror(strng)\n string.split(\"\\n\").map do |piece|\n piece.reverse\n end.join(\"/n\")\nend",
"def print_2d_array(a)\r\n\r\n max_word_length = 0 # keeps track of the longest string in layout\r\n flattened = a.flatten\r\n flattened.each{|x| if x.length > max_word_length\r\n max_word_length = x.length \r\n end}\r\n max_word_length += 1 # we want a space in front when printing\r\n \r\n # insert a row of numbers into layout for printing\r\n max_no_columns = 0\r\n a.each{|x| if x.length > max_no_columns\r\n max_no_columns = x.length\r\n end}\r\n counter_array = [*0...max_no_columns] # [0, 1, 2, 3....max_no_columns]\r\n \r\n # clone, insert numbers into array, then print\r\n temp = Marshal.load(Marshal.dump(a))\r\n temp.unshift(counter_array) # insert in front\r\n print_array(temp, max_word_length) \r\nend",
"def lu_decompose matrix\n nrows = matrix.shape[0]\n ncols = matrix.shape[1]\n \n nrows.times do |i|\n (i...ncols).each do |j|\n if j >= i # upper\n sum = 0.0\n i.times do |k|\n sum += matrix[k,j]*matrix[i,k]\n end\n matrix[i,j] = matrix[i,j] - sum\n else # lower\n sum = 0.0\n j.times do |k|\n sum += matrix[k,j]*matrix[i,k]\n end\n matrix[i,j] = (matrix[i,j] - sum)/matrix[j,j]\n end\n end\n end\n\n matrix\nend",
"def trify(string)\n new_tri = Array.new\n new_tri = string.split(\"\\n\")\n length = new_tri.length\n (0..length-1).each do |i|\n new_tri[i] = new_tri[i].split(\" \").collect{|i| i.to_i}\n end\n new_tri.reverse!\nend",
"def transpositions word\n n = word.length\n (0...n-1).collect {|i| word[0...i]+word[i+1,1]+word[i,1]+word[i+2..-1] }\n end",
"def spiral_rearrange1 array\n\t#rearrange 2d array of arrays square into a single spiral order arranged array. \n\tif array.flatten.length == 1\n\t\tresult = []\n\t\treturn result << array.flatten[0]\n\tend\n\n\tordered_array = []\n\tn = array.length - 1\n\tx = 0; y = 0\n while true\n\twhile true\n\t\tif array[x][y] != []\n\t\t\tordered_array << array[x][y]\n\t\t\tarray[x][y] = []\n\t\telse\n\t\t\tbreak\n\t\tend\t\n\t\tif y < n && array[x][y+1] != []\n\t\t\ty += 1\n\t\tend\n\tend\n\n\tx += 1\n\t\n\twhile true\n\t\tif array[x][y] != []\n\t\t\tordered_array << array[x][y]\n\t\t\tarray[x][y] = []\n\t\telse\n\t\t\tbreak\n\t\tend\n\t\tif x < n && array[x+1][y] != []\n\t\t\tx += 1\n\t\tend\n\tend\n\n\ty -= 1\n\n\twhile true\n\t\tif array[x][y] != []\n\t\t\tordered_array << array[x][y]\n\t\t\tarray[x][y] = []\n\t\telse\n\t\t\tbreak\n\t\tend\n\t\tif y > 0 && array[x][y-1] != []\n\t\t\ty -= 1\n\t\tend\t\n\tend\n\n\tx -= 1\n\n\twhile true\n\t\tif array[x][y] != []\n\t\t\tordered_array << array[x][y]\n\t\t\tarray[x][y] = []\n\t\telse\n\t\t\tbreak\n\t\tend\n\t\tif x > 0 && array[x-1][y] != []\n\t\t\tx -= 1\n\t\tend\t\n\tend\n\n\ty += 1\n\n\tif array[x][y] == []\n\t\tbreak\n\tend \n end\n\n\treturn ordered_array\nend",
"def fold_down(state)\n new_state = []\n state.column_vectors.each {|column|\n values = column.to_a.reverse\n values = @line_folder.fold(values)\n new_state << values.reverse\n }\n Matrix.columns(new_state)\n end",
"def horizontal_words\n word_vectors = []\n \n @grid.each_with_index do |line, index|\n words = discover_words(line)\n words.each do |word|\n #Set the direction as 'discover_words' is direction agnostic\n word.direction = :horizontal\n word.y_pos = index\n end\n word_vectors << words\n end\n \n word_vectors.flatten\n end",
"def to_s_v1\n output = \"+\" + \"---+\" * columns + \"\\n\"\n\n each_row do |row|\n top = \"|\"\n bottom = \"+\"\n\n row.each do |cell|\n cell = Cell.new(-1, -1) unless cell\n\n body = \" \" # <-- that's THREE (3) spaces!\n east_boundary = (cell.linked?(cell.east) ? \" \" : \"|\")\n top << body << east_boundary\n\n # three spaces below, too >>-------------->> >...<\n south_boundary = (cell.linked?(cell.south) ? \" \" : \"---\")\n corner = \"+\"\n bottom << south_boundary << corner\n end\n\n output << top << \"\\n\"\n output << bottom << \"\\n\"\n end\n\n output\n end",
"def flip_horizontal(matrix)\n matrix.map(&:reverse)\n end",
"def translate_word(word)\n split_array = split_into_array(word)\n rotated_array = rotate_at_vindex(split_array)\n ay_array = add_ay(rotated_array)\n final_array = back_to_s(ay_array)\nend",
"def back_substitution(matrix)\n (matrix.length - 1).downto(0) do |pivot_idx|\n # Multiply the current vector position by the pivot_idx inverse (1/pivot_idx)\n inverse = 1 / matrix[pivot_idx][pivot_idx]\n matrix[pivot_idx][-1] *= inverse\n matrix[pivot_idx][pivot_idx] = 1r # We know it will be 1\n puts \"Multiply the #{format_ordinal pivot_idx + 1} row by its diagonal inverse: \"\\\n \"#{inverse.to_s.split('').join(' ')}\"\n\n if (pivot_idx - 1).negative?\n puts 'And we don\\'t have to zero any row'\n else\n puts 'We iterate over the rows above the current pivot index, to zero them'\n print_new_line\n (pivot_idx - 1).downto(0) do |row|\n if !matrix[row][pivot_idx].zero?\n puts \"Cancel R#{row + 1} #{format_ordinal row + 1} coefficient: \" \\\n \"R#{row + 1} <- R#{row + 1} #{matrix[row][pivot_idx] >= 0 ? '-' : '+'} \" \\\n \"( #{matrix[row][pivot_idx].abs.to_s.split('').join(' ')} ) * R#{pivot_idx + 1}\"\n\n matrix[row][-1] -= matrix[row][pivot_idx] * matrix[pivot_idx].last\n matrix[row][pivot_idx] = 0r # We know it will be 0\n else\n puts \"The #{format_ordinal row + 1} coefficient in R#{row + 1} is already zeroed, \" \\\n 'so we follow along'\n end\n end\n end\n\n print_new_line\n puts 'After it, this is the matrix'\n pp_matrix matrix\n print_separator\n end\n\n puts 'And in the reduced row echelon form we have:'\n pp_matrix matrix\n print_separator\n\n matrix\nend",
"def triangulate(geometry)\n ring = geometry.exterior_ring\n\n input = ring.points.map { |point| [point.x, point.y] }\n input.pop if input.first == input.last\n\n cdt = Poly2Tri::CDT.new(input)\n cdt.triangulate!\n cdt.triangles\n end",
"def staircase(n)\n spaces=0\n arr = Array.new(n) { |i| Array.new(n) { |j| (i >= j) ? '#' : ' ' } }\n print_matrix(arr.map(&:reverse), spaces)\nend",
"def runAlgorithm(row)\n for column in 0..@width-1\n if @columns[column] >= 0 then\n next\n end\n\n ixDiag1 = row + column\n if @diagonals1[ixDiag1] then\n next\n end\n\n ixDiag2 = @lastRow - row + column\n if @diagonals2[ixDiag2] then\n next\n end\n\n @columns[column] = row\n @diagonals1[ixDiag1] = true\n @diagonals2[ixDiag2] = true\n\n if row == @lastRow then\n @solutions.push(@columns.dup)\n else\n runAlgorithm(row + 1)\n end\n\n @columns[column] = -1\n @diagonals1[ixDiag1] = false\n @diagonals2[ixDiag2] = false\n end\n end",
"def rotate_ninety_degs(array,direction='clockwise')\n if direction == 'clockwise'\n return array.transpose.reverse\n else\n return array.transpose.each{|x| x.reverse!}\n end\nend",
"def normalized_transpose(pad='')\n sizes = row_sizes\n min_size = sizes.min\n max_size = sizes.max\n source = if min_size != max_size # Multiple row sizes\n map{|row| row + [pad]*(max_size - row.size)}\n else\n source = self\n end\n source.transpose\n end",
"def diagonals\n vals = [[], []]\n (0...size).each do |i|\n vals[0].push(get_square({:column => i, :row => i}))\n vals[1].push(get_square({:column => i, :row => size - i - 1}))\n end\n vals.map {|v| Row.new(size, {:vals => v}) }\n end",
"def fold_right(state)\n new_state = []\n state.row_vectors.each {|row|\n values = row.to_a.reverse\n values = @line_folder.fold(values)\n new_state << values.reverse\n }\n Matrix.rows(new_state)\n end",
"def flip_horizontal\n (0...@text_lines.size).each do |i|\n @text_lines[i].reverse!\n @sltn_lines[i].reverse!\n end\n end",
"def gen_diagonal_up(row,col)\n array_diagonals =[]\n 0.upto(5).each do |num|\n if ( row - num < 0 || col + num > 6)\n break\n end\n\n array_diagonals << [row-num, col+num] \n end\n array_diagonals.map{|coordinates| @grid[coordinates[1]][coordinates[0]]}\n end",
"def linearize(lines)\n lines = lines.split(/\\n/) if lines.is_a? String\n lines = lines.select { |l| not l.blank? }\n return '' if lines.empty?\n i = lines.\n index_range.\n sort_by { |i| lines[i] =~ /^( *)(-*)/; [$1.length,-$2.length,i] }.\n first { |i| good_divider(lines,i) }\n above,below = lines.rows(0...i),lines.rows((i+1)..-1)\n last_text = nil\n segments(lines[i]).collect { |text,range|\n implicit_mult = ((last_text =~ /[a-z0-9.\\)\\]]$/i and text =~ /^[a-z0-9.\\(]/i))? '*' : ''\n #p [implicit_mult,last_text,text,last_text =~ /[a-z0-9.\\)\\]]$/i,text =~ /^[a-z0-9.\\(]/i]\n a = above.columns(range)\n b = below.columns(range)\n implicit_mult + case text\n when /^ *$/ then (b.all_blank? ? '' : \"[#{ linearize(b)}]\") + (a.all_blank? ? '' : \"**(#{linearize(a)})\")\n when /^---+$/ then last_text = \"((#{linearize(a)})/(#{linearize(b)}))\"\n else last_text = text.strip\n end\n }.join\n end",
"def diagonal_search \n diagonal = []\n diagonal_words = []\n search = @@boards_templates[1].to_s.scan(/./).each_slice(5).to_a\n for ca in 2..7 \n down = ca \n for row in 0..ca\n if row <= 4 \n diagonal << search[down][row]\n down -= 1 \n end \n end \n end\n diagonal = diagonal.join \n @@boards_templates[0].each { |x| diagonal.include?(x) ? diagonal_words << x : diagonal_words.reverse.include?(x) ? diagonal_words << x : \"No hay palabras en dirección diagonal\" }\n #diagonal_words \n end",
"def apply_solution array\n\n # Reverse the String to iterate right to left JUST because is easier :P\n index = find_small_neighbors array.reverse!\n \n return \"no answer\" unless index\n\n # Find rightmost successor to pivot in the suffix\n sec_index = array.index(array.slice(0..index).select{ |num| num > array[index] }.sort.first)\n # Swap with pivot\n array[index], array[sec_index] = array[sec_index], array[index]\n\n # Reverse the suffix REVERT rathern than sort\n solution = array.slice!(0..index-1).sort.join.reverse\n solution << array.join\n return solution.reverse\nend",
"def parse(min_size = 0)\n diagonals = []\n column = starting_column\n row = max_row_index\n while valid_column_to_parse(column) && row >= 0\n output = []\n tmp_row = row\n tmp_column = column\n loop do\n output << @grid[tmp_column][tmp_row]\n tmp_column = next_cell_column_index(tmp_column)\n tmp_row -= 1\n if column_out_of_bounds(tmp_column) || tmp_row < 0 #out of bounds\n diagonals << output if output.length >= min_size\n if column != ending_column\n column = next_column_index(column)\n else\n row -= 1\n end\n break\n end\n end\n end\n diagonals\n end",
"def word_mesh(arr)\n \"\".tap do |m|\n arr.each_cons(2) do |a,b|\n until a.end_with?(b)\n b = b.chop\n return \"failed to mesh\" if b.empty?\n end\n m << b\n end\n end\nend",
"def topLeftToBottomRight(grid, width, height)\n\n strings = Array.new\n string = String.new\n\n # Get the top-right half of the grid, including the longest diagonal\n for x in 1..width do\n\n string = \"\"\n\n for y in 0..x-1 do\n\n letter = grid[[width-x + y, y]]\n\n string << letter\n\n end\n\n strings << string\n\n end\n\n # Get the bottom-left half of the grid, not including the longest diagonal\n # TODO: find a better way of doing this, without needing to reverse the string\n for x in 0..width-2 do\n\n string = \"\"\n\n for y in 0..x do\n\n letter = grid[[x-y, height - y - 1]]\n\n string << letter\n\n end\n\n string.reverse!\n\n strings << string\n\n end\n\n return strings\n\nend",
"def rectilinear_obstruction_array(destination_row, destination_col)\n # Store initial variables\n new_row_position = current_row_index\n new_column_position = current_column_index\n obstruction_array = []\n # Determine horizontalincrements\n if new_row_position == destination_row # protector piece is on same row with king\n # begin moving across column positions\n column_increment = destination_col > new_column_position ? 1 : -1\n new_column_position += column_increment\n while (destination_col - new_column_position).abs > 0\n obstruction_array << [new_row_position, new_column_position]\n new_column_position += column_increment\n end\n elsif new_column_position == destination_col # protector piece is on same column with king\n # begin moving across row positions\n row_increment = destination_row > new_row_position ? 1 : -1\n new_row_position += row_increment\n while (destination_row - new_row_position).abs > 0\n obstruction_array << [new_row_position, new_column_position]\n new_row_position += row_increment\n end\n end\n # return obstruction array (values will be checked later )\n obstruction_array\n end",
"def to_s_v2\n output = \"+\" + \"---+\" * columns + \"\\n\"\n\n each_row do |row|\n top = \"|\"\n bottom = \"+\"\n\n row.each do |cell|\n cell = Cell.new(-1, -1) unless cell\n\n body = \" #{contents_of(cell)} \"\n east_boundary = (cell.linked?(cell.east) ? \" \" : \"|\")\n top << body << east_boundary\n\n south_boundary = (cell.linked?(cell.south) ? \" \" : \"---\")\n corner = \"+\"\n bottom << south_boundary << corner\n end\n\n output << top << \"\\n\"\n output << bottom << \"\\n\"\n end\n\n output\n end",
"def transpose() end",
"def simple_transposition(text)\n array = text.split('')\n even = array.values_at(* array.each_index.select {|i| i.even?})\n odd = array.values_at(* array.each_index.select {|i| i.odd?})\n\n return even.join('') + odd.join('')\nend",
"def IsTridiagonal?(matrixarray)\n # Pre : \n assert(old = matrixarray.clone)\n\n # Check for validity\n for i in 0...matrixarray.length\n for j in 0...matrixarray[0].length\n if i!=j and i!=j-1 and i!=j+1 and matrixarray[i][j] != 0 # non-zero value in position outside of 3 diagonals\n return false\n end\n end\n end\n\n # Post :\n assert(old == matrixarray)\n return true\n end",
"def hipsterfy(str)\n finalArray = []\n alphabet = (\"a\"..\"z\").to_a\n wordArray = str.split(\" \")\n wordArray.each do |word|\n firstSeen = false\n reversed = word.split(\"\").reverse\n finalWord = []\n reversed.each do |letter|\n if firstSeen == true || letter != \"a\" && letter != \"e\" && letter != \"i\" && letter != \"o\" && letter != \"u\"\n finalWord.push(letter)\n\n elsif firstSeen == false && letter == \"a\" || letter == \"e\" || letter == \"i\" || letter == \"o\" || letter == \"u\"\n # don't add here\n firstSeen = true\n end\n end\n \n newString = \"\"\n finalWord.reverse.each do |element|\n newString += String(element)\n end\n finalArray.push(newString)\n \n end\n \n \n \n # print finalArray\n finalString = \"\"\n \n finalArray.each_with_index do |word, index|\n if index != finalArray.length - 1\n finalString += word + \" \"\n else\n finalString += word\n end\n end\n \n \n \n \n \n \n return finalString\n \n \n\n \nend",
"def matrix_transpose(matrix)\r\n m_row = 0\r\n t_col = 0\r\n result = []\r\n while matrix[m_row]\r\n m_col = 0\r\n t_row = 0\r\n while matrix[m_row][m_col]\r\n result.push([])\r\n result[t_row][t_col] = matrix[m_row][m_col]\r\n m_col += 1\r\n t_row += 1\r\n end\r\n m_row += 1\r\n t_col += 1\r\n end\r\n return result\r\nend",
"def my_transpose\n ret = []\n i=0\n while i < self.length\n j=0\n ret2 = []\n while j < self[i].length\n ret2 << self[j][i]\n j += 1\n end\n ret << ret2\n i += 1\n end\n ret\n end",
"def symmetrize(array)\n\t\tfirst_matrix = Matrix.rows(array)\n\t\tfirst_matrix.each_with_index do |e, row, col|\n\n\t\t\tunless e == first_matrix[col, row]\n\t\t\t\tif e == 0\n\t\t\t\t\t# puts row, col\n\t\t\t\t\t# puts our_matrix[col,row]\n\t\t\t\t\tarray[col][row] = 0\n\t\t\t\telsif e == 1\n\t\t\t\t\tarray[row][col] = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tsecond_matrix = Matrix.rows(array)\n\t\treturn second_matrix\n\tend",
"def get_diagonal(representation)\n diagonals = []\n for k in (0..7)\n arr = []\n arr2 = []\n for i in (0..6)\n for j in (0..5)\n if (i == (j - k))\n arr << representation[i][j]\n end\n if ((i-k) == j)\n arr2 << representation[i][j]\n end\n end\n end\n diagonals.push(arr, arr2)\n end\n\n determine_winner(diagonals)\nend",
"def spiral_order(a)\n return [] if a.empty?\n res = []\n left, top = 0, 0\n bottom, right = a.length - 1, a[0].length - 1\n\n while left <= right && top <= bottom\n for i in (left..right)\n res << a[top][i]\n end\n top += 1\n for i in (top..bottom)\n res << a[i][right]\n end\n right -= 1\n if top <= bottom\n # decreament for loop\n for i in (right).downto(left)\n res << a[bottom][i] \n end\n bottom -= 1\n end\n if left <= right\n for i in (bottom).downto(top)\n res << a[i][left]\n end\n left += 1\n end\n end\n res\nend",
"def create_matrix\n @long.times do |long|\n @matriz.push([])\n @width.times do |_width|\n @matriz[long].push([' . ', ' * '].sample)\n end\n end\n kill_cells_in_borders\n end",
"def flattenize(replacements = nil)\n replace = replacements || Louisville::StringExtensions.pre_ascii_replacements\n Louisville::StringExtensions.downcase(asciify(replace)).gsub(/[^a-z\\s\\d]/, \"\").to_s\n end",
"def transform line\n i = 1\n tortoise = line[i]\n hare = line[i * 2]\n while tortoise != hare\n i += 1\n tortoise = line[i]\n hare = line[i * 2]\n end\n v = i\n\n mu = 0\n tortoise = line[mu]\n hare = line[v * 2 + mu]\n while tortoise != hare\n mu += 1\n tortoise = line[mu]\n hare = line[v * 2 + mu]\n end\n\n lam = 1\n hare = line[mu + lam]\n while tortoise != hare\n lam += 1\n hare = line[mu + lam]\n end\n #puts \"v mu lam %d %d %d\" % [v, mu, lam]\n \n line[mu, lam] \nend",
"def diagonals\n [board.map.with_index { |row, i| row[i] },\n board.map.with_index { |row, i| row[row.size - i - 1] }]\n end",
"def unnormalized; end",
"def transposed_search_vector\n @transposed_search_vector ||= super\n end",
"def transpose(a)\n # get the number of rows and columns\n # create empty matrix where # of rows = # of columns, and vice versa\n rows = a.length\n cols = a[0].length\n newA = Array.new(cols) {Array.new(rows)}\n\n i = j = 0\n while i < rows\n while j < cols\n # swap them\n newA[j][i] = a[i][j]\n j += 1\n end\n i += 1\n # don't forget to reset j after every column\n j = 0\n end\n\n newA\nend",
"def to_s\n result = \"--puzzle--\\n\"\n 9.times do |row|\n result << horiz_line if (row % 3).zero?\n line = @lines[row]\n 9.times do |col|\n result << '|' if column_before col\n square = line[col]\n if square.empty?\n result << '_'\n elsif square.metadata[:found]\n result << square.value.to_s.green\n else\n result << square.value.to_s\n end\n result << ' ' unless column_before(col + 1)\n result << '|' if col == 8\n end\n result << \"\\n\"\n result << horiz_line if row == 8\n end\n result\n end",
"def all_traversals(word)\n length = word.length\n results = []\n\n results << row_up(length)\n results << up_right(length)\n results << col_right(length)\n results << down_right(length)\n results << row_down(length)\n results << down_left(length)\n results << col_left(length)\n results << up_left(length)\n\n results\n end",
"def reverse_words(my_words)\n if my_words == nil\n return my_words\n end\n len = my_words.length\n i = 0\n low = nil\n high = nil\n len.times do\n if my_words[i] != \" \"\n if my_words[i - 1] == \" \" || i == 0\n low = i\n elsif my_words[i + 1] == \" \" || i + 1 == len\n high = i\n end\n if low != nil && high != nil\n j = 0\n len2 = high - low + 1\n (len2 / 2).times do\n l = my_words[low + j]\n h = my_words[high - j]\n x = l\n my_words[low + j] = h\n my_words[high - j] = x\n j += 1\n end\n high = nil\n low = nil\n end\n end\n i += 1\n end\n return my_words\nend",
"def transpose!(matrix)\n (0...matrix.size).each do |row|\n (0...matrix.size).each do |col|\n matrix[row][col], matrix[col][row] =\n matrix[col][row], matrix[row][col] if row < col\n end\n end\nend",
"def translate(word)\r\n vowels = \"aeio\".split('').to_a\r\n consonant = \"bcdfghjklmnpqrstuvwxyz\".split('').to_a \r\n answer = []\r\n \r\n while word.split(' ').length == 1 \r\n words = word.split('')\r\n until vowels.include?(words[0])\r\n words = words.rotate(1)\r\n end\r\n words << \"ay\"\r\n return words.join('')\r\n end # one word ^^\r\n \r\n if word.split(' ').length > 1 \r\n words = word.split(' ')\r\n end \r\n words.each do |i|\r\n if vowels.include?(i[0])\r\n i << \"ay\"\r\n answer << i\r\n #return answer\r\n end\r\n end\r\n \r\n words.each do |j|\r\n if consonant.include?(j[0])\r\n j = j.split('').rotate(1).join('') until vowels.include?(j[0])\r\n j = j + \"ay\"\r\n #return j\r\n #j << j #correct format for 1 consonant but it doesnt add to array\r\n answer << j\r\n end\r\n end\r\n \r\n return answer.join(' ')\r\n end",
"def convertFinalArrayToString\n string = \"\"\n @arrayOfElements.each { |row| \n rowString = \"\"\n row.each { |word|\n if \"\" == rowString\n rowString = rowString + word\n else\n rowString = rowString + \" \" + word\n end\n }\n if \"\" == string\n string = rowString\n else\n string = string + \"\\n\" + rowString\n end\n }\n return string\nend",
"def upper_triangle(k = 0)\n raise(NotImplementedError, \"only implemented for 2D matrices\") if self.shape.size > 2\n\n t = self.clone_structure\n (0...self.shape[0]).each do |i|\n if i - k < 0\n t[i, :*] = self[i, :*]\n else\n t[i, 0...(i-k)] = 0\n t[i, (i-k)...self.shape[1]] = self[i, (i-k)...self.shape[1]]\n end\n end\n t\n end",
"def normalize\n @height = @text_lines.size\n @width = 0\n @sltn_lines = [ ]\n @text_lines.each do |line|\n len = line.length\n @width = len if (len > @width)\n @sltn_lines << '+' * len\n end\n (0...@text_lines.size).each do |i|\n no_pad_chars = @width - @text_lines[i].length\n 1.upto(no_pad_chars) do\n @text_lines[i] << '+'\n @sltn_lines[i] << '+'\n end\n end\n end",
"def munge(name)\n infile = name + \".txt\"\n outfile = name + \".out\"\n line = File.open(infile) {|f| f.read}\n #i1 points at the first character in a word.\n #i2 points at the first character after a word.\n i1 = i2 = 0;\n while i1 < line.length || i2 < line.length\n i2 += 1 while i2 < line.length && line[i2, 1] =~ /[[:alpha:]]/ #in a word\n line[i1...i2] = permute_word(line[i1...i2])\n i1 = i2\n i1 += 1 while i1 < line.length && line[i1, 1] !~ /[[:alpha:]]/ #not in a word\n i2 = i1\n end\n File.open(outfile, \"w\") {|f| f.write(line)}\n# line\nend",
"def to_s\n str = \"\"\n outer_counter = 0\n\n @puzzle.each do |row|\n inner_counter = 0\n row.each do |element|\n inner_counter += 1\n element = \"_\" if element == nil\n str << element.to_s\n str << \"#\" if inner_counter % 3 == 0\n end\n outer_counter += 1\n str << \"\\n\"\n str << \"############\\n\" if outer_counter % 3 == 0\n end\n str.gsub(//,\" \")[0...-39]\n end",
"def subsequence\n setup_basecase\n\n ([email protected]).each do |row|\n (1...@matrix[0].length).each do |col|\n substring_one = @str_one[0...row]\n substring_two = @str_two[0...col]\n if substring_one[-1] == substring_two[-1]\n @matrix[row][col] = @matrix[row - 1][col - 1] + substring_one[-1]\n else\n if @matrix[row - 1][col].length > @matrix[row][col - 1].length\n @matrix[row][col] = @matrix[row - 1][col]\n else\n @matrix[row][col] = @matrix[row][col - 1]\n end\n end\n end\n end\n\n @matrix[-1][-1]\n end",
"def swasify(word)\r\n word = word.upcase.gsub(' ','').strip\r\n width = (word.length*2 - 1)*4 - 3\r\n sc = width/2\r\n word.split('')[0..-2].each do |letter|\r\n puts \" \"*sc + letter\r\n sc -= 2\r\n end\r\n sc2 = word.length*4 - 5\r\n puts \" \"*sc + word[-1] + \" \"*sc2 + word[-1]\r\n sc3 = 3\r\n \r\n word.split('')[1..-2].reverse.each do |letter|\r\n sc += 2\r\n sc2 -= 4 \r\n puts \" \"*sc + letter + \" \"*sc2 + letter + \" \"*sc3 + letter\r\n sc3 += 4\r\n end\r\n\r\n puts (word[0] + ' '*sc3)*2 + word[0]\r\n\r\n sc = 2\r\n word.split('')[1..-2].each do |letter|\r\n sc3 -= 4\r\n puts \" \"*sc + letter + \" \"*sc3 + letter + \" \"*sc2 + letter\r\n sc += 2\r\n sc2 += 4\r\n end\r\n\r\n sc2 = word.length*4 - 5\r\n puts \" \"*sc + word[-1] + \" \"*sc2 + word[-1]\r\n sc += sc2 - 1\r\n word.split('')[0..-2].reverse.each do |letter|\r\n puts \" \"*sc + letter\r\n sc -= 2\r\n end \r\nend",
"def sort_alien_language(words)\n vertices ={}\n\n # //b, d, c, a\n words.reduce(:+).split('').uniq.each do |character|\n vertices[character] = Vertex.new(character)\n end\n\n (0...words.length-1).each do |i|\n word1, word2 = words[i], words[i+1]\n smaller = word1.length <= word2.length ? word1.length : word2.length\n\n (0...smaller).each do |j|\n if word1[j] != word2[j]\n Edge.new(vertices[word1[j]], vertices[word2[j]])\n break\n end\n end\n end\n\n topological_sort(vertices.values).map {|v| v.value}\n # [b, d, c, a]\nend",
"def make_tabula_recta\n letters = @letter_set.dup\n table = []\n letters.length.times do\n table.push letters.dup\n letters.push letters.shift\n end\n indices = {}\n letters = letters.each_with_index { |letter, i| indices[letter] = i }\n [table, indices]\n end",
"def reduced_row_echelon_form(ary)\n lead = 0\n rows = ary.size\n cols = ary[0].size\n rary = convert_to_rational(ary) # use rational arithmetic\n catch :done do\n rows.times do |r|\n throw :done if cols <= lead\n i = r\n while rary[i][lead] == 0\n i += 1\n if rows == i\n i = r\n lead += 1\n throw :done if cols == lead\n end\n end\n # swap rows i and r \n rary[i], rary[r] = rary[r], rary[i]\n # normalize row r\n v = rary[r][lead]\n rary[r].collect! {|x| x /= v}\n # reduce other rows\n rows.times do |i|\n next if i == r\n v = rary[i][lead]\n rary[i].each_index {|j| rary[i][j] -= v * rary[r][j]}\n end\n lead += 1\n end\n end\n rary\n end",
"def redesign\n x = @mat[0].length\n y = @mat.size\n (1..y-2).each do |i|\n (1..x-2).each do |j|\n @mat[i][j] = \"0\"\n end\n end\n\n divide(1,x-2,1,y-2)\n end",
"def _locations_ordered_for_text_dump\n locations = Hash[(1..23).to_a.map {|row| [row, {}]}]\n @tiles.each {|t| locations [t.row * 4 ] [t.col * 4 - t.row * 2 + 5] = t}\n @up_vtexs.each {|v| locations [v.row * 4 - 3] [v.col * 4 - v.row * 2 + 5] = v}\n @down_vtexs.each {|v| locations [v.row * 4 + 3] [v.col * 4 - v.row * 2 + 5] = v}\n @asc_edges.each {|e| locations [e.row * 4 - 2] [e.col * 4 - e.row * 2 + 4] = e}\n @desc_edges.each {|e| locations [e.row * 4 - 2] [e.col * 4 - e.row * 2 + 6] = e}\n @vert_edges.each {|e| locations [e.row * 4 ] [e.col * 4 - e.row * 2 + 3] = e}\n return locations\n end",
"def resolve_duplicates(rows_as_strings)\n\trows_as_arrays = rows_as_strings.map{|row| row.split(' ')}\n\tmerged_row = rows_as_arrays.first[0..10] # first 11 elements are selected from the first row\n\t(11..rows_as_arrays.first.length-1).each do |col_idx|\n\t\talleles = []\n\t\trows_as_arrays.each do |row|\n\t\t\talleles << row[col_idx]\n\t\tend\n\t\tmerged_allele = resolve_alleles(alleles)\n\t\tmerged_row << merged_allele\n\tend\n\treturn merged_row.join(\" \")\nend",
"def bottomRightToTopLeft(grid, width, height)\n\n strings = topLeftToBottomRight(grid, width, height)\n\n for string in strings do\n string.reverse!\n end\n\n return strings\n\nend",
"def flatten_a_o_a(aoa)\n result = []\n x = 0\n while x < aoa.length do\n y = 0\n while y < aoa[x].length do\n result.push(aoa[x][y])\n y += 1\n end\n x += 1\n end\n return result\nend",
"def translate(arr)\n vowels = %w{a e i o u y}\n consonants = %w{b c d f g h j k l m n p q r s t v w x y z}\n\n a = arr.split.map do |word| \n if vowels.include?(word[0])\n word + \"ay\"\n elsif word[0..1] == \"qu\"\n word[2..-1] + \"quay\"\n elsif word[0..2] == \"sch\"\n word[3..-1] + \"schay\"\n elsif word[0..2] == \"squ\"\n word[3..-1] + \"squay\"\n elsif consonants.include?(word[0]) && consonants.include?(word[1]) && consonants.include?(word[2])\n word[3..-1] + word[0..2] + \"ay\"\n elsif consonants.include?(word[0]) && consonants.include?(word[1])\n word[2..-1] + word[0..1] + \"ay\"\n elsif consonants.include?(word[0])\n word[1..-1] + word[0] + \"ay\"\n end\n end\n\n a.join(\" \")\nend",
"def uncover (i,j)\t\t\t\n\t\tx_array = [i] \t\t\t\t\t\t\t\t\t\t\t#array containing x-indexes of clicked button which have 0 mines in the sorrounding\n\t\ty_array = [j]\t\t\t\t\t\t\t\t\t\t\t\t\t#y-index of clicked button \" \" \" \" \" \" \" \" \" \" \"\n\t\tx_array.each_with_index do |n,index|\t\n\t\t\ti = n\n\t\t\tj = y_array[index]\n\t\t\tfor x in i-1..i+1\n\t\t\t \tfor y in j-1..j+1\n\t\t\t\t\tif x>=0 && y >=0 && x < @rows && y < @cols\n\t\t\t\t\t\tnext if @buttons[x][y].state == \"insensitive\"\t# next iteration if this array index(button) has already been uncovered\n\t\t\t\t\t\t@buttons[x][y].label = @board[x][y].to_s\t\t\t\t\t\n\t\t\t\t\t\t@buttons[x][y].sensitive = false\n\t\t\t\t\t\t@clicks = @clicks + 1 \t\t\t\t\t#click count will be updated for every array index traversed\n\t\t\t\t\t\t@builder[\"window1\"].title = @clicks.to_s\n\t\t\t\t\t\tif @board[x][y] == 0 \t\t\t\t\t#if neighbours of the clicked button contain another 0 valued button,we will add that to our array\n\t\t\t\t\t\t\t@board[x][y] = \"-\"\t\t\t\t\t\t\n\t\t\t\t\t \t\tx_array << x\t\t\t\t\t\t\t\t#if another 0 is found in the neighbours, insert it in to uncover array\n\t\t\t\t\t\t\ty_array << y \t\t\t\t# same as above, saving y-index \n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t end \n\t\tend\n\tend",
"def upper_triangular?\n @colt_property.isUpperTriangular(@colt_matrix)\n end",
"def reanalyze_words(morpheme_hypotheses)\n # Create a table of morpheme hypotheses indexed by word.\n word_table = {}\n morpheme_hypotheses.each do |hyp|\n # TODO Check for overlapping morpheme ranges with asserts.\n if not word_table.has_key?(hyp.original_word)\n word_table[hyp.original_word] = []\n end\n word_table[hyp.original_word] <<= hyp\n end\n # Insert the new morphemes into the phonetic components of the original\n # words.\n changed_word_indexes = []\n word_table.each do |word, hyps|\n # Don't insert a morpheme at the same location more than once.\n hyps.uniq!\n # Sort the morphemes in reverse order. That way inserting the first\n # one doesn't change the offsets of the subsequent ones.\n hyps = hyps.sort_by {|hyp| -hyp.original_word_offsets[0] }\n # Insert the new morphemes into the specified positions in the words'\n # phonetic components. Make the changes to the word stored in this\n # analysis' word list so that we may maintain multiple independent\n # analyses.\n hyps.each do |hyp|\n source_index, dest_index = @alignment_table.indexes[hyp.alignment]\n word_index = case hyp.word\n when :source\n source_index\n when :dest\n dest_index\n else\n raise RuntimeError.new(\"Invalid word value #{word}\")\n end\n original_word = word_list[word_index]\n from, to = hyp.original_word_offsets\n LOGGER.debug(\"Insert #{hyp.morpheme} into \" +\n \"#{original_word.transcription}[#{from}..#{to}]\")\n original_word.phonetic_component[from..to] = hyp.morpheme\n changed_word_indexes << word_index\n end\n end\n # Delete alignments involving words that changed.\n changed_word_indexes.uniq!\n changed_word_indexes.each { |index| @alignment_table.delete(index) }\n # Rerun alignments for the words that changed.\n changed_word_indexes.each do |word_index|\n # The alignments are done so that source words always have larger\n # indexes than dest words.\n 0.upto(word_index - 1) do |dest_index|\n source_word = self[word_index]\n dest_word = self[dest_index]\n alignment = Alignment.new(source_word, dest_word)\n @alignment_table.add(alignment, word_index, dest_index)\n end\n (word_index + 1).upto(word_list.length - 1) do |source_index|\n source_word = self[source_index]\n dest_word = self[word_index]\n alignment = Alignment.new(source_word, dest_word)\n @alignment_table.add(alignment, source_index, word_index)\n end\n end\n end",
"def transpose(matrix)\n new_matrix = []\n\n column = 0\n while column < matrix.size\n new_row = []\n\n row = 0\n while row < matrix.size\n new_row << matrix[row][column]\n row += 1\n end\n\n new_matrix << new_row\n column += 1\n end\n\n new_matrix\nend",
"def transpose(string)\n arr = string.split(//)\n new_arr = ''\n\n i = 0\n while i < string.length\n if arr[i] == 'n' && arr[i - 1] == 'g'\n arr[i], arr[i - 1] = arr[i - 1], arr[i]\n i -= 2\n end\n i += 1\n end\n\n arr.each { |n| new_arr += n }\n new_arr\nend",
"def my_transpose(arr) \n new_arr = []\n (0...arr.length).each do |outer_el| # the second dimension of a matrix\n outer_arr = []\n (0...arr.length).each do |inner_el| \n outer_arr << arr[inner_el][outer_el] # flip everything inside the array and place in the outer_arr\n end\n new_arr << outer_arr # nest that outer_arr inside the new_arr\n end\n new_arr\nend",
"def all_diagonals(columns)\n diagonals = []\n valid_col_rows = [\n [ [0,2], [1,3], [2,4], [3,5] ],\n [ [0,1], [1,2], [2,3], [3,4], [4,5] ],\n [ [0,0], [1,1], [2,2], [3,3], [4,4], [5,5] ],\n [ [1,0], [2,1], [3,2], [4,3], [5,4], [6,5] ],\n [ [2,0], [3,1], [4,2], [5,3], [6,4] ],\n [ [3,0], [4,1], [5,2], [6,3] ],\n\n [ [0,3], [1,2], [2,1], [3,0] ],\n [ [0,4], [1,3], [2,2], [3,1], [4,0] ],\n [ [0,5], [1,4], [2,3], [3,2], [4,1], [5,0] ],\n [ [1,5], [2,4], [3,3], [4,2], [5,1], [6,0] ],\n [ [2,5], [3,4], [4,3], [5,2], [6,1] ],\n [ [3,5], [4,4], [5,3], [6,2] ],\n ]\n\n valid_col_rows.each do |diag|\n diagonal = ''\n diag.each do |coords|\n symbol = columns[coords.first][coords.last]\n symbol.nil? ? diagonal += '-' : diagonal += symbol\n end\n diagonals << diagonal\n end\n diagonals\n end"
] | [
"0.54619014",
"0.54381835",
"0.49719515",
"0.49665487",
"0.48483568",
"0.4683679",
"0.46210745",
"0.46083647",
"0.4568668",
"0.45678002",
"0.45645362",
"0.45624077",
"0.4529771",
"0.45120037",
"0.44696033",
"0.44653332",
"0.4447841",
"0.44448534",
"0.4438761",
"0.4408356",
"0.44000348",
"0.4395917",
"0.4391579",
"0.43895826",
"0.43865374",
"0.4385914",
"0.438362",
"0.43782526",
"0.43780565",
"0.4365346",
"0.43617168",
"0.43581268",
"0.43556613",
"0.43513072",
"0.43494555",
"0.4346737",
"0.42942828",
"0.42912254",
"0.4290942",
"0.4268625",
"0.4265652",
"0.42585248",
"0.4257314",
"0.42487276",
"0.4241121",
"0.4240408",
"0.42298216",
"0.42288485",
"0.4209845",
"0.42067748",
"0.4202207",
"0.42009118",
"0.42001542",
"0.4196175",
"0.41882098",
"0.41798508",
"0.41616505",
"0.4159688",
"0.4141504",
"0.41393715",
"0.41353798",
"0.41270918",
"0.41229182",
"0.41201845",
"0.4115608",
"0.4115173",
"0.41001412",
"0.41000235",
"0.40940815",
"0.4093818",
"0.40934685",
"0.40899155",
"0.4080696",
"0.40740207",
"0.40739954",
"0.40734425",
"0.40706807",
"0.40666723",
"0.40654168",
"0.4064448",
"0.40552813",
"0.4055198",
"0.40517944",
"0.4047725",
"0.40424812",
"0.40397826",
"0.4036684",
"0.40365526",
"0.4036159",
"0.40356985",
"0.4027038",
"0.4026362",
"0.402573",
"0.40240487",
"0.40232837",
"0.40215477",
"0.40193748",
"0.40182608",
"0.40177527",
"0.40132055"
] | 0.6686408 | 0 |
word_search.replicate_match(words) Update the solution lines of the current word search puzzle object with any matches of the word Strings . | def replicate_match(words)
@text_lines.each_with_index do |line, i|
line.replicate_match(words, @sltn_lines[i])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replicate_match(strs, replication_str)\n strs = [ strs ] unless (strs.is_a?(Array))\n strs.each do |str|\n str_len = str.length\n next if (length < str_len)\n offset, last_offset = 0, length - str_len\n while (offset <= last_offset)\n if str_pos = index(str, offset)\n replication_str[str_pos, str_len] = str\n offset = str_pos\n end\n offset += 1\n end\n end\n end",
"def solve(*words)\n words = words.collect { |word| word.upcase_trim }\n\n #\n # Make the various transformations, checking for matches along the\n # way.\n #\n normalize ; replicate_match(words) # match L->R\n flip_horizontal ; replicate_match(words) # match R->L\n diagonalize ; replicate_match(words) # match TL->BR\n flip_horizontal ; replicate_match(words) # match BR->TL\n undiagonalize(true) ; replicate_match(words) # match T->B\n flip_horizontal ; replicate_match(words) # match B->T\n flip_vertical ; flip_horizontal\n diagonalize ; replicate_match(words) # match BL->TR\n flip_horizontal ; replicate_match(words) # match TR->BL\n undiagonalize(false)\n\n #\n # And return the solution.\n #\n @sltn_lines\n end",
"def unordered_match (target_word, matrix, ans_arr_el, index, track, trace)\t\n\tif index == 0 \n\t\t$seed[ans_arr_el[0][0]][:num_groups][ans_arr_el[0][1]].each do |word|\n\t\t\ttemp_word = track + word \n\t\t\tif(target_word == temp_word.chars.sort.join)\t\t\t\t\n\t\t\t\ttemp_answer = trace.dup\n\t\t\t\ttemp_answer.push(word)\n\t\t\t\t$answer[:words].push(temp_answer)\t\t\t\t\n\t\t\tend\n\t\tend\n\telsif index > 0\n\t\t$seed[ans_arr_el[index][0]][:num_groups][ans_arr_el[index][1]].each do |word|\n\t\t\tc = trace.dup\n\t\t\tc.push(word)\n\t\t\tunordered_match(target_word, matrix, ans_arr_el, index - 1, track + word, c)\t\t\t\t\t\t\n\t\tend\t\t\n\tend\t\nend",
"def corrections\n #For each word to be looked at\n $words.each do |word_array|\n #If the word is misspelled attempt corrections\n possible_matches = Array.new\n if word_array[1] == false\n #Sets word to the actual word, instead of array pair\n word = word_array[0]\n # Get lexicon searching vars\n first_char = word[0]\n len = word.length\n\n ##Find words with similar letters\n #Saves the length of the word for eaiser access\n size = word.length\n #Iterates over words with matching starting letter and length +- 1\n $lexicon[first_char][len].each do |word_compare|\n possible_matches << word_compare[0]\n end\n\n # only check shorter words if length is greater than 1\n if len > 1\n $lexicon[first_char][len-1].each do |word_compare|\n possible_matches << word_compare[0]\n end\n end\n\n $lexicon[first_char][len+1].each do |word_compare|\n possible_matches << word_compare[0]\n end\n\n #Iterate over the possible matches, taking the match with the highest percentage\n #Hash to hold similarity\n similarity = Hash.new(0.0)\n possible_matches.each do |word_to_compare|\n similarity[word_to_compare] = match_percentage word, word_to_compare\n end\n\n best_match = ''\n similarity.each do |match|\n if match[1] > similarity[best_match]\n best_match = match[0]\n end\n end\n $correction[word] = best_match\n end\n end\nend",
"def find_replacement_translations(locale, variant_words, translations)\n pp \"Processing #{locale} strings\"\n unchanged = []\n to_be_replaced = []\n variant_words.each do |dict|\n current = dict[:source]\n origin = dict[:origin]\n replacement = dict[:target]\n # keeping a tally of how many will not change due to both current\n # and replacement being the same\n if current == replacement\n unchanged << { current: current, replacement: replacement }\n next\n end\n if current == '--'\n t = translations.where('copy LIKE ?', \"%#{origin}%\")\n puts \"#{t.count} strings found in #{locale} for #{origin}\"\n else\n t = translations.where('copy LIKE ?', \"%#{current}%\")\n puts \"#{t.count} strings found in #{locale} for #{current}\"\n end\n # t = translations.where(source_copy: source)\n # count = t.count\n # t = t.concat(fuzzy_match)\n unless (t.nil? or t.empty?) && current[0] != replacement[0]\n # pp \"#{current[0]} matched #{replacement[0]}\"\n t.each do |row|\n # exact match with word boundaries around the word\n # this will prevent words being part of ids/classes\n # and it will also prevent words like \"Unenroll\"\n # it's looking for \"enroll\"\n unless row.copy.match(/#{current}\\b/)\n next\n end\n if current[0] == replacement[0]\n pp \"#{current} will be replaced with #{replacement}\"\n end\n rep = {\n locale: locale,\n source: row.source_copy,\n current: row.copy,\n replacement: row.copy && row.copy.gsub(current, replacement),\n id: row.id,\n word: replacement,\n }\n if rep[:current] != rep[:replacement]\n puts \"Current and replacmeent match: #{rep[:current]} == #{rep[:replacement]}\"\n begin\n if rep[:replacement].strip_html_tags == rep[:replacement]\n to_be_replaced << rep\n else\n pp \"Stripped #{rep[:replacement]} and didn't add to list\"\n end\n end\n end\n end\n end\n end\n puts \"Ignoring: #{unchanged.size} strings\"\n puts \"Changing: #{to_be_replaced.size} strings\"\n to_be_replaced\nend",
"def match_letters \n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = @guess\n\t\tend\n\tend",
"def save_unmatched_words # :nodoc:\n tokens = phrase_without_matches.split(' ')\n unmatched_db = Corpus.new(\"unmatched-#{program_name}.db\")\n tokens.each do |token|\n if !complex_token_matches?(token) # token was not transformed earlier\n @to_match << token\n unmatched_db[token] = @processor.original_text\n end\n end\n unmatched_db.close\n end",
"def make_word_candidates\n while @e <= l \n @word = str[@s..@e]#.join\n end\n end",
"def solver (seed_char, blanks_words_sizes, matrix)\n\t# Set numerical target\n\ttarget = magic_num(seed_char)\t\n\t# Find magic number sum buckets\n\tskynet(target, blanks_words_sizes, blanks_words_sizes.length - 1, 0, [])\n\t# Alphabetical sort input matrix\n\tsorted_seed_char = seed_char.chars.sort.join\t\n\n\t# Find unique sets from skynet solutions\n\t$answer[:trace].each do |arrOarr|\n\t\tarrOarr.sort!\n\tend \n\n\t$answer[:trace].uniq!\t\n\t\n\t# Finds match for complete set of words from skynet solutions\n\t$answer[:trace].each do |answer_arr_el|\t\t\t\t\n\t\tunordered_match(sorted_seed_char, matrix, answer_arr_el, answer_arr_el.length - 1, \"\", [])\n\t\t# Can be ignored\n\t\t$ops += $seed[answer_arr_el[0][0]][:num_groups][answer_arr_el[0][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length\t\t\n\tend\n\t\n\treturn $answer[:words]\nend",
"def match_letters #handle_guess\n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = guess\n\t\tend\n\n\t\tputs @result_array\n\tend",
"def match_letters #handle_guess\n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = guess\n\t\tend\n\n\t\tputs @result_array\n\tend",
"def boardSolver2(index1, index2, prefix1)\n @possible_directions.each do |x,y|\n #making sure that the movement doesn't take you off the board\n if (0..3) === (x + index1) && (0..3) === (y + index2) \n prefix = prefix1 + @board[x + index1][y + index2]\n if find_prefix(prefix) == true\n @prefix[prefix] = \"#{x + index1}-#{y + index2}\"\n end\n end \n end\n prefixArray = []\n indexes = []\n @prefix.each do |pre, index|\n indexes << index\n prefixArray << pre\n end\n\n i = 0\n while i < prefixArray.length\n index = indexes[i].split(\"-\")\n if is_word(prefixArray[i]) == true\n @words << prefixArray[i]\n end\n @prefix = {}\n #if there were prefixes that can become words, it will continue going\n boardSolver2(index[0].to_i, index[1].to_i, prefixArray[i])\n i += 1\n end\nend",
"def match(array_possible_anagrams)\n matching_words=[]\n word_broken=self.word.split(\"\").sort\n array_possible_anagrams.each do |possible_match|\n #possible_match=possible.word\n possible_match_broken=possible_match.split(\"\").sort\n if possible_match_broken == word_broken\n matching_words << possible_match\n else\n end #end of if\n end #end of do\n matching_words\n end",
"def solve(dictionary)\n\t\n\t\tunique_word_lengths = (@@word_lengths).uniq\n\t\tunique_word_lengths.sort!\n\t\t\n\t\ti = 1\n\t\t\n\t\tunique_word_lengths.each { |len|\n\t\t\n\t\t\tputs \"\\nSearching for words of length \" << unique_word_lengths[i-1].to_s << \"...\"\n\t\t\t\n\t\t\tconstruct_word(\"\", len, dictionary)\n\t\t\t\n\t\t\ti = i + 1\n\t\t\t\n\t\t}\n\t\t\n\tend",
"def find_potential_matches\n comp_words.each_with_object([]) do |comp_word, collection|\n next if comp_word == word\n\n tokenized_comp_word = tokenize_string(comp_word)\n common_token_count = (tokenized_word & tokenized_comp_word).count\n similarity = (2 * common_token_count) / (word.length + comp_word.length).to_f\n collection << comp_word if similarity > PRECISION\n end\n end",
"def solve\n\t\t# Attempt to find a mismatch in start/end\n\t\t# letters in the maps. This signifies first\n\t\t# and last words of the solution\n\t\tdiff_list = []\n\t\t@start_map.each {|k,v|\n\t\t\tr = @end_map[k]\n\t\t\tdiff = r-v\n\t\t\tputs \"#{k} => #{v} | #{r} diff #{diff}\"\n\t\t\t\n\t\t\t# If values in map don't match, remember this\n\t\t\tif diff != 0\n\t\t\t\tdiff_list << diff\n\t\t\tend\n\t\t}\n\n\t\t# Ensure the matchings satisfy the properties of\n\t\t# and solvable puzzle. If there are \n\t\tputs diff_list\n\t\tif diff_list.size == 0\n\t\t\t# This means there are cycles (multiple\n\t\t\t# choices for the first word).\n\t\telsif diff_list.size == 2\n\t\t\t# Ensure there is exactly one starting\n\t\t\t# word and exactly one ending word\n\t\t\treturn [] if !diff_list.include?( 1 )\n\t\t\treturn [] if !diff_list.include?( -1 )\n\t\telse\n\t\t\t# This signifies an unsolvable puzzle\n\t\t\tputs \"Not Solvable\"\n\t\t\treturn []\n\t\tend\n\n\t\t# The characteristics of this word list look\n\t\t# good so far. Let's now try to enumerate the\n\t\t# solution array\n\t\treturn enumerate_solution\n end",
"def solved? (guesses, word)\n\tsolved = true\n\thits = []\n\tword.length.times do |i|\n\t\thits << word[i]\n\tend\n\thits.each do |hit|\n\t\tunless guesses.include? hit\n\t\t\tsolved = false\n\t\tend\n\tend\n\tsolved\n\n\n\t\nend",
"def create_codeword_matches(words)\n set = Set.new\n\t\twords.each do |word|\n\t\t\tset.add(word) if word.length == @codeword.length \n\t\tend\n set\n\tend",
"def add_letter(letter, locations)\n # for each occurrence of a letter, add the letter to the correct location in $build-word\n locations.each { |location| $build_word[location] = letter }\n word_test() # then run word_test()\nend",
"def match_words_yandex\n eng_size= @eng_sentence.length - 1\n collision= false\n updated= false\n\n (0..eng_size).each { |eng_index|\n if !@used_eng[eng_index]\n eng_word= @eng_sentence[eng_index]\n translations= @all_translations[eng_word]\n rus_indexes= []\n translations.each do |translation|\n rus_indexes+= matches_infinitives(translation)\n end\n rus_indexes.uniq!\n if rus_indexes.size == 1\n updated= true\n @used_eng[eng_index]= true\n @used_rus[rus_indexes[0].rus_index]= true\n @translation_eng_to_rus[eng_index]= rus_indexes[0].translation\n else\n collision|= rus_indexes.size > 1\n end\n end\n }\n\n if collision && updated\n match_words_yandex\n end\n end",
"def index!(words)\n ### FILL IN YOUR CODE HERE\n @line += 1\n if words == nil\n else\n words.each { |word|\n if !@hash[word].include?(@line)\n @hash[word].push(@line)\n else\n\n end\n }\n end\n end",
"def populate(words)\n # Create an array of words and normailze it: we delete all cr chars (\\r) and put all letters downcase\n words = words.downcase.delete(\"\\r\").split(\"\\n\")\n # The anagram words contain the same letters, so we can create an hash where the key is a common index,\n # and the value is an array of words with the same key\n self.words_hash = words.each_with_object(Hash.new []) do |word,hash|\n hash[create_index(word)] += [word]\n end\n end",
"def edits1(word)\n \n deletes = []\n i = 0\n while i < word.length\n deletes_word = word\n deletes << deletes_word.slice(0,i) + deletes_word.slice(i+1, word.length)\n i+=1\n end\n #all strings obtained by deleting a letter (each letter)\n transposes = []\n i = 0\n while i < word.length\n transpose_word = word\n letter_to_replace = transpose_word[i]\n\n transpose_word[i] = transpose_word[i-1]\n transpose_word[i-1] = letter_to_replace\n transposes << transpose_word\n\n transpose_word = word\n letter_to_replace = transpose_word[i]\n\n if(transpose_word[i+1] != nil)\n transpose_word[i] = transpose_word[i+1]\n transpose_word[i+1] = letter_to_replace\n transposes << transpose_word\n end\n\n i+=1\n end\n #all strings obtained by switching two consecutive letters\n inserts = []\n word\n inserts(word)\n\n # all strings obtained by inserting letters (all possible letters in all possible positions)\n replaces = []\n #all strings obtained by replacing letters (all possible letters in all possible positions)\n\n #return (deletes + transposes + replaces + inserts).to_set.to_a #eliminate duplicates, then convert back to array\n end",
"def run\n\n\tthreads = Array.new \t# a place to store threads\n\n\t# Use 4 threads when the word list is larger than 10\n\tnumber_of_threads = (@words_to_check.size < 10)? 1 : 4\n\t\n\t# Size of partisans \n\tpart = @words_to_check.size / number_of_threads\n\n\t# For each thread\n\tnumber_of_threads.times do |i|\n\n\t\t# Create a new Thread, add it to array\n\t\tthreads << Thread.new {\n\t\t\t\n\t\t\t# To make sure the partitioning is complete, calculate the upper bound\n\t\t\tif i == number_of_threads - 1\n\t\t\t\tlast = @words_to_check.size\n\t\t\telse\n\t\t\t\tlast = ((i+1) * part) - 1\n\t\t\tend\n\n\t\t\t# For each word in partitioned section of words to check\n\t\t\t@words_to_check[(i * part)..last].each do |word|\n\n\t\t\t\t# Retrieve the correct Hash for the corresponding word\n\t\t\t\tsection = (@dictionary[word[0]].nil?)? @dictionary['0'] : @dictionary[word[0]]\n\n\t\t\t\t# If direct match is found, return correct\n\t\t\t\tif section[word]\n\t\t\t\t\tputs \"CORRECT [#{word}]\"\n\t\t\t\t\n\t\t\t\t# Word is not a match\n\t\t\t\telse\n\t\t\t\t\tsuggestion = nil \t# initialize a suggestion\n\n\t\t\t\t\t# First try to find the fast solutions\n\t\t\t\t\t# For each word in the section, test for flipped, extra, and missing letters\n\t\t\t\t\tsection.each_key do |key|\n\n\t\t\t\t\t\tif flipped_letter(key, word)\n\t\t\t\t\t\t\tsuggestion = key\n\n\t\t\t\t\t\telsif extra_letter(key, word)\n\t\t\t\t\t\t\tsuggestion = key\n\n\t\t\t\t\t\telsif key.length > word.length # required comparison to avoid error\n\t\t\t\t\t\t\tsuggestion = key if missing_letter(key, word)\n\t\t\t\t\t\t\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\t# Still no suggestion found, resort to a more expensive route\n\t\t\t\t\tif suggestion.nil?\n\t\t\t\t\t\t\n\t\t\t\t\t\t# suggestion value works as a tolerance for an INCORRECT output\n\t\t\t\t\t\tsuggestion_value = 7\n\n\t\t\t\t\t\t# For each word in section\n\t\t\t\t\t\tsection.each_key do |key|\n\n\t\t\t\t\t\t\t# Get the defect count\n\t\t\t\t\t\t\tcount = defect_count(key, word)\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t# if the defect count is better, add a suggestion and associated cost\n\t\t\t\t\t\t\tif count < suggestion_value\n\n\t\t\t\t\t\t\t\tsuggestion_value = count\n\t\t\t\t\t\t\t\tsuggestion = key\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\t# No suggestion can be made\n\t\t\t\t\tif suggestion.nil?\n\t\t\t\t\t\tputs \"INCORRECT [#{word}]\"\n\t\t\t\t\t\n\t\t\t\t\t# Else, output the suggestion\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"#{suggestion} suggested for [#{word}]\"\n\t\t\t\t\t\t\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t}\n\tend\n\n\t# Run the Thread(s)\n\tthreads.each {|t| t.join}\t\nend",
"def apply_replacements(word)\n @replacements.each do |pattern, target|\n word.gsub!(pattern, target)\n end\n \n word\n end",
"def find_chain(word1, word2)\n\t\t word1_array = split_word(word1)\n\t\t word2_array = split_word(word2)\n\n\t\t \tindex = 0\n\n\t\t\t word1_array.cycle { |letter|\n\t\t\t \tletter_copy = word1[index]\n\t\t\t \t#p index\n\t\t\t \tword1[index] = word2[index]\n\t\t\t \tp word1\n\t\t\t \tif @dictionary.exists?(word1)\n\t\t\t \t\tp \"exists\"\n\t\t\t \t\tif word1 == word2\n\t\t\t \t\t\tputs \"MATCH\"\n\t\t\t \t\t\tbreak;\n\t\t\t \t\tend\n\t\t\t\telse\n\t\t\t\t\tp \"does NOT exist\"\n\t\t\t\t\tword1[index] = letter_copy\n\t\t\t \tend\n\t\t\t \tp index\n\t\t\t if index >= word1_array.length-1\n\t\t\t \tindex = 0\n\t\t\t else\n\t\t\t \tindex += 1\n\t\t\t end\n\n\t\t\t }\n end",
"def match_letters(player_guess) \n indexes_matched = @word_array.each_index.select { |i| @word_array[i] == player_guess}\n for x in indexes_matched do\n @results[x] = player_guess\n end\n end",
"def printSimilarities(guess,word)\n\t(0..4).each do |i|\n\t\tprint \"#{guess[i].upcase} \"\n\tend\n\tputs \"\"\n\t(0..4).each do |i|\n\t\tif guess[i].upcase==word[i].upcase\n\t\t\tprint \"* \"\n\t\telse\n\t\t\tprint findMatch(guess[i],word)\n\t\tend\n\tend\n\tputs \"\"\n\tprint \"--------- \"\n\t$linesPrinted += 3\nend",
"def make_regexp\n @intent = self.intent\n regexp = self.pattern.dup.downcase\n words = regexp.split(\" \")\n words.each do |word|\n if word.include? '/'\n regexp = regexp.gsub(word,\"(#{word})\")\n\n end\n\n end\n regexp = regexp.gsub('/',\"|\")\n regexp = regexp.gsub('^ ','.{0,60}').gsub(' ^','.{0,60}').gsub(' *','.{1,60}').gsub('* ','.{1,60}').gsub('^','.{1,60}').gsub(' [','.{0,60}[')\n regexp = regexp.gsub(' .{0,60}','.{0,60}')\n regexp = regexp.gsub(' .{1,60}','.{1,60}')\n regexp = '.{0,60}' + regexp + '.{0,60}'\n self.regexp = regexp\n chunks = self.pattern.split(' ')\n chunks.each do |ch|\n result= Regexp.new(/\\[.{0,12}\\]/) =~ ch\n if(result==0)\n set = WordSet.find_by_keyword(ch[1..-2])\n str = '(' + set.words.join('|') + ')'\n regexp = self.regexp.gsub(ch,str)\n self.regexp = regexp\n end\n end\n self.save\n end",
"def update_pose_words\n\n # Step 1: get an array of all words for the current object.\n search_text = instance_eval &(self.class.pose_content)\n new_words = Query.new([], search_text.to_s).query_words\n\n # Step 2: Add new words to the search index.\n Helpers.get_words_to_add(self.pose_words, new_words).each do |word_to_add|\n self.pose_words << Word.find_or_create_by(text: word_to_add)\n end\n\n # Step 3: Remove now obsolete words from search index.\n Helpers.get_words_to_remove(self.pose_words, new_words).each do |word_to_remove|\n self.pose_words.delete word_to_remove\n end\n end",
"def find_words(words)\n @words = words.map { |w| MatrixWord.new(w) }\n @words.each { |mw| place mw if (!mw.word.nil? && mw.word.size <= @width) }\n @words.select { |w| !w.place.nil? }\n end",
"def string_matching(words)\n result_words = []\n\n words.each_with_index do |possible_substring, index|\n (0..words.size - 1).each do |index_w|\n next if index_w == index || words[index_w].size < possible_substring.size\n \n result_words << possible_substring if words[index_w].index(possible_substring)\n end\n end\n \n result_words.uniq\nend",
"def run(source_word, target_word)\n @current_words = [source_word]\n @all_seen_words = {source_word => nil}\n\n until @current_words.empty?\n explore_current_words(@current_words)\n break if @all_seen_words.has_key?(target_word)\n end\n \n build_path(target_word).include?(source_word) ? @path : nil\n \n end",
"def make_word_from_board?(letters, word, i, j)\n matched_dices = []\n unmatched_dices = []\n letter_used = letters.map {|column| column.map { false }}\n letter_used[i][j] = true\n matched_dices.push([i, j])\n word_pos = 1\n while word_pos < word.size\n letter_matched = false\n # move a step next to the current letter to check if we can form the word\n (i-1..i+1).each do |m|\n # ignore if our matching window is outside the dices\n if m == -1 || m == letters.size\n next\n end\n (j-1..j+1).each do |n|\n # ignore if our matching window is outside the dices\n if n == -1 || n == letters[0].size\n next\n end\n # ignore for the central dice\n if m == i && n == j\n next\n end\n # ignore if letter at the position has already been used\n if letter_used[m][n]\n next\n end\n # skip if the dice is already unmatched\n if unmatched_dices.find{|dice| dice[0] == m && dice[1] == n}\n next\n end\n if letters[m][n] == word[word_pos]\n i = m\n j = n\n letter_matched = true\n letter_used[i][j] = true\n matched_dices.push([i, j])\n break\n end\n end\n if letter_matched\n word_pos += 1\n break\n end\n end\n unless letter_matched\n # return false when only a single letter is matching\n if word_pos == 1\n return false\n end\n word_pos -= 1\n # get the last matched dice\n i, j = matched_dices.pop\n letter_used[i][j] = false\n unmatched_dices.push([i, j])\n end\n end\n true\n end",
"def run(source, target)\n # Current words include your starting word\n @current_words = [source]\n # Create hash with source as key/value pair\n @all_seen_words = Hash[[[source,source]]]\n until @all_seen_words.include?(target)\n new_current_words = []\n # Iterate through the current words you have\n @current_words.each do |current_word|\n # p current_word\n # Filter current words that have not been seen\n explore_current_words(current_word,new_current_words)\n end\n # update @current_words\n @current_words = new_current_words\n end\n # Record all the words that you have seen\n @last_word = @all_seen_words\n build_path(source, target)\n end",
"def construct_word(word, word_len, dict, twos=@@two_tiles, threes=@@three_tiles, fours=@@four_tiles)\n\t\n\t\tleftover = word_len - word.length\n\t\t\n\t\t# NOTE: I decided to repeat .each routines, as the alternative would mean passing a whole lot of variables to a routine that only executes a few lines of code. When changing one scenario, all other matching scenarios must be changed.\n\t\t# 0: A word of appropriate length has been found. All that remains is to search the dictionary.\n\t\t# 1: There will never be a scenario with one left-over. There are no tiles of length 1.\n\t\t# 2: The only tiles that will fit is of length 2. Only query 'twos'.\n\t\t# 3: The only tiles that will fit is of length 3.\n\t\t# 4: Valid tile placement includes tiles of length 2 and 4.\n\t\t# 5: Valid tile placement includes tiles of length 2 and 3.\n\t\t# 6+: Valid tile placement includes tiles of length 2, 3, and 4.\n\t\tcase leftover\n\t\t\twhen 0 \n\t\t\t\tif (dict.query(word))\n\t\t\t\t\t@@valid_combinations.push(word)\n\t\t\t\tend\n\t\t\twhen 2\n\t\t\t\ttwos.each { |tile| \n\t\t\t\t\tnew_word = word + tile.letters\n\t\t\t\t\tnew_twos = twos - [tile]\n\t\t\t\t\tconstruct_word(new_word, word_len, dict, new_twos, threes, fours) \n\t\t\t\t}\n\t\t\twhen 3\n\t\t\t\tthrees.each { |tile| \n\t\t\t\t\tnew_word = word + tile.letters\n\t\t\t\t\tnew_threes = threes - [tile]\n\t\t\t\t\tconstruct_word(new_word, word_len, dict, twos, new_threes, fours) \n\t\t\t\t}\n\t\t\twhen 4\n\t\t\t\ttwos.each { |tile|\n\t\t\t\t\tnew_word = word + tile.letters\n\t\t\t\t\tnew_twos = twos - [tile]\n\t\t\t\t\tconstruct_word(new_word, word_len, dict, new_twos, threes, fours) \n\t\t\t\t}\n\t\t\t\tfours.each { |tile| \n\t\t\t\t\tnew_word = word + tile.letters\n\t\t\t\t\tnew_fours = fours - [tile]\n\t\t\t\t\tconstruct_word(new_word, word_len, dict, twos, threes, new_fours) \n\t\t\t\t}\n\t\t\twhen 5\n\t\t\t\ttwos.each { |tile| \n\t\t\t\t\tnew_word = word + tile.letters\n\t\t\t\t\tnew_twos = twos - [tile]\n\t\t\t\t\tconstruct_word(new_word, word_len, dict, new_twos, threes, fours) \n\t\t\t\t}\n\t\t\t\tthrees.each { |tile| \n\t\t\t\t\tnew_word = word + tile.letters\n\t\t\t\t\tnew_threes = threes - [tile]\n\t\t\t\t\tconstruct_word(new_word, word_len, dict, twos, new_threes, fours) \n\t\t\t\t}\n\t\t\twhen 6..15\n\t\t\t\ttwos.each { |tile| \n\t\t\t\t\tnew_word = word + tile.letters\n\t\t\t\t\tnew_twos = twos - [tile]\n\t\t\t\t\tconstruct_word(new_word, word_len, dict, new_twos, threes, fours) \n\t\t\t\t}\n\t\t\t\tthrees.each { |tile| \n\t\t\t\t\tnew_word = word + tile.letters\n\t\t\t\t\tnew_threes = threes - [tile]\n\t\t\t\t\tconstruct_word(new_word, word_len, dict, twos, new_threes, fours) \n\t\t\t\t}\n\t\t\t\tfours.each { |tile| \n\t\t\t\t\tnew_word = word + tile.letters\n\t\t\t\t\tnew_fours = fours - [tile]\n\t\t\t\t\tconstruct_word(new_word, word_len, dict, twos, threes, new_fours) \n\t\t\t\t}\n\t\t\telse \n\t\t\t\tputs \"Leftover: \" << leftover.to_s\n\t\t\tend\n\t\t\n\tend",
"def existing_words\n draw_current = draw\n p \"The 7 letters drawn are:\"\n p draw_current\n p \"-\"*70\n\n combinations = combine(draw_current).flat_map{ |w| w.permutation.to_a}.uniq.map { |e| e.join }\n combinations.map{|i| search(i, UPPER_BOUND_INI, LOWER_BOUND_INI, NO_ITERATION_INI)}.flatten.reject{|x| x==nil}\nend",
"def edits1(word) \n deletes = [] \n #all strings obtained by deleting a letter (each letter) \n for i in 0..word.length-1\n\ttemp = word.dup\n\ttemp.slice!(i)\n\tdeletes.push(temp)\n end \n\n transposes = []\n #all strings obtained by switching two consecutive letters\n loop_count = word.length-2\n if loop_count > 0\n for i in 0..loop_count\n\ttemp = word.dup\n \ttemp[i+1] = word[i]\t\n\ttemp[i] = word[i+1]\n\ttransposes.push(temp)\n end\n end \n\n inserts = []\n # all strings obtained by inserting letters (all possible letters in all possible positions)\n for i in 0..word.length\n ALPHABET.each_char do |c|\n temp = word.dup\n temp = temp.insert(i,c)\n inserts.push(temp)\n end\n end\n\n replaces = []\n #all strings obtained by replacing letters (all possible letters in all possible positions)\n for i in 0..word.length-1\n ALPHABET.each_char do |c|\n temp = word.dup\n temp[i] = c\n replaces.push(temp)\n end\n end\n\n return (deletes + transposes + replaces + inserts).to_set.to_a #eliminate duplicates, then convert back to array\n end",
"def good_guess(pattern)\n merge(pattern)\n @dictionary.keep_only_words_that_match(@solution)\n @possible_letters.delete(letter_in(pattern))\n end",
"def search_example_sentences_for_word\n word_forms = self.extract_verb_forms\n search_hits = [] # Put example sentence object hits in this array\n word_forms.each do |wf|\n search = ExampleSentence.solr_search do\n fulltext wf\n end\n if search.results.any?\n search_hits << search.results\n search_hits.uniq # Filter out any duplicate hits\n exs = self.example_sentences.to_a\n potential_exs = exs + search_hits # Create an array of the hits combined with the existing example sentences\n potential_exs.delete_if do |example|\n exs.include?(example) # Discard the matched example if it already exists in the self.example_sentences array\n end\n correct_matches = self.remove_errant_matches_from(potential_exs) # Prevent surface matches only from being added to the Word's example sentences\n self.example_sentences << correct_matches # Add on the new, unique example sentences found.\n return potential_exs\n else\n puts \"No matches found\"\n end\n end\n end",
"def run\n load_the_file\n word_frequency\n match_the_word\n end",
"def matching_bigrams(word1)\n list = @index[word1]\n list.map{ |word2| @table[[word1,word2]] }\n end",
"def find_words(lines, words, sec, point_map)\n found = {}\n max = @letters.length\n lines.each_with_index do |s, i|\n start = 0\n while start < 15\n pattern = ''\n match_regex = ''\n j = start\n while j <= 14 do\n break if s[j] == '!'\n #puts \"** #{i},#{j}\"\n match_regex << (s[j] == '?' ? \"(#{sec[i][j].keys.join('|')})\" : (s[j] == '*' ? '.' : s[j]))\n pattern << s[j]\n break if pattern.count(\".?\") >= max\n j += 1\n end\n if j && j < 14 && s[j] != '!' && words[i][j+1]\n pattern += words[i][j+1]\n match_regex += words[i][j+1]\n end\n\n\n #puts \"regex: #{match_regex}\"\n found.merge!(match(pattern, start, i, words[i], sec[i], point_map[i], match_regex)) unless pattern == ''\n\n if '.?!*'.include?(s[start])\n start += 1\n else\n start += words[i][start].length + 1\n end\n\n end\n end\n #puts \"found: #{found.inspect}\"\n found\n end",
"def edits1(word)\n deletes = []\n letters = word.split(\"\")\n letters.each do |c|\n word2 = word\n deletes.push(word2.delete(c))\n end\n\n transposes = []\n for i in 0..word.length-1\n letters = word.split(\"\")\n letters2 = letters\n letters2.insert(i+1 , letters2.delete_at(i))\n transposes.push(letters2.join())\n end\n\n inserts = []\n ALPHABET.split(\"\").each do |c|\n for i in 0..word.length\n letters = word.split(\"\")\n letters2 = letters\n letters2.insert(i,c)\n inserts.push(letters2.join())\n end\n end\n\n replaces = []\n ALPHABET.split(\"\").each do |c|\n\tfor i in 0..word.length-1\n letters = word.split(\"\")\n letters2 = letters\n letters2.delete_at(i)\n letters2.insert(i,c)\n replaces.push(letters2.join())\n end\n end\n\n return (deletes + transposes + replaces + inserts).to_set.to_a #eliminate duplicates, then convert back to array\n end",
"def get_all_matched_words(combination, dictionary)\n all_matched_words = []\n combination.map { |pattern| all_matched_words.push(find_matches(pattern, dictionary)) unless pattern.empty? }\n all_matched_words\n end",
"def count_word_combinations( text )\n combinations = @word_combinations_database.find_all{|v| text.index( v )}\n combinations.each{|combination|\n add_word( combination )\n }\n return combinations\n end",
"def build(words)\n words.each do |word|\n self.add(word)\n end\n end",
"def solve(words)\n x = 0\n while x < words.max.length\n equal = words.all? do |word|\n word[0..x] == words[0][0..x]\n end\n if equal == false\n return words[0][0...x]\n end\n x += 1\n end\nend",
"def recalculate_matches\n Match.destroy_all\n\n self.matches.each do |match_str|\n Match.parse(match_str)\n end\n end",
"def word_predictor(word_array)\n similar_words=[]\n word_array.each { |word|\n system(\"look #{word} > new.txt\")\n f = File.open(\"new.txt\")\n f.each_line {|line| similar_words << line.chomp }\n }\n self.word_checker(similar_words)\n end",
"def initialize(puzzle,dictionary,strategy=MostFrequentStrategy.new)\n @solution = puzzle.dup\n @dictionary = dictionary.with_only_words_of_size(puzzle.length)\n @possible_letters = ('a'..'z').to_a\n @strategy = strategy\n end",
"def adv\n @words1 = Word.all.sample(1)[0].word\n @words2 = Word.all.sample(1)[0].word\n end",
"def wordplay(string1, string2)\n str1_hash = {}\n str2_hash = {}\n position_hash = {}\n\n # save string1 into an hash\n string1.split('').each do |ch|\n if str1_hash[ch]\n str1_hash[ch] += 1\n else\n str1_hash[ch] = 1\n end\n end\n\n # save string2 into an hash\n string2.split('').each do |ch|\n if str2_hash[ch]\n str2_hash[ch] += 1\n else\n str2_hash[ch] = 1\n end\n end\n\n # check if each character of string2 can be found in string1\n # and if there are enough characters to make string2\n str2_hash.each do |key, value|\n if !str1_hash.key?(key)\n return false\n elsif str1_hash[key] < value\n return false\n end\n end\n\n # save the position of the characters found in string1\n # i = 0\n # while i < string1.length\n # position_hash[string1[i]] = i unless position_hash[string1[i]]\n # i += 1\n # end\n i = 0\n while i < string1.length\n if !position_hash.key?(string1[i])\n position_hash[string1[i]] = i\n end\n i += 1\n end\n\n # save the indices needed to create string2\n i = 0\n str2_arr = []\n while i < string2.length\n str2_arr << position_hash[string2[i]]\n i += 1\n end\n\n str2_arr\nend",
"def update_display_word\n length = @word.length\n length.times do |i|\n if @word[i] == @current_guess\n @display_word[i] = @word[i]\n end\n end\n end",
"def correct(word)\n if @dictionary.has_key?(word)\n return [word]\n end\n \n dist1_replacements = known(edits1(word))\n if dist1_replacements.length != 0\n \treturn dist1_replacements.sort_by{|value| @dictionary[value]}.reverse\n end\n \n dist2_replacements = known_edits2(word)\n if dist2_replacements.length != 0\n \treturn dist2_replacements.sort_by{|value| @dictionary[value]}.reverse\n end\n return nil\n end",
"def find_words(words)\n search_results = SearchResults.new\n \n general = Vector.new\n must_match = Vector.new\n must_not_match = Vector.new\n not_found = false\n \n extract_words_for_searcher(words.join(' ')) do |word|\n case word[0]\n when ?+\n word = word[1,99]\n vector = must_match\n when ?-\n \t word = word[1,99]\n vector = must_not_match\n else\n \t vector = general\n end\n \n index = @dict.find(word.downcase)\n if index\n vector.add_word_index(index)\n else\n not_found = true\n \t search_results.add_warning \"'#{word}' does not occur in the documents\"\n end\n end\n \n if (general.num_bits + must_match.num_bits).zero? \n search_results.add_warning \"No valid search terms given\"\n elsif not not_found\n res = []\n @document_vectors.each do |entry, (dvec, mtime)|\n score = dvec.score_against(must_match, must_not_match, general)\n res << [ entry, score ] if score > 0\n end\n \n res.sort {|a,b| b[1] <=> a[1] }.each {|name, score|\n search_results.add_result(name, score)\n }\n \n search_results.add_warning \"No matches\" unless search_results.contains_matches\n end\n search_results\n end",
"def guess(word_pattern, possible_words)\n all_words = possible_words.flatten\n guess = $avail_letters.sort_by {|c|\n all_words.select{|w|w.index c}.length}.last\n $avail_letters -= [guess]\n $guess = guess\nend",
"def closest_repeat(string)\n min_dist = nil\n closest_repeated_word = nil \n most_recent = {}\n pair_indices = nil\n \n string.split(\" \").each_with_index do |word, i|\n if most_recent[word]\n last_instance = most_recent[word]\n test_dist = i - last_instance\n\n if min_dist.nil? || test_dist < min_dist\n closest_repeated_word = word\n min_dist = test_dist\n pair_indices = [last_instance, i]\n end\n end\n \n most_recent[word] = i \n end\n \n\n [closest_repeated_word, pair_indices]\nend",
"def match(anagram_array)\n anagram_array.select do |word|\n if @word.split(//).sort == word.split(//).sort \n @@words << word \n end\n end \n end",
"def substrings (search_word_list, dictionary)\n #Hash to track word and its count\n word_count_hash = Hash.new\n #Turns search_word_list into an array\n search_word_list_array = search_word_list.split(\" \")\n \n #Loops through the search_word_list\n search_word_list_array.each do |search_word|\n search_word.downcase!\n #Loops through the dictionary\n dictionary.each do |dictionary_word| \n #Checks if dictionary_word is in search_word\n if search_word.include? dictionary_word\n #Checks if the key already exists and increments count by 1 if it does\n if word_count_hash.key?(dictionary_word)\n word_count_hash[dictionary_word] += 1\n else \n #Sets the value of the key to 1 if it doesn't already exist\n word_count_hash[dictionary_word] = 1\n end\n end\n end\n end\n return word_count_hash\nend",
"def compare_strings(input_text, dictionary_word)\n for i in 0..input_text.length - 1 do\n if input_text.length - i >= dictionary_word.length\n j = i + dictionary_word.length - 1\n arr = input_text.slice(i..j)\n if arr.eql?(dictionary_word)\n @output_hash = update_output_hash(arr, @output_hash)\n end\n end\n end\nend",
"def word_checker(user_guess)\n i = -1\n instances = []\n# Checks for the index of the first instance of user_guess AFTER index number i\n# Stops when @word.index(user_guess,i+1) returns nil\n while i = @word.index(user_guess,i+1)\n instances << i\n end\n\n# replace dashes in word display with the correctly guessed letters\n instances.each do |i| @word_display[i] = user_guess end\nend",
"def modified_word(word)\n idx = rand(-1...word.length)\n str = word[idx]\n tmp_word = if idx.even?\n word.insert(idx,str)\n else\n word.delete(str)\n end\n return tmp_word unless dictionary.dict.include?(tmp_word)\n modified_word(word)\n end",
"def run\n searching if @nr_of_words >= @phrase_length\n end",
"def match(array)\n array.select {|word| word.chars.sort.join == self.word.chars.sort.join}\n \n\nend",
"def word_substituter(string)\ntweet=string.split(\" \")\ni = 0 \nwhile i < tweet.length \nif dictionary.keys.include?(tweet[i].downcase)\ntweet[i] = dictionary[tweet[i].downcase]\nend \ni+=1\nend\ntweet.join(\" \")\nend",
"def cheat!(letters) \n reset_trie!\n letters.chars.each_with_index do |letter, index|\n x, y = index.divmod(4)\n @board[x][y].replace letter\n end\n end",
"def contain_match_at_indices(word, indices, guess)\n\t\t#Set secret_word to word from candidate_words\n\t\t#so we can use ComputerPlayer#check_guess method\n\t\t@secret_word = word\n\t\tmatching_indices = check_guess(guess)\n\t\t(indices == matching_indices) ? true : false\t\t\n\tend",
"def replace(replaced, newprog, results)\n new_hill = dup\n new_hill.replace!(replaced, newprog, results)\n new_hill\n end",
"def fill_word(word_guess)\n\t\tword_guess_arr = @word_guess.scan\n\t\t\n\n\tend",
"def word_pattern(pattern, input)\n \nend",
"def input_evaluation(guess, correct_word)\n if correct_word.word.include?(guess)\n # We learned that .each_with_index can be used to locate each letter corresponding with each spacific index\n # Then if the letter matches it will subsitue the \"_\", at the correct index, with the corresponding letter\n correct_word.word.each_with_index do |letter, index|\n if letter == guess\n correct_word.progress[index] = guess\n end\n end\n else\n # Storing wrong letters into an array and updating max_guesses\n correct_word.wrong_guesses << guess\n correct_word.max_guesses -= 3\n end\nend",
"def answer_update \r\n\t\t@guess_word.each_index do |i|\r\n\t\t\t@guess_word[i] ||= \"_\"\r\n\t\tend \r\n\t\tp @guess_word\r\n\tend",
"def reveal_matches(letter)\n hits = []\n i = 0\n @secret.split(\"\").each do |c|\n hits << i if c == letter\n i += 1\n end\n hits.each do |i|\n @solution[i] = letter\n end\n return @solution\n end",
"def analogy(a, b, c, word_to_id, id_to_word, word_matrix, top: 5, answer: nil)\n all_found = true\n [a, b, c].each do |word|\n unless word_to_id.include?(word)\n puts(\"#{word} not found.\")\n all_found = false\n end\n end\n\n return unless all_found\n\n puts(\"\\n[analogy] #{a}:#{b} = #{c}:?\")\n a_vec = word_matrix[word_to_id[a], true]\n b_vec = word_matrix[word_to_id[b], true]\n c_vec = word_matrix[word_to_id[c], true]\n query_vec = b_vec - a_vec + c_vec\n query_vec = normalize(query_vec)\n\n similarity = word_matrix.dot(query_vec).to_a\n\n if answer\n puts(\"===>#{answer}:#{word_matrix[word_to_id[answer]].dot(query_vec)}\")\n end\n\n count = 0\n\n sorted_indexes = similarity.map.with_index.sort.map(&:last).reverse\n\n sorted_indexes.each do |i|\n # TODO: Deal with NaNs\n next if [a, b, c].include?(id_to_word[i])\n\n puts(\" #{id_to_word[i]}: #{similarity[i]}\")\n\n count += 1\n break if count >= top\n end\nend",
"def search_words\n begin\n regex = Regexp.new(@pattern)\n rescue RegexpError => msg\n error_msg(msg)\n rescue NameError => msg\n error_msg(msg)\n end\n @results = DICT.select do |word|\n regex =~ word\n end\n @num_results = @results.length\n format_results\n display_results\n end",
"def verify_word_on_board(w, hash_table)\n w = w.upcase # Since the letters on board is in capital letter\n\n p hash_table\n i = 0\n searched_index = {} # Hash table to keep track what has been searched\n (0...w.length).each { |i| searched_index.store(i, -1)} # Initiate values to indicate that no letters have been searched\n\n while i >= 0 && i < w.length\n # puts \"\\nStart of while loop, i = #{i}, searching letter #{w[i]}...\" ###\n move = false\n\n unless hash_table[w[i]].empty?\n # print \"Letter #{w[i]} exist at #{hash_table[w[i]]}\\n\" ###\n hash_table[w[i]].each_with_index do | value , index |\n # puts \"Scanning through #{w[i]} at position #{value}\" ###\n \n # This unmark the position that was used previously during backtracking.\n if value + @total_letters < 0\n # puts \"Position #{hash_table[w[i]][index]} of #{w[i]} is restored...\" ###\n hash_table[w[i]][index] += (@total_letters * 2)\n # puts \"Position of #{w[i]} is now #{hash_table[w[i]][index]}.\" ###\n end\n\n if index <= searched_index[i] # This skips letters that are already searched\n # puts \"#{w[i]} at #{hash_table[w[i]][index]} is already searched.\" ###\n next\n end\n\n if value >= 0\n \n # The position is subtrated by no of total letters to indicate that it has been searched.\n # No of total letters is used so that duplicate of hash table is not required.\n \n if i == 0 || is_adjacent(hash_table[w[i]][index],(@total_letters + hash_table[w[i-1]][searched_index[i-1]]))\n hash_table[w[i]][index] -= @total_letters\n # puts \"#{value} has been subracted by @total_letters to #{hash_table[w[i]][index]}\" ###\n \n \n searched_index[i] = index\n # puts \"Moving to next letter, searched_index[#{i}] now has been updated to #{searched_index[i]}\" ###\n move = true\n i += 1\n break\n end\n\n end\n end\n\n end\n\n # i -= 1 if move == false\n if move == false\n if i > 0\n # puts \"Previously used #{w[i-1]} position of #{hash_table[w[i-1]][searched_index[i-1]]} is being marked for restoration.\" ###\n \n hash_table[w[i-1]][searched_index[i-1]] -= @total_letters # To mark position to be restored to original value as it will not be used anymore\n # puts \"Current position of #{w[i-1]} is #{hash_table[w[i-1]][searched_index[i-1]]}.\" ###\n searched_index[i] = -1\n end\n\n\n # puts \"Letter #{w[i]} is not available/not adjacent and i will be subtracted\" ###\n i -= 1\n end\n\n end\n\n # Restore back all coordinates for next word\n\n\n restore_hash_table(hash_table)\n\n # Check whether word exists.\n if i >= 0 \n puts \"#{w} exists!\"\n return true\n else\n puts \"#{w} is not available.\"\n return false\n end\n \n end",
"def solve\n solution_candidate(intersections.next_people_with_similar_tastes)\n end",
"def guess(word_pattern, possible_words)\r\n all_words = possible_words.flatten\r\n guess = $avail_letters.sort_by {|c|\r\n all_words.select{|w|w.index c}.length}.last\r\n $avail_letters -= [guess]\r\n $guess = guess\r\nend",
"def looper(word1, word2)\n\t\tputs word1\n\t\t@word1 = word1.split(\"\") \n\t\t@word2 = word2.split(\"\")\n\n\t\tuntil @word1 == @word2 do \n\n\t\t\[email protected]_with_index do |let, index|\n\t\t\t\tif let == @word2[index]\n\t\t\t\telse \n\t\t\t\t\ttemp = @word1.clone\n\t\t\t\t\ttemp[index] = @word2[index]\n\t\t\t\t\ttemp = temp.join(\"\")\n\t\t\t\t\tif @dictionary.exists?(temp) \n\t\t\t\t\t\tputs temp\n\t\t\t\t\t\ttemp = temp.split(\"\")\n\t\t\t\t\t\t@word1=temp\n\t\t\t\t\tend\n\t\t\t\tend \n\t\t\tend\n\t\tend\n\tend",
"def substrings (searchword, listOfWords)\n\n\n\n # create a array first with searchword and put any word in the array\n\n searchwords = searchword.split(/\\W+/)\n listOfWords = listOfWords\n\n\n dict = Hash.new(0)\n\n listOfWords.each do |word| # This function puts the word's inside the hash and increase the counter\n searchwords.each do |search|\n\n if search.downcase.include? word.downcase\n dict[word] += 1\n end\n end\n end\n\n\n dict.each do |word, count|\n\n puts \"Word: #{word} \\n Count: #{count}\"\n\n end\n\n\nend",
"def inc_match\n @matchedCount += 1\n end",
"def match(words_array)\n words_array.select do |element|\n element.split(\"\").sort == @word.split(\"\").sort\n\n end\n end",
"def mutate_spelling\n spelling_changes = rand(@options[:spelling_mutations]+1)\n spelling_changes.times{ self[rand(size)] = random_char }\n self\n end",
"def update_total_matches\n self.correct_matches = (maker.code.select.with_index { |v, i| v == breaker.guess[i] }).length\n self.matches = 4 - (maker.code - breaker.guess).length - correct_matches\n end",
"def find_words words\n # We will work with \"DictWord\" objects rather than with raw strings\n @words = words.map{|w| DictWord.new(w)}\n # It tries to find every single word (as long as it's possible because of size of grid) in the grid \n # If running on a UNIX system, we could use fork to improve the performance\n # Process.fork {\n @words.each{|dw| place dw if (dw.word != nil && dw.word.size <= @w )}\n # }\n # We return only the words that were found in the grid \n return @words.select{|w|w.place != nil} \n end",
"def substrings(input_text, dictionary)\n input_text.downcase!\n dictionary.each do |word|\n compare_strings(input_text, word)\n end\n return @output_hash\nend",
"def word_search_board\n @grid.each do |r|\n puts r.map { |p| p }.join(\" \")\n end\n end",
"def set_solution\r\n @solutions = true\r\n end",
"def test_score_a_word_with_recurring_tiles\n\t\t\"BOGO\".each_char { |x| @word.append x.to_sym }\n\t\tassert_equal 7, @word.score\n\tend",
"def bulk_tweet_shortener(array)\n replace= []\n \n array.each do |string|\n replace << string.split.each do |word| \n if dictionary.has_key?(\"#{word}\") == true\n word.replace(dictionary[\"#{word}\"])\n else word\n end\n end\n \n end \n\n replace.collect do |tweet| puts tweet.join(\" \") end\nend",
"def test_word\n 1000.times { assert_includes @wordlist, @tester.word }\n end",
"def train!(word_list)\n word_list.each do |s|\n @dictionary[s] += 1\n end\n end",
"def matched_words\n _matched_words\n end",
"def search( unique_words )\n Thread.new{\n wordHash = []\n tempResults = {}\n list = {}\n y = unique_words.length - 1\n for i in 0..y\n Thread.new(i){ |i2|\n wordHash[i2] = Hash_Func( unique_words[i2] )\n while @searchAckWait != nil && ( @searchAckWait[ wordHash[i2] ] == 1 || @searchAckWait[ wordHash[i2] ].kind_of?(Array) )\n end\n @searchAckWait[ wordHash[i2] ] = 1\n searchMesg = { :type => \"SEARCH\", :word => unique_words[i2], :node_id => wordHash[i2], :sender_id => @guid }.to_json\n nh, m, n = nextHop( wordHash[i2] )\n @s.send searchMesg, 0, nh.ip, nh.port\n t = Time.now.sec\n t2 = t + 90\n while t < t2 # Waits 30 seconds before checking route\n if @searchAckWait[ wordHash[i2] ].kind_of?(Array)\n tempResults[ wordHash[i2] ] = @searchAckWait[ wordHash[i2] ]\n break\n end\n t = Time.now.sec\n if t < t2 - 30\n t = t + 60\n end\n end\n if @searchAckWait[ wordHash[i2] ].kind_of?(Array)\n puts \"correct search result\"\n else\n puts \"The Search has failed time to check the route\"\n #puts @searchAckWait, wordHash[i2]\n routeChecker( wordHash[i2] )\n end\n @searchAckWait[ wordHash[i2] ] = 0\n }\n end\n t3 = Time.now.sec # returns results after 3 seconds\n t4 = t3 + 3\n while t3 < t4\n t3 = Time.now.sec\n if t3 < t4 - 3\n t3 = t3 + 60\n end\n end\n # Search algorithm return the minimum rank for each URL that is present for each word\n list = tempResults[ wordHash[0] ]\n removeList = []\n for j in 1..wordHash.length-1\n nList = tempResults[ wordHash[j] ]\n list.each { |h|\n removeFlag = true\n nList.any? { |nH|\n if nH[:url] == h[:url]\n removeFlag = false\n if nH[:rank] < h[:rank]\n h[:rank] = nH[:rank]\n end\n end\n }\n if removeFlag\n removeList << h\n end\n }\n for k in removeList\n list.delete(k)\n end\n end\n r = SearchResult.new() # Holds results\n r.words = unique_words\n r.resutls = list\n return r\n }\n end",
"def delegate_word(node)\n\tFile.open(\"input.txt\", \"r\").each_line do |l|\n\t\tline = l.downcase[0..-2].split(\"\")\n\t\t#For adding\n\t\tif(node.word.length + 1) == line.length\n\t\t\tcompare_words(node, line)\n\t\tend\n\t\t#For removing\n\t\tif(node.word.length - 1) == line.length\n\t\t\tcompare_words(node, line)\n\t\tend\n\t\t#For substiting\n\t\t#Checking to make sure they are the same length\n\t\tif node.word.length == line.length\n\t\t\tcompare_words(node, line)\n\t\tend\n\tend\nend",
"def checking_dictionary_for_word_match\n @prefix = @str[@i_last_real_word...@i]\n \n if valid_word?(@prefix)\n if @skip_counter > 0\n @skip_counter -= 1\n else\n @words[i] = @prefix\n @i_last_real_word = @i\n end\n end\n end",
"def fill_correct_guess(guess)\n indexes = find_guess_position(guess)\n indexes.map do |index|\n @incomplete_word[index] = guess\n end\n end",
"def process_list(word_list)\n word_set = {}\n output = []\n\n word_list.each_with_index do |word, index|\n hash = hash_word(word)\n word_set[hash] ||= []\n word_set[hash] << wrap_word_with_index(word, index)\n\n if word_set[hash].length >= 2\n word_set[hash].each do |word_index|\n word, i = word_index\n # Place the word in it's original index/placement of the original string\n output.insert(i, word)\n end\n end\n end\n output.compact\nend",
"def word_substituter(string)\n# dictionary.has_key(\"hello\") == true\n replace= []\n \n replace << string.split.each do |word| \n if dictionary.has_key?(\"#{word}\") == true\n word.replace(dictionary[\"#{word}\"])\n else word\n \n end\n \n end \n replace.flatten.join(\" \")\nend"
] | [
"0.66687953",
"0.633226",
"0.6130408",
"0.5979474",
"0.59396213",
"0.589451",
"0.5783897",
"0.57772106",
"0.5775033",
"0.5772448",
"0.5772448",
"0.5770923",
"0.5759949",
"0.575482",
"0.57043165",
"0.5687306",
"0.56778115",
"0.5673475",
"0.5670098",
"0.5667745",
"0.56358904",
"0.5616146",
"0.56128514",
"0.5592608",
"0.55837435",
"0.5566195",
"0.555898",
"0.55393153",
"0.5515473",
"0.5507541",
"0.54984057",
"0.549808",
"0.54862815",
"0.54714876",
"0.54567444",
"0.545535",
"0.54522693",
"0.5425504",
"0.5419048",
"0.54055303",
"0.5400869",
"0.54006255",
"0.5385365",
"0.5385238",
"0.5367053",
"0.5361073",
"0.5342813",
"0.5340691",
"0.5317432",
"0.5317236",
"0.5312459",
"0.5309179",
"0.52875197",
"0.52871025",
"0.52866435",
"0.5245434",
"0.524517",
"0.52381605",
"0.52355844",
"0.52349365",
"0.52331823",
"0.5231961",
"0.52302545",
"0.5221851",
"0.5216317",
"0.5208318",
"0.52075964",
"0.51969147",
"0.5195546",
"0.5193036",
"0.5188044",
"0.5186765",
"0.5179926",
"0.517977",
"0.5179735",
"0.51690674",
"0.5164254",
"0.5164025",
"0.516375",
"0.5157039",
"0.5156105",
"0.51519936",
"0.51514196",
"0.51485664",
"0.51462764",
"0.51425076",
"0.51255196",
"0.5123484",
"0.51201427",
"0.51199883",
"0.51141286",
"0.5109789",
"0.51095754",
"0.51079154",
"0.51029384",
"0.5101707",
"0.50966924",
"0.50886285",
"0.5087741",
"0.5079946"
] | 0.7980253 | 0 |
GET /site_configs GET /site_configs.json | def index
@site_configs = SiteConfig.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @site_config = SiteConfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site_config }\n end\n end",
"def index\n\t\t@siteconfigs = Siteconfig.all\n\tend",
"def index\n @app_configs = AppConfig.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @app_configs }\n end\n end",
"def new\n @site_config = SiteConfig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site_config }\n end\n end",
"def get_config()\n return @api.do_request(\"GET\", get_base_api_path() + \"/config\")\n end",
"def index\n @app_configs = AppConfig.all\n end",
"def get_serv_config\n\t\taction = \"configuration\"\n\t\tresponse = call_api(action)\n\tend",
"def index\n @configs = Config.all\n end",
"def all\n JSON.parse(@client.call('config.get'))\n end",
"def show\n @global_config = AppConfig.where(:section => params[:sect])\n @global_config.each do |conf|\n puts conf.confkey\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @global_config }\n end\n end",
"def index\n @api_configs = ApiConfig.all\n end",
"def index\n @system_configs = SystemConfig.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @system_configs }\n end\n end",
"def index\n @portal_configs = Portal::Config.all\n end",
"def index\n @system_configurations = SystemConfiguration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @system_configurations }\n end\n end",
"def index\n @system_configs = SystemConfig.all\n end",
"def show\n @app_config = AppConfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @app_config }\n end\n end",
"def site_config(site_name)\n load_config(\"#{Huzzah.path}/sites/#{site_name}.yml\")\n end",
"def config\n site.config\n end",
"def index\n @jenkins_app_configs = JenkinsAppConfig.all\n end",
"def configuration\n _get(\"/system/configuration\") { |json| json }\n end",
"def set_site_config\r\n @site_config = SiteConfig.find(params[:id])\r\n end",
"def site_config\n if File.exists?('laze.yml')\n YAML.load_file('laze.yml').symbolize_keys\n else\n {}\n end\n end",
"def index\n @sysconfigs = Sysconfig.order(created_at: :desc).page(params[:page])\n end",
"def sites_to_load\n @appl_settings[:registered_config_modules]\n end",
"def get_settings\n return @client.raw(\"get\", \"/config/settings\")\n end",
"def create\n\t\t@siteconfig = Siteconfig.new(siteconfig_params)\n\n\t\trespond_to do |format|\n\t\t\tif @siteconfig.save\n\t\t\t\tformat.html { redirect_to @siteconfig, notice: 'Siteconfig was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @siteconfig }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @siteconfig.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def server_settings\n [\n {\n url: \"https://{subdomain}.{site}\",\n description: \"No description provided\",\n variables: {\n site: {\n description: \"The regional site for Datadog customers.\",\n default_value: \"datadoghq.com\",\n enum_values: [\n \"datadoghq.com\",\n \"us3.datadoghq.com\",\n \"us5.datadoghq.com\",\n \"ap1.datadoghq.com\",\n \"datadoghq.eu\",\n \"ddog-gov.com\"\n ]\n },\n subdomain: {\n description: \"The subdomain where the API is deployed.\",\n default_value: \"api\",\n }\n }\n },\n {\n url: \"{protocol}://{name}\",\n description: \"No description provided\",\n variables: {\n name: {\n description: \"Full site DNS name.\",\n default_value: \"api.datadoghq.com\",\n },\n protocol: {\n description: \"The protocol for accessing the API.\",\n default_value: \"https\",\n }\n }\n },\n {\n url: \"https://{subdomain}.{site}\",\n description: \"No description provided\",\n variables: {\n site: {\n description: \"Any Datadog deployment.\",\n default_value: \"datadoghq.com\",\n },\n subdomain: {\n description: \"The subdomain where the API is deployed.\",\n default_value: \"api\",\n }\n }\n }\n ]\n end",
"def configs!\n @configs = begin\n # This global is set when Origen is first required, it generally means that what is considered\n # to be the pwd for the purposes of looking for a site_config file is the place from where the\n # user invoked Origen. Otherwise if the running app switches the PWD it can lead to confusing\n # behavior - this was a particular problem when testing the new app generator which switches the\n # pwd to /tmp to build the new app\n path = $_origen_invocation_pwd\n configs = []\n # Add any site_configs from where we are currently running from, i.e. the application\n # directory area\n until path.root?\n file = File.join(path, 'config', 'origen_site_config.yml')\n configs << YAML.load_file(file) if File.exist?(file) && YAML.load_file(file)\n file = File.join(path, 'origen_site_config.yml')\n configs << YAML.load_file(file) if File.exist?(file) && YAML.load_file(file)\n path = path.parent\n end\n\n # Add and any site_configs from the directory hierarchy where Ruby is installed\n path = Pathname.new($LOAD_PATH.last)\n until path.root?\n file = File.join(path, 'origen_site_config.yml')\n configs << YAML.load_file(file) if File.exist?(file) && YAML.load_file(file)\n path = path.parent\n end\n\n # Add the one from the Origen core as the lowest priority, this one defines\n # the default values\n configs << YAML.load_file(File.expand_path('../../../origen_site_config.yml', __FILE__))\n configs\n end\n\n # Add the site_config from the user's home directory as highest priority, if it exists\n # But, make sure we take the site installation's setup into account.\n # That is, if user's home directories are somewhere else, make sure we use that directory to the find\n # the user's overwrite file. The user can then override that if they want.\"\n user_config = File.join(File.expand_path(user_install_dir), 'origen_site_config.yml')\n if File.exist?(user_config)\n @configs.unshift(YAML.load_file(user_config)) if YAML.load_file(user_config)\n end\n\n @configs\n end",
"def index\n @cdn_configs = CdnConfig.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cdn_configs }\n end\n end",
"def create\n @site_config = SiteConfig.new(site_config_params)\n\n respond_to do |format|\n if @site_config.save\n format.html { redirect_to @site_config, notice: 'Site config was successfully created.' }\n format.json { render json: @site_config, status: :created, location: @site_config }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_config(context)\n context.registers[:site].config\n end",
"def get_config_infos\n configinfo =\n {\n :init_one_appointment_price => Settings.init_one_appointment_price,\n :income_call_number => Settings.income_call_number,\n :call_length => Settings.call_length,\n :tutor_online_time => Settings.tutor_online_time,\n :call_delay_time => Settings.call_delay_time,\n :tutor_single_price => Settings.tutor_single_price\n }\n render :json => configinfo.to_json(), :status => 200\n end",
"def index\n @machine_configs = MachineConfig.all\n end",
"def set_siteconfig\n\t\t@siteconfig = Siteconfig.find(params[:id])\n\tend",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def show\n @sysconfig = Sysconfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sysconfig }\n end\n end",
"def index\n @sys_configs = @system.sys_configs.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @sys_configs.to_xml }\n end\n end",
"def list_apps\n render :text => app_configs.keys\n end",
"def index\n\t\t@list_configs = current_user.list_configs.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @list_configs }\n\t\t\tformat.json { render :json => @list_configs }\n\t\t\tformat.yaml { render :text => @list_configs.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def index\n @a_serverconfigurations = AServerconfiguration.all\n end",
"def index\n respond_to do |format|\n format.html do \n @sites = Site.all\n end\n format.json do\n render json: Site.all\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @siteconfig.update(siteconfig_params)\n\t\t\t\tformat.html { redirect_to @siteconfig, notice: 'Siteconfig was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @siteconfig }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @siteconfig.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def get_sites\n\t\ts = get_admin_section \"system.applicationHost/sites\"\n\t IisObjectCollection.new s.Collection, :site, Site, lambda { |site| site.id = s.Collection.Count + 1 }\n end",
"def server_configurations\n response = get \"server_size\"\n response[\"server_sizes\"][\"server_size\"]\n end",
"def show\n @clientconfig = Clientconfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientconfig }\n end\n end",
"def sites\n request('/web_properties.json').map do |site_data|\n Site.new self, site_data['uid'], site_data['name']\n end\n end",
"def site_payload\n {\"site\" => self.config.merge({\n \"time\":\n \"posts\":\n \"pages\":\n \"html_pages\"\n \"categories\"\n \"tags\"\n })}\n end",
"def index\n @configurations = ::Configuration.all\n end",
"def find_configurations\n @configurations = @user.configurations\n @config_by_key = @configurations.inject({}) do |map, cfg|\n values = map[cfg.api_key] || []\n values << cfg\n map[cfg.api_key] = values\n map\n end\n end",
"def settings\n get('/account/settings.json')\n end",
"def list_config\n configs = store :get, 'configs'\n (configs.error?) ? 'No config vars set yet.' : configs.to_s\n end",
"def index\n @servers = @site.servers\n end",
"def index\n @sites = fetch_sites\n\n @formattedSites = @sites.map do |site|\n {\n 'title' => {'value' => site.name, 'link' => { 'url' => site.routes.first.host_with_scheme, 'external' => true}, 'searchable' => true, 'sortable' => true},\n 'template' => {'value' => site.site_template&.name, 'searchable' => true, 'sortable' => true},\n 'preview' => {'value' => site.routes.first.host_with_scheme, 'link' => { 'url' => site.routes.first.host_with_scheme, 'external' => true}, 'searchable' => true, 'sortable' => true},\n 'edit' => {'value' => edit_admin_site_site_step_path(site_slug: site.slug, id: :name), 'method' => 'get'},\n 'delete' => {'value' => admin_site_path(slug: site.slug), 'method' => 'delete'}\n }\n end\n\n gon.sites = @formattedSites\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @sites }\n end\n end",
"def index\n @site_setups = SiteSetup.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @site_setups }\n end\n end",
"def get_settings\n request :get, \"_settings\"\n end",
"def get_settings\n request :get, \"_settings\"\n end",
"def get_webcfg(bucket_name, options={})\n resp = get(nil, \"/#{bucket_name}?websiteConfig\", options)\n resp_obj = {}\n resp_obj[:raw] = Crack::XML.parse(resp.body) if resp.body\n if resp.code == \"200\"\n resp_obj[:success] = true\n resp_obj[:bucket_name] = bucket_name\n resp_obj[:config] = resp_obj[:raw]['WebsiteConfiguration']\n resp_obj[:message] = \"Website configuration retrieved\"\n else\n resp_obj[:success] = false\n resp_obj[:bucket_name] = bucket_name\n resp_obj[:message] = resp_obj[:raw][\"Error\"][\"Message\"].to_s if resp_obj[:raw][\"Error\"][\"Message\"]\n resp_obj[:code] = resp_obj[:raw][\"Error\"][\"Code\"] if resp_obj[:raw][\"Error\"][\"Code\"]\n end\n\n resp_obj.each_key {|key| resp_obj.delete(key) unless [:success, :bucket_name, :config, :message, :code, :raw].include?(key) }\n\n return resp_obj\n end",
"def show\n respond_to do |format|\n format.html do \n set_site\n @site\n end\n format.json do\n render json: @site\n end\n end\n end",
"def index\n @userconfigs = Userconfig.all\n end",
"def index\n set_user\n @sites = Site.all\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @sites.to_json }\n end\n end",
"def update\r\n respond_to do |format|\r\n if @site_config.update(site_config_params)\r\n format.html { redirect_to action: :index, notice: t('Site config 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: @site_config.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def index\n add_breadcrumb \"all\", nil, \"glyphicon-list\"\n\n @sites = current_user.account.sites || []\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end",
"def index\n @parsed_sites = ParsedSite.all\n\n render json: @parsed_sites\n end",
"def show\n @configure = Configure.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @configure }\n end\n end",
"def index\n @wx_configs = WxConfig.all\n end",
"def index\n @website_settings = WebsiteSetting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @website_settings }\n end\n end",
"def load_site_configs(*files)\n # Allows both:\n # load_site_configs('foo', 'bar')\n # load_site_configs(['foo', bar'])\n # but not:\n # load_site_configs(['foo'], 'bar')\n files = files[0] if files.length == 1 && files[0].is_a?(Array)\n\n load_files(*files)\n end",
"def index\n @sites = Cms::Site.all\n end",
"def index\n @servers = Server.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers.to_json(:include => { :websites => {:include => :plugins } }) }\n end\n end",
"def configure(site = :default, &block)\n @configs ||= {}\n @configs[site.to_s] = block\n end",
"def index\n @cfgs = Cfg.all\n end",
"def get_resource_configurations(user_id)\n self.class.available_hosts.map do |host|\n {name: short_name.to_sym, params: {plgrid_host: host}}\n end\n end",
"def index\n @tournament_configs = TournamentConfig.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tournament_configs }\n end\n end",
"def configurations\n @configurations ||= []\n end",
"def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end",
"def config\n overview[\"config\"]\n end",
"def all_merchant_configs\n profile.merchant_configs\n end",
"def show\n @wp_dyna_config = WpDynaConfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wp_dyna_config }\n end\n end",
"def configs\n @configuration.ids\n end",
"def show\n render json: @parsed_site\n end",
"def server_settings\n [\n {\n url: \"https://api.samsara.com/v1\",\n description: \"No descriptoin provided\",\n }\n ]\n end",
"def index\n @scriptconfigs = Scriptconfig.all\n end",
"def get_config_data_for_resource(resource_path)\n path = resource_path.is_a?(CanonicalPath) ? resource_path : CanonicalPath.parse(resource_path)\n resource_path = path.resource_ids.join('/')\n feed_id = path.feed_id\n query = generate_query_params dataType: 'configuration'\n http_get(\"feeds/#{feed_id}/resources/#{resource_path}/data#{query}\")\n rescue\n {}\n end",
"def config(host, port)\n uri = URI::HTTP.build(host: host, port: port, path: '/config')\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.get(uri.path, \"Accept\" => \"application/json\")\n end",
"def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end",
"def new\n @global_config = AppConfig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @global_config }\n end\n end",
"def index\n @landing_page_configs = LandingPageConfig.all\n end",
"def site\n AutoAdmin::AutoAdminConfiguration.site\n end",
"def update\n @site_config = SiteConfig.find(params[:id])\n\n respond_to do |format|\n if @site_config.update_attributes(site_config_params)\n format.html { redirect_to @site_config, notice: 'Site config was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @system_configuration = SystemConfiguration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system_configuration }\n end\n end",
"def show\n @system_configuration = SystemConfiguration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system_configuration }\n end\n end",
"def settings\n config = current_user.company.ms_teams_configs.for_entity(params[:entity_id])\n if request.delete?\n config.destroy!\n head :ok\n elsif request.post?\n # this should always save, so hard fail if it doesn't\n config.update!(config_settings)\n head :ok\n else\n render json: config.as_json\n end\n end",
"def websites\n self.dig_for_array(\"webSites\")\n end",
"def config\n @config ||= @site.config[\"feed\"] || {}\n end",
"def test_get_site_list\r\n endpoint = \"/sites\"\r\n uri = URI(\"#{@host}#{endpoint}\")\r\n request = Net::HTTP::Get.new(uri)\r\n request['Accept'] = 'application/json'\r\n \r\n test_start = Time.now\r\n response = Net::HTTP.start(uri.hostname, uri.port) do |http|\r\n http.request(request)\r\n end\r\n test_end = Time.now\r\n\r\n @results << {\r\n :api => 'GET /sites',\r\n :endpoint => endpoint,\r\n :start_time => test_start,\r\n :runtime => (test_end.to_f - test_start.to_f) * 1000.0,\r\n :status => response.code,\r\n :content_type => response['content-type']\r\n }\r\n end",
"def get_sites_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SiteApi.get_sites ...\"\n end\n # resource path\n local_var_path = \"/api/3/sites\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'sort'] = @api_client.build_collection_param(opts[:'sort'], :multi) if !opts[:'sort'].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;charset=UTF-8'])\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 = []\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 => 'PageOfSite')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SiteApi#get_sites\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @task_configs = TaskConfig.all\n end",
"def index\n @room_configs = RoomConfig.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @room_configs }\n end\n end",
"def index_configurations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UsersApi.index_configurations ...'\n end\n # resource path\n local_var_path = '/users/me/configurations'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'UserConfigurationCollection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\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: UsersApi#index_configurations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end"
] | [
"0.7330663",
"0.71956205",
"0.68466693",
"0.66667455",
"0.66290116",
"0.6621931",
"0.657767",
"0.6565218",
"0.6536528",
"0.6517258",
"0.64899653",
"0.6488413",
"0.640835",
"0.6363339",
"0.63609266",
"0.6355054",
"0.6299681",
"0.6274702",
"0.6224177",
"0.62056965",
"0.61674255",
"0.6142643",
"0.6082277",
"0.6073374",
"0.60639703",
"0.6052246",
"0.60499185",
"0.60340995",
"0.60153544",
"0.6015344",
"0.6015062",
"0.6004477",
"0.5990008",
"0.59795564",
"0.5966917",
"0.5966917",
"0.59619504",
"0.59609044",
"0.5951524",
"0.5943994",
"0.59433985",
"0.59319746",
"0.5927304",
"0.5924874",
"0.591954",
"0.5914091",
"0.5887979",
"0.5883527",
"0.5856594",
"0.5854125",
"0.5851022",
"0.5836384",
"0.58360946",
"0.5817125",
"0.5816219",
"0.58010185",
"0.58010185",
"0.5713479",
"0.5708827",
"0.57020164",
"0.5695745",
"0.56923753",
"0.56844234",
"0.56771153",
"0.56696105",
"0.56695575",
"0.56665975",
"0.56463176",
"0.5645156",
"0.5642695",
"0.5639051",
"0.56342095",
"0.5621669",
"0.56163234",
"0.5609535",
"0.56027657",
"0.56019586",
"0.55955195",
"0.559063",
"0.5579976",
"0.5579948",
"0.5571653",
"0.5569047",
"0.5568282",
"0.5566811",
"0.55620164",
"0.5559614",
"0.5559377",
"0.555411",
"0.5545056",
"0.554108",
"0.554108",
"0.5538055",
"0.5534298",
"0.5531306",
"0.5523513",
"0.55221134",
"0.55154645",
"0.5509091",
"0.5505629"
] | 0.7431591 | 0 |
PATCH/PUT /site_configs/1 PATCH/PUT /site_configs/1.json | def update
respond_to do |format|
if @site_config.update(site_config_params)
format.html { redirect_to action: :index, notice: t('Site config was successfully updated.') }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @site_config.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @site_config = SiteConfig.find(params[:id])\n\n respond_to do |format|\n if @site_config.update_attributes(site_config_params)\n format.html { redirect_to @site_config, notice: 'Site config was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @siteconfig.update(siteconfig_params)\n\t\t\t\tformat.html { redirect_to @siteconfig, notice: 'Siteconfig was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @siteconfig }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @siteconfig.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @app_config = AppConfig.find(params[:id])\n\n respond_to do |format|\n if @app_config.update_attributes(params[:app_config])\n format.html { redirect_to @app_config, notice: 'App config was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @app_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @app_config.update(app_config_params)\n format.html { redirect_to @app_config, notice: 'App config was successfully updated.' }\n format.json { render :show, status: :ok, location: @app_config }\n else\n format.html { render :edit }\n format.json { render json: @app_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @configs = args[:configs] if args.key?(:configs)\n end",
"def update\n authorize! :update, @concerto_config\n params[:concerto_config].each do |k,v|\n ConcertoConfig.set(k,v) #only set this if the config already exists\n end\n redirect_to :action => :index\n end",
"def update\n respond_to do |format|\n if @jenkins_app_config.update(jenkins_app_config_params)\n format.html { redirect_to @jenkins_app_config, notice: 'Jenkins app config was successfully updated.' }\n format.json { render :show, status: :ok, location: @jenkins_app_config }\n else\n format.html { render :edit }\n format.json { render json: @jenkins_app_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @system_config = SystemConfig.find(params[:id])\n\n respond_to do |format|\n if @system_config.update_attributes(params[:system_config])\n format.html { redirect_to system_configs_url, :notice => 'System config was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @system_config.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_config.update(api_config_params)\n format.html { redirect_to @api_config, notice: 'Api config was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_config }\n else\n format.html { render :edit }\n format.json { render json: @api_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sysconfig = Sysconfig.find(params[:id])\n\n respond_to do |format|\n if @sysconfig.update_attributes(params[:sysconfig])\n format.html { redirect_to @sysconfig, notice: 'Sysconfig was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sysconfig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n if params[:site][:manager_ids]\n format.html { redirect_to sites_url(subdomain: \"www\"), notice: 'Site was successfully updated.' }\n else\n format.html { redirect_to edit_site_url(subdomain: @site.subdomain), notice: 'Site was successfully updated.' }\n end\n format.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize!(@site)\n\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to site_site_steps_path(@site), notice: t('notice.site.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def gu_update_site_from_app\n @app = App.find(params[:app]) rescue nil\n @site = [email protected]? ? @app.site : nil\n\n respond_to do |format|\n format.html # gu_update_site_from_app.html.erb does not exist! JSON only\n format.json { render json: @site }\n end\n end",
"def update\n respond_to do |format|\n if @config.update(config_params)\n format.html { redirect_to @config, notice: \"Config was successfully updated.\" }\n format.json { render :show, status: :ok, location: @config }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(params[:id])\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to @site, :notice => 'Site was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\", :layout=>\"site\"}\n format.json { render :json => @site.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @site = current_user.sites.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { flash_and_redirect(\"successfully updated!\", sites_url) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site_option.update(site_option_params)\n format.html { redirect_to @site_option, notice: 'Site option was successfully updated.' }\n format.json { render :show, status: :ok, location: @site_option }\n else\n format.html { render :edit }\n format.json { render json: @site_option.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @system_config.update(system_config_params)\n format.html { redirect_to system_configs_path, notice: \"#{@system_config.description} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @system_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @configure = Configure.find(params[:id])\n\n respond_to do |format|\n if @configure.update_attributes(params[:configure])\n format.html { redirect_to @configure, notice: 'Configure was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @configure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to sites_path, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @wp_dyna_config = WpDynaConfig.find(params[:id])\n\n respond_to do |format|\n if @wp_dyna_config.update_attributes(params[:wp_dyna_config])\n format.html { redirect_to @wp_dyna_config, notice: 'Wp dyna config was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @wp_dyna_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(id_from_params)\n\n respond_to do |format|\n current_user.account.sites.delete(@site)\n current_user.account.sites << @site\n if current_user.account.sites.exists? @site\n format.html { redirect_to root_path, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site.errors.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sysconfig.update(sysconfig_params)\n format.html { redirect_to @sysconfig, notice: 'Sysconfig was successfully updated.' }\n format.json { render :show, status: :ok, location: @sysconfig }\n else\n format.html { render :edit }\n format.json { render json: @sysconfig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find_by_site(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = current_user.sites.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_siteconfig\n\t\t@siteconfig = Siteconfig.find(params[:id])\n\tend",
"def update\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n respond_to do |format|\n if @site.update(params)\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { render json: { result: :ok, notice: 'changes saved succesfully', site: @site } }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sys_config.update(sys_config_params)\n format.html { redirect_to root_path, notice: 'Configuration was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def set_site_config\r\n @site_config = SiteConfig.find(params[:id])\r\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to sites_url, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site_type = SiteType.find(params[:id])\n\n respond_to do |format|\n section_type_ids = params[:site_type].delete(\"section_type_ids\")\n if @site_type.update_attributes(params[:site_type]) && @site_type.section_type_ids = section_type_ids\n format.html { redirect_to @site_type, notice: 'Site type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @scrape_config.update(scrape_config_params)\n format.html { redirect_to @scrape_config, notice: 'Scrape config was successfully updated.' }\n format.json { render :show, status: :ok, location: @scrape_config }\n else\n format.html { render :edit }\n format.json { render json: @scrape_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n redirect_to \"/sites\" and return\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to edit_site_path(@site), notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n do_load_resource\n get_project_if_exists\n do_authorize_instance\n\n @original_site_name = @site.name\n\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to [@project, @site], notice: 'Site was successfully updated.' }\n format.json { respond_show }\n else\n format.html do\n render action: 'edit'\n end\n format.json { respond_change_fail }\n end\n end\n end",
"def update\n logger.debug \"debug_update:params=#{params.inspect}\"\n @m_site = MSite.where(id: params[:id].to_i).first\n @m_site.name = params['app_job_offer_name']\n @m_site.password = params['app_password'].nil? ? '' : params['app_password']\n @m_site.no_scraping_flg = params['app_no_scraping_flg']\n #@m_site.recruitment_site_id = params['app_site_id'].nil? ? '' : params['app_site_id']\n @m_site.user_id = params['app_user_id'].nil? ? '' : params['app_user_id']\n @m_site.extra1 = params['extra1'].nil? ? '' : params['extra1']\n @m_site.extra2 = params['extra2'].nil? ? '' : params['extra2']\n @m_site.extra3 = params['extra3'].nil? ? '' : params['extra3'].to_i\n @m_site.enterprise_cnt = params['enterprise_cnt'].nil? ? 0 : params['enterprise_cnt']\n\n respond_to do |format|\n if @m_site.valid? && @error_msg.blank?\n @m_site.save\n format.html { redirect_to '/m_sites', notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @m_site }\n else\n format.html { render :edit }\n format.json { render json: @m_site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to site_path(@site), notice: 'Site was successfully updated.' }\n # format.html { redirect_to project_site_path(@site.project, @site), notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { flash.now[:error] = \"Error: See details below.\"\n render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @app_setting.update(app_setting_params)\n format.html { redirect_to edit_app_settings_path, notice: t('.notice') }\n format.json { render :show, status: :ok, location: @app_setting }\n else\n format.html { render :edit }\n format.json { render json: @app_setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to after_update_path, notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_update(options = {})\n options[:id] ||= @website.id\n options[:website] ||= @attributes\n\n put :update,options\n end",
"def update\n @site = Site.find params[:id]\n return unless authorize_resource(@site, UPDATE_SITE)\n\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to sites_path, notice: 'Site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sm_backend_config = SmBackendConfig.find(params[:id])\n\n respond_to do |format|\n if @sm_backend_config.update_attributes(params[:sm_backend_config])\n format.html { redirect_to @sm_backend_config, notice: 'Sm backend config was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sm_backend_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site_setup = SiteSetup.find(params[:id])\n\n respond_to do |format|\n if @site_setup.update_attributes(params[:site_setup])\n format.html { redirect_to @site_setup, notice: 'Site setup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site_setup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to xmt_press_sites_url, notice: '站点更新成功.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to(@site, :notice => 'Site was successfully updated.') }\n format.json { head :ok }\n format.xml { head :ok }\n else\n format.html { render :action => '#edit' }\n format.json { render :json => @site.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\tif signed_in?\n\t\t@current_client = current_user.username\n\t\tif current_user.username == 'admin'\n\t\t\t@clientconfig = Clientconfig.find(params[:id])\n\t\telse\n\t\t\tredirect_to home_path\n\t\tend\n\telse\n\t\tredirect_to signin_path\n\tend\n\n respond_to do |format|\n if @clientconfig.update_attributes(params[:clientconfig])\n format.html { redirect_to @clientconfig, notice: 'Clientconfig was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientconfig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @app_setting.update(app_setting_params)\n format.html { redirect_to @app_setting, notice: 'App setting was successfully updated.' }\n format.json { render :show, status: :ok, location: @app_setting }\n else\n format.html { render :edit }\n format.json { render json: @app_setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @watch_site = WatchSite.find(params[:id])\n\n respond_to do |format|\n if @watch_site.update_attributes(params[:watch_site])\n format.html { redirect_to @watch_site, notice: 'Watch site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @watch_site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @systemsetting.update(systemsetting_params)\n format.html { redirect_to root_path, notice: 'Se Actualizo la Configuracion Correctamente.' }\n else\n format.html { render :edit }\n format.json { render json: @systemsetting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.find(params[:id])\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html {redirect_to sites_url, flash[:info]='Site was successfully updated.' }\n format.js { flash[:info]='Site was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to @site, notice: t('.flash_updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @anatomic_site.update(anatomic_site_params)\n format.html { redirect_to @anatomic_site, notice: 'Anatomic site was successfully updated.' }\n format.json { render :show, status: :ok, location: @anatomic_site }\n else\n format.html { render :edit }\n format.json { render json: @anatomic_site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:site][:virtualhost] = nil if params[:site][:virtualhost] =~ /^\\s*$/\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n flash[:notice] = 'Site was successfully updated.'\n format.html { redirect_to(@site) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n format.html { redirect_to controller: \"sites\", action: \"checklists_manager\" }\n format.json { head :no_content }\n end\n end",
"def update\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n categories = [:general, :menu, :topic, :note, :smtp, :feed, :user, :log]\n\n yaml = ApplicationHelper.get_config_yaml\n\n categories.each do |cat|\n next if params[cat].nil? or params[cat].empty?\n\n yaml[cat] = Hash.new if yaml[cat].nil?\n\n params[cat].each do |key, val|\n if cat == :general\n case key\n when 'symbol_image'\n ConfigHelper.save_img('symbol.png', val) if val.size > 0\n else\n yaml[cat][key] = val\n end\n elsif cat == :topic\n case key\n when 'src'\n ConfigHelper.save_html('topics.html', val) if val.size > 0\n else\n yaml[cat][key] = val\n end\n elsif cat == :note\n case key\n when 'src'\n ConfigHelper.save_html('note.html', val) if val.size > 0\n else\n yaml[cat][key] = val\n end\n else\n if params[:smtp]['auth_enabled'] == '0'\n val = nil if ['auth', 'user_name', 'password'].include?(key)\n end\n yaml[cat][key] = val\n end\n end\n end\n\n ApplicationHelper.save_config_yaml(yaml)\n\n flash[:notice] = t('msg.update_success')\n redirect_to(:controller => 'config', :action => 'edit')\n end",
"def update!(**args)\n @site = args[:site] if args.key?(:site)\n @versioned_data = args[:versioned_data] if args.key?(:versioned_data)\n end",
"def update\n @system_configuration = SystemConfiguration.find(params[:id])\n\n respond_to do |format|\n if @system_configuration.update_attributes(params[:system_configuration])\n format.html { redirect_to @system_configuration, notice: 'System configuration was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @system_configuration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @site.update(cms_site_params)\n\n format.html { redirect_to cms.sites_url, notice: '站点已修改.' }\n format.json { head :no_content }\n else\n @cms_theme = Cms::Theme.all\n format.html { render action: 'edit' }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_config\n if File.directory?(yolo_dir) and File.exist?(yaml_path)\n @yaml = YAML::load_file yaml_path\n update_yaml_setting(@yaml, \"deployment\", \"api_token\", \"example\")\n update_yaml_setting(@yaml, \"deployment\", \"team_token\", \"example\")\n end\n end",
"def update\n respond_to do |format|\n if @admin_site_structure.update(admin_site_structure_params)\n format.html { redirect_to @admin_site_structure, notice: 'Site structure was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_site_structure }\n else\n format.html { render :edit }\n format.json { render json: @admin_site_structure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @config_file = ConfigFile.find(params[:id])\n\n respond_to do |format|\n if @config_file.update_attributes(params[:config_file])\n format.html { redirect_to @config_file, notice: 'Config file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @config_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @app_config = AppConfig.find(params[:id])\n\n respond_to do |format|\n if @app_config.update_attributes(params[:app_config])\n format.html {\n flash.now[:notice] = \"更新しました。\"\n render :action => \"edit\" \n #redirect_to(@app_config, :notice => 'App config was successfully updated.') \n }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @app_config.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def settings\n config = current_user.company.ms_teams_configs.for_entity(params[:entity_id])\n if request.delete?\n config.destroy!\n head :ok\n elsif request.post?\n # this should always save, so hard fail if it doesn't\n config.update!(config_settings)\n head :ok\n else\n render json: config.as_json\n end\n end",
"def update\n @node_config = NodeConfig.find(params[:id])\n\n respond_to do |format|\n if @node_config.update_attributes(params[:node_config])\n format.html { redirect_to(@node_config, :notice => 'NodeConfig was successfully updated.') }\n format.json { render :json => @node_config, :status => :ok }\n format.xml { render :xml => @node_config, :status => :ok }\n else\n format.xml { render :xml => @node_config.errors, :status => :unprocessable_entity }\n format.any { render :json => @node_config.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @subsite = Subsite.find(params[:id])\n\n respond_to do |format|\n if @subsite.update_attributes(params[:subsite])\n format.html { redirect_to @subsite, notice: 'Subsite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subsite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @api_configuration.update(api_configuration_params)\n\t\t\t\tformat.html { redirect_to api_configurations_path, notice: 'Api configuration was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @api_configuration }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @api_configuration.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @site_admin.update(site_admin_params)\n format.html { redirect_to @site_admin, notice: 'Site admin was successfully updated.' }\n format.json { render :show, status: :ok, location: @site_admin }\n else\n format.html { render :edit }\n format.json { render json: @site_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @conf = Conf.find(params[:id])\n\n respond_to do |format|\n if @conf.update_attributes(params[:conf])\n format.html { redirect_to @conf, notice: 'Conf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @conf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site = Site.first\n\n respond_to do |format|\n if @site.update_attributes(params[:site])\n format.html { redirect_to(root_url, :notice => 'Site was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @site.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.tconfig.update_attributes(params[:tconfig])\n @status = \"good\"\n @message = \"Settings updated\"\n @resource = @user.tconfig\n elsif [email protected]?\n @message = \"Oops! Please make sure all fields are valid!\"\n end\n\n serve_json_response\n end",
"def update\n respond_to do |format|\n if @cfg.update(cfg_params)\n format.html { redirect_to @cfg, notice: 'Cfg was successfully updated.' }\n format.json { render :show, status: :ok, location: @cfg }\n else\n format.html { render :edit }\n format.json { render json: @cfg.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @sys_config.update_attributes(params[:sys_config])\n flash[:notice] = 'SysConfig was successfully updated.'\n format.html { redirect_to user_system_sys_configs_path(@user, @system) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sys_config.errors.to_xml }\n end\n end\n end",
"def update\n @my_configuration = MyConfiguration.find(params[:id])\n\n respond_to do |format|\n if @my_configuration.update_attributes(params[:my_configuration])\n format.html { redirect_to @my_configuration, notice: 'My configuration was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_configuration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_all_config\n @admin.updateConfiguration\n end",
"def update\n @installation_site = InstallationSite.find(params[:id])\n\n respond_to do |format|\n if @installation_site.update_attributes(params[:installation_site])\n format.html { redirect_to @installation_site, notice: 'Installation site was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @installation_site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @conf.update(conf_params)\n format.html { redirect_to @conf, notice: 'Conf was successfully updated.' }\n format.json { render :show, status: :ok, location: @conf }\n else\n format.html { render :edit }\n format.json { render json: @conf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @conf.update(conf_params)\n format.html { redirect_to @conf, notice: 'Conf was successfully updated.' }\n format.json { render :show, status: :ok, location: @conf }\n else\n format.html { render :edit }\n format.json { render json: @conf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @org_setting.update(update_params)\n render json: @org_setting.to_json(include: :tracker)\n else\n render json: @org_setting.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n puts \"==========\"\n #puts params.require(:site).permit(:name, :url, :description)\n puts params[:url]\n puts params[:name]\n puts \"==========\"\n if @site.update(site_params)\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @job_site_application.update(job_site_application_params)\n format.html { redirect_to @job_site_application, notice: 'Job site application was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @job_site_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # TODO: see if mass-assigning gleaning_attributes works in Rails 5\n gleanings = params[:site].delete :gleaning_attributes\n if update_and_decorate\n if @site.errors.empty?\n @site.gleaning_attributes = gleanings\n respond_to do |format|\n format.html { redirect_to @site, notice: \"Site #{@site.name} was successfully updated.\" }\n format.json {\n flash[:popup] = \"#{@site.name} updated\"\n render :update\n }\n end\n return\n end\n end\n if @site\n resource_errors_to_flash @site\n else\n flash[:alert] = 'Couldn\\'t fetch site'\n end\n smartrender :action => :edit\n end",
"def update\n respond_to do |format|\n if @jobsite.update(jobsite_params)\n format.html { redirect_to @jobsite, notice: 'Jobsite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @jobsite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @site.user_id = current_user.id\n respond_to do |format|\n if @site.update(site_params)\n format.html { redirect_to @site, notice: 'Site was successfully updated.' }\n format.json { render :show, status: :ok, location: @site }\n else\n format.html { render :edit }\n format.json { render json: @site.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @jobsite.update(jobsite_params)\n format.html { redirect_to @jobsite, notice: 'Jobsite was successfully updated.' }\n format.json { render :show, status: :ok, location: @jobsite }\n else\n format.html { render :edit }\n format.json { render json: @jobsite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @site = args[:site] if args.key?(:site)\n end",
"def update!(**args)\n @import_configs = args[:import_configs] if args.key?(:import_configs)\n end",
"def update\n if @user.tconfig.update_attributes(settings_params)\n @status = \"good\"\n @message = \"Settings updated\"\n @resource = @user.tconfig\n elsif [email protected]?\n @message = \"Oops! Please make sure all fields are valid!\"\n end\n\n serve_json_response\n end",
"def update\n respond_to do |format|\n if @config_element.update(config_element_params)\n format.html { redirect_to @config_element, notice: 'Config element was successfully updated.' }\n format.json { render :show, status: :ok, location: @config_element }\n else\n format.html { render :edit }\n format.json { render json: @config_element.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_by_ajax\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n cat_h = {:desktop => User::AUTH_DESKTOP, :user => User::AUTH_USER, :log => User::AUTH_LOG}\n\n yaml = ApplicationHelper.get_config_yaml\n\n cat_h.keys.each do |cat|\n\n next if params[cat].blank?\n\n unless @login_user.admin?(cat_h[cat])\n render(:text => t('msg.need_to_be_admin'))\n return\n end\n\n yaml[cat] ||= {}\n\n params[cat].each do |key, val|\n yaml[cat][key] = val\n end\n end\n\n ApplicationHelper.save_config_yaml(yaml)\n\n render(:text => '')\n end",
"def update_site_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SiteApi.update_site ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling SiteApi.update_site\"\n end\n # resource path\n local_var_path = '/api/3/sites/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json;charset=UTF-8'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'site'])\n auth_names = []\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Links')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SiteApi#update_site\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update!(**args)\n @deployment_config = args[:deployment_config] if args.key?(:deployment_config)\n end",
"def update\n @var_conf = VarConf.find(params[:id])\n\n respond_to do |format|\n if @var_conf.update_attributes(params[:var_conf])\n format.html { redirect_to @var_conf, :notice => 'Var conf was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @var_conf.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @setting.update(setting_params)\n head :no_content\n else\n render json: @setting.errors, status: :unprocessable_entity\n end\n end"
] | [
"0.7103503",
"0.686727",
"0.6414311",
"0.6321009",
"0.6306876",
"0.6113059",
"0.60946023",
"0.6075398",
"0.6069154",
"0.6054861",
"0.6024975",
"0.5986819",
"0.59717935",
"0.5967716",
"0.594994",
"0.5942937",
"0.5923646",
"0.5922549",
"0.58637697",
"0.5863342",
"0.5862443",
"0.58622205",
"0.5860933",
"0.5858455",
"0.5855822",
"0.58537644",
"0.58454794",
"0.5842238",
"0.5841729",
"0.5839891",
"0.5838427",
"0.58370525",
"0.58211166",
"0.57888883",
"0.57888883",
"0.577011",
"0.5765459",
"0.5763693",
"0.57636195",
"0.57619756",
"0.5761445",
"0.5744691",
"0.57394165",
"0.5712334",
"0.5709356",
"0.5700845",
"0.5699835",
"0.5698036",
"0.5698036",
"0.5685783",
"0.5681811",
"0.5679673",
"0.56795007",
"0.5674698",
"0.56731516",
"0.5670513",
"0.56461006",
"0.5631412",
"0.5624377",
"0.56213695",
"0.56198186",
"0.56149924",
"0.56065905",
"0.56065625",
"0.5593958",
"0.5591521",
"0.5584994",
"0.558058",
"0.55793065",
"0.55725956",
"0.55676746",
"0.55654013",
"0.555321",
"0.5550141",
"0.5547518",
"0.5542003",
"0.55287343",
"0.55254364",
"0.5525271",
"0.5520712",
"0.55204386",
"0.55134046",
"0.5507513",
"0.550711",
"0.55009085",
"0.54964185",
"0.549568",
"0.5491418",
"0.54885054",
"0.5462583",
"0.54567266",
"0.5454833",
"0.5447751",
"0.5440249",
"0.54367",
"0.54329926",
"0.54326516",
"0.5431277",
"0.543085",
"0.54290634"
] | 0.70730835 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_site_config
@site_config = SiteConfig.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 site_config_params
params.require(:site_config).permit(:key, :display_name, :value_type, :value_s, :value_b)
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 valid_params_request?; 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 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 safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\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 user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\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 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 valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\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 parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\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"
] | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",
"0.6290449",
"0.6282986",
"0.6241265",
"0.62392694",
"0.62192893",
"0.621427",
"0.62099457",
"0.6195319",
"0.61785376",
"0.61747766",
"0.6172739",
"0.6162921",
"0.6152228",
"0.6152062",
"0.6148811",
"0.6122391",
"0.6117956",
"0.61083806",
"0.6106195",
"0.609274",
"0.60815483",
"0.60710186",
"0.6064253",
"0.60213476",
"0.6018128",
"0.60146624",
"0.601063",
"0.60068774",
"0.60068774",
"0.60026145",
"0.6000521",
"0.59987193",
"0.5992379",
"0.59922844",
"0.5991889",
"0.59803206",
"0.5966244",
"0.5959778",
"0.5959708",
"0.59588563",
"0.5956974",
"0.5953329",
"0.59528023",
"0.59439695",
"0.59413165",
"0.59397036",
"0.59397036",
"0.5933782",
"0.59323835",
"0.59258395",
"0.59253365",
"0.5917244",
"0.59111005",
"0.59093463",
"0.5907942",
"0.59047514",
"0.58979666",
"0.58971125",
"0.589613",
"0.5895083",
"0.5893643",
"0.5892825",
"0.5887658",
"0.5883417",
"0.5878839",
"0.5874345",
"0.5869008",
"0.5868205",
"0.58672875",
"0.5867031",
"0.58662426",
"0.5864551",
"0.5863614",
"0.5862626",
"0.5861952",
"0.58596134",
"0.5855716",
"0.58536863",
"0.5851665",
"0.5850823"
] | 0.0 | -1 |
Initializes a new TurnComponent object Arguments player_entities = an array of player entities Postcondtion The TurnComponent object is properly initialized | def initialize(player_entities)
@turn = 0
@turn_count = 1
@players = player_entities
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(player, party_horn)\n\t\t@player = player\n\t\t@party_horn = party_horn\n\n\t\t@x = @y = @angle = 0\n\n\t\t@width = TILE_WIDTH\n\t\t@height = TILE_HEIGHT\n\n\t\t@swimming = false\n\n\t\t@tile_idx = 0\n\t\t@prev_time = 0\n\t\t@animation_update_interval = STD_ANIMATION_UPDATE_INTERVAL\n\tend",
"def initialize(players)\n self.players = players\n end",
"def initialize(player)\n @player = player\n end",
"def initialize(position)\n @position = position\n @players = []\n end",
"def initialize_players\n\n end",
"def initialize(playerClass)\n @player = initialize_player playerClass\n end",
"def initialize (humanplayer)\n @humanplayer = HumanPlayer.new(\"#{humanplayer}\",100,1)\n @player_1 = Player.new(\"Melee creep\", 10)\n @player_2 = Player.new(\"Ranged creep\", 10)\n @player_3 = Player.new(\"Siege creep\", 10)\n @player_4 = Player.new(\"Mega creep\", 10)\n @ennemies = [@player_1, @player_2, @player_3, @player_4]\n end",
"def initialize(player1, player2)\n\t\t@player_array = Array.new #create an array with 2 players inside (usefull to change easaly the current player)\n\t\t@player_array << player1\n\t\t@player_array << player2\n\t\t@current_player = player1\n\t\t@new_board = Board.new\n\tend",
"def initialize\n @player1 = Player.new(\"Player 1\")\n @player2 = Player.new(\"Player 2\")\n @player1_turn = true; # true -> player1's turn, false -> player2's turn\n end",
"def initialize(players, board = Board.new)\n @players = players\n @board = board\n # shuffle the first player in players list\n @current_player, @other_player = players.shuffle\n end",
"def initialize(dif=1, players=[], game=GAME_C4)\n # Array of all players. Can be modified dynamically as players leave\n # and enter.\n self.players = players \n self.currentPlayer = 0\n self.game = game \n self.turn = 1\n self.difficulty = dif\n @board = Array.new(HEIGHT) { Array.new(WIDTH) } \n # Initialize our strategy\n initStrategy\n end",
"def initialize(player_1_obj = Player::Human.new(\"X\"), player_2_obj = Player::Human.new(\"O\"), board_obj = Board.new)\n self.players = []\n self.player_1 = player_1_obj\n self.players << self.player_1\n self.player_2 = player_2_obj\n self.players << self.player_2\n self.board = board_obj\n \n if computer = self.players.find {|player| player.class == Computer}\n if computer.token == player_1.token\n computer.player_number = 1\n elsif computer.token == player_2.token\n computer.player_number = 2\n end\n end\n self.current_player = player_1\n self.turn\n end",
"def initialize # utilise la classe player pour demander les infos aux joueurs et la classe baord pour lancer la tipar\n puts \" The Houmous Project présente Morbac\"\n @player_one = Player.new\n @player_one.informations\n @player_two = Player.new\n @player_two.informations\n @boboard = Board.new\n end",
"def initialize(num_players)\n @num_players = num_players\n @players = []\n @current_player_index = nil\n (0..num_players - 1).each { |i| @players[i] = Player.new }\n end",
"def initialize(player, delay)\n super delay\n @player = player\n end",
"def initialize(players, board = Board.new)\n @players = players\n @board = board\n @current_player, @other_player = @players.shuffle\n end",
"def initialize(name_player1, name_player2)\n @current_player = :player1\n @player1 = Player.new(name_player1, PLAYER_MARKS[:player1], 1)\n @player2 = Player.new(name_player2, PLAYER_MARKS[:player2], 2)\n\n @game_array = [[nil, nil, nil],\n [nil, nil, nil],\n [nil, nil, nil]]\n end",
"def initialize(player_1=Players::Human.new(\"X\"), player_2=Players::Human.new(\"O\"), board=Board.new ) #Game initialize defaults to two human players, X and O, with an empty board\n @board = board #Game initialize accepts 2 players and a board\n @player_1 = player_1\n @player_2 = player_2\n end",
"def initialize \n\t@first_player = Player.new(\"joueur 1\")\n\t@second_player = Player.new(\"joueur 2\")\n\t self.create_board\n\t self.play_until_victory\n end",
"def initialize(player)\n @player = player\n @cards = player.cards\n @@all << self\n end",
"def initialize(needed_players=2)\n @players = []\n @needed_players = needed_players\n end",
"def initialize(first_name1, first_name2, board)\n @board = board\n #on initialise les players avec les signes x et o\n player1 = Player.new(first_name1, \"X\")\n player2 = Player.new(first_name2, \"O\")\n #tableau des joueurs, peut etre a supprimer\n @array_players = [player1, player2]\n #nombre de tour pour finir le jeu apres 9 coups, current player pour definir qui joue\n @turn_count = 1\n @current_player = player1\n end",
"def initialize(p1, p2)\n @players = [p1, p2]\n @current_player = @players[0]\n \n end",
"def initialize(player_1=nil, player_2=nil)\n @player_1 = player_1\n @player_2 = player_2\n end",
"def initialize(position: nil, player: nil)\n self.player = player\n self.position = position\n self.moved = false\n end",
"def initialize(player_class_array)\r\n @state = Vector.new # state variables should have a fixed order\r\n @state_keys = {} # hash state variable names to indexes into @state\r\n @players = player_class_array.map {|c| c.new(self)}\r\n @next_player = 0 # index of player to move, set at end of do_move\r\n @game_over = false # set true in do_move on detecting end of game\r\n @min_turn_moves = nil # set value in subclass to enforce, and\r\n @max_turn_moves = nil # set value in subclass to enforce, and\r\n @turn_moves = 0 # increment in do_move if enforcing bounds\r\n @reward = nil # set in do_move for @next_player if game supports learning agents\r\n end",
"def init_caterpillar\n # add player controlled character\n @actors = [$game_player]\n # MAX-PARTY size - 1 times create actor\n (1...Config::MAX_PARTY).each {|i| @actors.push(Map_Actor.new(i))}\n # refresh all battlers\n $game_player.refresh\n # if not very beginning of the game\n if $game_map.map_id != nil && $game_map.map_id > 0\n # move all actors to the player's position\n $game_player.moveto($game_player.x / pixel, $game_player.y / pixel)\n end\n end",
"def initialize\n\t\t@grid = Board.new\n\t\t@player_1 = Player.new\n\t\t@player_2 = Player.new\n\t\t@game_status = true #true means game is still playing\n\t\tassign_players\n\tend",
"def initialize(current_player)\n\n\t@current_player = current_player\n\n\t@board = Array.new(BOARD_MAX_INDEX + 1) {Array.new(BOARD_MAX_INDEX + 1) {EMPTY_POS} }\n\n#puts \"You are playing as #{HUMAN_PLAYER}, and the computer is playing as #{COMPUTER_PLAYER}.\"\n\nend",
"def initialize(player_1 = Player::Human.new(\"X\"), player_2 = Player::Human.new(\"O\"),board = Board.new)\n @board = board\n @player_1 = player_1\n @player_2 = player_2\n end",
"def initialize(position)\n player = :human\n @curren\n t_state = State.new(position, player)\n initialize_ai(1, 100)\n end",
"def initialize\n\t\t@ttt = Board.new\n\t\[email protected]_board\n\t\t@x = Player.new(\"X\")\n\t\t@o = Player.new(\"O\")\n\t\t@player_number = 0 # player turn counter\n\tend",
"def initialize_player\n\n Player.new\n\nend",
"def initialize\n @points = 0\n @opponent = opponent\n end",
"def initialize\n @players = []\n @p1 = Player.new('player')\n @players << @p1\n @p2 = ComputerPlayer.new('com')\n @players << @p2\n play\n end",
"def create_player_entities(play_state, players)\n\t\tplayers.each do |curr_player|\n\t\t\tparty_horn = PartyHorn.new\n\t\t\tparty_horn.player = curr_player\n\n\t\t\tpos = next_starting_position\n\t\t\tsub = Submarine.new(pos.x, \n\t\t\t\t\t\t\t\tpos.y, \n\t\t\t\t\t\t\t\t0, \n\t\t\t\t\t\t\t\tPrawn.new(curr_player, party_horn))\n\n\t\t\tsub.player = curr_player\n\t\t\tplay_state.add_entity(sub)\n\n\t\t\tcurr_player.submarine = sub\n\t\t\tcurr_player.party_horn = party_horn\n\t\tend\n\tend",
"def initialize(player_count)\n\t\t@total_players = player_count\n\t\tplayers = []\n\t\tplayer_count.times do |i|\n\t\t\tplayers << Player.new(i+1)\n\t\tend\n\t\t@players = players\n\tend",
"def initialize (row,col)\n @row = row\n @col = col\n @player = 0\n @choiced = false\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @player_1 = player_1;\n @player_2 = player_2;\n @board = board;\n end",
"def initialize(player_1=Players::Human.new(\"X\"), player_2=Players::Human.new(\"O\"), board=Board.new)\n @board = board\n @player_1 = player_1\n @player_2 = player_2\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @board = board\n @player_1 = player_1\n @player_2 = player_2\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @board = board\n @player_1 = player_1\n @player_2 = player_2\n end",
"def initialize(team_name, players, coach, points=0)\n #don't need to have points=0 parameter if ALWAYS going to be zero, below can then just be @points = 0\n @team_name = team_name\n @players = players\n @coach = coach\n @points = points\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n end",
"def initialize (name, life_points, weapon_level)\n @life_points = 100\n @weapon_level = weapon_level = 1\n super(name,life_points) #on récupère les attributs de la classe Player\n end",
"def initialize\n @players = []\n @p1 = Player.new('p1')\n @players << @p1\n @p2 = ComputerPlayer.new('com')\n @players << @p2\n play\n end",
"def initialize(name)\n @human_player = HumanPlayer.new(name)\n @enemies = []\n for i in 1..3\n robot_name = \"player#{i}\"\n enemies << Player.new(robot_name)\n end\n end",
"def initialize(human_player_name)\n\n @human_player = HumanPlayer.new(human_player_name)\n\n\n ennemy_1 = Player.new(\"Josiane\")\n ennemy_2 = Player.new(\"José\")\n ennemy_3 = Player.new(\"Jacky\")\n ennemy_4 = Player.new(\"Janine\")\n\n @ennemies = [ennemy_1, ennemy_2, ennemy_3, ennemy_4]\n end",
"def initialize\n\t\t@players = []\n\t\t@players << @p1 = Player.new(\"p1\")\n\t\t@players << @p2 = ComputerPlayer.new(\"p2\")\n\t\t\n\t\t#@p1 = Player.new\n\t\t#@p2 = ComputerPlayer.new\n\t\tplay\n\tend",
"def initialize(current_player)\n\n # An instance variable for the current player (X or O)\n @current_player = current_player\n\n # An instance variable for the board, a 3x3 array\n # Declare an array of size 3...\n @board = Array.new(BOARD_MAXIMUM_INDEX + 1) {\n\n # ...with each element being an array of size 3...\n Array.new(BOARD_MAXIMUM_INDEX + 1) {\n\n # ...initialized to a space (neither X nor O)\n EMPTY_POSITION }\n }\n\n end",
"def initialize(player_name) #initialize player_name so we can create a local variable.\n @player = Player.new(player_name)\n @rooms = [] #could also do @rooms = Array.new\n end",
"def initialize(player_1 = Human.new(\"X\"), player_2 = Human.new(\"O\"), board = Board.new)\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n end",
"def initialize(player_1, player_2)\n @board = Board.new\n @status = \"ongoing\"\n @players_board = []\n @players_board << player_1\n @players_board << player_2\n @current_player = @players_board[rand(0..1)]\n end",
"def initialize(players)\n\n # we may need preprocessing if players are given as strings\n players = parse(players) unless players.first.kind_of? Player\n\n # preprocessing the player list to ensure an optimal distribution\n # of groups\n @players = prepare_group_sort(players)\n\n @starter = @players.first # all our circles start here\n\n # We prepare the core graph.\n breed(@players)\n\n # Now we add all the other players step by step\n @players[5..-1].each.with_index do |p,i|\n insert(p, 0, 5+i)\n insert(p, 1, 5+i)\n insert(p, 2, 5+i)\n end\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new)\n @board = board\n @player_1 = player_1\n @player_2 = player_2\n end",
"def initialize(game_player)\n @game_player = game_player\n @sprite = Sprite.new($visuals.viewport)\n @sprite.set_bitmap(\"gfx/characters/\" + game_player.graphic_name)\n @sprite.src_rect.width = @sprite.bitmap.width / 4\n @sprite.src_rect.height = @sprite.bitmap.height / 4\n @sprite.src_rect.y = @sprite.src_rect.height * (@game_player.direction / 2 - 1)\n @sprite.ox = @sprite.src_rect.width / 2\n @sprite.oy = @sprite.src_rect.height\n @sprite.x = Graphics.width / 2\n @sprite.y = Graphics.height / 2 + 16\n @sprite.z = @sprite.y + 31\n @oldx = @game_player.global_x\n @oldy = @game_player.global_y\n @xdist = []\n @xtrav = []\n @xstart = []\n @xloc = []\n @ydist = []\n @ytrav = []\n @ystart = []\n @yloc = []\n @anim = []\n @fake_anim = nil\n @stop_fake_anim = false\n end",
"def initialize\n @player1 = get_player_name('1')\n @player2 = get_player_name('2')\n @current_player = @player1\n end",
"def initialize(player_1 = Players::Human.new(\"X\"), player_2 = Players::Human.new(\"O\"), board = Board.new )\n\t \t@board = board\n\t\t\t# Computer instance will need access to WIN_COMBINATIONS (via move(board)) to make decisions\n\t\t\t# on how to move. This passes WIN_COMBINATIONS to board instance.\n\t\tboard.win_combinations = self.class::WIN_COMBINATIONS\n\t\t@player_1 = player_1\n\t \t@player_2 = player_2\n\t end",
"def initialize # Demande les paramètres aux joueurs\n puts \"Welcome to the BDX Tic-Tac-Toe ! Have fun with our progZ !\"\n @p_one = Player.new\n @p_one.infos\n @p_two = Player.new\n @p_two.infos\n @board_game = Board.new\n end",
"def initialize\n greeting\n init_players\n end",
"def initialize(player_name, number, shoe, points, rebounds, assists)\n @name = player_name\n @number = number\n @shoe = shoe\n @points = points\n @rebounds = rebounds\n @assists = assists\n end",
"def initialize(player)\n @en_passant = false\n super(player)\n end",
"def player_creation\n @players = []\n @available_roles_to_pick = ROLES.keys.shuffle\n @number_players = 0\n\n prompt_number_of_players\n\n @epidemic_cards_number = 0\n determine_epidemic_cards_number\n\n determine_deal_player_card_number\n create_players\n prompt_player_info\n end",
"def setup_players\n @players = []\n @players << add(Spaceship, 400, 320)\n @players << add(Tank, width/2, height-100)\n end",
"def initialize(game_container)\n @game_container = game_container\n\n @collisions = {\n # origin type => targets types\n :enemy_moved => [ :plazors, :player ] ,\n :elazor_moved => [ :player ],\n :powerup_moved => [ :player ]\n }\n end",
"def init_player_hands\n\n @player1_hand = []\n @player2_hand = []\n @player3_hand = []\n @player4_hand = []\n\n end",
"def initialize(player_x, player_o)\n @player_x = Player.new(player_x, 'X')\n @player_o = Player.new(player_o, 'O')\n @board = Board.new\n @winning_patterns = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [2, 4, 6], [0, 4, 8]]\n @current_player = [@player_x, @player_o].sample\n @number_of_turns = 0\n prompt\n end",
"def initialize\n @current_player = 1\n @player_1 = Player.new\n @player_2 = Player.new\n @num_1 = rand(1..20)\n @num_2 = rand(1..20)\n end",
"def initialize(name_player)\n @life_points = 10\n @name = name_player\n end",
"def initialize\n @board = Board.new\n @players_1_turn = true\n end",
"def initialize(number_of_players)\n @players = []\n number_of_players.times {|n| @players << Player.new}\n end",
"def initialize\n @currentPlayerIndex = -1;\n\n\n end",
"def initialize(player_1 = nil, player_2 = nil, board = nil)\n if player_1 == nil && player_2 == nil && board == nil\n @player_1 = Players::Human.new(\"X\")\n @player_2 = Players::Human.new(\"O\")\n @board = Board.new\n else\n @player_1 = player_1\n @player_2 = player_2\n @board = board\n end\n end",
"def initialize(player)\n @player = player\n @state = 'draw'\n @swaps = []\n end",
"def initialize(player_goid, *args)\n super(*args)\n @player = player_goid\n @equipment = {}\n end",
"def initialize player\r\n @card_player=player\r\n @name = player.name\r\n end",
"def initialize(name_of_human_player)\n @name = name_of_human_player\n @life_points = 100\n @weapon_level = 1\n end",
"def initialize(player_name)\n\t\t@player = Player.new(player_name)\n\t\t@rooms = []\n\tend",
"def initialize(player_name)\n\t\t@player = Player.new(player_name)\n\t\t@rooms = []\n\tend",
"def initialize\n @player1 = Player.new\n @player2 = Player.new\n\n @player1.opponent = @player2\n @player2.opponent = @player1\n end",
"def initialize(x, y, width, height, party_id, actors=nil)\n super(x, y, width, height, 28, 48)\n @column_max = 2\n @ucPartyActorsList = []\n @party_id = party_id\n window_update(actors)\n self.index = 0\n @cursor_transfer = false\n end",
"def initialize(name)\n @human_player = HumanPlayer.new(name)\n @enemies = []\n for i in 1..3\n robot_name = \"player#{i}\"\n enemies << Player.new(robot_name)\n end\n end",
"def init_players\n\t\t@human = Human.new(\"Jack\", Field.new)\n\t\t@computer = Computer.new(Field.new)\n\t\tinit_fields\n\tend",
"def create #players are in an array\n @players = [\n Player.new('Contestant 1')\n Player.new('Contestant 2')\n ]\n end",
"def initialize(color, player)\n xpos = if player == 1\n GRID_WIDTH * 2 / 3\n else\n GRID_WIDTH / 3\n end\n @position = [[xpos, GRID_HEIGHT - 3], [xpos, GRID_HEIGHT - 4], [xpos, GRID_HEIGHT - 5]]\n # @position = [[xpos, GRID_HEIGHT - 3], [xpos, GRID_HEIGHT - 4]]\n @direction = 'up'\n @growing = @turned = false\n @snake_color = color\n @z = 0\n end",
"def init(container)\n @entities = []\n @entities += Array.new(3) { Giant.new(container, self) }\n @entities += Array.new(20) { Goblin.new(container, self) }\n @entities += Array.new(20) { Human.new(container, self) }\n end",
"def initialize(player1, player2)\n @player1 = player1\n @player2 = player2\n @p1_score = 0\n @p2_score = 0\n end",
"def initialize(player_name)\n\t\t\t@player = Player.new(player_name)\n\t\t\t@rooms = []\n\t\tend",
"def initialize(cards)\n\n\n #while start waiting to east to start\n @state = :start\n #hand for each player\n @hands = {} \n @hands[:south] = cards.slice(0,10).sort!\n @hands[:east] = cards.slice(10,10).sort!\n @hands[:west] = cards.slice(20,10).sort!\n \n \n #cards played on table\n @played = {}\n # number of tricks taken by each player\n @taken = {}\n\n #sets taken and played\n @@PLAYERS.each do |player|\n @played[player] = nil\n @taken[player] = Array.new\n end \n # hole cards \n @hole_cards = cards.slice(30,2) \n @on_move = :east \n end",
"def init\n\t\t## Pathfind\n\t\t#@pathfind = Pathfind.new\n\n\t\t## Add player\n\t\t@player = Player.new #spawn: @room.get_spawn\n\n\t\t## Song controller\n\t\t@song = SongController.new\n\n\t\t## Only load one level\n\t\t@level = load_level @level_name\n\n\t\t#@room = @levels[@level_name].rooms.first unless (@levels[:first].nil?)\n\t\t@room = @level.get_room @room_name\n\t\[email protected]_to_spawn @room.get_spawn\n\n\t\tputs \"Level: #{@level.name}\"\n\t\tputs \" Room: #{@room.name}\"\n\t\tputs \"INSTANCE_COUNT:\\n\\tsolid:\\t\\t#{@room.instances[:solid].size}\"\n\t\tputs \"\\tpassable:\\t#{@room.instances[:passable].size}\"\n\n\t\t## Init Pathfinder\n\t\t#@pathfind.pathfind_init\n\t\t## Add Solid blocks to pathfind grid (bootstrap it)\n\t\t#@pathfind.add_solids @room.get_instances(:solid)\n\n\t\ttracker0 = Tracker.new pos: @player.pos, track: @player\n\t\ttracker1 = Tracker.new pos: @player.pos, track: tracker0\n\t\ttracker2 = Tracker.new pos: @player.pos, track: tracker1\n\t\ttracker3 = Tracker.new pos: @player.pos, track: tracker2\n\t\ttracker4 = Tracker.new pos: @player.pos, track: tracker3\n\t\ttracker5 = Tracker.new pos: @player.pos, track: tracker4\n\n\t\t@entities = [\n\t\t\t@player,\n\t\t\tEnemy.new,\n\t\t\ttracker0, tracker1, tracker2, tracker3, tracker3, tracker4, tracker5\n\t\t]\n\n\t\t## Move camera to player\n\t\t$camera.center_on x: @player.pos(:x), y: @player.pos(:y)\n\n\t\t## Font for FPS display\n\t\t@font_fps = Gosu::Font.new 32\n\n\t\t## For consequtive updating of entities, instead of all at once\n\t\t#@update_entity_index = 0\n\tend",
"def init args\n\n # Create the various objects\n args.state.world = World.new args\n args.state.player = Player.new args\n args.state.turrets = Array.new\n args.state.bullets = Array.new\n\nend",
"def initialize(token)\n @token = token #when we initialize a player, the game knowns each player has a specific token\n end",
"def initialize_entity(entity)\n if @entities[entity.class.name].nil?\n @entities[entity.class.name] = []\n end\n end",
"def initialize(name, players, coach)\n @name = name\n @players = players\n @coach = coach\n @points = 0\n end",
"def initialize(args)\n\n # Remember our args reference\n @args = args\n\n # Our default location will be in the middle of the screen\n @x = @args.grid.center_x\n @y = @args.grid.center_y\n\n # Set up our base parameters\n @turn_speed = 4\n @vector_x = 0\n @vector_y = 0\n @delta_v = 0\n @peak_velocity = 0\n @target_velocity = 0\n @fired = false\n\n # The size is set to the basic size of the player ship.\n @w = 64\n @h = 64\n @angle = 180\n @target_angle = 0\n\n end"
] | [
"0.6417395",
"0.6257679",
"0.61922026",
"0.6152883",
"0.6152448",
"0.6146337",
"0.5983289",
"0.59534407",
"0.5952249",
"0.590282",
"0.5886908",
"0.58730894",
"0.5869555",
"0.5866913",
"0.58645254",
"0.5860836",
"0.58590674",
"0.58425456",
"0.5821833",
"0.5817465",
"0.581274",
"0.57798415",
"0.5779778",
"0.57773453",
"0.57699174",
"0.57643396",
"0.57524055",
"0.5735085",
"0.5732253",
"0.5722097",
"0.5718466",
"0.57153016",
"0.5689287",
"0.5687993",
"0.5676479",
"0.5668037",
"0.56572706",
"0.5655664",
"0.56537455",
"0.56533825",
"0.5647454",
"0.5647454",
"0.564576",
"0.56374353",
"0.563232",
"0.5616494",
"0.5616494",
"0.5616494",
"0.5616494",
"0.5610578",
"0.5577854",
"0.55763763",
"0.5575694",
"0.5575514",
"0.5570034",
"0.556091",
"0.5552368",
"0.5535427",
"0.5534478",
"0.5515167",
"0.55142486",
"0.5513019",
"0.5509881",
"0.55097854",
"0.5508644",
"0.5504421",
"0.5499498",
"0.54961485",
"0.54777414",
"0.5474337",
"0.54631317",
"0.5458474",
"0.545242",
"0.5449602",
"0.54455173",
"0.5442281",
"0.54404473",
"0.54404",
"0.54305655",
"0.5424839",
"0.54243475",
"0.54065967",
"0.5399571",
"0.5399571",
"0.5397051",
"0.53969914",
"0.5395972",
"0.5392383",
"0.53913736",
"0.538817",
"0.53806305",
"0.53780025",
"0.5376483",
"0.53753036",
"0.5372975",
"0.53696907",
"0.53475684",
"0.5345038",
"0.5337268",
"0.53366446"
] | 0.8230874 | 0 |
Returns the player entity whose turn it currently is | def current_turn()
@players[@turn]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_player\n Player.find(player_turn) unless player_turn.nil?\n end",
"def current_player\n @players[@turn%2]\n end",
"def current\n self.players[self.current_turn]\n end",
"def current_player\n players.first\n end",
"def current_player\n @players.first\n end",
"def current_player\n @players.first\n end",
"def current_player\n @players.first\n end",
"def current_player\n @players.each do |name, letter|\n if letter == whose_turn\n return name\n end\n end\n end",
"def player\n return $BlizzABS.actors[0]\n end",
"def getCurrentPlayer() # : Player\n @currentPlayer\n end",
"def current_player_name\n Player.find(player_turn).name unless player_turn.nil?\n end",
"def whose_turn\n self.advance_turn unless self.active_slot\n game_players.joins(:slot).joins(:game).where('games.active_slot = slots.sequence').first.player\n end",
"def player\n\t\t@current_player\n\tend",
"def acting_player\n return parent.state.current_player unless parent.nil?\n -1\n end",
"def player\n\t\t\tPlayer.find(self.playerID)\n\t\tend",
"def player_board\n boards.player.first\n end",
"def current_player\n\tif $turn == 0\n\t\tplayerone\n\telse\n\t\tplayertwo\n\tend\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\n if @board.turn_count.even?\n @player_1\n else\n @player_2\n end\n end",
"def current_player\n player = nil\n if turn_count() % 2 == 0\n player = 'X'\n else\n player = 'O'\n end\n return player\n end",
"def getCurrentPlayer\n @currentPlayer\n end",
"def get_curr_player \n current_player = @player_arr.first()\n return current_player\n end",
"def current_player()\n # Assume player X goes first\n return turn_count() % 2 == 0 ? \"X\" : \"O\"\n end",
"def retrieve_current_player\n session[:current_player]\n end",
"def current_player\n board.turn_count % 2 == 0 ? player_1 : player_2\n end",
"def acting_for_entity(entity)\n return entity if entity.player?\n return entity.owner if entity.owner.player?\n\n acting = @players.find { |p| !director?(p) }\n acting || @players.first\n end",
"def stack_playing_player\n return phase_playing_player if stack.empty?\n stack.last.player.opponent\n end",
"def opponent(player)\n @sides[0]\n end",
"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 first_player\n singles_player_of_team first_team\n end",
"def current_opponent\n Opponent.find_by_id(session[:opponent_id])\n end",
"def current_player\n @board.turn_count.even? ? @player_1 : @player_2\n end",
"def get_player_on_turn(turn)\n\t\tif turn%2==0 then\n\t\t\treturn @player2\n\t\telse\n\t\t\treturn @player1\n\t\tend\t\t\n\tend",
"def current_player\n if turn_count.even?\n player_1\n else\n player_2\n end\n end",
"def get_move\n @players[0].get_move(@board)\n end",
"def get_turn\n @pos, @action = @player.prompt\n end",
"def opponent\n (@player_num - 1).abs\n end",
"def opponent_board\n boards.opponent.first\n end",
"def opponent_of(the_player)\n the_player == player_1 ? player_2 : player_1\n end",
"def current_player\n self.board.turn_count.even?? self.player_1 : self.player_2\n end",
"def second_player\n singles_player_of_team second_team\n end",
"def opponent\n @player == :human ? :computer : :human\n end",
"def playerTurn\n if @current_player == @player1\n @current_player = @player2\n else \n @current_player = @player1\n end\n return @current_player\n end",
"def cursor\n return $game_player\n end",
"def cursor\n return $game_player\n end",
"def current_player\n @board.turn_count.even? ? @player_1 : @player_2;\n end",
"def getplayer1\r\n\t\t\treturn @player1\r\n\t\tend",
"def getplayer2\r\n\t\t\treturn @player2\r\n\t\tend",
"def current_player()\n current_turn = turn_count()\n if current_turn == 0 || current_turn % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n end",
"def current_player\n\n if session[:player_id]\n @current_player ||= Player.find(session[:player_id])\n end\n end",
"def goid\n @player\n end",
"def player1\n @players.first\n end",
"def player_of_game(game)\n game.player(self)\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 player_position\n @ole.PlayerPosition\n end",
"def player_state\n @ole.PlayerState\n end",
"def current_player\n @current_player ||= Player.find(session[:player_id])\n end",
"def current_player\n return turn_count%2==0 ? \"X\" : \"O\"\n end",
"def get_next_player\n crnt_plyr_indx = @game.user.index(@game.whoseTurn)\n temp_usr_array = @game.user.rotate(crnt_plyr_indx)\n if(@game.clockwise) then\n return User.find(temp_usr_array[1])\n else\n return User.find(temp_usr_array[-1])\n end\n end",
"def current_player\n board.turn_count.even? ? @player_1 : @player_2\n end",
"def player\n fetch('football.players')\n end",
"def get_current_winner\r\n if self.rank_one == nil\r\n return nil\r\n else\r\n return rank_one.owner\r\n end\r\n end",
"def get_player\n\t @name\n\tend",
"def player1\n if self.game_type == 'cvc'\n player1 = Computer.find(self.player1_id)\n else \n player1 = Human.find(self.player1_id)\n end\n return player1\n end",
"def right_player?\n current_player == Player.find(@piece.owner)\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\r\n if turn_count % 2 != 0\r\n return \"O\"\r\n else\r\n return \"X\"\r\n end\r\n end",
"def current_player\n { name: @game.cur_player.name, home_base: @game.cur_player.home_base }\n end",
"def current_player\r\n turn_count\r\n if turn_count % 2 == 0\r\n return \"X\"\r\n else\r\n return \"O\"\r\n end\r\n end",
"def current_player\n turn = turn_count\n if turn%2 == 0\n return \"X\"\n else\n return 'O'\n end\n end",
"def get_next_player(player)\n \tresult = player\n \tif (not self.players.nil?) and (not self.players.empty?)\n \t\tif self.players.first == player\n \t\t\tresult = self.players.last\n \t\telse\n \t\t\tresult = self.players.first\n \t\tend\n \tend\n send_update\n \treturn result\n end",
"def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\"\n end",
"def active_player\n @playing_player.active? ? @playing_player : opponent\n end",
"def player_name\n player.name\n end",
"def current_player\n if turn_count % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n end",
"def last_mover\n Player.find(self.last_player_id) if last_player_id.present?\n end",
"def current_player\n turn_count%2==0 ? \"X\" : \"O\"\n end",
"def current_player\r\n if self.turn_count == 0\r\n return \"X\"\r\n elsif self.turn_count.odd?\r\n return \"O\"\r\n else\r\n return \"X\"\r\n end\r\n end",
"def get_player_id\n\t\t@player_id\n\tend",
"def phase_playing_player\n turn.phase.is_a?(BlockPhase) ? defending_player : playing_player\n end",
"def next_player\n return self.player_1_id if board.next_player == :player_1\n self.player_2_id\n end",
"def current_player\n return turn_count.even? ? \"X\" : \"O\"\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n end",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\n end",
"def turn_player\n go_fish.turn_player\n end",
"def p1\n if (s = session[:players][0]) and (p = Player.find(s)) then return p end\n end",
"def current_player\n\t\tturn_count % 2 == 0 ? \"X\" : \"O\"\n\tend",
"def current_player_move\n @on_move == HUMAN_PLAYER ? human.move : computer.move\n end",
"def player(player_name)\n players.find{|player| player.name == player_name}\n end",
"def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\"\n end",
"def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\"\n end",
"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 opponent(player)\n (player == player_one) ? player_two : player_one\n end",
"def next_player\n\t\tvar = -1\n\t\tvar = 1 if self.flowing_right\n\t\tplayers_remaining = self.players_remaining\n\t\tlast_turn = self.turns.last\n\t\tplayers_remaining[(players_remaining.index(last_turn.player) + var) % players_remaining.size]\n\tend",
"def challenger\n Competitor.find_by(id: self.game.challenger_id).username\n end",
"def player\n @player ||= Player.new\n end"
] | [
"0.77469265",
"0.73377615",
"0.7138472",
"0.6995961",
"0.696029",
"0.6953253",
"0.69511634",
"0.6931323",
"0.69022036",
"0.68991995",
"0.6863436",
"0.6668175",
"0.661631",
"0.66016763",
"0.659411",
"0.65421146",
"0.65319973",
"0.6511491",
"0.6511491",
"0.6511491",
"0.6511491",
"0.64374673",
"0.64217305",
"0.64080185",
"0.6396199",
"0.63943523",
"0.6376782",
"0.63736993",
"0.63730526",
"0.6372354",
"0.63649386",
"0.63549376",
"0.6340597",
"0.63046706",
"0.63011265",
"0.62934667",
"0.6290932",
"0.6290004",
"0.62854344",
"0.62781906",
"0.62701875",
"0.62689",
"0.62642926",
"0.6256474",
"0.6234202",
"0.6222944",
"0.62149847",
"0.62149847",
"0.62113345",
"0.6205435",
"0.6202932",
"0.618952",
"0.6187191",
"0.61770576",
"0.6159544",
"0.61498326",
"0.6141482",
"0.6125076",
"0.6106565",
"0.6097866",
"0.60961884",
"0.6085273",
"0.6079311",
"0.60694855",
"0.60563815",
"0.6049493",
"0.6041661",
"0.602218",
"0.6020167",
"0.6016474",
"0.5986246",
"0.5985695",
"0.59773344",
"0.59661657",
"0.59578985",
"0.5955271",
"0.59526867",
"0.5950436",
"0.5946676",
"0.59356326",
"0.5924513",
"0.5921174",
"0.59132653",
"0.5904197",
"0.59029907",
"0.5885836",
"0.5885836",
"0.58728766",
"0.5872844",
"0.58727217",
"0.58715624",
"0.5852133",
"0.585191",
"0.5849",
"0.5849",
"0.5847526",
"0.5833147",
"0.5827761",
"0.5823554",
"0.5817969"
] | 0.7396393 | 1 |
Ends the turn for the current player and moves to the next player's turn. Postcondtion The old player's turn is ended and the new player now has a turn. | def next_turn()
@turn = (@turn + 1) % @players.size
@turn_count += 1
self.current_turn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_turn\n @players_1_turn = !@players_1_turn\n end",
"def end_turn\n current_username = self.up_next\n current_num = 0\n self.game_players.each do |player|\n if player.user.username == current_username\n current_num = player.turn_order\n end\n end\n if current_num == self.game_players.length\n next_num = 1\n else\n next_num = current_num + 1\n end\n next_player = self.game_players.where(turn_order: next_num).first\n self.up_next = next_player.user.username\n msg = current_username + ' has played their turn.'\n LogEntry.create(message: msg, game_id: self.id)\n notification = 'Its your move in ' + self.name\n Notification.create(message: notification, user_id: next_player.user.id)\n self.save\n end",
"def next_turn\n precondition do\n raise \"Game is not ongoing.\" unless self.state == Game::ONGOING\n raise \"Not enough players\" unless self.players.length == REQUIRED_PLAYERS\n end\n self.turn = self.turn + 1\n self.currentPlayer = self.players.find { |p| p.name != self.currentPlayer }.name\n save\n # Move if necessary.\n computer_actions\n end",
"def next_turn\n if @current_player == @player_1\n @current_player = @player_2\n else\n @current_player = @player_1\n end\n until @current_moves.length == 2\n ask_player_for_move(@current_player)\n end\n end",
"def end_turn\n if @turns < 1 || current_guess == @secret_word\n player_won?\n end\n end",
"def end_turn\n @turns -= 1\n if turns == 0 || current_guess == secret_word\n puts \"Game over! \\n\\nThe word was #{secret_word}\"\n exit_game?\n else\n puts \"Turns left: #{turns} \\n\\n______________________________________________\"\n end\n end",
"def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end",
"def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end",
"def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n end\n end",
"def next\n if self.is_last_player\n current_turn = 0\n else\n current_turn += 1\n end\n end",
"def end_turn(turn)\n #todo have another turn???\n @@cli.say \"Your turn is over!\"\n @purchased_card = nil\n end",
"def next_turn\n print \"\\nYour move, #{@mover.designation}: \"\n move = get_move\n\n print \"\\nMover = #{@mover.designation}. Move = #{move}.\\n\"\n\n if move == 'Q'.to_i\n @is_active = false\n print \"\\n***** Game halted by user. *****\\n\"\n return\n end\n\n add_good_move(move)\n check_winner\n check_tie_game\n\n print_color_grid\n\n @turn = @turn + 1\n @mover = @player[@turn % 2]\n end",
"def change_turn\n @turn += 1\n @this_players_turn = @players.reject{|x| x == @this_players_turn}[0]\n take_turn(@this_players_turn)\n end",
"def turn\n current_move = current_player.move(@board)\n current_token = current_player.token\n if self.board.valid_move?(current_move)\n self.board.update(current_move, current_player)\n self.board.display\n # binding.pry\n else\n turn\n end\n end",
"def next_turn\n # Changes the turn to the next player.\n if turn < players_array.length\n @turn += 1\n else\n @turn = 1\n end\n end",
"def next_turn\n # Changes the turn to the next player.\n if turn < players_array.length\n @turn += 1\n else\n @turn = 1\n end\n end",
"def turn\n most_recent_move = current_player.move(@board)\n if [email protected]_move?(most_recent_move)\n turn\n else\n @board.update(most_recent_move, current_player)\n end\n end",
"def turn\n \n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end",
"def switch_player\n @current_player = if @current_player == @player_o\n @player_x\n else\n @player_o\n end\n\n @number_of_turns += 1\n end",
"def turn\n player = current_player\n current_move = player.move(@board)\n\n if [email protected]_move?(current_move)\n # Game turn asks for input again after a failed validation\n turn\n else\n # Game turn changes to player 2 after the first turn\n puts \"Turn: #{@board.turn_count+1}\\n\"\n @board.display\n @board.update(current_move, player)\n puts \"#{player.token} moved #{current_move}\"\n @board.display\n puts \"\\n\\n\"\n end\n end",
"def do_turn\n raise \"Turn has already been finalized on original board\" if @finalized\n board = try_turn\n board.finalize_move!\n board\n end",
"def do_turn!\n raise \"Turn has already been finalized on original board\" if @finalized\n apply_turn(@original_board)\n @original_board.finalize_move!\n @finalized = true\n @original_board\n end",
"def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end",
"def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end",
"def end_game\n if player1.score == end_score\n @winner = player1\n @loser = player2\n puts \"#{@winner.name} is the winner!\"\n elsif player2.score == end_score\n @winner = player2\n @loser = player1\n puts \"#{@winner.name} is the winner!\"\n end\n end",
"def play_until_end\n current_player, other_player = @players\n\n until @winner || [email protected]_left? do\n play_turn(current_player)\n @winner = current_player if @board.winner?(current_player)\n current_player, other_player = other_player, current_player\n end\n @board.print_grid\n @winner\n end",
"def turn\n input = current_player.move(board)\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n board.display\n turn\n end\n end",
"def pass_player_turn\n @active_player_idx += 1\n if @active_player_idx == @players.length\n @active_player_idx = 0\n end\n end",
"def next_turn\n turn_sequence = game.players.find(player_turn).turn_order\n if turn_sequence == game.players.maximum(:turn_order)\n turn_sequence = 1\n else\n turn_sequence = turn_sequence + 1\n end\n update_attributes(player_turn: game.players.find_by(turn_order: turn_sequence).id)\n end",
"def turn\n puts \"Turn #{@board.count_turn + 1}, player #{get_current_player.name} choose:\"\n @board.play_turn\n end",
"def next_round\n sleep(1)\n puts \"\\n----- NEW TURN -----\"\n self.players.rotate!\n round_gameplay\n end",
"def process_player_turn\n\t\tself.current_player = \"Computer\"\n\t\tindicate_player_turn\n\t\tplayer_good_move= self.get_good_move\n\t\tchange_state(player_symbol, player_good_move)\n\t\tplayer_good_move\n\tend",
"def play_turn\n @board.place_mark(@current_player.get_move, @current_player.mark)\n switch_players!\n end",
"def turn\n puts \"Round #{@board.turn_count}\"\n input = current_player.move(@board)\n if @board.valid_move?(input)\n @board.cells[input.to_i - 1] = current_player.token\n @board.display\n else\n turn\n end\n end",
"def playerTurn\n if @current_player == @player1\n @current_player = @player2\n else \n @current_player = @player1\n end\n return @current_player\n end",
"def end_game\n @state = 'stop'\n @winner = true\n get_winning_player\n puts \"================ ===================== ===================\"\n puts \"-------------------- GAME OVER! ______________________________________\"\n puts \"____________________ WINNER: #{get_winning_player.try(:name)} --------------------------\"\n puts \"================ ===================== ===================\"\n # write stats/scores to dB ...\n end",
"def next_turn\n @player_turn = @players.reject { |player| player.id == @board_turn.player.id }.first\n @board_turn = @boards.select { |board| board.player.id == @player_turn.id }.first\n end",
"def play_turn\n move = @current_player.get_move\n switch_players!\n @board.place_mark(move, :X)\n end",
"def turn_back_end(chosen_box)\n\t\tfill_box(chosen_box)\n\t\tif check_if_won(@current_player.boxes_filled) == true\n\t\t\t@player_won = true\n\t\telse\n\t\t\t@current_player = (@current_player.marker == @player_x.marker ? @player_o : @player_x)\n\t\tend\n\t\t@swap_player = false\n\n\tend",
"def change_turn\n if @player_to_move == \"w\"\n @player_to_move = \"b\"\n else\n @player_to_move = \"w\"\n end\n end",
"def nextTurn()\r\n index = @players.index(@curplayer)\r\n puts \"index = #{index}\"\r\n if(index == nil)\r\n #this is probably the dealer\r\n return\r\n end\r\n if(index == @players.size - 1) #This is the last player\r\n @curplayer = @dealer #its now the dealer's turn\r\n else #not last persons turn yet\r\n index += 1 #get the next index\r\n if(@players[index].split)\r\n @curplayer = @dealer \r\n else\r\n @curplayer = @players[index] #set the current player to the next one\r\n end\r\n end\r\n @nummoves = 0\r\n end",
"def finish_heroes_turn!(hero)\n\n controller_redirect_to = :boards\n\n self.transaction do\n hero_end_turn_operations(hero)\n\n # If we have more than one player\n if current_heroes_count > 1\n\n unless switch_to_next_hero\n # If all heroes have played, we switch to sauron turn\n actions_before_switch_to_sauron\n end\n else\n # If we have only one player\n if start_hero_second_turn(hero)\n # We started a new turn for hero\n controller_redirect_to = :hero_draw_cards_screen\n end\n end\n\n self.save!\n\n controller_redirect_to\n end\n end",
"def increment_turn\n @players.rotate!\n end",
"def turn_away_from_player\n turn_away_from_character($game_player)\n end",
"def advance_turn!\n\t\tboard_history << @board.clone\n\t\t@current_player = (@current_player == hunter ? @prey : @hunter)\n\t\t@current_turn += 1\n\tend",
"def play_turn\n @players.each do |p|\n dice = @dice.roll\n move_player p, dice\n @board.landed_by p\n end\n end",
"def change_turns\n (@current_player == @p1) ? @current_player = @p2 : @current_player = @p1\n end",
"def turn\n victory = false\n while victory == false do\n player_place\n @board.show_board\n end\n end",
"def turn\n input = current_player.move(board)\n\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n turn\n end\n end",
"def turn\n marker = @turn_count.even? ? marker = \"X\" : marker = \"O\"\n move\n print \"Current board: \"\n show_board\n @player +=1\n end",
"def start_turn\n puts \"----- NEW TURN -----\"\n @turn += 1\n if (@turn.odd?)\n active = @player1\n Turn.new(active)\n else\n active = @player2\n Turn.new(active)\n end\n\n if (game_over?)\n winner_message\n puts \"----- GAME OVER -----\"\n else\n player_lives\n start_turn\n end\n end",
"def game_with_two_players\n\t\t@current_turn = @player_one if @current_turn == false\n\t\tuntil check_or_checkmate(@current_turn) == \"CHECKMATE\"\n\t\t\tmove\n\t\t\tif @current_turn == @player_one\n\t\t\t\t@current_turn = @player_two\n\t\t\telsif @current_turn == @player_two\n\t\t\t\t@current_turn = @player_one\n\t\t\tend\n\t\t\tclear_screen\n\t\tend\n\tend",
"def next_turn!\n @campaign.gangs.update_all( retreating: false )\n @campaign.players.update_all( maintenance_required: false )\n\n @campaign.turn += 1\n @campaign.players_hire_and_move!\n\n @campaign.save!\n end",
"def start\n while @player1.lives > 0 && @player2.lives > 0\n ask_question_and_update_lives(@players[@turn])\n puts \"P1: #{@player1.display_lives} vs P2: #{@player2.display_lives}\"\n puts \"----- NEW TURN -----\"\n change_turn\n end\n # the change_turn above automatically set the next player as winner\n puts \"#{@turn} wins with a score of #{@players[@turn].display_lives}\"\n puts \"----- GAME OVER -----\"\n puts \"Good bye!\"\n end",
"def next_player\n\t\tvar = -1\n\t\tvar = 1 if self.flowing_right\n\t\tplayers_remaining = self.players_remaining\n\t\tlast_turn = self.turns.last\n\t\tplayers_remaining[(players_remaining.index(last_turn.player) + var) % players_remaining.size]\n\tend",
"def do_end_turn_routine\n # print \"end_turn_routine TM.no_ones_turn? = #{TM.no_ones_turn?} TM.turn = #{TM.turn}\\n\"\n do_turn_end_evs if TM.curr_teams_queue.empty? # skip after first call here\n TM.curr_teams_queue.push(:EVAL_END_TURN)\n \n finish_turn_end_evs if @wait_on_turn_end_evs\n \n if !@wait_on_turn_end_evs\n TM.restart_all_turns\n go_next_turn_tb \n end\n end",
"def play\n until @board.winner?(:X) || @board.winner?(:O)\n p \"#{@current_player.mark}'s turn\"\n @board.print\n self.play_turn\n end\n\n @board.print\n self.switch_players!\n p \"#{@current_player.mark} has won!\"\n end",
"def second_players_move(current_player)\n player = second_player(current_player)\n player_move(player)\n end",
"def turn\n @player_1.new_question\n check_score\n @player_2.new_question\n check_score\n match_stats\n puts \"-----NEW-TURN-----\"\n turn\n end",
"def play_turn\n reset_hand\n @winning_player = nil\n unless is_game_over?\n all_play_a_card\n score_battle @hand_played\n else\n end_game\n end\n end",
"def perform\n @turn += 1\n if @turn%2 != 0\n slot = players[0].play(@board)\n else\n slot = players[1].play(@board)\n end\n @board.update_board(slot, @turn.even? ? 2 : 1)\n end",
"def end_game\n puts \"\\n\\n________ GAME OVER ________\"\n puts \"#{@active_player.name}, you've run out of lives.\\nYou're RIGHT DEAD.\\n\\n\"\n switch_player!\n puts \"#{@active_player.name}, you had #{@active_player.lives} #{(@active_player.lives) == 1 ? \"life\" : \"lives\"} remaining and survived for #{(@which_round / 2).to_i} rounds, which means YOU WIN!\\n... By which we mean, you didn't die.\\nRight now.\\n\\nGood...\\n\\n\\n\"\n end",
"def turns\n while @board.game_check == false\n player_process(@player1_name,@player1_symbol,@turn)\n break if @board.game_check == true\n\n player_process(@player2_name,@player2_symbol,@turn)\n end\n @board.display\n print \"\\nDone \\n\"\n end",
"def turn\n move_input = current_player.move\n if !board.valid_move?(move_input) # if #valid_move false\n puts \"That is not a valid move. Please try again.\\n\"\n turn\n else\n board.update(move_input,current_player)\n board.display\n end\n end",
"def player_turn(turn)\n get_player_input\n compare_guesses\n update_board(turn)\n system 'clear'\n display_board(turn)\n end",
"def play\n outcome = ''\n [1, 2].each {|ix| _select_players(ix)}\n c_player, o_player = _init_players\n o_player.set_other!(c_player) if o_player.is_IA_S?\n c_player.set_other!(o_player) if c_player.is_IA_S?\n #\n move_already_played = []\n #\n loop do\n STDOUT.print(\"#{@board.to_s}\\n#==> #{c_player.name}/#{c_player.type}'s TURN:\\n\")\n loop do\n m, sym = _get_move_from(c_player, move_already_played) # current player do his move\n v = @board.set_cell(m, sym.to_s)\n if m == -1 || v == sym # if sym not valid symbol, set_cell(m, sym != sym\n move_already_played << m.to_i\n break\n end\n STDERR.print \"! cell[#{m}] already set, try something else - v was: #{v.inspect} // #{v.class}\\n\"\n end\n move_already_played.sort!\n outcome = @board.game_over?\n break if outcome == :draw || outcome == :winner\n c_player, o_player = _switch_players(c_player, o_player)\n end\n _conclusion(outcome, c_player)\n end",
"def change_turn\n @turn = @turn >= 'X' ? 'O' : 'X'\n @turn_played += 1\n end",
"def next_turn\n @play == 0 ? @play +=1 : @play -=1 #change la valeur de play, donc change de joueur\n tu_vas_jouer_oui?(player[play])\n end",
"def next_move\n\n @board.board[@choice] = id\n @board.free.delete(@choice)\n p self\n puts \"player #{id + 1} chooses #{@choice}\"\n puts @board\n\n @board.winner || @board.free.empty?\n end",
"def playerTurn\n\t\tGem.win_platform? ? (system \"cls\") : (system \"clear\")\n\t\tputs \"#{@active.name}'s turn\"\n\t\tgets\n\t\tcontinue = true\n\t\twhile continue\n\t\t\t# Print board and hand\n\t\t\tprintBoard\n\t\t\[email protected]\n\t\t\tsize = @active.handSize\n\t\t\tputs \"(B) Buy a card\"\n\t\t\tputs \"(E) End turn\"\n\t\t\tprint \"Enter Selection: \"\n\t\t\tinput = gets.chomp.downcase\n\t\t\tnumInput = input.to_i\n\n\t\t\tif(input == 'b')\n\t\t\t\t# Automatically use treasure cards\n\t\t\t\tcoins = @active.coins\n\t\t\t\t@coins += coins\n\t\t\t\t# End the player's turn if they bought at least one card\n\t\t\t\tcontinue = !buyMenu\n\t\t\t\t@coins -= coins\n\t\t\telsif(input == 'e')\n\t\t\t\tcontinue = false\n\t\t\telsif(numInput > 0 and numInput <= size)\n\t\t\t\tcardPlayMenu(@active.getCard(numInput))\n\t\t\telse\n\t\t\t\tputs \"Invalid input\"\n\t\t\t\tgets\n\t\t\tend\n\t\tend\n\n\t\[email protected]\n\tend",
"def final_round(starting_player)\n @winner = starting_player\n puts 'Final Round started!'\n puts ''\n @players.each do |p|\n next if p == starting_player\n p.turn\n @winner = p if p.score > @winner.score\n end\n puts \"Congratulations! #{@winner.name} won the game with #{@winner.score} points!\"\n end",
"def switch_player(player_turn)\n\t\tplayer_turn == @player1 ? @player2 : @player1\n\tend",
"def increment_game\n change_turn\n @turn += 1 if @player_to_move == \"w\"\n end",
"def player_in_turn\n \tif self.turns.where(round: self.round).exists?\n \t\t\tself.next_player\n \t\telse\n \t\t\tself.loser_of_round(self.round-1)\n \t\tend\n end",
"def turn\n puts \"#{@player_1.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_1)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n puts \"#{@player_2.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_2)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n end",
"def take_turn\n system(\"clear\")\n puts \"It's #{current_player}'s turn!\"\n letter = nil\n\n until letter\n letter = current_player.guess(fragment)\n\n unless valid_play?(letter)\n current_player.alert_invalid_move(letter)\n letter = nil\n end\n end\n add_letter(letter)\n puts \"#{current_player} added the letter '#{letter}' to the fragment.\"\n end",
"def player_turn\n hit_loop(@player)\n end",
"def next_round\n if @round > 1\n puts \"----- NEW TURN -----\"\n end\n # next round\n @round += 1\n @players.rotate!\n end",
"def turn\n puts \"\"\n puts \" \" * 35 + \"c'est au tour à #{@current_player.name} de joué (1-9): \"\n puts \"\"\n print \" \" * 40 + \"> \"\n choice = gets.chomp.to_i\n if choice > 9 || choice < 1\n puts \"Tu te trompe de touche jeune apprentie\"\n elsif @current_player.move(choice) != false\n @winner = @current_player if @current_player.winner?\n @turn += 1\n switch_player\n end\n end",
"def get_next_turn\n\n # Using an X?\n if @current_player == 'X'\n\n # Yes, change to O\n @current_player = 'O'\n\n else\n\n # No, change to X\n @current_player = 'X'\n\n end\n\n return @current_player\n\n end",
"def play_turn\n move_info = FileReader.get_move(\"#{@turn}#{@player_to_move}\", @data) \n @cur_board.move_piece(move_info)\n end",
"def play\n p_arr = randomize_players(@player_1, @player_2)\n current_player = p_arr[0]\n next_player = p_arr[1]\n current_player.piece = 'X'\n next_player.piece = 'O'\n puts \"Player #{current_player.id.to_s} goes first!\"\n\n end_message = \"\"\n loop do\n set_cell(current_player.move(self))\n if check_win?\n end_message = current_player.win_message\n break\n elsif check_draw?\n end_message = \"It's a draw.\"\n break\n end\n current_player, next_player = next_player, current_player\n end\n\n display_board\n end_message\n end",
"def dealer_turn\n if win_state == CHECK\n do_hit_or_stay(players[0])\n end\n end",
"def change_turn\n active = get_active_turn_player\n receiver = get_receive_turn_player\n\n return false if !can_change_turn?\n\n active.update(active_turn: false)\n receiver.update(active_turn: true, turn_has_targeted: false)\n\n true\n end",
"def ending_screen\n if @winner == @player1\n color = :red\n elsif @winner == @player2\n color = :blue\n else\n color = :green\n end\n puts\n puts \"The game is finished.\"\n if @winner.nil?\n puts \"The game is a draw!\".colorize(color)\n else\n puts \"#{@winner.name} wins the game!\".colorize(color)\n end\n puts\n puts \"Would you like to play again? (Y/N)\"\n print \">> \"\n response = gets.chomp\n reset_board if response.downcase == \"y\"\n end",
"def botTurn\n # check if we can win with one move or need to block\n if positions = winOrBlock?(currentPlayer) || positions = winOrBlock?( (currentPlayer == 'X')? 'O' : 'X')\n takeLastSpot(positions)\n \n # check if there is a chance for bot to create a fork, or block oponent from making fork \n elsif forks = possibleFork?(currentPlayer) || forks = possibleFork?((currentPlayer == 'X')? 'O' : 'X')\n \n \n if forks.size == 1\n # find the most common index and move there\n commonElement = forks.max_by {|i| forks.count(i)}\n move(commonElement, currentPlayer)\n else\n # more than one fork possible,\n # find optimal block point, move there\n move(blockPoint(forks), currentPlayer)\n end\n \n # take the center if its available\n elsif !position_taken?(4)\n move(4, currentPlayer)\n \n # take an opposite corner from the oponent. If not available, take any corner\n elsif corner = cornerMove\n move(corner, currentPlayer)\n \n # play in a middle square on any of the sides \n else\n SIDE_MIDDLE.each do |position|\n if !position_taken?(position)\n move(position, currentPlayer)\n break\n end\n end\n end\n puts \"#{(currentPlayer == 'X')? 'O': 'X'}'s move: \"\n displayBoard\n end",
"def switch_players\n @player1_turn = !@player1_turn\n end",
"def switch_to_next_hero\n result = true\n\n transaction do\n self.current_hero.turn_finished = true\n self.current_hero.save!\n\n remaining_heroes = heroes.where( turn_finished: false )\n\n if remaining_heroes.count >= 1\n next_hero = remaining_heroes.order('playing_order ASC').first\n raise \"Board #{self.id} : hero.playing_order should not be nil\" unless next_hero.playing_order\n\n self.current_hero = next_hero\n self.save!\n\n self.activate_current_hero\n\n self.next_to_finish_hero_turn!\n self.next_to_hero_draw_cards_screen!\n else\n result = false\n end\n end\n\n result\n end",
"def move_player2 (choice_case)\n symbole_player2 = @player2.symbole\n @board.move_player2(choice_case, symbole_player2) \n @@game_count+=1\n end",
"def next_turn( )\n\t\t\t@turn = if @turn == :white then :black else :white end\n\t\tend",
"def next_turn(player)\r\n Turn.new(player, self.min, self.max)\r\n end",
"def switch_players\n @current_player, @other_player = @other_player, @current_player\n end",
"def switch_players\n @current_player, @other_player = @other_player, @current_player\n end",
"def turn\n puts \"Please enter 1-9:\"\n move = current_player.move(@board);\n if @board.valid_move?(move)\n @board.update(move, current_player);\n @board.display;\n else\n turn;\n end\n end",
"def take_turn\n @board.show_board\n puts \"#{@current_player}'s turn.\"\n square = 0\n until ((1..9) === square) && @board.take_a_square(square, @current_player)\n puts \"Which square do you want to take?\"\n square = gets.to_i\n end\n @current_player.occupy_a_square(square)\n @current_player, @other_player = @other_player, @current_player\n @turns += 1\n end",
"def play\n until game_over\n start_new_turn\n show_board\n make_move @current_player\n end\n show_board\n puts \"#{game_over} wins!\"\n end",
"def end_game\n @first_player.points += Ranking.pointsCalculator(true)\n @second_player.points += Ranking.pointsCalculator(false)\n record_player(first_player)\n record_player(second_player)\n redirect_to home\n end",
"def end_round\n\t\tshow_hands unless round_over? \n\t\tremaining_hands = players.reject{ |p| p.folded? }\n\t\t.map{|p| p.hand }\n\t\twinner = Hand.highest_hand(remaining_hands)\n\t\twinner.take_winnings(@pot)\n\t\t\n\t\tputs \"This round's winner is #{winner.name}, with a #{winner.hand.rank}.\".colorize(:light_white).colorize(:background => :magenta)\n\t\t\n\tend",
"def end_game()\n get_winners()\n end",
"def new_turn\n # Update whose turn it is\n increment_player_idx\n\n puts \"It's #{@players[@current_player_idx].name}'s turn.\"\\\n \" (#{@players[@current_player_idx].marker}'s)\"\n end"
] | [
"0.77377325",
"0.74456555",
"0.7393943",
"0.7277434",
"0.689509",
"0.67457783",
"0.6655862",
"0.6655862",
"0.6643923",
"0.66382116",
"0.6634809",
"0.66288143",
"0.6597986",
"0.65976334",
"0.6580962",
"0.6580962",
"0.6556613",
"0.6553201",
"0.64923966",
"0.6479178",
"0.64528203",
"0.64405245",
"0.64306355",
"0.64306355",
"0.64168876",
"0.64075047",
"0.6404369",
"0.6393069",
"0.6383014",
"0.6364261",
"0.6353992",
"0.63535905",
"0.6352471",
"0.63350576",
"0.631093",
"0.63012016",
"0.6281516",
"0.62665564",
"0.6252565",
"0.62514967",
"0.62504774",
"0.62380266",
"0.62155867",
"0.6200768",
"0.619538",
"0.6194596",
"0.6194264",
"0.61808497",
"0.61798877",
"0.6103238",
"0.6073571",
"0.6068827",
"0.6057858",
"0.6043013",
"0.6042755",
"0.60404",
"0.60359216",
"0.6024495",
"0.60112363",
"0.6006996",
"0.6005731",
"0.60054475",
"0.60045475",
"0.60025746",
"0.5999771",
"0.59983975",
"0.59977037",
"0.59966964",
"0.59934145",
"0.5967748",
"0.5953345",
"0.59365",
"0.5930361",
"0.59121656",
"0.5899435",
"0.58927757",
"0.58917964",
"0.58908653",
"0.58672625",
"0.5864517",
"0.5861147",
"0.5861029",
"0.58576614",
"0.5857005",
"0.5854906",
"0.5847092",
"0.58307976",
"0.5830264",
"0.5818364",
"0.581622",
"0.58158016",
"0.58072335",
"0.58072335",
"0.58064336",
"0.5798256",
"0.57940984",
"0.578395",
"0.57695353",
"0.57606447",
"0.5758778"
] | 0.6574706 | 16 |
Returns a string representation of the component | def to_s
return "Turn => #{self.current_turn}, Players => #{@players}, "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n \"Component '#{name}' #{id}\"\n end",
"def inspect\n\t\treturn %{#<%s:0x%0x (%s)>} % [\n\t\t\tself.class.name,\n\t\t\tself.object_id * 2,\n\t\t\tself.component,\n\t\t]\n\tend",
"def to_s\n fail @error if @error && @value.empty?\n\n @template.sub('{value}', URI.encode(@value.to_s)) + @component\n end",
"def to_s\n return \"#{namespace}:#{project}:#{component}:#{version}\"\n end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n\t\t\t@string\n\t\tend",
"def to_s\n %(<#{ @name }#{attributes}>)\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n return '#<' + self.class.to_s + \":\" + self.name + '>'\n end",
"def to_s\n\t\t\"#{self.name}\"\n\tend",
"def to_s\n toString()\n end",
"def to_s\n self.inspect\n end",
"def to_s\n \"[#{@name}]\"\n end",
"def to_s\n puts @name\n puts @vcenter.to_yaml\n puts @components.to_yaml\n puts @nodenameconvention.to_yaml\n end",
"def to_s\n \"[#{@type}]#{@content}\"\n end",
"def to_s\n self.ref\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n \"#{@value}\"\n end",
"def to_s\n \"#{@value}\"\n end",
"def to_s\r\n value.inspect\r\n end",
"def to_s\n toString\n end",
"def to_s\n value\n end",
"def to_s\n value\n end",
"def to_s\n raise NotImplementedError\n end",
"def to_s\n inspect\n end",
"def to_s\n object.to_s\n end",
"def to_s\n \"#<#{classname}>\"\n end",
"def to_s\n raise 'To be implemented in child classes'\n end",
"def to_s\n @value\n end",
"def to_s\n @literal\n end",
"def to_s\n @components.map do |c|\n if c.errors.any?\n c.errors.map(&:to_s).join(\"\\n\")\n else\n c.to_s\n end\n end.join(\"\\n\\n\")\n end",
"def string\n element().to_s\n end",
"def to_s\n \"#<#{self.class.name}:#{object_id} #{info}>\"\n end",
"def to_s\n each_with_object([]) do |(name, value), array|\n if value.is_a?(Component::Attr)\n # Flatten nested hashs and inject them unless empty\n value = value.to_s\n array << value unless value.empty?\n else\n name = [@prefix, name].compact.join(\"-\").gsub(/[\\W_]+/, \"-\")\n array << %(#{name}=\"#{value}\") unless value.nil?\n end\n end.sort.join(\" \")\n end",
"def to_s\n @value\n end",
"def to_s\n @subcomposites[self.class.start_index].to_s\n end",
"def to_s\n \"[ #{@name} ]\"\n end",
"def to_str\n @value\n end",
"def to_s\n @value\n end",
"def to_s\n Alf::Renderer.text(self).execute(\"\")\n end",
"def to_s\r\n @value.to_s\r\n end",
"def to_s\n @object.to_s\n end",
"def to_s\n \"#{@x}\"\n end",
"def to_s\n \t\t\"#{name}\"\n end",
"def to_s\n value\n end",
"def inspect\n to_s\n end",
"def to_s\n @string ||= Builder::ToString.new(self).string\n end",
"def to_s\n @module.to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def to_s\n @unit.s_for(value)\n end",
"def to_s\n return self.get_info()\n end",
"def to_s\n full\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s\n string\n end",
"def to_s\n return \"#{self.name}\"\n end",
"def to_s\n self.inspect\n end",
"def to_s\n const.to_s\n end",
"def to_s\n self\n end",
"def to_s\n raise NotImplementedError\n end",
"def to_s\n @value.to_s\n end",
"def to_s\n @value.to_s\n end",
"def to_s\n \"#{@imc}, #{@resul}, #{@rcc}\"\n end",
"def to_s\n @value.to_s\n end",
"def to_str() @value.to_s end",
"def to_s\n \"#{self.class} #{self.name}\"\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n \"#{self.class.name} #{name}\"\n end",
"def to_s\n \"#{@value}\"\n end",
"def to_s\n \"#{@value}\"\n end",
"def to_s\n @value\n end",
"def to_s\n @value\n end",
"def to_s\n @value\n end",
"def to_s\n '[custom]'\n end",
"def to_s\r\n \"<#{self.class.name} id: #{self[:id]}, description: #{self[:description]}, definition: #{self[:definition]}, has_inverse: #{self[:has_inverse]} accuracy: #{self[:accuracy]}\"\r\n end",
"def to_str\n \"#{@name} - #{@type}: @(#{@xPos},#{@yPos}), HP: #{@hp}, CP: #{@cp}, #{@life_cyc}\"\n end",
"def to_s\n return @value.to_s\n end",
"def to_s\n @g.to_s\n end",
"def to_s\n return \"#<#{self.class.name}>\"\n end",
"def to_s\n value.to_s\n end",
"def to_str\n @value.to_s\n end",
"def to_s\n str = \"#{value.to_s}#{units}\"\n str += \" | #{self.text}\" if status != \"normal\"\n str\n end",
"def to_s; \"<Label: #{@name}>\"; end",
"def to_s\n \"#<#{self.class.name}>\"\n end",
"def inspect\n self.to_s\n end",
"def inspect\n self.to_s\n end",
"def to_s\n if @value then \"#{@name}=#{@value}\"\n else \"#{@name}\"\n end\n end"
] | [
"0.82379895",
"0.76293397",
"0.7255166",
"0.7078531",
"0.70406765",
"0.70266217",
"0.69887286",
"0.69808745",
"0.69808745",
"0.69808745",
"0.69808745",
"0.6978229",
"0.6952142",
"0.6938335",
"0.6932769",
"0.69316447",
"0.6924792",
"0.6921064",
"0.68997866",
"0.6878768",
"0.6878768",
"0.6878768",
"0.6878768",
"0.68595695",
"0.6841666",
"0.6835412",
"0.6812869",
"0.6808979",
"0.6808979",
"0.68083036",
"0.6807342",
"0.6804749",
"0.67989516",
"0.67973953",
"0.6767508",
"0.6766387",
"0.6766284",
"0.6756934",
"0.67437845",
"0.67433333",
"0.6733927",
"0.6728689",
"0.67279077",
"0.6724079",
"0.67147166",
"0.6712124",
"0.6712096",
"0.6706375",
"0.67000157",
"0.6695005",
"0.66892004",
"0.66889685",
"0.66884863",
"0.6687595",
"0.66816556",
"0.66816556",
"0.66795444",
"0.6677109",
"0.6675611",
"0.66691214",
"0.66665846",
"0.66651356",
"0.66634667",
"0.66630214",
"0.6662573",
"0.66534764",
"0.6648194",
"0.6648194",
"0.6647896",
"0.6646959",
"0.66426694",
"0.6641101",
"0.6635841",
"0.6635841",
"0.6635841",
"0.6635841",
"0.6635841",
"0.6635841",
"0.6635841",
"0.6631943",
"0.6631943",
"0.66213644",
"0.66197973",
"0.66197973",
"0.66175616",
"0.66175616",
"0.66175616",
"0.66145694",
"0.66134125",
"0.66127324",
"0.6607054",
"0.66046643",
"0.6604657",
"0.6599253",
"0.65957004",
"0.6588535",
"0.6584487",
"0.65809333",
"0.65756357",
"0.65756357",
"0.6572324"
] | 0.0 | -1 |
Initialize the Response object with the HTTPResponse object to parse, the client that made the request and the original request made | def initialize(http_response, request)
@http_response = http_response
@request = request
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def net_http_init(net_http_response)\n\n @original = net_http_response\n @status = net_http_response.code.to_i\n @body = net_http_response.body\n @headers = {}\n net_http_response.each { |k, v|\n @headers[k.split('-').collect { |s| s.capitalize }.join('-')] = v\n }\n end",
"def initialize(response)\n @response = response\n @headers = response.headers\n @status = response.status\n @body = response.body || ''\n end",
"def initialize(response, request)\n @response = response\n @request = request\n end",
"def initialize(raw_response, req, ignore_signature_check = false)\n @raw_response, @request = raw_response, req\n parse ignore_signature_check\n end",
"def initialize(http_response, http_response_code, http_raw_response)\n @http_status_code = http_response_code\n @http_raw_response = http_raw_response\n\n # only set these variables if a message-body is expected.\n if not @http_raw_response.kind_of? Net::HTTPNoContent\n @body = MultiJson.load(http_response) unless http_response.nil?\n @request = MultiJson.load(@body[\"request\"].to_s) if @body[\"request\"]\n @api_status = @body[\"status\"].to_i if @body[\"status\"]\n @api_error_message = @body[\"error_message\"].to_s if @body[\"error_message\"]\n end\n end",
"def initialize( request )\n @request = request\n @response = Rack::Response.new\n end",
"def initialize(request, response)\n @request = request\n @response = response\n end",
"def request\n self.response = prepare_response(http_communication.content)\n end",
"def initialize(response, path, options = {})\n\n # puts \"Init NG:Response , original response : #{response}\"\n # headers\n # @fields = response.get_fields\n # @header = response.to_hash\n @response = response\n puts @response\n puts \"\"\n\n #status\n @code = response.code\n puts @code\n puts \"\"\n # @message = response.message\n @response_name = response.class.name\n\n # @cookie = response.get_fields('set-cookie')\n\n #body\n if( response.body[0] != '{' && response.body[0] != '[')\n #puts \"no wrapper\"\n @body = response.body\n\n else\n # puts \"wrapper : #{response.body[0]}\"\n @body = JSON.parse(response.body)\n end\n\n @path = path\n end",
"def initialize(response)\n @status = response.code.to_i\n @headers = response.each_header { |_, _| }\n @body = extract_body(response.body, *headers[Futile::Headers::CONTENT_ENCODING])\n @status = response.code.to_i\n end",
"def post_init\n @request = Request.new\n @response = Response.new\n end",
"def initialize\n @isRequest = nil\t# true, false and nil\n @httpVersion = 'HTTP/1.1'\n @bodyType = nil\n @bodyCharset = nil\n @bodySize = nil\n @bodyDate = nil\n @headerItem = []\n @chunked = false\n @responseStatusCode = nil\n @reasonPhrase = nil\n @requestMethod = nil\n @requestUri = nil\n @requestQueryUri = nil\n @requestViaProxy = false\n end",
"def build_response(connection, request); end",
"def initialize\n @headers = HeaderHash.new\n @trace = []\n self.code = 200\n self.redirect = false\n end",
"def initialize\n @headers = {}\n @trace = []\n self.code = 200\n self.redirect = false \n end",
"def initialize(opts)\n @version = opts.fetch(:version)\n @request = init_request(opts)\n @status = HTTP::Response::Status.new(opts.fetch(:status))\n @headers = HTTP::Headers.coerce(opts[:headers] || {})\n @proxy_headers = HTTP::Headers.coerce(opts[:proxy_headers] || {})\n\n if opts.include?(:body)\n @body = opts.fetch(:body)\n else\n connection = opts.fetch(:connection)\n encoding = opts[:encoding] || charset || default_encoding\n\n @body = Response::Body.new(connection, :encoding => encoding)\n end\n end",
"def initialize text, client_ip=nil\n \n \n @client = client_ip ? client_ip : \"\"\n @complete_request = ''\n @verb = ''\n @resource = ''\n @http_version = [0,0]\n @extra_args = {}\n \n \n # if text is nil at this point, we will leave it at a stub request\n # for debugging purposes.\n return if text.nil?\n \n \n #\n # Separate and chomp each line into array.\n headlines = text.each_line(\"\\r\\n\").map{|line| line.chomp }.to_a\n \n #\n # Rip off the first line and store it as complete request\n requestLine = headlines.shift\n @complete_request = requestLine\n \n #\n # Split request line.\n requestComponents = requestLine.split(/ /) # split on single-space exactly.\n raise HTTPStandardError.new(400, self) unless requestComponents.count == 3 # Bad Request\n \n # We now know there are three parts to the request line.\n @verb, @resource, versionString = requestComponents\n raise HTTPStandardError.new(501, self) unless HTTPHandler::ImplementedVerbs.include?(@verb) # Not Implemented\n raise HTTPStandardError.new(400, self) unless @resource.length > 0 && @resource[0] == '/'\n \n @http_version = version_from versionString\n \n #\n # Having gotten the request, parse the additional information:\n headlines.each do |messageHeader|\n next if messageHeader.length == 0\n \n #\n # Split leading token from the rest.\n headParts = messageHeader.split(':', 2) # Limit split to 2 pcs. b/c rest may contain colons\n raise HTTPStandardError.new(400, self) unless headParts.count == 2\n \n #\n # We take all keys as lowercase, and disallow any key\n # which contains a Token Separator.\n fieldName, fieldValue = headParts\n fieldName.downcase! ; fieldValue.strip!\n TokenSeparators.each {|sep| raise HTTPStandardError 400 if fieldName.include?(sep) }\n \n #\n # Add to dictionary.\n if @extra_args[fieldName]\n # Field already specified; comma-append the new value:\n @extra_args[fieldName] = \"#{@extra_args[fieldName]},#{fieldValue}\"\n else\n @extra_args[fieldName] = fieldValue\n end\n end\n \n end",
"def initialize(response)\n self.savon = response\n self.body = response.body\n self.http_code = response.http.code\n # TODO: handle errors here\n end",
"def response\n @response ||= Net::HTTP.new(uri.host).request(request)\n end",
"def convert_response(response)\r\n HttpResponse.new(response.status, response.headers, response.body)\r\n end",
"def create_response(request)\n response = Response.new\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(response)\n @response = response\n end",
"def initialize(request, response, body = nil)\n @request = request\n @response = response\n @body = body\n end",
"def response\n [ @_status || DEFAULT_RESPONSE_CODE, headers, @_body || DEFAULT_RESPONSE_BODY.dup ]\n end",
"def response\n [ @_status || DEFAULT_RESPONSE_CODE, headers, @_body || DEFAULT_RESPONSE_BODY.dup ]\n end",
"def initialize(http_response)\n @http_response = http_response\n @uri = http_response.uri\n @status_code = http_response.status_code\n parse_response\n # Use reason phrase as the description if description is empty\n @description = http_response.reason_phrase if (@description.nil? || @description.empty?) && http_response.reason_phrase\n super(\"#{type} (#{status_code}): #{description}\")\n end",
"def prepare_response(response)\n response\n end",
"def initialize(client, res)\n @client = client\n @status = res.status\n @headers = res.headers\n @env = res.env\n @body = res.body\n end",
"def initialize(response)\n response.error = self\n @response = response\n\n message = []\n\n if response.parsed.is_a?(Hash)\n @code = response.parsed['error']\n @description = response.parsed['error_description']\n message << \"#{@code}: #{@description}\"\n end\n\n message << response.body.force_encoding(\"UTF-8\")\n\n super(message.join(\"\\n\"))\n end",
"def parse_response!; end",
"def initialize(http_resp)\n @content = http_resp.body\n @data = JSON.parse(http_resp.body, symbolize_names: true)\n @status_code = http_resp.code.to_i\n end",
"def initialize(http_response, result_format = :mashie)\n @result_format = result_format\n @headers = parse_headers(http_response.to_hash)\n @body = parse_body(http_response.body)\n end",
"def set_http_response(response, skip_body=false)\n @data[:response][:instance] = HTTPResponse.new(\n response.code,\n skip_body ? nil : response.body,\n response.to_hash,\n response\n )\n nil\n end",
"def init_from_response_body!\n return unless self.response_body\n self.objects. init_from_hal(self.response_body);\n self.links. init_from_hal(self.response_body);\n self.attributes.init_from_hal(self.response_body);\n self.loaded = true\n self\n end",
"def initialize(response, url, query_params = {})\n @response_status = response.status\n @response_body = response.body\n @response_headers = response.headers\n message = \"Status code #{response.status} on resource #{url}\"\n message += \" with params: #{query_params.inspect}\" if query_params.present?\n super(message)\n end",
"def initialize(response)\n raise ArgumentError, \"Response doesnot exist\" if ((response.nil? || response.empty?) && response.code.nil? && response.code.empty?)\n @_response = response\n @_statusCode = response.code\n @_responseBody = response.body\n end",
"def initialize(req, res, route_params = {})\n @request, @response = req, res\n @params = Params.new(@request, route_params)\n @already_built_response = false\n end",
"def initialize(response, to_s_sym=nil)\n\t\t\tresponse = response.body if Net::HTTPResponse === response\n\t\t\t@body = response\n\t\t\t@to_s_sym = to_s_sym\n\t\tend",
"def response_parser; end",
"def initialize(httparty)\n @data = httparty.parsed_response\n @http = httparty.response\n end",
"def wrap_response(response)\n\t\t\t\t\tif body = response.body\n\t\t\t\t\t\tresponse.body = parser_for(response).new(body)\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\treturn response\n\t\t\t\tend",
"def initialize(request_id)\n super request_id, SERVERDATA_RESPONSE_VALUE, nil\n end",
"def build_object\n response = make_request\n body = JSON.load(response.body) if response.body \n body = { response: body } if body.is_a? Array\n hash = body.to_snake_keys if body\n response_object = Hashie::Mash.new(hash)\n response_object.status_code = response.code.to_i unless response_object.status_code\n response_object\n end",
"def response #:nodoc:\n current_params = request.params\n @response ||= {}\n return @response[current_params] if @response.has_key? current_params\n response_object = Response.new self\n response_object.load_data\n @response[current_params] = response_object\n end",
"def call_reponse_wrapper(response)\n response_wrapper.new(response)\n end",
"def initialize(responses)\n parse_response responses\n end",
"def initialize(request:, response: nil)\n @request = request\n @response = response\n end",
"def parse_response(response)\n @response = response.body\n @code = response.code\n @message = response.message\n end",
"def initialize(text)\n @headers = {}\n @http_version = ''\n @status = -1\n @response_text = ''\n \n parse text\n end",
"def initialize(response, connection)\n @location = response.header[\"location\"]\n @status_code = response.code\n @status_message = response.message\n \n if response.body\n \n #If a receipt was returned, parse it\n begin\n #ensure that there are not parse errors. If there are, warn, rather then raise\n @entry = ::Atom::Entry.parse(response.body) \n @has_entry = true\n @entry.http = connection\n rescue Exception => message\n @has_entry = false\n $stderr.puts \"ERROR: An error occured processing the Response XML: #{message}\"\n rescue StandardError => error\n @has_entry = false\n $stderr.puts \"WARN: The deposit was successful, but there was an issue with Response XML. It could be missing. (#{error})\"\n end\n \n else\n #if the receipt was not returned, try and retrieve it\n if @location\n @entry = ::Atom::Entry.parse(connection.get(@location).body)\n @has_entry = true\n else\n #Otherwise, there is no receipt (e.g. for a delete)\n @has_entry = false\n @entry = nil\n end\n end\n end",
"def http_response\n @http_response ||=\n Strava::Web::ApiResponse.new(deep_copy(@web_response).http_response)\n end",
"def initialize_request_and_response(env)\n @request = Rack::Request.new env\n @response = Rack::Response.new\n end",
"def from_response(response)\n\n payload = response.body\n @error = payload['error']\n @error_code = payload['error_code']\n @details = payload['details']\n @response = response\n\n logger.error(\"Request failed with status #{response.code.to_s}: '#{@error_code} #{@error}': #{response.body}\")\n\n self\n end",
"def initialize(response, envelope = [])\n @response = response\n @envelope = envelope\n end",
"def post_init\n @current = nil\n @requests = []\n @pending = []\n @parser = Http::Parser.new(self)\n end",
"def make_adapter_response(response)\n adapter_response = Response.new\n case response\n when Net::HTTPSuccess \n adapter_response.body = JSON.parse(response.body)\n adapter_response.success = true\n when Net::HTTPServerError \n adapter_response.success = false\n adapter_response.error = :server_error\n when Net::HTTPClientError \n adapter_response.success = false\n adapter_response.error = :client_error\n else\n adapter_response.success = false\n adapter_response.error = :unknown\n end\n adapter_response\n end",
"def response #:nodoc:\n warn \"#{caller(1)[0]}: warning: HTTPResponse#response is obsolete\" if $VERBOSE\n self\n end",
"def initialize(request_id)\n super request_id, SERVERDATA_RESPONSE_VALUE, nil\n end",
"def initialize(resp)\n @response = resp\n @parsed = -> { MultiJson.load(body) rescue body }.call\n end",
"def initialize response, xml_options = {}\n super(response, xml_options)\n end",
"def initialize(response)\n self.response_dup = response\n if response.body.is_a?(Hash) and !response.body[PARAM_PAGE].nil?\n self.first = path_for_page(FIRST_PAGE_NUMBER)\n self.next = response.body[META_NEXT] unless response.body\n self.prev = response.body[META_PREV]\n end\n end",
"def create_response(request, http_response, body = nil)\n HttpOperationResponse.new(request, http_response, body)\n end",
"def dup_from_response(resp)\n return self if resp.nil?\n\n # Faraday's API is a little unusual. Normally it'll produce a response\n # object with a `headers` method, but on error what it puts into\n # `e.response` is an untyped `Hash`.\n headers = if resp.is_a?(Faraday::Response)\n resp.headers\n else\n resp[:headers]\n end\n\n context = dup\n context.request_id = headers[\"X-Request-Id\"]\n context\n end",
"def parse_response\n if @http_response.body && @http_response.respond_to?(:headers) && @http_response.headers['Content-Type']\n if @http_response.headers['Content-Type'].include?('xml')\n parse_xml_response\n elsif @http_response.headers['Content-Type'].include?('json')\n parse_json_response\n end\n else\n parse_unknown_response\n end\n end",
"def parsed_response\n #logger.debug { \"Parsing Response: #{response.content_type}\" }\n @parsed_response ||= ResponseParser.parse(response)\n end",
"def initialize success, body\n @success = success || false\n @body = body.fetch('RESPONSE', {})\n end",
"def intitiate_response_object \n response_object = Hash.new\n response_object[:status] = \"failure\"\n response_object[:statusCode] = 500\n response_object[:response] = \"\"\n response_object[:message] = \"The server encountered an unexpected condition which prevented it from fulfilling the request\"\n return response_object\n end",
"def call\n conn = http_setup\n res = set_up_response(method.to_sym, uri, conn, headers ,body)\n\n response = HttpResponse.new(res)\n response.uri = uri\n raise response.error if !response.success? && !@has_retry_filter\n response\n end",
"def initialize(msg, api_response = nil)\n super(msg)\n\n # Automatically use included response object if possible\n @api_response = api_response.respond_to?(:response) ? api_response.response : api_response\n\n # Parse response and set instance vars\n parse_response unless @api_response.nil?\n end",
"def initialize(response)\n @response = response\n\n if outcome\n @code = outcome[:reason_code]\n message = outcome[:reason_message]\n else\n message = \"the server responded with status #{response[:status]}\"\n end\n\n super(message)\n end",
"def response=(response); @response = response end",
"def setup\n @response ||= {}\n end",
"def response_body=(_arg0); end",
"def fetch_from_backend\n status, headers, body = backend.call(request.env)\n response = Response.new(status, headers, body)\n @response = response.dup\n @original_response = response.freeze\n end",
"def fetch_from_backend\n status, headers, body = backend.call(request.env)\n response = Response.new(status, headers, body)\n @response = response.dup\n @original_response = response.freeze\n end",
"def initialize\n\n response = list\n end",
"def initialize(http_response, collection)\n super\n\n pagination = http_response[\"pagination\"]\n @page = pagination[\"current_page\"]\n @per_page = pagination[\"per_page\"]\n @total_entries = pagination[\"total_entries\"]\n @total_pages = pagination[\"total_pages\"]\n end",
"def http_response\n return @http_response\n end",
"def initialize(response)\n @document = response.to_hash\n end",
"def initialize(msg, response = nil)\n @response = response\n msg += \" => #{response.body}\" if response&.body\n super(msg)\n end",
"def http_response(response)\n status_code, headers, body = response\n http_response = status_line(status_code)\n DefaultResponseHeaders.merge(headers).each do |k,v|\n http_response << \"#{k}: #{v}\\r\\n\"\n end\n http_response << \"\\r\\n\"\n body.each do |s|\n http_response << s\n end\n http_response\n end",
"def initialize(response, status)\n @response = response\n @status = status\n end",
"def initialize\n @action = :get\n @headers = {}\n @timeout = 0\n @connect_timeout = 0\n @max_redirects = -1\n end",
"def assign_http_variables(request, http_response, xml)\n @request = request\n @http_response = http_response\n @xml = xml\n end",
"def init_response\n headers = SSE_HEADER.merge @headers\n @parser.headers stringify_headers(headers)\n rescue ::HTTP2::Error::StreamClosed\n @stream.log :warn, \"stream closed early by client\"\n end",
"def initialize(method, path, response)\n @method = method\n @path = path\n @code = response.code\n @body = response.body.to_s\n @body = @body.empty? ? \"<none>\" : \"#{response.body}\"\n message = \"Unexpected server response:\\n Method: #{@method}\\n Path: \"\\\n \"#{@path}\\n Code: #{@code}\\n Body: #{@body}\"\n super message\n end",
"def setup_status_and_body\n @status, @body = @response.status, @response.body # TODO: Need to status.to_i?\n end",
"def reset_response\n self.instance_variable_set(:@_response_body, nil)\n end",
"def parsed_response\n response\n end",
"def from_response(resource_class, response)\n case response['Content-Type']\n when nil\n response.body\n when %r{application/pdf}\n response.body\n when %r{text/html}\n response.body\n when %r{text/plain}\n response.body\n when %r{application/octet-stream}\n response.body\n when %r{text/xml}\n if response['location']\n response['location']\n else\n response.body\n end\n when %r{application/json}\n record = from_json resource_class, response.body\n if record.nil?\n record = resource_class.new\n record.uri = response['location']\n end\n\n session_id = extract_session_id(response)\n record.instance_eval {\n @clazz = resource_class\n @etag = response['ETag']\n @session_id = session_id\n @pagination_max_nb_records = response['X-Killbill-Pagination-MaxNbRecords'].to_i unless response['X-Killbill-Pagination-MaxNbRecords'].nil?\n @pagination_total_nb_records = response['X-Killbill-Pagination-TotalNbRecords'].to_i unless response['X-Killbill-Pagination-TotalNbRecords'].nil?\n @pagination_next_page = response['X-Killbill-Pagination-NextPageUri']\n @response = response\n }\n record\n else\n raise ArgumentError, \"#{response['Content-Type']} is not supported by the library\"\n end\n end",
"def build_response(response)\n \"HTTP/1.1 #{response[:status_code]} #{response[:status_message]}\\r\\n\" +\n \"Content-Type: text/plain\\r\\n\" +\n \"Content-Length: #{response[:bytesize]}\\r\\n\" +\n \"Connection: close\\r\\n\"\n end",
"def perform!\n @request_time = Time.now\n\n http_resp = adapter.make_request(@method, @resource.uri, @body, @header)\n @response = Resourceful::Response.new(uri, *http_resp)\n @response.request_time = @request_time\n @response.authoritative = true\n\n @response\n end",
"def parsed_response\n #logger.debug { \"Parsing Response: #{response.content_type}\" }\n return response unless response\n @parsed_response ||= case response.content_type\n when 'application/json'; response.body.empty? ? '' : JSON.parse(response.body)\n when 'text/html'; { } #HTMLResponseParser.parse(response.body)\n else; response.respond_to?(:to_hash) ? response.to_hash : response.to_s\n end\n @parsed_response\n end",
"def parse_response(response)\n raise NotImplementedError, '.parse_response should be implemented in subclass'\n end",
"def reset_response\n self.instance_variable_set(:@_response_body, nil)\n end",
"def response\n @response ||= begin\n if self.class.http_method == :post\n self.class.post path, :body => post_data\n else\n self.class.send self.class.http_method, path\n end\n end\n end"
] | [
"0.72845155",
"0.7277241",
"0.72050834",
"0.7126053",
"0.71196204",
"0.7066198",
"0.70610034",
"0.700385",
"0.6958043",
"0.6924923",
"0.68967605",
"0.6880573",
"0.687959",
"0.6806632",
"0.6767952",
"0.67265785",
"0.6714907",
"0.6700294",
"0.66875917",
"0.6687205",
"0.66769457",
"0.66721416",
"0.66721416",
"0.66721416",
"0.66721416",
"0.66383696",
"0.66354746",
"0.6595211",
"0.6595211",
"0.65634507",
"0.65481067",
"0.6545797",
"0.65430987",
"0.6539936",
"0.65039265",
"0.650089",
"0.6492623",
"0.6480623",
"0.6449639",
"0.6441123",
"0.64376384",
"0.64271027",
"0.6398851",
"0.6396115",
"0.6384572",
"0.63752675",
"0.6370762",
"0.6349358",
"0.63485634",
"0.633728",
"0.6330116",
"0.63215435",
"0.6315474",
"0.6310055",
"0.6306666",
"0.6302637",
"0.62718844",
"0.62600774",
"0.624249",
"0.6239857",
"0.6231886",
"0.62286246",
"0.6227229",
"0.622438",
"0.62141323",
"0.6212965",
"0.6206284",
"0.62048054",
"0.618673",
"0.61789954",
"0.61644536",
"0.61583143",
"0.6153469",
"0.6148927",
"0.61339396",
"0.6131538",
"0.6130094",
"0.61260504",
"0.61260504",
"0.61256284",
"0.61250985",
"0.6123847",
"0.6114192",
"0.6104342",
"0.60982126",
"0.60979676",
"0.6092622",
"0.6077413",
"0.6074482",
"0.6052054",
"0.60416067",
"0.6007717",
"0.60004133",
"0.5995501",
"0.59945923",
"0.5991579",
"0.5987989",
"0.5976382",
"0.5971545",
"0.5967418"
] | 0.7353917 | 0 |
Parses the response, using the client to log any errors | def parse(client)
parse_status_code
parse_data(client)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_response(response)\n if response.kind_of?(Net::HTTPServerError)\n raise Jamendo::Error.new(\"Jamendo Server Error: #{response} - #{response.body}\", response)\n end\n \n case @format\n when :json\n JSON.parse(response.body, symbolize_names: true)\n when :xml\n REXML::Document.new(response.body)\n else\n raise Jamendo::Error.new('You are trying to parse unparsable!')\n end\n end",
"def parse_response(response)\n response.parse\n rescue HTTP::Error\n nil\n end",
"def parse_response(response)\n @response = response.body\n @code = response.code\n @message = response.message\n end",
"def parse_response!; end",
"def parsed_response\n #logger.debug { \"Parsing Response: #{response.content_type}\" }\n @parsed_response ||= ResponseParser.parse(response)\n end",
"def parse_response\n parse_address()\n parse_expires()\n parse_token_type()\n parse_token()\n end",
"def parse_response(response)\n check_version_and_warn(response.headers[X_KONTENA_VERSION])\n\n if response.headers[CONTENT_TYPE] =~ JSON_REGEX\n parse_json(response)\n else\n response.body\n end\n end",
"def parse_response_line\n if @headers.first =~ /\\AHTTP\\/1\\.[01] ([\\d]{3})/\n @status = $1.to_i\n else\n set_deferred_status :failed, {\n :status => 0 # crappy way of signifying an unrecognized response. TODO, find a better way to do this.\n }\n close_connection\n end\n end",
"def parsed_response\n response\n end",
"def parse!(response)\n case response.code\n when 404\n raise Rioter::Errors::SummonerNotFound.new\n when 403\n # TODO: custom errors\n raise StandardError.new(\"Riot error: Forbidden.\")\n when 429\n retry_after = response.headers[\"Retry-After\"]\n raise Rioter::Errors::RateLimited.new(msg: \"Rate limit reached, retry after: #{retry_after}\", retry_after: retry_after)\n else\n JSON.parse(response.body)\n end\n end",
"def parse_response\n if @http_response.body && @http_response.respond_to?(:headers) && @http_response.headers['Content-Type']\n if @http_response.headers['Content-Type'].include?('xml')\n parse_xml_response\n elsif @http_response.headers['Content-Type'].include?('json')\n parse_json_response\n end\n else\n parse_unknown_response\n end\n end",
"def parse_response(body)\n json = JSON.parse body, symbolize_names: true\n @success = json[:success]\n @failed = json[:failure]\n @canonical_ids = json[:canonical_ids]\n @results = (json[:results] || []).map { |result| gcm_result_for result }\n end",
"def parse_response(response)\n if response.headers['Content-Type'] == \"application/json\"\n JSON.parse(response.body) rescue nil\n else\n response.body\n end\n end",
"def parse_response(response)\n if response['content-type']\n [ response['content-type'].gsub(/\\s*;.*$/,''), uncompress_body(response) ]\n else\n raise _(\"No content type in http response; cannot parse\")\n end\n end",
"def process_response(response)\n case response.code.to_i\n when 200, 404\n parse_message response.body\n when 401, 500\n error_message = parse_message response.body\n raise \"Unauthorized: #{error_message['error']['message']}\"\n else\n raise \"Response code #{response.code} not recognized\"\n end\n end",
"def parse_response(response)\n raise NotImplementedError\n end",
"def validate(response)\n error_klass = Error.klass(response)\n raise error_klass, response if error_klass\n\n parsed = response.parsed_response\n parsed.client = self if parsed.respond_to?(:client=)\n parsed.parse_headers!(response.headers) if parsed.respond_to?(:parse_headers!)\n parsed\n end",
"def parse_response(response)\n if response['content-type']\n [ response['content-type'].gsub(/\\s*;.*$/,''), response.body ]\n else\n raise _(\"No content type in http response; cannot parse\")\n end\n end",
"def parsed_response\n #logger.debug { \"Parsing Response: #{response.content_type}\" }\n return response unless response\n @parsed_response ||= case response.content_type\n when 'application/json'; response.body.empty? ? '' : JSON.parse(response.body)\n when 'text/html'; { } #HTMLResponseParser.parse(response.body)\n else; response.respond_to?(:to_hash) ? response.to_hash : response.to_s\n end\n @parsed_response\n end",
"def parse_response(response)\n raise NotImplementedError, '.parse_response should be implemented in subclass'\n end",
"def parse\n # if body.chomp!\n if body.include?(\"\\n\")\n parse_multi_line\n else\n parse_line(response_keys, body)\n end\n end",
"def process_response(response)\n case response\n when Net::HTTPSuccess\n JSON.parse response.body\n when Net::HTTPUnauthorized\n { 'error' => \"#{response.message}:\n username and password set and correct?\" }\n when Net::HTTPServerError\n { 'error' => \"#{response.message}: try again later?\" }\n else\n { 'error' => response.message }\n end\n end",
"def interpret_response(response)\n case response.code.to_i\n when 200\n puts 'OK'\n when 201,202,204\n puts 'OK'\n return\n when 400\n puts 'Bad request'\n return\n when 404\n puts 'Resource not found'\n return\n when 500\n puts 'Sensu encountered an error'\n return\n else\n puts \"Unexpected HTTP response code #{response.code}\"\n return\n end\n\n return JSON.parse(response.body)\n end",
"def handle_response(response)\n response.value\n JSON.parse(response.body).with_indifferent_access\n rescue Net::HTTPClientException => e\n raise_error(e)\n end",
"def parse_response(response)\n begin\n data = JSON.parse(response.to_s)\n return data\n rescue JSON::ParserError\n # try as HTML\n logger.debug(\"Error parsing JSON response, now trying HTML ...\")\n data = Nokogiri::HTML(response.to_s)\n errors = data.css(\"div.error span.help-inline\").map(&:text)\n logger.warn(\"Nagyo Model errors: #{errors.inspect}\")\n return errors\n rescue Exception => e\n logger.error(\"Errors parsing response: #{e}: #{e.inspect}\")\n raise e if self.raise_errors\n end\n end",
"def parse(response)\n\nend",
"def parse(uri, response, body); end",
"def parse_response(response)\n return response unless response.respond_to?(:body)\n\n JSON.parse(response.body, symbolize_names: true)\n rescue StandardError => e\n puts \"Error parsing response from #{api_path}\"\n handle_error(e)\n end",
"def parse_response(resp)\n return resp unless resp.respond_to?(:body)\n\n JSON.parse(resp.body, symbolize_names: true)\n rescue StandardError => e\n puts \"Error parsing response from #{api_path}\"\n handle_error(e)\n end",
"def parse_and_format_response(response)\n response_body = response.body\n\n # is used for logout action that returns empty body\n if response_body.empty?\n response_body = \"{}\"\n end\n\n body_hash = OpsviewHelper.symbolize_keys(JSON.parse(response_body))\n\n if response.code == 200 || response.code == 409 # 409 - reload already in progress\n if body_hash.has_key? :list\n body_hash[:list]\n elsif body_hash.has_key? :object\n body_hash[:object]\n else\n body_hash\n end\n else\n error_message = \"Request failed (code = #{response.code}):\"\n\n if body_hash.has_key? :message\n error_message << \" #{body_hash[:message]}\"\n if body_hash.has_key? :detail\n error_message << \", details: #{body_hash[:detail]}\"\n end\n elsif body_hash.has_key? :messages\n body_hash[:messages].each { |message| error_message << \" details: #{message[:detail]}\" }\n else\n error_message << \" unknown reason\"\n end\n\n raise error_message\n end\n end",
"def parse_result(response)\n response_code = response.code\n query = response.request.options[:query]\n unless response_code == 200\n @logger.error(\"returned status code : #{response_code} query : #{query} response : #{response.body[(0..1000)]}\")\n raise \"returned status code : #{response_code}, query is #{query}\"\n end\n @logger.info(\"query succeeded with: #{response_code}, query is #{query}\")\n JSON.parse(response.body, symbolize_names: true)\n end",
"def response_parser; end",
"def parse_response(value)\n @resp_message << value\n\n value = @buffer + value\n\n response_chunk, @resp_message_codes, @buffer = decode_message(value)\n\n @resp_message_codes.each do |resp_mc|\n if resp_mc.equal?(ERROR_RESPONSE)\n raise FailedRequest.new(MC_RESPONSE_FOR[@req_message_code], @resp_message_codes, response_chunk)\n end\n\n # The below should never really happen\n if resp_mc != MC_RESPONSE_FOR[@req_message_code]\n raise FailedExchange.new(MC_RESPONSE_FOR[@req_message_code], @resp_message_codes, response_chunk, \"failed_request\")\n end\n end\n\n if response_chunk.size > 0\n @response.parse_from_string response_chunk\n end\n\n @status = true\n return(@response)\n end",
"def parse_response(response)\n # @todo Parse the response based on the @format (\"txt\", \"json\" or \"xml\")\n JSON.parse(response)\n end",
"def parse_response(response)\n # @todo Parse the response based on the @format (\"txt\", \"json\" or \"xml\")\n JSON.parse(response)\n end",
"def parse_rest(response)\n if response.code == 200\n require 'json'\n JSON.parse(response.body)\n else\n {\n status: response.code,\n message: \"Error on IP21: #{response.body}\"\n }\n end\n end",
"def parse_response(response)\n case response.content_type\n when JSON_CONTENT_TYPE\n JSON.parse(response.body, quirks_mode: true, symbolize_names: true)\n else\n response.body\n end\n end",
"def get_response\n response = @raw_client.get_response\n if response\n response[1] = reader_deserialize(response.last)\n else\n raise ServerError, \"No response.\"\n end\n\n raise ServerError, \"Malformed response.\" unless response[1].is_a?Hash\n\n if response[0] == 0\n response[1][\"errors\"] ||= [\"Unknown server error.\"]\n raise ServerError, response[1][\"errors\"].join(\"\\n\")\n end\n\n response\n end",
"def handle_response(response)\n case response\n when Net::HTTPOK \n begin\n JSON.parse(response.body)\n rescue JSON::ParserError\n response.body\n end\n when Net::HTTPUnauthorized\n raise ClearanceTwitter::Unauthorized, 'The credentials provided did not authorize the user.'\n else\n message = begin\n JSON.parse(response.body)['error']\n rescue JSON::ParserError\n if match = response.body.match(/<error>(.*)<\\/error>/)\n match[1]\n else\n 'An error occurred processing your Twitter request.'\n end\n end\n\n raise TwitterAuth::Dispatcher::Error, message\n end\n end",
"def parse_response_body(body)\r\n case body\r\n when SUCCESS_REGEXP\r\n log :success, $1\r\n $1\r\n when FAILURE_REGEXP \r\n log :failure, $1.gsub(\"<BR>\", \"\\n\")\r\n nil\r\n else \r\n raise \"unparseable response: #{body}\"\r\n end\r\n end",
"def handle_response(response)\n begin\n if ok?(response.code)\n if response.body.present?\n parse_response_body(response.body)\n else\n true # blank body\n end\n else\n Rails.logger.error \"Unexpected response #{response.code}, not sure what to do here...\"\n response.message\n end\n rescue => e\n # don't report, just return\n response.message\n end\n end",
"def response\n response = typhoeus_response\n ErrorHandler.precheck(response)\n parsed_body = MultiJson.load(response.body, JSON_OPTIONS)\n ErrorHandler.check(parsed_body.fetch(:meta))\n\n if @block\n @block.call(parsed_body)\n else\n parsed_body\n end\n rescue MultiJson::ParseError => e\n logger = Logger.new($stdout)\n logger.error(\"#{e.class}: #{e.message}\")\n\n if response\n logger.error('Response body:')\n logger.error(response.body.inspect)\n end\n\n raise Error::InternalError, 'AfterShip internal error, please try again.'\n end",
"def parse_response(response)\n status = RESPONSE_STATUSES.fetch(response.code) { raise \"Response not known\" }\n raise Amfetamine::RecordNotFound if status == :notfound\n body = if response.body && !(response.body.blank?)\n response.parsed_response\n else\n self.to_json\n end\n { :status => status, :body => body }\n end",
"def parse_response(uri)\n response = Net::HTTP.get_response(uri)\n\n if response.code.to_i == 403\n if response.body.include?(\"Forbidden\")\n e = EANException.new(\"You have not been granted permission to access the requested method or object.\")\n e.type = :forbidden\n elsif response.body.include?(\"Not Authorized\")\n e = EANException.new(\"The API key associated with your request was not recognized, or the digital signature was incorrect.\")\n e.type = :not_authorized\n elsif response.body.include?(\"Developer Inactive\")\n e = EANException.new(\"The API key you are using to access the API has not been approved, is not correct, or has been disabled. If using SIG Authentication, your digital signature is incorrect and does not match the one generated when receiving your request.\")\n e.type = :developer_inactive\n elsif response.body.include?(\"Queries Per Second Limit\")\n e = EANException.new(\"The API key you are using has attempted to access the API too many times in one second.\")\n e.type = :query_limit\n elsif response.body.include?(\"Account Over Rate Limit\")\n e = EANException.new(\"The API key you are using has attempted to access the API too many times in the rate limiting period.\")\n e.type = :rate_limit\n elsif response.body.include?(\"Rate Limit Exceeded\")\n e = EANException.new(\"The service you have requested is over capacity.\")\n e.type = :over_capacity\n elsif response.body.include?(\"Authentication Failure\")\n e = EANException.new(\"The combination of authentication checks failed.\")\n e.type = :authentication_failure\n else\n e = EANException.new(\"An unknown error occured: #{response.body}.\")\n e.type = :unknown\n end\n\n raise e\n end\n\n JSON.parse(Net::HTTP.get_response(uri).body)\n end",
"def response_message\n parsed_response['message']\nend",
"def process_response(response)\n @last_response = response.body\n\n logger.debug @last_response if logger.present?\n\n if response.body =~ /:Fault>/ then\n handle_error(response)\n else\n response.body\n end\n end",
"def parse_response(body)\n return nil if body.nil? or body.empty?\n case options.format\n when :xml\n MultiXml.parse(body)\n else\n body\n end\n end",
"def handle res, opts = {}\n @response = res\n\n parse = opts.has_key?(:parse) ? opts[:parse] : true\n\n case res.status\n when 200..299, 422 then JSON.parse res.body if parse\n when 401, 403 then raise Audiosocket::Unauthorized\n when 404 then nil\n\n else\n raise \"Unexpected response (#{res.status}) from the API:\\n#{res.body}\"\n end\n end",
"def parse_response\n @api_method = @api_response.env[:method]\n @api_url = @api_response.env[:url].to_s\n @api_status = @api_response.status\n @api_message = 'undef'\n @api_request_id = 'undef'\n\n unless @api_response.body.empty?\n begin\n parsed = JSON.parse(@api_response.body, symbolize_names: true)\n @api_message = parsed[:message]\n @api_request_id = parsed[:requestId]\n rescue JSON::ParserError\n # We fail silently as defaults have been set\n end\n end\n end",
"def response_errors\n parsed_response['error']\nend",
"def handle_response(response)\n response.body if response.success?\n end",
"def try_to_parse_erroneous_response(response)\n if response[:body].present?\n parsed = Oj.load(response[:body], mode: :compat)\n if parsed.is_a?(Hash)\n parsed.values.join(', ')\n else\n parsed\n end\n end\n rescue Oj::ParseError\n nil\n end",
"def parse_json_response(response) # :nodoc:\n doc = JSON.parse(response)\n\n result_params = {\n :doctype => :html5,\n :checked_by => MARKUP_VALIDATOR_URI\n }\n\n result_params[:uri] = doc['url'] ||= nil\n if doc['source']\n result_params[:charset] = doc['source']['encoding'] ||= nil\n end\n\n result_params[:validity] = !doc['messages'].any? { |msg| msg['type'] =~ /^error$/i }\n\n results = Results.new(result_params)\n\n doc['messages'].each do |msg|\n if msg['type'] =~ /^error$/i\n msg_type = :error\n elsif msg['subType'] =~ /^warning$/\n msg_type = :warning\n else\n next\n # TODO: should throw exceptions here\n end\n\n message_params = {\n :line => msg['lastLine'],\n :col => msg['firstColumn'],\n :message => msg['message'],\n :source => msg['extract']\n }\n\n results.add_message(msg_type, message_params)\n end\n\n return results\n\n rescue Exception => e\n handle_exception e\n end",
"def parse(response)\n case response\n when /\\ANOTIFY/ then\n SSDP::Notification.parse response\n when /\\AHTTP/ then\n SSDP::Response.parse response\n when /\\AM-SEARCH/ then\n SSDP::Search.parse response\n else\n raise Error, \"Unknown response #{response[/\\A.*$/]}\"\n end\n end",
"def parse_response_data\n log :debug, \"cas_server response.body:\\r\\n#{@raw_data}\"\n formatted_data = format_data\n formatted_data = formatted_data.nil? ? @raw_data : formatted_data\n log :debug, \"Formatted response.body: #{formatted_data}\"\n\n formatted_data\n end",
"def handle_response(response); end",
"def handle_response(response); end",
"def parse_response(response)\n JSON.parse response if response && !response.blank\n end",
"def parse(body)\n puts \"DATACASH RESPONSE\"\n puts body\n\n response = {}\n xml = REXML::Document.new(body)\n root = REXML::XPath.first(xml, \"//Response\")\n\n root.elements.to_a.each do |node|\n parse_element(response, node)\n end\n\n response\n end",
"def response\n @parsed_response ||= JSON.parse(@response.body, symbolize_names: true)\n end",
"def success(response)\n ChefAPI::Log.info \"Parsing response as success...\"\n\n case response[\"Content-Type\"]\n when /json/\n ChefAPI::Log.debug \"Detected response as JSON\"\n ChefAPI::Log.debug \"Parsing response body as JSON\"\n JSON.parse(response.body)\n else\n ChefAPI::Log.debug \"Detected response as text/plain\"\n response.body\n end\n end",
"def parse_scsb_response(response)\n parsed = response.status == 200 ? JSON.parse(response.body) : {}\n parsed.class == Hash ? parsed.with_indifferent_access : parsed\n rescue StandardError => error\n Rails.logger.error(\"Invalid response from the SCSB server: #{error}\")\n { success: false, screenMessage: 'A server error arose, please contact your local administrator for assistance.' }\n end",
"def parse_body\n Nori.new.parse(body)['Response']\n end",
"def parse_response(response)\n response = sanitize_response_keys(response.parsed_response)\n end",
"def error(response)\n ChefAPI::Log.info \"Parsing response as error...\"\n\n case response[\"Content-Type\"]\n when /json/\n ChefAPI::Log.debug \"Detected error response as JSON\"\n ChefAPI::Log.debug \"Parsing error response as JSON\"\n message = JSON.parse(response.body)\n else\n ChefAPI::Log.debug \"Detected response as text/plain\"\n message = response.body\n end\n\n case response.code.to_i\n when 400\n raise Error::HTTPBadRequest.new(message: message)\n when 401\n raise Error::HTTPUnauthorizedRequest.new(message: message)\n when 403\n raise Error::HTTPForbiddenRequest.new(message: message)\n when 404\n raise Error::HTTPNotFound.new(message: message)\n when 405\n raise Error::HTTPMethodNotAllowed.new(message: message)\n when 406\n raise Error::HTTPNotAcceptable.new(message: message)\n when 504\n raise Error::HTTPGatewayTimeout.new(message: message)\n when 500..600\n raise Error::HTTPServerUnavailable.new\n else\n raise \"I got an error #{response.code} that I don't know how to handle!\"\n end\n end",
"def process_response(response)\n\n if response and response.is_a? Nokogiri::XML::NodeSet and response.length > 0\n @last_revision = response.first.attr('revision')\n response.map do |entry|\n\n body = []\n entry.css('path').each do |path|\n body.push \"#{path.attr('action')} #{path.text.gsub(/^\\//, '')}\"\n end\n\n body = [body.join(\"\\n\")]\n\n message = entry.css('msg').text.gsub(/\\n/, ' | ')\n\n body.push \"#{entry.css('author').text.upcase}: #{message}\" if entry.css('msg').length > 0\n body.push Time.parse(entry.css('date').text)\n\n {\n id: \"#{@url}|#{entry.attr('revision')}\",\n title: \"#{entry.css('author').text} | Rev. #{entry.attr('revision')}\",\n body: body.join(\"\\n----\\n\"),\n icon_path: File.realpath(\"#{APPLICATION_PATH}/assets/svn.png\"),\n object: entry\n }\n\n end\n elsif response and response.is_a? Exception\n response\n else\n []\n end\n end",
"def handle_response(resp)\n self.response = JSON.parse(resp.body, symbolize_names: true)\n\n # :content and :reference must be included in response.\n if response.keys.include?(:content) && response.keys.include?(:reference)\n return\n end\n\n # :content or :reference not included.\n raise ::EasyManageClient::InvalidResponseContent\n end",
"def parse_response(curl_response)\n lines = curl_response.readlines\n # Absence of network connection\n raise IOError, 'Curl response empty' if lines.blank?\n\n code = lines.first.split(' ').last\n body = JSON.parse(lines.last)\n\n response = Nordea::Siirto::Response.new\n response.code = code\n # Nordea server responds to curl in HTTP/2, and apparently in HTTP/2\n # there is no standard way to return HTTP status message (e.g. OK, Not\n # Found), unlike in HTTP/1.1. We would need to either force HTTP/1.1\n # or map status codes to messages here.\n response.message = ''\n response.body = body\n response\n end",
"def parse_response(response, raw=false) # :nodoc:\n if response.kind_of?(Net::HTTPServerError)\n raise DropboxError.new(\"Dropbox Server Error: #{response} - #{response.body}\", response)\n elsif response.kind_of?(Net::HTTPUnauthorized)\n raise DropboxAuthError.new(response, \"User is not authenticated.\")\n elsif not response.kind_of?(Net::HTTPSuccess)\n begin\n d = JSON.parse(response.body)\n rescue\n raise DropboxError.new(\"Dropbox Server Error: body=#{response.body}\", response)\n end\n if d['user_error'] and d['error']\n raise DropboxError.new(d['error'], response, d['user_error']) #user_error is translated\n elsif d['error']\n raise DropboxError.new(d['error'], response)\n else\n raise DropboxError.new(response.body, response)\n end\n end\n\n return response.body if raw\n\n begin\n return JSON.parse(response.body)\n rescue JSON::ParserError\n raise DropboxError.new(\"Unable to parse JSON response: #{response.body}\", response)\n end\n end",
"def parse_response(input)\n i = StringIO.new(input)\n code = i.read(1).unpack('C').first\n result = i.read(1).unpack('C').first\n if result == 0\n # good response read the port\n port = i.read(2).unpack('n').first\n set_deferred_success port\n else\n set_deferred_failure 0\n end\n end",
"def parse(response)\n Hpricot.XML(response || '')\n end",
"def parse_response(response)\n split_response = response.split(/\\n/).map(&:strip)\n ((/^total/.match(split_response.first)) ? split_response[1..-1] : []).each_with_object(Hash.new { |h,k| h[k] = []}) do |e, acc|\n fields = e.split(/\\s +/)\n acc[fields.last] << { :state => fields[0], :uuid => fields[1], :pid => fields[2], :description => fields.last }\n end\n end",
"def process_response\n LOGGER.debug \"WORLDCAT DISCOVERY - Response from target: #{@response_status}\"\n #LOGGER.debug \"WORLDCAT DISCOVERY - Headers: #{@response_headers.collect{ |k,v| \"#{k} = #{v}\" }.join(', ')}\"\n #LOGGER.debug \"WORLDCAT DISCOVERY - Body: uncomment line!\"\n LOGGER.debug @response_body\n \n @response_body\n end",
"def handle_response(response)\n case response.code\n when 200..299\n response\n else\n if response.request.format == :json\n raise FreebaseAPI::ServiceError.new(response['error'])\n else\n raise FreebaseAPI::NetError.new('code' => response.code, 'message' => response.response.message)\n end\n end\n end",
"def parse(http_response)\n return { 'OK' => 'session_id' } if API.test_mode\n \n if http_response.body.scan(/ERR/).any?\n raise Clickatell::API::Error.parse(http_response.body)\n end\n results = http_response.body.split(\"\\n\").map do |line|\n # YAML.load converts integer strings that have leading zeroes into integers\n # using octal rather than decimal. This isn't what we want, so we'll strip out any\n # leading zeroes in numbers here.\n response_fields = line.scan(PARSE_REGEX)\n response_fields = response_fields.collect { |field| field.gsub(/\\b0+(\\d+)\\b/, '\\1') }\n YAML.load(response_fields.join(\"\\n\"))\n end\n results.length == 1 ? results.first : results\n end",
"def process_response!(response)\n\t\t\t\tfinish_request!\n\t\t\t\t\n\t\t\t\tif Exception === response\n\t\t\t\t\[email protected] \"[#{@message.id}] Failure while processing response #{response}!\" if @logger\n\t\t\t\t\tRubyDNS.log_exception(@logger, response) if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t\telsif response.tc != 0\n\t\t\t\t\[email protected] \"[#{@message.id}] Received truncated response!\" if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t\telsif response.id != @message.id\n\t\t\t\t\[email protected] \"[#{@message.id}] Received response with incorrect message id: #{response.id}\" if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t\telse\n\t\t\t\t\[email protected] \"[#{@message.id}] Received valid response #{response.inspect}\" if @logger\n\t\t\t\t\t\n\t\t\t\t\tsucceed response\n\t\t\t\tend\n\t\t\tend",
"def process_response(url, response)\n json = response.parsed_response\n response_code = json['responseCode']\n return json unless response_code != 1\n\n # we got an error response from the handle server, so convert it into\n # an actual exception and throw it here\n\n message = if json['message']\n json['message']\n elsif Error.response_codes.include? response_code\n Error.response_codes[response_code]\n else\n 'Unexpected error'\n end\n\n error = Error.new(response_code, message)\n error.handle = json['handle']\n error.url = url\n raise error\n end",
"def handle_response(request, response)\n case response.code.to_i\n when 301,302\n raise(Redirection.new(request, response))\n when 200...400\n response\n when 400\n raise(BadRequest.new(request, response))\n when 401\n raise(UnauthorizedAccess.new(request, response))\n when 403\n raise(ForbiddenAccess.new(request, response))\n when 404\n raise(ResourceNotFound.new(request, response))\n when 405\n raise(MethodNotAllowed.new(request, response))\n when 409\n raise(ResourceConflict.new(request, response))\n when 412\n raise(PreconditionFailed.new(request, response))\n when 422\n raise(ResourceInvalid.new(request, response))\n when 401...500\n raise(ClientError.new(request, response))\n when 500...600\n raise(ServerError.new(request, response))\n else\n raise(ConnectionError.new(request, response, \"Unknown response code: #{response.code}\"))\n end\n begin\n if response.body.blank?\n nil\n else\n hash = JSON(response.body)\n normalize_hash(hash)\n end\n rescue JSON::ParserError => e\n raise(ConnectionError.new(request, response, \"Invalid json response: #{e.body}\"))\n end\n end",
"def parse_api_response(http_response)\n response_data = Oj.load(http_response.body, mode: :strict) rescue {} #, {symbol_keys: true}\n case http_response.class.name\n when 'Net::HTTPOK'\n if response_data['success']\n # Success\n formatted_data = format_success_response_data(response_data['data'])\n Rails.logger.debug(\"API formatted data ==*== #{formatted_data.inspect}\")\n Rails.logger.debug(\"API response_data['go_to'] ==*== #{response_data['go_to'].inspect}\")\n success_with_data(formatted_data, response_data['go_to'])\n elsif response_data['err']['go_to'].present?\n # API Error\n Rails.logger.info(\"=*=COMPANY-API-ERROR-WITH-GOTO=*= #{response_data.inspect}\")\n error_with_go_to('company_api_error', 'company api error with goto', GlobalConstant::ErrorCode.temporary_redirect, response_data['err']['go_to'])\n else\n # API Error\n Rails.logger.info(\"=*=COMPANY-API-ERROR=*= #{response_data.inspect}\")\n error_with_internal_code(\n \"company_api_error\",\n response_data['err']['display_text'],\n GlobalConstant::ErrorCode.internal_server_error,\n {},\n response_data['err']['error_data'],\n response_data['err']['display_text']\n )\n end\n when 'Net::HTTPUnauthorized', 'Net::HTTPPreconditionFailed'\n # Login required\n Rails.logger.info(\"=*=COMPANY-API-ERROR=*= Net::HTTPUnauthorized\")\n error_with_go_to('company_api_login_required', 'company api login required', '', {'by_screen_name' => 'login'})\n when 'Net::HTTPNotFound'\n # Page not found - 404\n Rails.logger.info(\"=*=COMPANY-API-ERROR=*= '404 Not Found'\")\n error_with_internal_code('company_api_not_found', 'company api not found', GlobalConstant::ErrorCode.not_found, {}, {}, '404 Not Found')\n else\n # HTTP error status code (500, 504...)\n exception_with_internal_code(\n Exception.new(\"COMPANY API STATUS CODE #{http_response.code.to_i}\"),\n 'company_api_exception',\n 'company api exception',\n http_response.code,\n debug_data\n )\n end\n \n end",
"def get_response(request)\n socket = TCPSocket.open(@host, @port)\n socket.print(request)\n response = socket.read\n \n headers, body = response.split(\"\\r\\n\\r\\n\", 2)\n response_code, response_message = headers.split(\"\\r\\n\")[0].split(\" \")[1], headers.split(\"\\r\\n\")[0].split(\" \")[2..-1].join(\" \")\n if response_code =~ /^2\\d\\d/\n print body # And display it\n else\n puts \"#{response_code} #{response_message}\"\n end\n end",
"def parse_error(response)\n ret = ''\n code = nil\n message = nil\n details = nil\n if (response.respond_to?(:status))\n code = response.status.to_s\n end\n if (response.respond_to?(:body))\n details = response.body.to_s\n begin\n err_msg = MultiJson.decode(response.body)\n err_msg.map { |_,v|\n if ! v.kind_of? Hash\n message = v.to_s\n next\n end\n code = v[\"code\"].to_s if v.has_key?(\"code\")\n message = v[\"message\"] if v.has_key?(\"message\")\n details = nil\n details = v[\"details\"] if v.has_key?(\"details\")\n }\n rescue MultiJson::DecodeError => error\n end\n else\n message = \"Unknown error response: \" + response.to_s\n end\n ret += code + \" \" unless code.nil?\n ret += message unless message.nil?\n unless details.nil?\n ret += \": \" unless ret.empty?\n ret += details\n end\n return ret\n end",
"def parse(response)\n XMLRPC::Marshal.load_response(response.body)\n end",
"def parse_response(body)\n # Handling first response\n if INITIAL_FEELINGS.include? body\n @answers.push(body)\n create_response(create_second_text_message(body))\n # Handling second response\n elsif FOLLOWUP_FEELINGS.include? body\n @answers.push(body)\n if (@answers.length >= 1)\n create_response(\"Feel #{@answers[0]} and #{@answers[1]} throughout the day!\")\n else\n create_response(\"Empower youself with these feelings throughout the day. You can do it.\")\n end\n else\n create_response(\"We're not sure how to reply, please follow up with a valid feeling.\")\n end\n end",
"def parse_response(response_string)\n\n if (response_string.include? \"ERROR~\")\n return parse_errors(response_string)\n end\n\n pairs = response_string.split(@field_delim)\n pairs.each do |p|\n k,v = p.split(@value_delim)\n if @values.has_key?(k)\n @values[k] = [@values[k]] unless @values[k].is_a?(Array)\n @values[k] << v\n else\n @values[k] = v\n end\n end\n end",
"def parse_api_response(http_response)\n response_data = Oj.load(http_response.body, mode: :strict) rescue {}\n\n # Rails.logger.info(\"=*=HTTPResponse=*= #{response_data.inspect}\")\n\n case http_response.class.name\n when 'Net::HTTPOK'\n if response_data['success']\n # Success\n success_result(response_data['data'])\n else\n # API Error\n deprecated_error_with_internal_code(response_data['err']['code'],\n 'simple token api error',\n GlobalConstant::ErrorCode.ok,\n {}, response_data['err']['error_data'],\n response_data['err']['display_text'])\n end\n when \"Net::HTTPUnauthorized\"\n # 401\n deprecated_error_with_internal_code('oka_r_unauthorized', 'ost kyc api authentication failed',\n GlobalConstant::ErrorCode.ok, {}, {}, 'Invalid Credentials')\n else\n # HTTP error status code (500, 504...)\n exception_with_internal_code(Exception.new(\"Ost Kyc API STATUS CODE #{http_response.code.to_i}\"), 'ost_kyc_api_exception', 'ost kyc api exception',\n GlobalConstant::ErrorCode.ok)\n end\n end",
"def extract_error(response, _parsed_response)\n [response.status.to_s, response.body.to_str].reject(&:empty?).join(': ')\n end",
"def get_response\n parse_response(parse_JSON(get_request))\n end",
"def validate(response)\n case response.code\n when 400; raise Error::BadRequest.new error_message(response)\n when 401; raise Error::Unauthorized.new error_message(response)\n when 403; raise Error::Forbidden.new error_message(response)\n when 404; raise Error::NotFound.new error_message(response)\n when 405; raise Error::MethodNotAllowed.new error_message(response)\n when 409; raise Error::Conflict.new error_message(response)\n when 500; raise Error::InternalServerError.new error_message(response)\n when 502; raise Error::BadGateway.new error_message(response)\n when 503; raise Error::ServiceUnavailable.new error_message(response)\n end\n\n response.parsed_response\n end",
"def parse_response(response)\n response = Hash.from_xml( response.parsed_response.gsub(\"\\n\", \"\") ) if response.parsed_response.is_a? String\n response = sanitize_response_keys(response)\n end",
"def prepare_response(response)\n JSON.parse(response)\n end",
"def parse response\n if response #and response.code >= 200 and response.code < 300\n return !response.empty? ? JSON.parse(response) : true\n else\n false\n end\n rescue => e\n $logger.trace \"Failed to parse response: #{response} -> #{e}\"\n false\n end",
"def handle_response(response)\n handle_response_errors(response)\n json_response = JSON.parse(response)\n return json_response if json_response['errors'].empty?\n json_response['errors'].each { |e| warn e }\n false\n end",
"def validate(response)\n raw_validate response\n\n response.parsed_response\n end",
"def handle_error_response(response)\n # Some errors come back under the `message` key while others are nested\n # under `error`\n error_message = response.body.dig('message') || response.body.dig('error', 'message')\n Rails.logger.error(\"SOLIDUS DRIP | #{error_message}\")\n end",
"def parse_json(request_body)\n begin\n puts '-RESPONSE-'.yellow\n response = RestClient.post @url , request_body.to_json, {content_type: :json, accept: :json , Authorization: @access_token}\n rescue RestClient::ExceptionWithResponse => err\n puts '###################### ERROR #####################'.red\n p err.response\n write_to_error_file(@url, response, err.response)\n @number_of_timeouts += 1\n end\n p response\nend",
"def parse_response(response)\n response = Hash.from_xml(response.parsed_response.gsub(\"\\n\", \"\")) if response.parsed_response.is_a? String\n response = sanitize_response_keys(response)\n end",
"def handle_response(response)\n case response.code.to_i\n when 200...300\n response\n else\n raise ResponseError.new(response)\n end\n end",
"def parse(response_body)\n Filepreviews::Response.new(JSON.parse(response_body))\n end",
"def parse(response_body)\n Filepreviews::Response.new(JSON.parse(response_body))\n end",
"def parse_response_json(response)\n begin\n JSON.parse(response.body)\n rescue JSON::ParserError\n raise TflApi::Exceptions::ApiException, logger, \"Invalid JSON returned from #{host.host}\"\n end\n end"
] | [
"0.7715834",
"0.7695897",
"0.7636979",
"0.7559383",
"0.7391786",
"0.73851657",
"0.7268152",
"0.717713",
"0.71524835",
"0.71520627",
"0.7100609",
"0.6992145",
"0.6966249",
"0.69432837",
"0.694044",
"0.69256794",
"0.6910564",
"0.68950933",
"0.6885284",
"0.6875679",
"0.6844567",
"0.6825061",
"0.68154585",
"0.68108267",
"0.6810681",
"0.6810673",
"0.6777717",
"0.6758131",
"0.67389977",
"0.67328095",
"0.6732323",
"0.67292863",
"0.67254364",
"0.6706685",
"0.6706685",
"0.6704502",
"0.6699134",
"0.66900426",
"0.66882557",
"0.667575",
"0.66643494",
"0.66559243",
"0.66525555",
"0.6640953",
"0.6627086",
"0.66173494",
"0.65847206",
"0.65786934",
"0.6570127",
"0.6540758",
"0.65269655",
"0.65096724",
"0.64859295",
"0.64795226",
"0.6473097",
"0.6462087",
"0.6462087",
"0.6450427",
"0.6438987",
"0.6437289",
"0.64363503",
"0.642178",
"0.6410211",
"0.6391986",
"0.6391022",
"0.63903385",
"0.63779837",
"0.6373099",
"0.63658005",
"0.63544583",
"0.6349977",
"0.6348989",
"0.63368934",
"0.63123155",
"0.63084215",
"0.6259721",
"0.6252434",
"0.62495524",
"0.6242001",
"0.62402034",
"0.6235192",
"0.621414",
"0.62112826",
"0.6208677",
"0.6206832",
"0.62024176",
"0.618355",
"0.6177593",
"0.617402",
"0.6168904",
"0.6157367",
"0.6153841",
"0.6151982",
"0.6150169",
"0.61490065",
"0.6147217",
"0.61355996",
"0.61351436",
"0.61351436",
"0.6119598"
] | 0.6896452 | 17 |
generic email action params[:from], params[:to], params[:subject], params[:body], params[:redirect_to] | def email
options = { :from => params[:email], :to => "[email protected]", :subject => params[:subject], :body => "From: #{params[:user]} <#{params[:email]}>\r\nCategory: #{params[:category]}\r\nSubject:#{params[:subject]}\r\n\r\n#{params[:body]}"}
RequestMailer.deliver_generic(options)
flash[:notice] = "Your email was sent successfully"
redirect_to params[:redirect]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_email( params )\n puts \"From: #{params[:from]}\"\n puts \"To: #{params[:to]}\"\n puts \"Email subject: #{params[:subject]}\"\n puts \"Email body: #{params[:body]}\" \n return true\n end",
"def my_mailer \n from_email = params[:comment][:email] \n message = params[:comment][:message] \n begin\n #First check if the senders email is valid\n if from_email =~ /^[a-zA-Z0-9._%-]+@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,4}$/\n #put all the contents of my form in a hash\n mail_info = {\"from_name\" => current_user.login,\"user_email\" => current_user.email, \"from_email\" => from_email, \"message\" => message}\n #Call the Notifier class and send the email\n Notifier.deliver_contact_mail(mail_info)\n #Display a message notifying the sender that his email was delivered.\n flash[:notice] = 'Your message was successfully delivered to the SIR Administrator.'\n #Then redirect to index or any page you want with the message\n redirect_to(:action => 'contact_mail') \n else\n #if the senders email address is not valid\n #display a warning and redirect to any action you want\n flash[:warning] = 'Your email address appears to be invalid.'\n redirect_to(:action => 'contact_mail')\n end \n rescue\n #if everything fails, display a warning and the exception\n #Maybe not always advisable if your app is public\n #But good for debugging, especially if action mailer is setup wrong\n flash[:warning] = \"Your message could not be delivered at this time. #$!. Please try again later\"\n redirect_to(:action => 'contact_mail') end\n end",
"def send_email(to, subject, content)\r\n\r\n end",
"def contact(params)\n mail :from => params[:email], :to => \"[email protected]\", :subject => \"[softa.com.br] Contato pelo site\", :body => \"email:\\n#{params[:email]}\\n\\nnome:\\n#{params[:name]}\\n\\nmensagem:\\n#{params[:message]}\"\n end",
"def contact(params)\n @name = params['name']\n @email = params['email']\n @service = params['service']\n @message = params['message']\n\n mail to: \"[email protected]\", subject: \"Message from #{@name}<#{@email}>\"\n end",
"def email_contact(params)\n @first_name = params['firstname']\n @last_name = params['lastname']\n @email = params['email']\n @drop_down = params['selection']\n @message = params['message']\n mail to: \"[email protected]\", subject: \"You've been sent a new message!\"\n end",
"def send_to_friend(params, template, record = nil)\n ActivityScore.boost_score(record, :email) if (record.class == Story)\n setup_email(:recipients => params[:to],\n :from => \"\\\"#{params[:from_name]}\\\"<#{params[:from]}>\",\n :from_name => params[:from_name],\n :body => render_message(\"mailer/send_to_friend/#{template}\", :record => record, :recipient => params[:to], :page =>params[:page], :body => params[:body]))\n @subject = \"#{params[:from_name]} sent you a link to #{APP_NAME}\"\n end",
"def contact_me(params)\n @params = params\n @greeting = \"Hi\"\n #mail to: \"[email protected]\"\n mail(:from => @params.personal_email,:to =>@params.personal_email, :subject => \"- EJJE -Gracias Por tu ayuda\")\n end",
"def email\n # If there is no url passed in, this will fail, so just redirect to the homepage\n redirect_to \"/\" and return if params[:u].blank?\n if request.post?\n @message = Message.new(params[:message])\n @message.subject = \"#{@message.from} has sent you a page from the NORC Blueprint Website\"\n if @message.save\n SiteMailer.deliver_page(@message, \"http://#{request.host_with_port}#{params[:u]}\")\n flash[:notice] = \"Your message was sent successfully\"\n redirect_to params[:u]\n end\n end\n end",
"def email_params\n params.require(:email).\n permit(:to, :subject, :body).\n merge(from: @user.to_s.downcase).tap do |params|\n params[:to] = params[:to].downcase\n end\n end",
"def notify(params)\n @body = params[\"/contact\"][:message]\n @from = params[\"/contact\"][:email]\n @phone = params[\"/contact\"][:phone]\n @name = params[\"/contact\"][:name]\n mail to: \"[email protected]\", subject: 'Mail from website', from: \"#{@from}\"\n end",
"def bar(to,a,b)\n @a = a\n @b = b\n mail :to => to\n end",
"def mail params = {}, &block\n\n raise ArgumentError.new( \"sender required\" ) unless params[ :from ].present?\n raise ArgumentError.new( \":to needs to be an array\" ) unless params[ :to ].present? && params[ :to ].is_a?( Array )\n raise ArgumentError.new( \"at least one recipient required\" ) unless params[ :to ].size > 0\n\n # binding.pry\n\n super.tap do |message|\n\n ensure_substitutions_match_recipients! params\n\n # Setting the headers on the Mailer class rather than on the Mail message as\n # per the documentation of ActionMailer::Base\n # http://api.rubyonrails.org/classes/ActionMailer/Base.html#method-i-headers\n self.headers['X-SMTPAPI'] = headers_as_json_for_sendgrid message\n\n end\n\n end",
"def mail; end",
"def emailform\n end",
"def emailform\n end",
"def post_email\n @email = Email.new\n @email.subject = params[:subject]\n @email.body = params[:body]\n @email.sender = User.find(params[:sender]).id\n @email.receiver = params[:receiver]\n @email.save()\n# flash[:notice] = \"Email sent successfully.\"\n if params[:linkedfrom] == 'listing'\n redirect_to :controller => :listings, :action => :listing, :id => params[:listing]\n else\n redirect_to :controller => :user, :action => :inbox\n end\n end",
"def submit\n local_params = params\n Contact.contact(local_params[:from], local_params[:text]).deliver\n redirect_to contact_path, notice: 'Contact mail sent'\n end",
"def email_action documents\n mail = RecordMailer.email_record(documents, { to: params[:to], message: params[:message], :callnumber => params[:callnumber], :status => params[:itemStatus] }, url_options, params)\n if mail.respond_to? :deliver_now\n mail.deliver_now\n else\n mail.deliver\n end\n end",
"def mail_contacto(params)\n @nombre = params[:nombre]\n @email = params[:email]\n @asunto = 'Alerta envío mail'\n @mensaje = params[:mensaje]\n\n mail to: @email, subject: @asunto do |format|\n format.text\n format.html\n end\n\n end",
"def new_apply_email(feedback_params)\n @firstname = feedback_params[:firstname]\n @lastname = feedback_params[:lastname]\n @telephone = feedback_params[:telephone]\n @email = feedback_params[:email]\n @address = feedback_params[:address]\n @landlord = feedback_params[:landlord]\n @landlordnum = feedback_params[:landlordnum]\n @employer = feedback_params[:employer]\n @employername = feedback_params[:employername]\n @employernum = feedback_params[:employernum]\n @income = feedback_params[:income]\n # Initialize the message here\n # mail(to: [\"[email protected]\",\"[email protected]\", \"[email protected]\", \"[email protected]\", \"[email protected]\", \"[email protected]\"], subject: 'There is a new institution registration pending')\n mail(to: [\"*Some Email*\", \"*Some Email*\"], subject: 'Akridge LLC: A new applicant has applied')\n end",
"def enviar(params)\n @asunto = params[:asunto]\n @mensaje = params[:mensaje]\n @destinatario = params[:destinatario]\n mail to: @destinatario, \n subject: \"Curso Rails - #{@asunto}\"\n end",
"def mail_to(email_address, name = T.unsafe(nil), html_options = T.unsafe(nil), &block); end",
"def request_contact\n email = params[:email]\n message = params[:message]\n\n if email.blank?\n flash[:alert] = t('emailErr')\n else\n flash[:notice] = t('emailSuccess')\n ContactMailer.contact_email(email, message).deliver_now\n \n end\n\n redirect_to root_path\n \n\n end",
"def contact_email\n @contact = params[:contact]\n mail(:to => \"[email protected]\", :subject => \"You have received a question from #{@contact[:name]} @ #{@contact[:email]}\", :body => \"#{@contact[:body]}\")\n end",
"def notification(params)\n mail(params)\n end",
"def deliverForm data\n @fromContact = data['fromContact']\n @data = data\n tomail = data['toEmail'].length > 0 ? data['toEmail'] : '[email protected]'\n\n mail(to: tomail, subject: data['fromContact'] || 'Want to be a Partner')\n end",
"def email_action documents\n mail = RecordMailer.email_record(documents, { to: params[:to], message: params[:message], :callnumber => params[:callnumber], :status => params[:itemStatus] }, url_options, params)\n if mail.respond_to? :deliver_now\n mail.deliver_now\n else\n mail.deliver\n end\n end",
"def hired!(options={}) \n raise \"You need to specify from, subject and body\" unless options.key?(:from) || options.key?(:body) || options.key?(:subject)\n Pony.mail({:to => '[email protected]'}.merge(options))\n end",
"def index\n options = params.dup\n email = options.delete(:email)\n if ContactsMailer.receive(email, options)\n render :nothing => true, :status => :created\n else\n render :nothing => true, :status => :unprocessable_entity\n end\n end",
"def create_email to, from, subject, message\n\n @from = from\n @to = to\n @subject = subject\n @message = message\n\n mail(to: to, subject: subject, from: from)\n end",
"def email\n @response, @documents = get_solr_response_for_field_values(SolrDocument.unique_key,params[:id])\n if request.post?\n if params[:to]\n url_gen_params = {:host => request.host_with_port, :protocol => request.protocol}\n\n flash[:error] = I18n.t('blacklight.email.user_not_signed_in') if !user_signed_in?\n\n if params[:to].match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$/)\n email = RecordMailer.email_record(@documents, {:to => params[:to], :message => params[:message]}, url_gen_params)\n else\n flash[:error] = I18n.t('blacklight.email.errors.to.invalid', :to => params[:to])\n end\n else\n flash[:error] = I18n.t('blacklight.email.errors.to.blank')\n end\n\n unless flash[:error]\n email.deliver\n flash[:success] = \"Email sent\"\n redirect_to catalog_path(params['id']) unless request.xhr?\n end\n end\n\n unless !request.xhr? && flash[:success]\n respond_to do |format|\n format.js { render :layout => false }\n format.html\n end\n end\n end",
"def safe_email(*args, **_arg1, &block); end",
"def email; end",
"def email; end",
"def email; end",
"def email; end",
"def send_message\n if !params[:from].blank? && !params[:name].blank? && !params[:message].blank?\n UserMailer.deliver_user_message(@user.email, params[:from], params[:name], params[:message])\n redirect_to user_portfolio_path(@user.login)\n flash[:notice] = \"Your <strong>message</strong> has been sent.\"\n else\n redirect_to user_portfolio_path(@user.login)\n flash[:notice] = \"YOU MUST FILL IN NAME, EMAIL AND MESSAGE.\"\n end\n end",
"def receive_email\n \n \n #if one of the to addresses matches us, use that one. todo - correctly handle mulitple emails, or correctly fail\n if params[:to].match(/group\\+(\\d+)@/) && @group = Group.find($1)\n from = params[:from]\n body = params[:plain].gsub(/^On .* wrote:$\\s*(^>.*$\\s*)+/,'') #strip out replies and whatnot\n\n if @sender = @group.students.find_by_email(from)\n @group.send_message(@sender.name+\": \"+body,@sender,[@group.user])\n elsif @group.user.email==from\n @group.send_message(@group.user.display_name+\": \"+body,@group.user)\n end\n end\n render :text => 'success', :status => 200\n end",
"def email\n\n email = email_params\n ContactMailer.status_email(email[:email], email[:subject], email[:body]).deliver\n render nothing: true, status: 200\n\n # put logic for sending an email\n # TODO: send the email here.\n end",
"def send_an_email(message, subject, to)\n message_params = {}\n message_params[:from] = 'QuikSort Bot <***@quiksort.in>'\n message_params[:to] = to\n message_params[:subject] = subject\n message_params[:text] = message\n logger.info $MG_CLIENT.send_message 'quiksort.in', message_params\nend",
"def message_email(user, sender, message, convoID)\n \t@user = user\n \t@message = message\n \t@sender = sender\n \t@url = 'http://www.projecthelp.co/inbox/' + convoID.to_s\n\n \tmail :to\t\t=> user.email,\n :subject\t=> \"New message from \" + @sender.first_name\n end",
"def email_params\n begin\n params.require(:email).permit(:sender, :recipient, :subject, :body_html, :cc, :bcc)\n rescue\n params.permit(:sender, :recipient, :subject, 'body-plain', 'stripped-html', 'body-html')\n end\n end",
"def contact_form(email)\n\n @sender = email[0]\n @website = email[1]\n @email = email[2]\n @message = email[3]\n\n @greeting = @sender+ \"sent a message\"\n\n mail :to => \"[email protected]\",:subject=>@greeting\n end",
"def general_email(addresses, subject_line, body_content, article_content=nil)\n \n if article_content != nil\n attachments.inline['attachment.txt'] = article_content\n end \n \n @content = body_content\n \n #TODO check that email is creatible, ie has valid addresses\n mail(:to => addresses, :subject => subject_line)\n \n end",
"def request_contact\n\n email = params[:email]\n firstname = params[:firstname]\n surname = params[:surname]\n message = params[:message]\n\n if email.blank? or !validEmail(email)\n flash[:alert] = \"Sorry, your email has not been sent. Please try again with a valid email address. \"\n else\n ContactMailer.contact_email(email, firstname, surname, message).deliver_now\n flash[:notice] = \"Your email has been successfully sent! A response will soon be on it's way :)\"\n end\n redirect_to root_path\n end",
"def copy_email(params)\n @name = params[:name]\n @email = params[:email]\n @message = params[:message]\n\n mail from: ENV.fetch('WEBMASTER_EMAIL'),\n to: @email,\n template_name: 'send_email'\n end",
"def process_rcpt_to params\n # Since we require :mail_from to have been seen before we process RCPT TO,\n # we don't need to repeat the tests for TLS and AUTH.\n if [email protected]?(:mail_from)\n reply 503, \"No sender given\"\n return\n end\n \n forward_path, rcpt_parameters = params.split(' ', 2)\n if forward_path !~ /@/\n reply 501, \"Syntax: RCPT TO:<address>\"\n # NOTIFY=[SUCCESS],[FAILURE],[DELAY],[NEVER], ORCPT=\n # \"555 5.5.4 Unsupported option: %s\"\n elsif !receive_recipient(unbracket(forward_path))\n reply 550, \"recipient is unacceptable\" # or too many recipients\n else\n reply 250, \"Ok\"\n @state << :rcpt unless @state.include?(:rcpt)\n end\n end",
"def email_action documents\n mail = RecordMailer.email_record(documents, { to: params[:to], message: params[:message], config: blacklight_config }, url_options)\n if mail.respond_to? :deliver_now\n mail.deliver_now\n else\n mail.deliver\n end\n end",
"def send_support_email(to_email, subject, body, from_email, user_first_name, user_last_name)\n @from = \"#{user_first_name} #{user_last_name} <#{from_email}>\"\n @subject = subject\n @recipients = to_email\n @body[:body] = body\n# @content_type = \"text/html\"\n end",
"def mail_method(data,email,subject)\n @body=data\n mail(to: email, subject: subject)\n end",
"def konsalt_mail params\n build_params params\n send_email t('emails.konsalta_mail.subject')\n end",
"def contact_message\n @contact_message = params[:contact_message]\n mail to: self.class.admin_emails\n end",
"def message_email(name, email, body)\n @name = name\n @email = email\n @body = body\n mail(:to => \"[email protected]\", :subject => \"New Message from CONSIGN.NYC\")\n end",
"def send_email_record\n @response = get_solr_response_for_doc_id\n @document = SolrDocument.new(@response.docs.first)\n if params[:to]\n from = request.host # host w/o port for From address (from address cannot have port#)\n host = request.host\n host << \":#{request.port}\" unless request.port.nil? # host w/ port for linking\n case params[:style]\n when 'sms'\n if !params[:carrier].blank?\n if params[:to].length != 10\n flash[:error] = \"You must enter a valid 10 digit phone number\"\n else\n email = RecordMailer.create_sms_record(@document, {:to => params[:to], :carrier => params[:carrier]}, from, host)\n end\n else\n flash[:error] = \"You must select a carrier\"\n end\n when 'email'\n if params[:to].match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$/)\n email = RecordMailer.create_email_record(@document, {:to => params[:to], :message => params[:message]}, from, host)\n else\n flash[:error] = \"You must enter a valid email address\"\n end\n end\n RecordMailer.deliver(email) unless flash[:error]\n redirect_to catalog_path(@document.id)\n else\n flash[:error] = \"You must enter a recipient in order to send this message\"\n end\n end",
"def sms_recieved(contactnumber,storecode,usermessage,category,sydreferencenume)\n @contactnumber_controller = contactnumber\n @storecode_controller = storecode\n @usermessage_controller=usermessage\n @category_controller = category\n @syd_refnum_controller = sydreferencenume\n date= Time.now()\n @date_controller = date.strftime(\"%d-%m-%Y\")\n subject_controller = \"#{@category_controller}:#{@storecode_controller}\"\n mail to: '[email protected]',:subject => subject_controller\n\n end",
"def request_mail(from_email, content_body, requestor_type)\n @content= content_body\n @sender = from_email\n @requestor_type = requestor_type\n mail from: from_email, to: '[email protected]', subject: 'PFS general enquiry'\n end",
"def request_contact\n name = params[:name]\n email = params[:email]\n telephone = params[:telephone]\n message = params[:message]\n\n if email.blank?\n flash[:alert] = I18n.t('home.request_contact.no_email')\n else\n ContactMailer.contact_email(email, name, telephone, message).deliver_now\n flash[:notice] = I18n.t('home.request_contact.email_sent')\n end\n\n redirect_to root_path\n end",
"def sendmail_params\n params.require(:sendmail).permit(:to, :subject, :body)\n end",
"def receive_inbound_email_from_mail(**kwargs, &block); end",
"def correspond_mail(user, recipient, message, body_session, title_session)\n @recipient = recipient\n @sender = user\n @message = message\n @body_session = body_session\n @title_session = title_session\n\n mail(:to =>recipient.email, :subject => message.subject)\n\n end",
"def notice_from_objective_auth\n\n @auth = User.find(params[:auth_id])\n user_mail = User.find(params[:user_id]).email\n @url = params[:url]\n mail(to: user_mail, subject:'承認されました。')\n \n end",
"def email_params\n params.require(:email).permit(:subject, :body, :from, :to)\n end",
"def ab e,s,m\n @e = e\n @s = s\n @m = m \n @greeting = \"Hi\"\n mail to: \"[email protected]\"\n end",
"def create\n # Check that there is at least something entered in the recipients and body field\n if mail_params[:recipients].blank? || mail_params[:body].blank?\n flash[:error] = \"Either recipients or body missing. Retry.\"\n redirect_to '/'\n return\n end\n\n # Loop through the recipients list breaking on every ',' character (Strips whitespace first)\n mail_params[:recipients].strip.split(\",\").each do |recipient|\n DemoMailer.send_email(recipient, mail_params[:body]).deliver_later\n end\n\n flash[:success] = \"Emails Sent.\"\n redirect_to '/'\n end",
"def initialize(action, args={})\n @controller = self.class.to_s\n @action = action\n \n #holds all variables for template binding\n @view={}\n @to = args[:to]\n @from = args[:from]\n @cc = args[:cc]\n @bcc = args[:bcc]\n @subject = args[:subject] || ''\n @date = args[:date] || Time.now()\n @charset = args[:charset] || \"ISO-8859-1\"\n \n @message_id = \"#{DateTime.now().strftime('%Y%m%d%H%M%S')}.#{(rand(1000) * 1024).to_s}\"\n @envelope = nil\n @render_args = {:layout=>nil, :view=>nil, :text=>nil}\n render({\n :view=>args[:view] || action,\n :layout=>args[:layout] || mailer_class.layout,\n :text=>args[:text]\n })\n \n # turn the rest of the args into instance variables\n args.delete(:view) if args[:view]\n args.delete(:layout) if args[:delete]\n args.delete(:text) if args[:text]\n args.each { |key, value| self.instance_variable_set(\"@#{key}\".to_sym, value)}\n \n end",
"def contact\n \n ContactMailer.contact_email(params).deliver\n\n begin\n flash[:notice] = \"Successfully...\"\n rescue\n flash[:notice] = \"failed ...\"\n end\n end",
"def micorreo(parametros)\n @nombre = parametros[:nombre]\n @email = parametros[:email]\n @asunto = parametros[:asunto]\n @mensaje = parametros[:mensaje]\n\n mail to: \"[email protected]\", :subject => \"PQRS CES\" \n\n end",
"def email\n \n @searches = current_user.searches\n\n if request.post? and validate_email_params\n \n # only send searches that were checked in the email form\n @searches = Array.new\n @comments = Hash.new\n\n current_user.searches.each do |s|\n if params[(s.id).to_s] == \"1\"\n @searches << s\n @comments[s.id] = params[(\"notes_\" + (s.id).to_s)]\n end\n end\n \n email = SearchMailer.email_search(@searches, @comments, {:to => params[:to], :message => params[:message]}, url_options)\n email.deliver\n\n flash[:success] = I18n.t(\"blacklight.email.success\")\n\n respond_to do |format|\n format.html { redirect_to catalog_path(params['id']) }\n format.js { render 'email_sent' }\n end and return\n end\n\n respond_to do |format|\n format.html\n format.js { render :layout => false }\n end\n end",
"def message_for(params)\n date = params.has_key?(:date) ? params[:date] : Time.now\n message = <<END_OF_MESSAGE\nFrom: #{@smtp_username}\nTo: #{params[:address]}\nSubject: #{params[:subject]}\nDate: #{date.strftime(\"%a, %d %b %Y %H:%M:%S +0500\")}\n#{params[:body]}\nEND_OF_MESSAGE\n end",
"def devise_mail(record, action, opts = T.unsafe(nil), &block); end",
"def email0(to, from)\n mail(\n to: to,\n from: from,\n subject: 'email0 subject'\n )\n end",
"def request_contact\n name = params[:name]\n email = params[:email]\n telephone = params[:telephone]\n message = params[:message]\n if email.blank?\n flash[:alert] = I18n.t('contact.no_email')\n else\n ContactMailer.contact_email(email,name,telephone,message).deliver_now\n flash[:notice] = I18n.t('contact.yes_email')\n end\n redirect_to root_path\n end",
"def sendmail(to, notification_mail, params, attachments = [])\n raise NotImplementedError, \"you should implement #{self.class}##{__method__}\"\n end",
"def basic(customer,template)\n @body = Liquid::Template.parse(template.body)\n .render(\"person\" => customer.attributes)\n mail to: customer.email, subject: template.title\n end",
"def send_mail_with opts\n # Remove cc duplicates\n opts[:cc].uniq!\n # don't allow :to value in :cc array\n opts[:cc].delete(opts[:to])\n opts = development_filter(opts)\n # Send email\n mail(:to=>opts[:to],\n :cc=>opts[:cc],\n :attachments=>opts[:attachments],\n :subject=>opts[:subject],\n :from=>opts[:from]\n )\n end",
"def postEmail( to_email_address, reply_email_address, source_account, subject, body, html_body)\n params = Hash.new\n params['to_email_address'] = to_email_address\n params['reply_email_address'] = reply_email_address\n params['source_account'] = source_account\n params['subject'] = subject\n params['body'] = body\n params['html_body'] = html_body\n return doCurl(\"post\",\"/email\",params)\n end",
"def action_chain_notice(head_action, user, new_action)\n @head_action = head_action\n @user = user\n @new_action = new_action\n\n mail(:to => @user.email, :subject => \"#{new_action.user.name} replied to your SocialStreet Message\") unless @user.email.blank?\n end",
"def send_email\r\n if User.exists? params[:id]\r\n @email_to_usr = User.find(params[:id])\r\n if params[:commit]\r\n if @sending_res = profile_mail_sending(params, @email_to_usr)\r\n return if @sending_res.kind_of? Hash\r\n redirecting(t(:email_redir), session[:last_page])\r\n else\r\n redirect_to_info_page t(:email_error)\r\n end\r\n return\r\n end\r\n else\r\n redirect_to_info_page\r\n end\r\n end",
"def email_for_no_pto(full_name, pto, pto_type) \n Mail.defaults do\n delivery_method :smtp,\n address: \"email-smtp.us-east-1.amazonaws.com\",\n port: 587,\n :user_name => ENV['a3smtpuser'],\n :password => ENV['a3smtppass'],\n :enable_ssl => true\n end\n email_body = \"#{full_name[0]} #{full_name[1]} tried to request #{pto_type}and they have #{pto}PTO days left to request.<a href= 'https://wv-timesheet-clock.herokuapp.com/'> To Reply Click Here . </a>\"\n mail = Mail.new do\n from ENV['from']\n to '[email protected]'\n subject \"PTO Request with no days to request\"\n \n html_part do\n content_type 'text/html'\n body email_body\n end\n end\n mail.deliver!\nend",
"def eventifier_mail(user, records, action)\n initialize_from_record(user, records)\n mail headers_for(action)\n end",
"def request_contact\n #Gets form values that user has typed in:\n name = contact_params[\"name\"]\n email = contact_params[\"email\"]\n telephone = contact_params[\"telephone\"]\n message = contact_params[\"message\"]\n\n #If user has not typed in an email, alert them that\n #they should type one in:\n if email.blank?\n flash[:alert] = I18n.t('home.request_contact.no_email')\n else\n #Send an email:\n ContactMailer.contact_email(email, name, telephone, message).deliver_now\n flash[:notice] = I18n.t('home.request_contact.email_sent')\n end\n #Go back to home page, where the appropriate prompt will be shown:\n redirect_to root_path\n end",
"def email_params\n params.require(:email).permit(:headers, :text, :html, :from, :to, :cc, :subject)\n end",
"def email_params\n params.require(:email).permit(:from, :received_at, :subject, :user_id)\n end",
"def review_request(user)\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def deliver_activation_email(action, params)\n from = MaSA[:from_email]\n raise \"No :from_email option set for Merb::Slices::config[:merb_auth_slice_activation][:from_email]\" unless from\n MaSA::ActivationMailer.dispatch_and_deliver(action, params.merge(:from => from, :to => self.email), :user => self)\n end",
"def send_to(params)\n nil\n end",
"def confirm_booksbymail_email(user, bib, values)\n @to = \"[email protected]\"\n @from = \"#{user.name} <#{user.data['email']}>\"\n @subject = \"Books by Mail Request\"\n\n @title = values['title']\n @bibid = values['bibid']\n @author = values['author']\n @publication = values['publication']\n @callno = values['call_no']\n @volume = values['volume']\n @comments = values[:comments]\n @patronname = user.name \n @patronemail = values['email']\n @pennid = user.data['penn_id']\n\n if Rails.env.development?\n @subject = \"TEST \" + @subject + \" (to: #{@to}, from: #{@from})\"\n @to = ENV['DEVELOPMENT_EMAIL']\n @from = ENV['DEVELOPMENT_EMAIL']\n end\n\n mail(to: @to,\n from: @from,\n subject: @subject,\n template_name: 'confirm_booksbymail')\n end",
"def mailfrom(from_addr); end",
"def send_newsletter(to,sha1_id,from, newsletter_subject, description, newsletter_body)\n recipients to\n from from\n\t\tsubject newsletter_subject\n\t\tbody :description => description, :newsletter_body => newsletter_body, :site => self.site_name,:sha1_id => sha1_id,:url => self.daurl\n sent_on Time.now\n content_type \"text/html\"\n end",
"def create\n \n txtresponse = ''\n to = params[:to]\n subject = params[:subject]\n body = params[:body]\n \n if to.to_s == ''\n\t \ttxtresponse= '\"to\" field missing'\n\t end\t\n if subject.to_s == ''\n\t \ttxtresponse= txtresponse + ' \"subject\" field missing'\n\t end\t\n\t if body.to_s == ''\n\t \ttxtresponse= txtresponse + ' \"body\" field missing'\n end\n if txtresponse == ''\n txtresponse = 'Success'\n end\n \n @sendmail = Sendmail.new(to, subject, body, txtresponse) \n\t \n\t if txtresponse == 'Success'\n UserMailer.send_email(to, subject, body ).deliver\n puts 'Mail Sent'\n respond_to do |format| \n format.json { render :show, status => 200 }\n end\n else\n puts txtresponse\n respond_to do |format| \n format.json { render :show, status: :bad_request}\n end\n end\t \n end",
"def new_request(name_, subject_, content_)\n @subject = subject_\n @name = name_\n @content = content_\n\n mail to: \"[email protected]\", subject: @subject\n #mail to: \"[email protected]\", subject: @subject\n end",
"def send_email(from_name,from_email,to_name,to_email,subject,body)\n # TODO replace with something bulkier and more of a hassle later?\n # TODO it is overspecialized to use the domain name here\n from_domain = \"foodgenome.com\"\n if !from_name || from_name.length < 1\n from_name = \"twitter\"\n from_email = \"twitter@#{from_domain}\"\n end\n begin\n message = \"From: #{from_name} <#{from_email}>\\n\" +\n \"To: #{to_name} <#{to_email}>\\n\" +\n \"Subject: #{subject}\\n\" +\n \"#{body}\\n\"\n Net::SMTP.start('localhost') do |smtp|\n smtp.send_message message, from_email, to_email\n end\n rescue\n # TODO if the email fails we can use this to filter bad users\n end\n end",
"def contact_email(name, email, body)\n @name = name\n @email = email\n @body = body\n \n mail(from: email, subject: 'Contact Form Message')\n end",
"def mailer; end",
"def request_contact\n name = params[:name] # The value of the name field.\n email = params[:email] # The value of the email field.\n telephone = params[:telephone] # The value of the telephone field.\n message = params[:message] # The value of the message field.\n\n if email.blank? # Checks whether an email address has been submitted.\n flash[:alert] = I18n.t('home.request_contact.no_email') # Shows an alert if the email field is empty.\n else\n ContactMailer.contact_email(email, name, telephone, message).deliver_now # Sends an email.\n flash[:notice] = I18n.t('home.request_contact.email_sent') # Shows an notice if email has been sent successfully.\n end\n\n redirect_to root_path # Re-display the root path.\n end",
"def sendmail_book(b)\n mail :to => \"[email protected]\"\n end",
"def email_friend(sent_to,message,subject)\n @message=message\n mail to: '[email protected],'+sent_to,:subject => subject\n end",
"def send(**options)\n cnt = 0\n chkeys = [:subject, :body, :rcpt_to]\n options.keys.each do |k|\n cnt += 1 if chkeys.include?(k)\n end\n return false if cnt != chkeys.length\n \n rcpt = Array.new # send to user-mailaddress\n unless options[:rcpt_to].nil?\n rcpt.push(options[:rcpt_to])\n end\n if options[:mail_from].to_s.strip.empty?\n unless @mlname.empty?\n options[:mail_from] = \"#{@mlname} <#{@mladdr}>\"\n else\n options[:mail_from] = @mladdr\n end\n end\n\n smtpserver = @host # :p\n if smtpserver.to_s.strip.empty?\n emsg = \"unknown mail server (host is empty).\"\n raise MLMailError.new(emsg)\n end\n smtpport = @smtpport\n \n mail = RMail::Message.new\n mail.return_path = options[:return_path]\n mail.from = options[:mail_from]\n mail.to = rcpt\n mail.subject = options[:subject]\n mail.body = options[:body]\n smtpinfos = { :address => smtpserver,\n :port => smtpport,\n :enable_starttls_auto => @starttls }\n if @starttls\n smtpinfos[:authentication] = \"plain\"\n smtpinfos[:user_name] = @username\n smtpinfos[:password] = @password\n end\n mail.delivery_method(:smtp, smtpinfos)\n mail.deliver\n return true\n end",
"def follow_up_alert(email, name, body, body_part2, location_link)\n @name = name \n @body = body\n @body_part2 = body_part2\n @location_link = location_link\n\n mail to: email, subject: \"Follow-up info from Grapevine\", from: \"[email protected]\", reply_to: \n \"[email protected]\"\n\n end"
] | [
"0.72289807",
"0.6862396",
"0.6753879",
"0.67461765",
"0.6633784",
"0.6609428",
"0.65690297",
"0.6566992",
"0.6560881",
"0.65576375",
"0.65518254",
"0.65429914",
"0.6527561",
"0.65186566",
"0.65111893",
"0.65111893",
"0.65089023",
"0.65027213",
"0.64958733",
"0.644438",
"0.6443123",
"0.64379185",
"0.64325005",
"0.64138067",
"0.64024466",
"0.6370585",
"0.636754",
"0.6364685",
"0.6351489",
"0.63463825",
"0.6328422",
"0.6306087",
"0.6289812",
"0.6270708",
"0.6270708",
"0.6270708",
"0.6270708",
"0.6257165",
"0.62492836",
"0.622235",
"0.62189895",
"0.6212754",
"0.61990714",
"0.619432",
"0.6187068",
"0.61681706",
"0.6161822",
"0.61584026",
"0.6154169",
"0.6150117",
"0.61480874",
"0.61459243",
"0.61384314",
"0.61260045",
"0.611134",
"0.61032176",
"0.6091168",
"0.60911334",
"0.60892075",
"0.6083669",
"0.6075345",
"0.60735214",
"0.6070624",
"0.6053808",
"0.6053677",
"0.60489166",
"0.604687",
"0.6044258",
"0.60385346",
"0.60347664",
"0.6030791",
"0.60266054",
"0.6026117",
"0.601945",
"0.6018788",
"0.60185784",
"0.60177636",
"0.5991833",
"0.59807646",
"0.5980154",
"0.5971822",
"0.5971676",
"0.5970542",
"0.59655994",
"0.5957097",
"0.5952922",
"0.5949807",
"0.5947341",
"0.5944836",
"0.5942348",
"0.59417176",
"0.5939604",
"0.5936961",
"0.5934602",
"0.5934249",
"0.5929524",
"0.59281826",
"0.59238935",
"0.59154665",
"0.5910499"
] | 0.7444223 | 0 |
Add more helper methods to be used by all extension tests here... | def with(value)
yield value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def define_helpers; end",
"def test_legacy\n # Set up legacy handlers\n setup_legacy_handling\n\n common_tests\n end",
"def my_tests\n end",
"def helpers(*extensions, &block)\n instance_eval(&block) if block\n extend(*extensions) if extensions.any?\n end",
"def tests; end",
"def tests; end",
"def test_added_methods\r\n assert_respond_to @default_user, :roles\r\n assert_respond_to @default_user, :has_role?\r\n \r\n assert_respond_to @default_user, :permissions\r\n assert_respond_to @default_user, :has_static_permission?\r\n end",
"def self_test; end",
"def self_test; end",
"def test_defaults\n end",
"def helpers(*extensions, &block)\n self.class.helpers(*extensions, &block)\n end",
"def general_mime_magic_specs\n it { is_expected.to contain_apache__mod('mime_magic') }\nend",
"def test_extended\r\n\t\tassert('two'.length == 3)\t\t\t\t\t\t# Boolean expression\r\n\t\tassert_not_equal(\"Expected\", \"Actual\")\t\t\t# != \r\n\t\tassert_raise(ZeroDivisionError) { 2/0} \t\t\t# Exception type\r\n\t\tassert_nothing_raised(ZeroDivisionError) { 2/1 }# Positive if the none of the exceptions raised\r\n\t\tassert_instance_of(String, 23) \t\t\t\t# Checks the object against its type\r\n\tend",
"def default_test; end",
"def testing\n # ...\n end",
"def extensions; end",
"def extensions; end",
"def extensions; end",
"def test_get_content_for\n end",
"def default_test\n end",
"def test_hack\n assert(true)\n end",
"def default_test\n end",
"def test_respond_to\r\n\r\n assert_respond_to @storage, :add\r\n assert_respond_to @storage, :contains?\r\n assert_respond_to @storage, :find\r\n\r\n end",
"def __dummy_test__\n end",
"def default_test\r\n end",
"def test_entry_attrs\n raise 'Implement the method \"test_entry_attrs\" in your test class'\n end",
"def extension; end",
"def extension; end",
"def extension; end",
"def extension; end",
"def helper_method(*methods); end",
"def test_entry_attrs\n raise \"Implement this method in your test class\"\n end",
"def spec; end",
"def spec; end",
"def test_respond_to\n assert_respond_to system_wide, :role\n assert_respond_to system_wide, :role=\n assert_respond_to system_wide, :inspect\n assert_respond_to system_wide, :object_id\n end",
"def file_utils; end",
"def adapter_helpers(adapter)\n adapter.class.ancestors.each_with_object([]) do |klass, ret|\n next unless klass.is_a?(Class)\n next unless klass.const_defined?(HELPERS_MODULE_NAME)\n ret.unshift klass.const_get(HELPERS_MODULE_NAME)\n end\n end",
"def extended(*) end",
"def test_extract_files_and_options\n files, options = public_extract_files_and_options('some')\n assert_equal(['some'], files)\n assert_equal({}, options)\n \n files, options = public_extract_files_and_options('some', 'other')\n assert_equal(['some', 'other'], files)\n assert_equal({}, options)\n \n \n files, options = public_extract_files_and_options('some', 'other', :key => :value)\n assert_equal(['some', 'other'], files)\n assert_equal({:key => :value}, options)\n \n files, options = public_extract_files_and_options('some', 'other', {})\n assert_equal(['some', 'other'], files)\n assert_equal({}, options)\n end",
"def before_test(test); end",
"def before_test(test); end",
"def define_name_helpers; end",
"def test_frameworks; end",
"def include_helpers(scope); end",
"def test_case; end",
"def assertions; end",
"def assertions; end",
"def helpers(helper_name)\r\n extend _package_.load_helper(helper_name)\r\n end",
"def test_method\n end",
"def stest_method_1(test); end",
"def ext; end",
"def ext; end",
"def test_nothing\n end",
"def test_should_eat()\n yay_or_nay = should_eat(\"ice cream\", \"winter\")\n assert_equal(\"False\", should_eat)\n end",
"def test_setup\r\n \r\n end",
"def path_helpers_module; end",
"def prepare_helpers\n base = File.join(config[:test_base_path], \"helpers\")\n\n helper_files.each do |src|\n dest = File.join(sandbox_suites_dir, src.sub(\"#{base}/\", \"\"))\n FileUtils.mkdir_p(File.dirname(dest))\n FileUtils.cp(src, dest, preserve: true)\n end\n end",
"def all_application_helpers; end",
"def should; super end",
"def modules_for_helpers(modules_or_helper_prefixes); end",
"def test_nothing\n end",
"def test_entry\n raise 'Implement the method \"test_entry\" in your test class'\n end",
"def build_test_helper \n \n return if skip_method(__method__)\n \n puts \"build Rails test helper for #{model_name} in test/helpers\"\n filename = \"#{plural_table_name}_helper_test.rb\"\n\n template = File.read(template(\"rails/test/helper_test.rb\"))\n # #text = ERB.new(template, nil, '-').result(binding)\n text = Erubis::Eruby.new(template).evaluate( self )\n\n path = namespaced_path(\"test/helpers\",filename)\n write_artifact(path,text) \n end",
"def compare_tests(test_a, test_b); end",
"def compare_tests(test_a, test_b); end",
"def test_nothing; end",
"def helpers_paths; end",
"def helpers_paths; end",
"def helpers_paths; end",
"def helpers_paths; end",
"def override_test_helper\n if config.dig(\"test_suite\") == \"minitest\"\n template \"templates/minitest_test_helper.tt\", \"test/test_helper.rb\", force: true\n else\n template \"templates/rspec_test_helper.tt\", \"spec/rails_helper.rb\", force: true\n end\n end",
"def application_helpers\n copy_file \"app/helpers/layout_helper.rb\"\n copy_file \"app/helpers/retina_image_helper.rb\"\n copy_file \"app/helpers/meta_tag_helper.rb\"\nend",
"def prepare_helpers\n base = File.join(test_folder, \"helpers\")\n\n helper_files.each do |src|\n dest = File.join(sandbox_path, src.sub(\"#{base}/\", \"\"))\n debug(\"Copying #{src} to #{dest}\")\n FileUtils.mkdir_p(File.dirname(dest))\n FileUtils.cp(src, dest, preserve: true)\n end\n end",
"def require_test_helper\n record_api_supportability_metric(:require_test_helper)\n require File.expand_path('../../../test/agent_helper', __FILE__)\n end",
"def test_entry\n raise \"Implement this method in your test class\"\n end",
"def version_helper; end",
"def version_helper; end",
"def version_helper; end",
"def version_helper; end",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend"
] | [
"0.6966541",
"0.66597885",
"0.66597885",
"0.66597885",
"0.6359399",
"0.62459975",
"0.6241368",
"0.6065263",
"0.60067934",
"0.60067934",
"0.59747875",
"0.59480065",
"0.59480065",
"0.59204155",
"0.59180105",
"0.5897143",
"0.58831435",
"0.5811964",
"0.58118355",
"0.5759587",
"0.5759587",
"0.5759587",
"0.57457733",
"0.5716744",
"0.5706196",
"0.5697311",
"0.5688452",
"0.5675115",
"0.5669201",
"0.5657",
"0.56429327",
"0.56429327",
"0.56429327",
"0.56429327",
"0.5641003",
"0.562682",
"0.56251484",
"0.56251484",
"0.56192577",
"0.5618341",
"0.56104994",
"0.5590755",
"0.55832386",
"0.55656374",
"0.55656374",
"0.55605525",
"0.55470055",
"0.55361503",
"0.55266047",
"0.55219585",
"0.55219585",
"0.5521503",
"0.5519978",
"0.5518801",
"0.55090994",
"0.55090994",
"0.54842496",
"0.54723895",
"0.54635584",
"0.5462094",
"0.54618484",
"0.54335105",
"0.542883",
"0.542049",
"0.5417402",
"0.5416744",
"0.541469",
"0.5406911",
"0.5406911",
"0.5403289",
"0.53900266",
"0.53900266",
"0.53900266",
"0.53900266",
"0.538751",
"0.53846335",
"0.53739613",
"0.5366258",
"0.536538",
"0.5361196",
"0.5361196",
"0.5361196",
"0.5361196",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262",
"0.5358262"
] | 0.0 | -1 |
key is a string of the key you want to retrieve | def find_key(key)
if env_map.has_key?(key)
return { key => env_map[key]}
else
raise 'Key not found!'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key)\n end",
"def get(key)\n \n end",
"def get(key)\n end",
"def fetch(key); end",
"def get key; call key; end",
"def read_key; end",
"def get(key)\n Lib.get @path, @no_follow, key.to_s\n end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def [](key)\n\t\tget key\n\tend",
"def get(namespace, key); end",
"def get(key)\n response = db.get_item(@table_name, {'HashKeyElement' => {'S' => key}})\n get_item_from_body(response.body)\n end",
"def handle_key(key); end",
"def get(key)\n\t\t\t@@driver.get(key.to_s, (key.is_a? Array) ? true : false)\n\t\tend",
"def fetch(*key); end",
"def _get(key)\r\n\t\treturn _get_with_connection(@connection, @store_name, key, true)\r\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def find_by_key(key)\n by_key[key]\n end",
"def find_by_key(key)\n by_key[key]\n end",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def get(key)\n get_all(key).first\n end",
"def parse_key(key)\n end",
"def get key\n\t\t@data_base[ key ]\n\tend",
"def key\n @key\n end",
"def key\n @key\n end",
"def [](key)\n key = convert_key(key)\n regular_reader(key)\n end",
"def get(key)\n db.get(key)\n end",
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def underbang_reader(key); end",
"def [](key)\n fetch(key)\n end",
"def get_item(key)\n self[key]\n end",
"def find_by_key(key)\n find_by('key', key)\n end",
"def get key\n deserialize backend.get key.to_s rescue nil\n end",
"def key=(key); end",
"def get(key)\n @hash[key]\n end",
"def get(key)\n @manager.retrieve(key)\n end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def [](key)\n ruby_get(key&&key.to_s)\n end",
"def get(key)\n send_command([:get, key])\n end",
"def [](key)\n @keychain[key]\n end",
"def get(key)\n @content[key]\n end",
"def get_from_key(key)\n @bucket_key_map[key]\n end",
"def find_by_key(key)\n find_by_id(key) # backlog method looks exactly the same except for the parameter type\n end",
"def get(key)\n @content[key]\n end",
"def get(key)\n @content[key]\n end",
"def handle_key key\n key\n end",
"def key\n @key\n end",
"def key\n @key\n end",
"def key_field\n 'key'\n end",
"def get(key)\n @first.get(key)\n end",
"def get(key)\n @hash.get(key)\n end",
"def get_from_key(key)\n @bucket_key_map[key]\n end",
"def get_by_key(key)\n @store_[key] || YakvdConstants.key_not_found\n end",
"def get(key)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key \n return ele[1]\n end\n end\n end",
"def get key\n @redis.get key\n end",
"def get(key)\n @@list[key]\n end",
"def key(key_id)\n from_resource :key,\n connection.get(api_uri(\"keys/#{key_id}\"))\n end",
"def [](key)\n\n lookup(key.to_s)\n end",
"def key\n @key.id2name\n end",
"def [](key)\n\t\t\t\treturn(lookup(key))\n\t\t\tend",
"def [](key)\n\t\t\t\treturn(lookup(key))\n\t\t\tend",
"def read_key(key)\n raise RuntimeError.new(\"read_key not implemented!\")\n end",
"def [](key)\n load(key)\n end",
"def [](key)\n load(key)\n end",
"def from_simple_key(key)\n key\n end",
"def []( key )\n hash = load_hash\n hash[key]\n end",
"def retrieve key\n\t\tnode = traverse @root, key\n\t\tnode.key\n\tend",
"def get(kind, key)\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](key)\n get(key)\n end",
"def [](*key)\n get(*key)\n end",
"def get_key_value_\n @redis.hget @url, 'key'\n end",
"def map_key(key)\n key\n end",
"def fetch(key)\n @root.fetch(key.upcase.split(\"\"))\n end",
"def [](key)\n data[key.to_s]\n end",
"def get(key)\n return do_get(key, false)\n end"
] | [
"0.83017176",
"0.83017176",
"0.83017176",
"0.83017176",
"0.8286379",
"0.8234236",
"0.81853914",
"0.79365474",
"0.7911228",
"0.77594936",
"0.7671483",
"0.7533836",
"0.75086147",
"0.74500424",
"0.7448539",
"0.7427963",
"0.7424928",
"0.74043584",
"0.73740095",
"0.7365028",
"0.73555464",
"0.73555464",
"0.72963595",
"0.72963595",
"0.7293978",
"0.72916424",
"0.7291361",
"0.7266375",
"0.7266375",
"0.7262541",
"0.7259785",
"0.7249453",
"0.7248889",
"0.721943",
"0.72143495",
"0.7211058",
"0.72063065",
"0.7192387",
"0.71892875",
"0.7171884",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71655226",
"0.71308386",
"0.711019",
"0.7100675",
"0.70914865",
"0.70883685",
"0.7080994",
"0.70612437",
"0.70612437",
"0.704701",
"0.704475",
"0.704475",
"0.70245767",
"0.7023257",
"0.701798",
"0.701747",
"0.701038",
"0.7009838",
"0.7006396",
"0.70044357",
"0.70021915",
"0.7001599",
"0.69933575",
"0.6975853",
"0.6975853",
"0.6974216",
"0.69536495",
"0.69536495",
"0.6932181",
"0.6923373",
"0.6915395",
"0.6912636",
"0.69045484",
"0.69045484",
"0.69045484",
"0.69045484",
"0.6894327",
"0.6892759",
"0.68927336",
"0.6891756",
"0.68899095",
"0.68894327"
] | 0.0 | -1 |
POST /create This means somebody filled out the contact form | def create
@contact_info = params
GeneralMailer.delay.website_contact_form(@contact_info)
flash[:notice] = 'Thank you for your inquery. We\'ll be in touch with you shortly.'
redirect_to "/"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n\t\t@contact = Contact.new()\n\t\[email protected] = params[:fname] \n\t\[email protected] = params[:lname]\n\t\[email protected] = params[:email]\n\t\[email protected] = params[:reason]\n\t\[email protected] = params[:message]\n\t\[email protected]\n\t\t\n\t\trespond_with(@contact)\n end",
"def create\n @contact_form = ContactForm.new(params[:contact_form])\n if @contact_form.deliver\n\t\tredirect_to root_path, :notice => \"Thanks for your message\"\n\telse \t\n\t render \"new\"\t\t\n end\n end",
"def create\n @form_contact = FormContact.new(form_contact_params)\n\n respond_to do |format|\n if @form_contact.save\n format.html { redirect_to @form_contact, notice: 'Your message was successfully sent.' }\n format.json { render :show, status: :created, location: @form_contact }\n else\n format.html { render :new }\n format.json { render json: @form_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n ContactMailer.contact_email(@contact).deliver\n format.html { redirect_to new_contact_url, notice: 'Messaggio inviato!' }\n else\n format.html { render action: 'new' }\n end\n end\n end",
"def create\n\t@contacto = Contacto.new(params[:contacto])\n if @contacto.save\n flash[:success] = \"Se ha enviado su mensaje correctamente.\"\n\t\tredirect_to root_path\n else\n flash[:success] = \"Error. No se ha podido enviar su mensaje.\"\n end\n\n end",
"def create\n @my_contact_form = MyContactForm.new(my_contact_form_params)\n\n respond_to do |format|\n if @my_contact_form.save\n format.html { redirect_to @my_contact_form, notice: 'My contact form was successfully created.' }\n format.json { render :show, status: :created, location: @my_contact_form }\n else\n format.html { render :new }\n format.json { render json: @my_contact_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n ContactMailer.send_contact_form(@contact).deliver_now\n format.html { redirect_to new_contact_path, notice: 'Mensaje enviado exitosamente.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \t@contact = Contact.create(params[:contact])\n \tredirect_to :root, notice: \"Contact Created!\"\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n UserMailer.fale_conosco_enviado(@contact).deliver\n format.html { redirect_to action: \"index\", notice: 'sucess' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # contact_params = mass assignment of form fields into contact object\n @contact = Contact.new(contact_params)\n \n # Saves the Contact object to the database\n if @contact.save\n # We need to retrieve info from contact_params\n # This stores form fields via parameters into variables\n name = params[:contact][:name]\n email = params[:contact][:email]\n body = params[:contact][:comments]\n \n # Send an email to the contact email\n ContactMailer.contact_email(name, email, body).deliver\n \n # Display the success message\n flash[:success] = \"Message sent.\"\n \n # Redirect the user back to the contact page\n redirect_to new_contact_path\n else\n # The error messages comes in as an array. \n # We need to join them together and display them\n flash[:danger] = @contact.errors.full_messages.join(\", \")\n redirect_to new_contact_path\n end\n end",
"def create\n # Mass assignment - masowe przypisanie pól formularza do obiektu Contact\n @contact = Contact.new(contact_params)\n # Zapisz obiekt Contact do bazy danych\n if @contact.save\n # Zachowaj dane z formularza\n # Store form fields via parameters into variables\n name = params[:contact][:name]\n email = params[:contact][:email]\n body = params[:contact][:comments]\n # Wstaw zmienne (variables) do Contact Mailer,\n # do metody email i wyślij email\n ContactMailer.contact_email(name, email, body).deliver\n # Wiadomość o sukcesie w hashu flash\n # i przenieś do nowej akcji\n flash[:success] = \"Message sent.\"\n redirect_to new_contact_path\n else\n # Jesli obiekt Contact sie nie zapisze,\n # zapisz errory do hasha FLASH\n # i redirectuj do new action\n flash[:danger] = @contact.errors.full_messages.join(\", \")\n redirect_to new_contact_path\n end\n end",
"def create\n # Assignment of form fields in to contact object\n @contact = Contact.new(contact_params)\n #Save to the database\n if @contact.save\n # Store form fields via parameters into variables\n name = params[:contact][:name]\n email = params[:contact][:email]\n body = params[:contact][:comments]\n # send via contact mailer\n ContactMailer.contact_email(name, email, body).deliver\n flash[:success] = \"Message sent.\"\n redirect_to contact_us_path\n else\n flash[:danger] = @contact.errors.full_messages.join(\", \")\n redirect_to contact_us_path\n end\n end",
"def create_contact(params={})\n @obj.post('create-contact', @auth.merge(params))\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to thank_you_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contacte = Contacte.new(contacte_params)\n\n respond_to do |format|\n if @contacte.save\n format.html { redirect_to @contacte, notice: 'Contactul s-a adaugat cu succes' }\n format.json { render :show, status: :created, location: @contacte }\n else\n format.html { render :new }\n format.json { render json: @contacte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n ContactMailer.create\n end",
"def create\n @contact = contacts.new(params[:contact])\n\n if @contact.save\n redirect_to contacts_path, notice: '联系人创建成功'\n else\n render action: \"new\"\n end\n end",
"def create\n @contact_form = ContactForm.new(contact_form_params)\n\n respond_to do |format|\n if @contact_form.save\n\n # send an email to our inbox on save of a contact form\n ContactMailer.contact_email(@contact_form).deliver_now\n flash[:success] = \"<strong>Success</strong>\".html_safe + \": Thank you for contacting us.\"\n format.html { redirect_to root_path }\n format.json { render action: 'show', status: :created, location: @contact_form }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n flash[:notice] = @contact.errors.empty? ? \"Your Contact has not been saved\" : \"Your Contact has not been saved because: \" + @contact.errors.full_messages.to_sentence\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n \n \tif @contact.save\n \t\tContactMailer.deliver_message(@contact)\n \tflash[:notice] = 'Σας ευχαριστούμε για το μήνυμα σας.'\n redirect_to :action => :new \n else\n \tflash[:error] = 'Σφάλμα αποστολής μηνύματος. Παρακαλούμε συμπληρώστε τα απαραίτητα πεδία και ξαναδοκιμάστε.'\n redirect_to :action => :new \n end\n end",
"def create\n\t\t@contact = Contact.new(contact_params)\n\t\tif @contact.save\n\t\t\tname = params[:contact][:name]\n\t\t\temail = params[:contact][:email]\n\t\t\tcomment = params[:contact][:comments]\n\t\t\tContactMailer.contact_email(name, email, comment).deliver\n\t\t\tflash[:success] = \"Successfully sent message!\"\n\t\t\tredirect_to new_contact_path\n\t\telse\n\t\t\tflash[:danger] = @contact.errors.full_messages.join(\", \")\n\t\t\tredirect_to new_contact_path\n\t\tend\n\tend",
"def create\n @contact = Contact.new(contact_params)\n if @contact.save\n respond_to do |format|\n format.html { redirect_to new_contact_path, notice: 'Thanks for contacting us, we will get back to you shortly.' }\n format.json { render :show, status: :created, location: @contact }\n end\n else\n flash[:alert] = @contact.errors.full_messages.join(\"<br/>\").html_safe\n render :new\n end\n end",
"def create\n \n # Mass assignment of form fields into Contact object.\n @contact = Contact.new(contact_params)\n \n # Save the contact details into the Database.\n if @contact.save\n # If successful, save into local variables to allow\n # further processing, email.\n name = params[:contact][:name]\n email = params[:contact][:email]\n body = params[:contact][:comments]\n # Plug in the data into the mail message and send\n ContactMailer.contact_email(name, email, body).deliver\n \n # Store success message in flash hash and reset\n # new Contact screen.\n flash[:success] = \"Contact saved.\"\n redirect_to new_contact_path\n else\n # else if contact fails to save,\n # Store reported errors in flash hash and reset\n # new contact screen.\n flash[:danger] = @contact.errors.full_messages.join(\", \")\n redirect_to new_contact_path\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contato foi criado com sucesso.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Contact object is re-assigning to the fields\n # Mass assigment of form fields into Contact object\n @contact = Contact.new(contact_params)\n # Save the Contact object to the database\n if @contact.save\n # If the save is successful\n # Grab the name, email, and comments from the parameters\n # and store them in these variables\n name = params[:contact][:name]\n email = params[:contact][:email]\n body = params[:contact][:comments]\n # Plug variables into Contact Mailer email method and send email\n ContactMailer.contact_email(name, email, body).deliver\n # Store success message in flash hash and redirect to new action\n flash[:success] = \"Message sent.\"\n redirect_to new_contact_path\n else\n # If Contact object doesnt save, store errors in flash hash\n # and redirect to new action\n # Errors will be in an array format\n flash[:danger] = @contact.errors.full_messages.join(\", \")\n redirect_to new_contact_path\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n notify_slack\n format.html { redirect_to finish_contacts_path, notice: '送信しました' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contacts_url, notice: 'Contact was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to new_contact_path, notice: 'We got your info! We\\'ve sent you a copy and we\\'ll get back to you soon.' }\n format.json { render :new, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n if @contact.save\n flash[:success] = \"Contact was successfully created.\"\n redirect_to crm_path\n else\n render :action => 'new'# Clear page\n end\n end",
"def create\n form_key = params.keys.select { |k| k.end_with?('contact_form') }.first\n klass = contact_form_class(form_key)\n @contact = klass.new(params[form_key])\n\n if @contact.valid? && captcha_solved? && @contact.deliver\n flash.delete :error\n flash.now[:notice] = I18n.t('cms.contact_form.sent')\n @contact = nil\n end\n\n @partial_name = klass::PARTIAL_NAME\n rescue NameError => e\n Rails.logger.error \"=====> Error in creating ContactForm: #{e.message} URL: #{request.url} REMOTE_ADDR: #{request.remote_addr}\"\n @contact = nil\n @partial_name = ContactForm.PARTIAL_NAME\n end",
"def create\n @forma_contacto = FormaContacto.new(forma_contacto_params)\n\n respond_to do |format|\n if @forma_contacto.save\n format.html { redirect_to @forma_contacto, notice: 'Forma Contacto was successfully created.' }\n format.json { render :show, status: :created, location: @forma_contacto }\n else\n format.html { render :new }\n format.json { render json: @forma_contacto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact_form = ContactForm.new(params[:contact_form])\n if @contact_form.valid?\n ContactMailer.contact_benvarim(@contact_form).deliver\n flash[:notice] = \"Mesajınız tarafımıza ulaştı. En kısa sürede sizinle iletişime geçeceğiz. Teşekkürler\"\n return redirect_to :action => :index\n else\n render :new\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n @contact.sender = current_user.pseudo\n @contact.state = \"new\"\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to session[:previous_request_url], notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n UserMailer.deliver_contact(@contact)\n UserMailer.deliver_contact_to_user(@contact)\n flash[:notice] = '谢谢您的咨询,我们会尽快回复!'\n format.html { redirect_to contact_path(@contact.serial) }\n format.xml { render :xml => @contact, :status => :created, :location => @contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = ContactForm.new(params[:contact_form])\n\n respond_to do |format|\n if @user.valid?\n # Tell the UserMailer to send a welcome email after save\n ContactFormMailer.notification_email(@user).deliver\n format.html { redirect_to(@user, notice: 'Email was successfully sent.') }\n format.json { render json: \"Email enviado correctamente.\" }\n format.js { render :create }\n else\n logger.error \"ContactForm Errors: @user.errors.full_messages\"\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n format.js { render :create }\n end\n end\n end",
"def create\n @contact = Contact.create!(contact_params)\n if @contact.present?\n # binding.pry\n UserMailer.signup_confirmation(@contact).deliver\n end\n\n respond_with(@contact)\n end",
"def create\n @contact_request = ContactRequest.new(params[:contact_request])\n\n respond_to do |format|\n if @contact_request.save\n ContactRequestMailer.contact_request_submitted(@contact_request).deliver\n format.html { redirect_to new_contact_request_path, notice: 'Contact request was successfully submitted.' }\n format.json { render json: @contact_request, status: :created, location: @contact_request }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contacto = Contacto.new(params[:contacto])\n\n respond_to do |format|\n if @contacto.save\n flash[:notice] = 'El contacto ha sido creado satisfactoriamente.'\n format.html { redirect_to(contactos_url) }\n format.xml { render :xml => @contacto, :status => :created, :location => @contacto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contacto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n @contact.user_id = current_user.id if current_user\n @contact.request = request.headers.env.reject { |content|\n content.inspect.include?('rack') ||\n content.inspect.include?('action_dispatch') ||\n content.inspect.include?('warden') ||\n content.inspect.include?('SERVER') ||\n content.inspect.include?('COOKIE') ||\n content.inspect.include?('cookie') ||\n content.inspect.include?('session') ||\n content.inspect.include?('instance')\n }.inspect\n\n if @contact.save\n flash[:notice] = t('views.message.create.success')\n else\n flash[:alert] = ContactDecorator.flash(@contact, flash)\n end\n redirect_to :back\n end",
"def create\n @contact = Contact.new(contact_params)\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Kontakten skapades, success.' }\n format.json { render action: 'show', status: :created, location: @contact }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact_post = ContactPost.new(contact_post_params)\n\n respond_to do |format|\n if @contact_post.save\n format.html { redirect_to new_contact_post_path, notice: 'Message sent successfully' }\n format.json { render :show, status: :created, location: @contact_post }\n else\n format.html { render :new }\n format.json { render json: @contact_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @welcome.save\n format.html { redirect_to root_path, notice: 'Vielen Dank für die Nachricht.' }\n #format.json { render :show, status: :created, location: @welcome }\n else\n format.html { render root_path}\n #format.json { render json: @welcome.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render action: 'show', status: :created, location: @contact }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_contact\n\t\t@contact = Contact.new(params[:contact])\n\n\t\tif @contact.valid?\n\t\t begin\n\t\t\t ContactMailer.contact_message(@contact).deliver\n\n redirect_to(home_contact_url, notice:\n \"Contact request was successfully submitted.\")\n\n rescue Timeout::Error, Net::SMTP, Net::SMTPAuthenticationError,\n Net::SMTPServerBusy, Net::SMTPSyntaxError, Net::SMTPFatalError,\n Net::SMTPUnknownError => e\n logger.error(\"Unable to send email to: #{@contact.email} - error = #{e}\")\n flash[:alert] = \"Contact delivery error sending email - #{e.message}\"\n redirect_to home_contact_url\n end\n\n\t\telse\n\t\t\t# Create a hash that holds the request options\n\t\t\t@verrors = @contact.errors.full_messages\n\t\t\trender \"contact\"\n\t\tend\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to(@contact, :notice => 'Contact was successfully created.') }\n format.xml { render :xml => @contact, :status => :created, :location => @contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contacts_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n AdminMailer.notification(@contact).deliver_now\n format.html { redirect_to after_save_path, notice: 'Gracias por comunicarte con Beigel Bienes Raices.<br>Un profesional responderá su consulta a la brevedad.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact_form = ContactForm.new(params[:contact_form])\n \n respond_to do |format|\n if @contact_form.valid?\n Contact.deliver_contact(@contact_form)\n flash[:notice] = 'Message succesfully sent.'\n format.html { redirect_to(root_path) }\n #format.xml { render :xml => @contact_form, :status => :created, :location => project_item_path(project, @item) }\n else\n format.html { render :action => \"new\" }\n #format.xml { render :xml => @contact_form.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to edit_contact_path(@contact), notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n contact = Contact.create(contact_params)\n\n if contact.new_record?\n render json: { errors: contact.errors.messages }, status: 422\n else\n render json: contact, status: 201\n end\n end",
"def create\n @contact_message = ContactMessage.new( params[:contact_message])\n if @contact_message.save\n ContactMailer.deliver_confirmation\n flash[:notice] = 'Vielen Dank für Ihre Nachricht.'\n redirect_to(@contact_message)\n else\n render :action => \"new\"\n end\nend",
"def create\n # updating the @contact instance variable with the entered parameters (each user's information) to be saved to the db\n # 'contact_params' is a method that is called (outlined below) that says that we will securely save the entered data into the db\n # AKA: Mass assignment of form fields into Contact object\n @contact = Contact.new(contact_params)\n \n # Save the Contact object to the database\n if @contact.save\n # In order to send the ContactMailer email, we need to lift the parameter values for our instance variables from the params hash\n # From the private function below, we are grabbing :name, :email, and :comments (renamed to body) from the :contact KEY to use in our 'contact_email' method\n name = params[:contact][:name]\n email = params[:contact][:email]\n body = params[:contact][:comments]\n \n # Calls the 'contact_email' method from the contact_mailer.rb file with the above variables, and .deliver it\n ContactMailer.contact_email(name, email, body).deliver\n \n # Setting a specific message (flash) into a hash when the submission was successful\n flash[:success] = [\"Submission Successful\"]\n redirect_to new_contact_path\n else\n # Setting up the flash hash to show any errors that are incurred by concatenating them with a ', '\n # 'errors' method generates raw errors to be displayed when the '@contact.save' method was not successful\n # 'full_messages' method creates nice error messages from the raw 'errors' method that can then be joined\n flash[:danger] = @contact.errors.full_messages\n redirect_to new_contact_path\n end\n end",
"def post_contact\n\t\tcontact = Contact.new\n\t\tcontact.first_name = params[:first_name]\n\t\tcontact.last_name = params[:last_name]\n\t\tcontact.phone_number = params[:phone_number]\n\t\tcontact.email = params[:email]\n\t\tcontact.save\n\t\tcurrent_agendify_user.contacts.push(contact)\n\t\tcurrent_agendify_user.save\n\t\tredirect_to root_path\n\tend",
"def create\n @enquiry = Enquiry.new(enquiry_params)\n\n respond_to do |format|\n if @enquiry.save\n format.html { redirect_to root_path, notice: 'Message was successfully sent.' }\n format.json { render :show, status: :created, location: @enquiry }\n else\n format.html { render :new }\n format.json { render json: @enquiry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n flash[:notice] = 'Contact was successfully created.'\n format.html { redirect_to(@contact) }\n format.xml { render :xml => @contact, :status => :created, :location => @contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n flash[:notice] = 'Contact was successfully created.'\n format.html { redirect_to(@contact) }\n format.xml { render :xml => @contact, :status => :created, :location => @contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n flash[:notice] = 'Contact was successfully created.'\n format.html { redirect_to(@contact) }\n format.xml { render :xml => @contact, :status => :created, :location => @contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n Contact.create(name:params[:name],title:params[:title],content:params[:content],information:params[:information])\n flash[:success] = \"谢谢您对公司的关注,我们会尽快处理您的留言!\"\n redirect_to contacts_path\n\n\n\n end",
"def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n # format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n flash.now[:notice] = 'Thank You for Signing Up.'\n format.html { render :show }\n format.json { render :show, status: :created, location: @contact }\n else\n @allow_change_to_email = true\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Rails.logger.info \"Completed in #{contact_params}\"\n @contact = Contact.new(contact_params)\n @contact.user_id = current_user.id\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Hier ontvangen we de gegevens van de het formulier, met nodige, en eventueel ingevulde velden.\n @contact = Contact.new(contact_params)\n \n if @contact.save\n # Ontvangen gegevens (uit een hash) terug in tijdelijke variabelen steken, om dan de contact in te vullen in email dmv \"deliver\".\n name = params[:contact][:name]\n email = params[:contact][:email]\n body = params[:contact][:comments]\n\n # contact_mailer zal dan die tijdelijke variabelen gebruiken.\n # Die zal ze in een andere variablenen steken, met een @ voor, zoals @name.\n ContactMailer.contact_email(name, email, body).deliver\n\n # Bij naam geven van een FLASH-gebreurtenissen best woorden gebruiken die ook bij BOOTSTRAP gebruitk wordt.\n # Hier gebruiken we \"succes\" en \"danger\".\n # Dan kunnen we die naam van de FLASH gebruiken als variabele om een \"stijl\" te benoemen.\n # Met een andere Random naam werkt het even goed, maar dan moet je nog de stijl appart gaan toevoegen = extra code = trager.\n flash[:success] = 'Message sent.'\n redirect_to new_contact_path\n else\n flash[:danger] = 'Error occured, message has not been sent.'\n redirect_to new_contact_path\n end\n end",
"def create\n \n @contact = Contact.new(params[:contact])\n \n if @contact.save\n render :json => { :success => true, :message => \"Created new contact #{@contact.id}\", :contact => @contact }\n else\n render :json => { :success => false, :message => \"Failed to create contact\"}\n end\n \n # @contact = Contact.new(params[:contact])\n # \n # respond_to do |format|\n # if @contact.save\n # format.html { redirect_to(@contact, :notice => 'Contact was successfully created.') }\n # format.xml { render :xml => @contact, :status => :created, :location => @contact }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n # end\n # end\n end",
"def create\n @site_contact = SiteContact.new(params[:site_contact])\n\n respond_to do |format|\n if @site_contact.save\n format.html { redirect_to @site_contact, notice: 'Site contact was successfully created.' }\n format.json { render json: @site_contact, status: :created, location: @site_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if verify_google_recaptsha(Rails.application.secrets.recaptsha_secret_key, params['g-recaptcha-response'])\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Yhteydenotto lähetetty!.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n\n else\n redirect_to contactp_path, alert: 'Botti :('\n end\n\n end",
"def create\n @user_contact = UserContact.new(user_contact_params)\n\n respond_to do |format|\n if @user_contact.save\n format.html { redirect_to @user_contact, notice: 'User contact was successfully created.' }\n format.json { render :show, status: :created, location: @user_contact }\n else\n format.html { render :new }\n format.json { render json: @user_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(contact_params)\n\n if @contact.save\n render json: @contact, status: :created, location: @contact\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end",
"def create\n @contact_us_email = ContactUsEmail.new(params[:contact_us_email])\n\n respond_to do |format|\n if @contact_us_email.save\n\t ContactMailer.send_contact_us_email(@contact_us_email).deliver\n format.html { redirect_to(@contact_us_email, :notice => 'Thank you for your email. We will review it soon.') }\n format.xml { render :xml => @contact_us_email, :status => :created, :location => @contact_us_email }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact_us_email.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contactos = Contactos.new(params[:contactos])\n\n respond_to do |format|\n if @contactos.save\n flash[:notice] = 'Contactos was successfully created.'\n format.html { redirect_to(@contactos) }\n format.xml { render :xml => @contactos, :status => :created, :location => @contactos }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contactos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = @user.contacts.build(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to root_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_contact = UserContact.new(params[:user_contact])\n\n respond_to do |format|\n if @user_contact.save\n format.html { redirect_to(@user_contact, :notice => 'UserContact was successfully created.') }\n format.xml { render :xml => @user_contact, :status => :created, :location => @user_contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\r\n\t\t@contact = current_user.contacts.new(contact_params)\r\n\t\t\r\n\t\tif @contact.save\r\n\t\t\tflash[:success] = \"New Contact Added\"\r\n\t\t\tredirect_to @contact\r\n\t\telse\r\n\t\t\trender 'new'\r\n\t\tend\r\n\tend",
"def create\n body = message_params[:Body]\n phone_number = message_params[:From]\n @message = Message.create(body: body, phone_number: phone_number)\n @message.reply_to_user\n head :ok\n end",
"def new(contact)\n @contact = contact\n mail :subject => \"Contact Form Completed (#{SITE_SETTINGS[\"Name\"]})\"\n end",
"def create\n @contact_method = ContactMethod.new(contact_method_params)\n\n respond_to do |format|\n if @contact_method.save\n format.html { redirect_to @contact_method, notice: 'Contact method was successfully created.' }\n format.json { render :show, status: :created, location: @contact_method }\n else\n format.html { render :new }\n format.json { render json: @contact_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Rails.logger.info params\n render status: :ok\n # @enquiry = Enquiry.new(enquiry_params)\n\n # respond_to do |format|\n # if @enquiry.save\n # format.html { redirect_to @enquiry, notice: 'Enquiry was successfully created.' }\n # format.json { render json: @enquiry, status: :created }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @enquiry.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @contact = Contact.new(params.require(:contact).permit(:name, :email, :subject, :message))\n\n respond_to do |format|\n if @contact.save\n # Tell the ContactMailer to send a welcome email after save\n ContactMailer.contact_email(@contact).deliver_later\n\n format.html {\n redirect_to('/'+I18n.default_locale.to_s+'/contact', alert: 'success', notice: 'Message was successfully submitted.')\n }\n format.js {render 'form', locals: {alert: 'success', notice: 'Message was successfully submitted.'}} #default behaviour is to run app/views/contact/create.js.erb file\n format.json {\n render json: @contact, status: :created, location: @contact\n }\n else\n error = @contact.errors.any? ? @contact.errors.full_messages[0] : 'Message failed to submit.'\n format.html {\n flash.now[:alert] = 'danger'\n flash.now[:notice] = error\n render action: 'form'\n }\n format.js {render 'form', locals: {alert: 'danger', notice: error}}\n format.json {\n render json: @contact.errors, status: :unprocessable_entity\n }\n end\n end\n end",
"def create\n @emailcontact = Emailcontact.new(params[:emailcontact])\n\n respond_to do |format|\n if @emailcontact.save\n format.html { redirect_to(@emailcontact, :notice => 'Emailcontact was successfully created.') }\n format.xml { render :xml => @emailcontact, :status => :created, :location => @emailcontact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @emailcontact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def contact_pidgin\n\t\t@contact = Contact.new\n\t\[email protected] = params[:name]\n\t\[email protected] = params[:email]\n\t\[email protected] = params[:subject]\n\t\[email protected]_message = params[:message]\n\t\[email protected]\n\tend",
"def create\n @contact = Contact.new(params[:contact])\n @user = current_user_session.user\n @contact.user_id = @user.id\n \n if @contact.save\n ContactMailer.contact_confirmation(@user, @contact).deliver \n redirect_to contacts_url, notice: 'Contact was successfully created.' \n else\n render action: \"new\"\n end\n end",
"def create\n @contact = Contact.new(params[:contact].merge(:created_by => current_user.id)) \n respond_to do |format|\n if @contact.save\n @contact.client.my!(current_user) if @firm.free? || current_user.is_first_manager?\n format.html { redirect_to client_contacts_path(@firm), :notice => \"Новый #{ Contact.model_name.human } успешно создан.\" }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to(admin_contacts_url :notice => 'Contact was successfully created.') }\n format.xml { render :xml => @contact, :status => :created, :location => @contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = @resource.contacts.build(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to(@resource, :notice => 'Contact was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n\t\t@contact = Contact.new(contact_params)\n\n\t\trespond_to do |format|\n\t\t\tif @contact.save\n\t\t\t\tformat.html { redirect_to user_contacts_path, notice: 'Contact was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @contact }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render json: @contact.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @entity_contact = EntityContact.new(params[:entity_contact])\n\n respond_to do |format|\n if @entity_contact.save\n format.html { redirect_to @entity_contact, notice: 'Entity contact was successfully created.' }\n format.json { render json: @entity_contact, status: :created, location: @entity_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contacts = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contacts.save\n flash[:notice] = 'Mensagem enviada com sucesso.'\n format.html { redirect_to(root_path) }\n format.xml { render :xml => @contacts, :status => :created, :location => @contacts }\n else\n flash[:notice] = \"Erro ao enviar mensagem\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contacts.errors }\n end\n end\n end",
"def create\n @contactinfo = Contactinfo.new(params[:contactinfo])\n\n respond_to do |format|\n if @contactinfo.save\n format.html { redirect_to @contactinfo, notice: 'Contactinfo was successfully created.' }\n format.json { render json: @contactinfo, status: :created, location: @contactinfo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contactinfo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_contact(options = {})\n post(:contacts, contacts: [options]).pop\n end",
"def create\n @form_message = FormMessage.new(form_message_params)\n respond_to do |format|\n if @form_message.save\n ContactQueryMailer.new_contact_query(@form_message).deliver_now\n format.html { redirect_to root_path, notice: 'Thanks for contacting us. We’ll get back to you in the next 12 hours.' }\n format.json { render :root, status: :created, location: @form_message}\n else\n format.html { render :new }\n format.json { render json: @form_message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n klass = Contact.create_model_class(params[:contact][:klaas], params[:contact])\n \n @contact = klass.new(contact_params)\n debugger\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contact_url @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: (contact_url @contact) }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @person_contact = PersonContact.new(params[:person_contact])\n\n respond_to do |format|\n if @person_contact.save\n format.html { redirect_to(@person_contact, :notice => 'Person contact was successfully created.') }\n format.xml { render :xml => @person_contact, :status => :created, :location => @person_contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @person_contact.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @contactperson_email = ContactpersonEmail.new(contactperson_email_params)\n\n respond_to do |format|\n if @contactperson_email.save\n format.html { redirect_to @contactperson_email, notice: 'Contactperson email was successfully created.' }\n format.json { render :show, status: :created, location: @contactperson_email }\n else\n format.html { render :new }\n format.json { render json: @contactperson_email.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end"
] | [
"0.77107054",
"0.76763564",
"0.7523418",
"0.7508727",
"0.7472217",
"0.74500203",
"0.7444583",
"0.74211144",
"0.74095815",
"0.7352242",
"0.7344172",
"0.7334178",
"0.7327714",
"0.72949445",
"0.7289816",
"0.7280939",
"0.72682154",
"0.72604793",
"0.7252345",
"0.72436917",
"0.7243641",
"0.7232881",
"0.7229758",
"0.7226388",
"0.7215769",
"0.7206878",
"0.71993625",
"0.7196234",
"0.7195102",
"0.71926653",
"0.7177433",
"0.71744996",
"0.71696436",
"0.7163859",
"0.7158835",
"0.71476334",
"0.71248645",
"0.71173495",
"0.71053725",
"0.7105124",
"0.70995295",
"0.70995295",
"0.70995295",
"0.70995295",
"0.70995295",
"0.70995295",
"0.7085021",
"0.7076037",
"0.7059883",
"0.70501",
"0.70250964",
"0.7008111",
"0.70030814",
"0.6997382",
"0.69923896",
"0.696876",
"0.696583",
"0.6948164",
"0.6942994",
"0.69347966",
"0.69311875",
"0.6928248",
"0.6914124",
"0.6914124",
"0.6914124",
"0.69056",
"0.6874715",
"0.6873216",
"0.686823",
"0.6838264",
"0.6833381",
"0.6830403",
"0.6820085",
"0.68158644",
"0.6797579",
"0.67867875",
"0.6765161",
"0.6751976",
"0.67512035",
"0.67510337",
"0.67490876",
"0.6747688",
"0.6742278",
"0.67352617",
"0.6734257",
"0.67334753",
"0.67309004",
"0.6727257",
"0.6727013",
"0.67119265",
"0.6711263",
"0.66995454",
"0.6694409",
"0.6686523",
"0.6683565",
"0.66719836",
"0.6670673",
"0.66674364",
"0.66652656",
"0.66646767"
] | 0.68371785 | 70 |
Returns nil if no such key | def retrieve key
node = traverse @root, key
node.key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def key\n @key or raise MissingKey\n end",
"def [](key)\n entry = find_entry(key)\n return(entry.nil? ? nil : entry[1])\n end",
"def find(key)\n # TODO(himanshujaju) - possible improvement by not checking for contains.\n if contains?(key)\n return @key_data[key].value\n end\n\n return nil\n end",
"def get_by_key(key)\n @store_[key] || YakvdConstants.key_not_found\n end",
"def get_single_key(key)\n key = @size+key if key < 0\n r = @results[key]\n unless r.nil? && key < @size\n r\n else\n retrieve_for_index(key)\n @results[key]\n end\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def first_key\n first = node_next(@head, 0)\n return first ? first[1] : nil\n end",
"def first_key\n first = node_next(@head, 0)\n return first ? first[1] : nil\n end",
"def get_first_key(hash)\n return \nend",
"def get(key)\n a_hash[key] || -1 \n end",
"def try_get(namespace, key)\n begin\n return get(namespace, key)\n rescue ItemNotFoundError\n return nil\n end\n end",
"def key\n `return #{self}.__key__ || #{nil};`\n end",
"def get(key)\n end",
"def find_key(key)\n leaf, stack = walk_towards_key(key)\n return nil if leaf && leaf.peek_item.key != key\n leaf\n end",
"def read_key; end",
"def get(key)\n end",
"def get(key)\n get_all(key).first\n end",
"def obtain!(key)\n raise \"Missing key #{key}\" unless @hash.key?(key)\n @hash[key]\n end",
"def fetch(key); end",
"def get(key)\r\n\t\treturn nil if !key\r\n\t\t# Get the hash of our key\r\n\t\tindex = key.hash % @size\r\n\t\t# If location in array is empty then return nil otherwise find the \r\n\t\t# key and return associated value from the list\r\n\t\treturn nil if !@arr[index]\r\n\t\treturn @arr[index].find(key)\r\n\tend",
"def required key\n if !has?(key)\n $stderr.print self\n raise \"Key #{key} does not exist\"\n end\n self[key]\n end",
"def get(key)\n position = find(key)\n if position != nil\n @values[position]\n else\n nil\n end\n end",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def [](key)\n if @items[index(key, @items.length)] != nil && @items[index(key, @items.length)].key == key\n puts @items.length\n return @items[index(key, @items.length)].value\n else\n puts \"This value does not exist in the hash\"\n end\n end",
"def get_key(hash, key)\n if hash.has_key? key\n return hash[key]\n else\n raise \"key '#{key}' was expected but not found in #{hash}\"\n end\n end",
"def [](key)\n current_node = @buckets[index(key, size)].head\n if !current_node\n #raise InvalidKeyError \"Cannot retrieve that item - not instantiated\"\n return nil\n end\n while current_node.key != key\n current_node = current_node.next\n break unless current_node\n end\n\n if !current_node\n #raise InvalidKeyError \"Cannot retrieve that item - not instantiated\"\n return nil\n end\n\n return current_node.value\n end",
"def get(key)\n \n end",
"def find_by_key(key)\n by_key[key]\n end",
"def find_by_key(key)\n by_key[key]\n end",
"def get(key)\n found = @hash[key]\n\n if found\n @list.move_node_to_head(found)\n return found\n end\n\n -1\n end",
"def get_key(data)\n\t\t keys = data.keys\n\t\t if keys.length != 1 || INDICES.none? { |key| key.to_sym == keys.first.to_sym }\n\t\t raise ArgumentError.new(\"`find_by` accepts only one of #{INDICES.join(\" or \")} as argument. none provided\")\n\t\t end\n\t\t keys.first\n\t\t end",
"def has_key?(p0) end",
"def get_key(key, default: nil, error: false)\n if(has_key?(key))\n return self[key]\n end\n \n raise ArgumentError.new(\"Value #{key} not found.\") unless !error\n return default\n end",
"def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end",
"def find(key)\n if !contains?(key)\n return nil\n end\n\n @semaphore.synchronize {\n @internal_clock += 1\n previous_data = @key_data[key]\n update_access_time_locked(key, @internal_clock, previous_data.access_time)\n\n return previous_data.value\n }\n end",
"def search key\r\n #start searching from the head (if the head is NULL, get out of the function and return NULL)\r\n node = @head\r\n #while there's still any unsearched node in the list (you haven't reach the end of the list) and the wanted node hasn't been found\r\n while (node != nil) && (node.get_value != key)\r\n #search the wanted node linearly using the next pointer\r\n node = node.get_next_node\r\n #You MUST keep the order of the logical checking or you'll get an error for trying to check the key of NULL\r\n end\r\n #return a pointer to the wanted node (if no node with the key appears in the list, this will return NULL)\r\n return node\r\n end",
"def key\n attributes['key'] or raise NoKeySpecified\n end",
"def get!(key)\n get(key) || raise(Cooler::KeyNotFound)\n end",
"def key\n @keys.last or raise \"No key specified for collectible! (#{__FILE__}, #{__LINE__})\"\n end",
"def read(key)\n exists?(key) ? @data[key] : nil\n end",
"def get_key(data)\n keys = data.keys\n if keys.length != 1 || INDICES.none? { |key| key.to_sym == keys.first.to_sym }\n raise ArgumentError, \"`find_by` accepts only one of #{INDICES.join(' or ')} as argument. None provided\"\n end\n\n keys.first\n end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def key?(key); end",
"def get(key)\n position = search(key)\n return nil if (key <=> @keys[position]) != 0\n @values[position]\n end",
"def get key\n deserialize backend.get key.to_s rescue nil\n end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def get key\n\t\t\tif @my_hash.has_key? key\n\t\t\t\tnode = @my_hash[key]\n\t\t\t\t@my_list.promote_node node\n\t\t\t\tnode.value\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\tend",
"def get(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n return @a[row][column][1] \n else\n return -1\n end\n end",
"def extract_key(obj, key)\n if obj.respond_to?(:key?) && obj.key?(key)\n obj[key]\n elsif obj.respond_to?(:each)\n r = nil\n obj.find{ |*a| r=extract_key(a.last,key) }\n r\n end\n end",
"def has_key?(key)\n dummy = Pair.new(key,nil)\n return @tree.get(dummy)\n end",
"def get_key(data)\n keys = data.keys\n if keys.length != 1 || INDICES.none? { |key| key.to_sym == keys.first.to_sym }\n raise ArgumentError, \"`find_by` accepts only one of #{INDICES.join(' or ')} as argument. none provided\"\n end\n\n keys.first\n end",
"def [](key)\n\t\t\t\treturn(lookup(key))\n\t\t\tend",
"def [](key)\n\t\t\t\treturn(lookup(key))\n\t\t\tend",
"def key\n self.keys.first\n end",
"def get_key(id)\n @keys[id]\n end",
"def has_key?(key); end",
"def has_key?(key); end",
"def lookup(key)\n if key_pair = pair(key, hash(key))\n key_pair[1]\n end\n end",
"def get(key)\n key = normalize(key) or return\n table[key]\n end",
"def find_key(name)\n debug \"Finding key #{name}\"\n user.find_key(name) or raise RHC::KeyNotFoundException.new(\"Key #{name} does not exist\")\n end",
"def find(key)\n if root.nil?\n return nil\n else\n root.find(key)\n end\n end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def get(key)\n self.map_var.each do |pair|\n return pair[1] if pair[0] == key\n end\n nil\n end",
"def get key; call key; end",
"def get(key)\n index = key_index(key)\n if( index )\n self.values.get(index)\n else\n nil\n end\n end",
"def find_key(name)\n logger.debug \"Finding key #{name}\" if @mydebug\n user.keys.each { |key| return key if key.name == name }\n\n raise RHC::KeyNotFoundException.new(\"Key #{name} does not exist\")\n end",
"def key\n @key\n end",
"def key\n @key\n end",
"def [](key)\n result = default(key)\n result ? result.value : nil\n end",
"def key?\n @key\n end",
"def key?\n @key\n end",
"def key_pair(key_name)\n key_pairs(key_name)[0]\n end"
] | [
"0.7865293",
"0.7541485",
"0.73830056",
"0.7199287",
"0.7106905",
"0.70677984",
"0.70454776",
"0.70454776",
"0.70454776",
"0.70454776",
"0.7006005",
"0.7006005",
"0.6967451",
"0.6913904",
"0.6908253",
"0.68922406",
"0.6887032",
"0.6873208",
"0.68594354",
"0.6837338",
"0.6833043",
"0.68329364",
"0.68011194",
"0.67892784",
"0.67818695",
"0.6766751",
"0.675196",
"0.675196",
"0.6747203",
"0.6743155",
"0.6737814",
"0.67332816",
"0.66912395",
"0.66912395",
"0.6690921",
"0.6683033",
"0.66662204",
"0.66525966",
"0.6642386",
"0.6637991",
"0.6628484",
"0.66040736",
"0.6603291",
"0.65989083",
"0.658023",
"0.6577187",
"0.65724695",
"0.65724695",
"0.65724695",
"0.65724695",
"0.65724695",
"0.65724695",
"0.65681726",
"0.65538216",
"0.6542898",
"0.6526093",
"0.651565",
"0.65016335",
"0.649566",
"0.64814955",
"0.6476746",
"0.6476746",
"0.6472662",
"0.64647347",
"0.64563835",
"0.64563835",
"0.6451006",
"0.6446689",
"0.64374083",
"0.64372313",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64362276",
"0.64342624",
"0.64051294",
"0.6394764",
"0.6389656",
"0.6380638",
"0.6380638",
"0.63794756",
"0.63787895",
"0.63787895",
"0.6360905"
] | 0.6485357 | 59 |
== CANCAN Authorization == | def ability
@ability ||= Admin::SystemAdminAbility.new(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize\n end",
"def authorize\n end",
"def authorization; end",
"def authorization(*args, &block); end",
"def authorize(options = {})\r\n # full_res_file_access = ['10.128.99.55','10.128.1.167','10.224.6.10','10.128.99.167','10.128.98.50','10.224.6.26','10.224.6.35','172.16.1.94', '66.234.38.35']\r\n #'65.88.88.115'\r\n # logger = Java::edu.illinois.library.cantaloupe.script.Logger\r\n # logger.debug(\"CONTEXT HASH: #{context}\")\r\n # logger.debug(\"REQUEST URI: #{context['request_uri']}\")\r\n if context['request_uri'].include?(\"info.json\") \r\n true\r\n else \r\n type = is_region?()? \"full_res\" : derivative_type(context['resulting_size'])\r\n # logger.debug(\"TYPE: #{type}\")\r\n rights = get_rights(context['identifier'], context['client_ip'])\r\n allowed = returns_rights?(rights) && is_not_restricted?(rights, type)\r\n # logger.debug(\"ALLOWED? #{allowed}\")\r\n allowed\r\n end\r\n end",
"def sscan(*arguments)\n\t\t\t\t\tcall(\"SSCAN\", *arguments)\n\t\t\t\tend",
"def check_auth\n authorize @equipment_listing\n end",
"def host_authorization; end",
"def host_authorization; end",
"def authorize_access\r\n # authorize!(action_name.to_sym, \"#{controller_name}_controller\".camelcase.constantize)\r\n end",
"def authorization_mode; end",
"def authorize(amount, card_number, card_expiry, cvv, reference, customer_ip)\n\t\t\traise \"Sorry we haven't compelted this functionality yet.\"\n\t\tend",
"def has_access? c\n access_rights[controller2right c] == '1'\n end",
"def authorize \n self.make 'authorization' \n end",
"def authorize_ip_address(ip)\n authorize_cidrip(\"#{ip}/32\")\n end",
"def authorize!\n response = till_response { send_raw_request(authorization_params) }\n raise AuthenticationError.new(\"Could not authenticate with Zabbix API at #{uri}: #{response.error_message}\") if response.error?\n raise AuthenticationError.new(\"Malformed response from Zabbix API: #{response.body}\") unless response.string?\n @auth = response.result\n end",
"def authorize_pot\n authorize @pot, :contribute?\n end",
"def authorizer\n current_ability\n end",
"def authorize_me\n authorize_ip_address(Fog::CurrentMachine.ip_address)\n end",
"def authorize(_subject, _auth)\n false\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 can?(auth, resource_type = :general)\n has_access_to? :access, resource_type, auth\n end",
"def authorize(ctrl = params[:controller], action = params[:action])\n company = current_company\n company_groups = company.groups\n current_groups = company_groups & current_user.groups\n if company.nil?\n allowed = false\n elsif current_user.groups.nil?\n allowed = false\n elsif current_groups\n allowed = current_user.allowed_to?(current_user, {:controller => ctrl, :action => action}, company)\n else\n allowed = false\n end\n\n allowed ? true : deny_access\n end",
"def authorize (permission_name)\n self.allowances.detect {|a| a.permission.name == permission_name.to_s}\n end",
"def authorize\n \n token = decode_token(@auth_header)\n data = get_canvas_data(@canvas, token.first[\"user_id\"])\n \n data[\"group_id\"] == token.first[\"group_id\"] && data[\"has_access\"] == \"true\"\n \n rescue StandardError => _\n false\n end",
"def authorized?\n true\n end",
"def authorize channel_key\n @conn.send_data :opcode => AUTHORIZE, :channel => @name, :data => channel_key.to_s\n end",
"def test_authorization_and_capture\n assert authorization = @gateway.authorize(100, @good_creditcard)\n assert authorization.success?\n \n assert capture = @gateway.capture(100, authorization.authorization)\n assert capture.success?\n assert_equal 'Success', capture.message\n end",
"def host_authorization=(_arg0); end",
"def host_authorization=(_arg0); end",
"def authorize(verb); send_or_default(\"authorize_#{verb}\",true) ; end",
"def pre_authorize_cb; end",
"def authorize subscriber, node\n true\n end",
"def authorize\n action = {:controller => params[:controller], :action => params[:action]}\n allowed = User.current.allowed_to?(action, project = nil, options={:global => true})\n allowed ? true : deny_access\n end",
"def authorize\n action = {:controller => params[:controller], :action => params[:action]}\n allowed = User.current.allowed_to?(action, project = nil, options={:global => true})\n allowed ? true : deny_access\n end",
"def initialize(user)\n\n # The first argument to `can` is the action you are giving the user\n # permission to do.\n # If you pass :manage it will apply to every action. Other common actions\n # here are :read, :create, :update and :destroy.\n #\n # The second argument is the resource the user can perform the action on.\n # If you pass :all it will apply to every resource. Otherwise pass a Ruby\n # class of the resource.\n #\n # The third argument is an optional hash of conditions to further filter the\n # objects.\n # For example, here the user can only update published articles.\n #\n # can :update, Article, :published => true\n #\n # See the wiki for details:\n # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities\n\n user ||= User.new\n\n # we don't do role inheritance b/c I have a sneaking feeling we\n # will want more fine-grained control for our roles as the system\n # grows.\n\n\n if ['contributor', 'editor', 'super_editor', 'admin'].member? user.role\n can [:edit, :update, :show], :all, :created_by_id => user.id\n can :create, DericciLink\n\n can :destroy, [Comment, Reply], :created_by_id => user.id\n cannot :manage, Page\n\n can :link, :all\n can :unlink, :all, :created_by_id => user.id\n can :history, :all\n\n can [:index, :new], DericciGame\n can :index, [Entry, Source, Manuscript, Comment]\n\n can :manage, PrivateMessage, :created_by_id => user.id\n can :manage, PrivateMessage do |pm|\n pm.users.include? user\n end\n can :manage, Rating\n cannot [:import, :upload], Entry\n end\n\n if ['editor', 'super_editor', 'admin'].member? user.role\n can :unlink, :all\n can :edit, Manuscript\n can :manage, DericciRecord\n\n cannot :deprecate, :all\n can :manage, Name\n cannot :review, Name\n # this needs to be RE-Established, since it has been overriden by line 51\n can :edit, :all, :created_by_id => user.id\n cannot :manage, Page\n end\n\n if ['super_editor'].member? user.role\n # allow super-editors to edit legacy records\n can [:edit, :update, :verify, :deprecate], Entry, :unverified_legacy_record => true\n can [:edit, :update], Source, :legacy => true\n can :manage, Place\n can :manage, Language\n end\n\n if ['admin'].member? user.role\n can :manage, :all\n can :update_type, Source\n end\n\n can [:edit, :update], Entry, contributors: { :id => user.id }\n cannot :manage, [Group]\n can [:edit, :update, :destroy], Group, admin: { :id => user.id }\n can [:destroy], Entry, {created_by_id: user.id, draft: true}\n\n can :show, Entry\n cannot :show, Entry do |entry|\n (entry.created_by != user && !entry.contributors.include?(user)) && entry.draft\n end\n end",
"def test_authorization_and_capture\n assert authorization = @gateway.authorize(@amount, @good_card, @options)\n assert_success authorization\n\n assert capture = @gateway.capture(@amount, authorization.authorization)\n assert_success capture\n assert capture.params['aux_msg'].include? 'has been successfully marked for settlement.'\n assert_equal 'Success', capture.message\n end",
"def can_certify\n authorize! :certify, @registration\n end",
"def authorization_checking\n authorize!(:authorization_checking,current_user) unless current_user.role?(:livia_admin) || current_user.role?(:lawfirm_admin)\n end",
"def authorize?(user)\n true\n end",
"def authorize_patron\n unless current_user.nil?\n if current_user.admin? or current_user.override_access? or current_user.authorized?\n return true\n else\n render 'errors/unauthorized_patron'\n end\n else\n redirect_to login_url(origin: request.url) unless performed?\n end\n end",
"def check_authorization\r\n params[:table] ||= params[:t] || CmsHelper.form_param(params)\r\n # Only show menu\r\n return login if params[:id].in?(%w(login logout test))\r\n\r\n table = params[:table].to_s.strip.downcase\r\n set_default_guest_user_role if session[:user_roles].nil?\r\n # request shouldn't pass\r\n if table != 'dc_memory' and \r\n (table.size < 3 or !dc_user_can(DcPermission::CAN_VIEW))\r\n return render(action: 'error', locals: { error: t('drgcms.not_authorized')} )\r\n end\r\n dc_form_read\r\n\r\n # Permissions can be also defined on form\r\n #TODO So far only can_view is used. Think about if using other permissions has sense\r\n can_view = @form.dig('permissions','can_view')\r\n if can_view.nil? or dc_user_has_role(can_view)\r\n extend_with_control_module\r\n else\r\n render(action: 'error', locals: { error: t('drgcms.not_authorized')} )\r\n end \r\nend",
"def pre_authorize_cb=(_arg0); end",
"def allow?(packet); end",
"def find_borrowership\n @borrowership = @car.borrowerships.find(params[:id])\n authorize @borrowership\n end",
"def authorize_users\n authorize :user\n end",
"def needs_authorization?\n true\n end",
"def authorize!\n if current_user && current_user.clearance_level > 1\n return true\n else\n respond_to do |format|\n format.html do\n redirect_to main_app.new_session_path\n end\n format.json do\n render status: 403, nothing: true\n end\n end\n end\n end",
"def authorize\r\n # check if action is allowed on public projects\r\n if @project.is_public? and Permission.allowed_to_public \"%s/%s\" % [ @params[:controller], @params[:action] ]\r\n return true\r\n end \r\n # if action is not public, force login\r\n return unless require_login \r\n # admin is always authorized\r\n return true if self.logged_in_user.admin?\r\n # if not admin, check membership permission \r\n @user_membership ||= Member.find(:first, :conditions => [\"user_id=? and project_id=?\", self.logged_in_user.id, @project.id]) \r\n if @user_membership and Permission.allowed_to_role( \"%s/%s\" % [ @params[:controller], @params[:action] ], @user_membership.role_id ) \r\n return true\t\t\r\n end\t\t\r\n render :nothing => true, :status => 403\r\n false\r\n end",
"def authorize_action\n YamledAcl.init(current_user_group_name, params[:controller])\n allowed_to?(params[:action]) or raise(YamledAcl::AccessDenied)\n end",
"def authorize\n authorization_check(params[:controller], params[:action], request.request_method.downcase, self) || unauthorized\n end",
"def authorize!\n api_key = ApiKey.find_by_access_token(params[:access_token])\n head :unauthorized unless api_key\n return false\n end",
"def authorize_access(url,param_value=nil)\n\t user = User.find(current_user.id)\n\n\t # if @split_tax_and_non_tax_transaction == 1\n\t if param_value.present?\n\t if param_value.to_s == 'x' || param_value.to_s == 'l' || param_value.to_s == 'm'\n\t\t status = authorize_url(\"/#{url}?tt=#{param_value.to_s}\")\n\t\t elsif param_value.is_a? Integer\n\t\t \tstatus = authorize_url(\"/#{url}?type=#{param_value.to_i}\")\n\t\t else\n\t\t \tstatus = authorize_url(\"/#{url}\")\n\t\t \tend\n\t else\n\t status = authorize_url(\"/#{url}\")\n\t end\n\t # else\n\t # status = authorize_url(\"/#{url}\")\n\t # end\n\n\t if status == false\n\t raise CanCan::AccessDenied\n\t end\n\tend",
"def authorized?\n true\n end",
"def authorize(ctrl = params[:controller], action = params[:action], global = false)\n allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project, :global => global)\n allowed ? true : deny_access\n end",
"def authorize(ctrl = params[:controller], action = params[:action], global = false)\n allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project, :global => global)\n allowed ? true : deny_access\n end",
"def can(action, resource, options={})\n before do\n ability.can action, resource, options\n end\n end",
"def authorize\n \t\t#teste http://localhost:3000/products/2/who_bought.atom\n \t\t#ou curl --silent --user dave:secret http://localhost:3000/products/2/who_bought.atom \n \t\treturn if User.count.zero?\n\n \t\tif request.format == Mime[:html]\n \t\t\tuser = User.find_by(id: session[:user_id])\n \t\telse\n \t\t\tuser = authenticate_or_request_with_http_basic do |u,p|\n \t\t\t\tUser.find_by_name(u).try(:authenticate, p)\n \t\t\tend\n \t\tend\n\n \t\tredirect_to login_url, notice: \"Please log in\" unless user\n \t\t\n \tend",
"def authorization_mode=(mode); end",
"def authorize\n @user = User.find_by_id_and_multitrack_token(params[:user_id], params[:token])\n head(@user ? :ok : :forbidden)\n end",
"def authorize_resource(*args); end",
"def authorize!(action, object)\n if can?(action, object)\n true\n else\n raise Kant::AccessDenied, \"You are not permitted to #{action} this record.\"\n end\n end",
"def guest\n can :read, ChallengeGroup, visible: 1\n can :read, Challenge, challenge_group: {visible: 1}\n can :read, User\n\n cannot :goto, Challenge\n cannot :complete, Challenge\n cannot :show_hint, Challenge\n end",
"def authorized?(action, subject)\n ability.can? action, subject\n end",
"def authorize_patron\n if is_admin? or is_authorized? \n return true\n elsif !current_user.nil?\n render 'user_sessions/unauthorized_patron'\n else\n redirect_to login_url unless performed?\n end\n end",
"def can?(thing)\n return true if admin?\n # Check if user is granted the function\n return true if granted?(thing)\n # Check if user is denied the function\n return false if denied?(thing)\n # Ignore \"System Admin\" function from CSUM/CSEM users\n return false if thing.include?(\"System Admin\")\n roles.include?(thing)\n end",
"def authorize\n debug 'authorize:'\n unless User.authorized? params[:controller], params[:action], params[:func]\n flash[:error] = I18n.t('general.Flash.NotAuth')\n debug 'authorize: not authorized'\n raise \"User not authorized\"\n end\n debug 'authorize: authorized'\n true\n rescue => err\n error 'authorize: ' + err.to_s\n redirect_to :controller => 'reservation', :action => 'list'\n end",
"def authorize(ctrl = params[:controller], action = params[:action], global = false)\n case action\n when \"rootwebdav\", \"webdavnf\"\n allowed = true\n else\n allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project, :global => global)\n end\n allowed ? true : deny_access\n end",
"def authorization(action, object = \"default - missing something?\")\n if action == \"create\"\n not_authorised and return unless current_user.can_create?\n elsif action == \"update\"\n not_authorised and return unless current_user.can_update?(object)\n elsif action == \"destroy\"\n not_authorised and return unless current_user.can_destroy?(object)\n elsif action == \"owner\"\n not_authorised and return unless current_user.owner?(object)\n elsif action == \"admin\"\n not_authorised and return unless current_user.admin_only\n end\n end",
"def authorize_access\n # byebug\n redirect_to root_path, alert: \"Access Denied\" unless can? :modify, Post\n end",
"def authorize_admin\n\t\tauthorize( ADMIN_USER_LEVEL ) \n\tend",
"def initialize(user, controller_namespace)\n # Define abilities for the passed in user here. For example:\n #\n # user ||= User.new # guest user (not logged in)\n # if user.admin?\n # can :manage, :all\n # else\n # can :read, :all\n # end\n #\n # The first argument to `can` is the action you are giving the user permission to do.\n # If you pass :manage it will apply to every action. Other common actions here are\n # :read, :create, :update and :destroy.\n #\n # The second argument is the resource the user can perform the action on. If you pass\n # :all it will apply to every resource. Otherwise pass a Ruby class of the resource.\n #\n # The third argument is an optional hash of conditions to further filter the objects.\n # For example, here the user can only update published articles.\n #\n # can :update, Article, :published => true\n #\n # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities\n \n # if user.role? :moderator\n # can :manage, Project\n # cannot :destroy, Project\n # can :manage, Comment\n # end\n # if user.role? :admin\n # can :destroy, Project\n # end\n\n=begin\n user ||= User.new # guest user \n if user.role? :super_admin\n can :manage, :all #This shows that the super_admin can manage everything\n\n elsif user.role? :product_admin\n can :manage, [Product, Asset, Issue] # Show that the product_admin can manage products and its related other things.\n\n elsif user.role? :product_team\n can :read, [Product, Asset] # manage products, assets he owns\n can :manage, Product do |product|\n product.try(:owner) == user\n end\n can :manage, Asset do |asset|\n asset.assetable.try(:owner) == user\n end\n end \n=end\n\n #puts(\".... controller_namespace: #{controller_namespace}\")\n user ||= User.new # guest user (not logged in)\n case controller_namespace\n when 'Admin'\n can :manage, :all if user.has_role? :admin\n else\n # rules for non-admin controllers here\n #can :read, :all\n # can [:update, :destroy], [Article, Comment]\n cannot :manage, :all\n can :manage, Todo\n end\n \n end",
"def authorize_request\n @current_user = AuthorizeApiRequest.new(request.headers).call[:user]\n\n # Check if the user record is ban and cancel all actions\n json_response({ error: 'Bannis' }, :unauthorized_request) if @current_user.isBan\n\n # Check achievements in all queries by the user, three times out of ten\n @current_user.check_achievements if rand(10) >= 7\n end",
"def test_authorization_and_void\n return if Base.mode == :test # only tests in production mode\n assert_equal Base.mode, :production\n assert authorization = @gateway.authorize(@amount, @credit_card, @options)\n assert_success authorization\n \n assert void = @gateway.void(authorization.authorization)\n assert_success void\n assert_match(/This transaction has been approved/, void.message)\n end",
"def can_access(u)\n if $config.options['debug']\n puts(\"ident: #{@ident} vs. #{u.ident}\")\n puts(\" host: #{@host} vs. #{u.rhost}\")\n puts(\" cert: #{@certfp} vs. #{u.certfp}\")\n puts(\" acct: #{@account} vs. #{u.su}\")\n puts(\"matc1: #{Match.match(@ident, u.ident, true)}\")\n puts(\"matc2: #{Match.match(@host, u.rhost, true)}\")\n puts(\" cert: #{(u.certfp && @certfp && u.certfp == @certfp)}\")\n puts(\" acct: #{u.su && @account && u.su == @account}\")\n end\n #identmatch = match(@ident, u.ident, true)\n #hostmatch = match(@host, u.rhost, true)\n #certfpmatch = u.certfp && @certfp && u.certfp\n Match.match(@ident, u.ident, true) && (Match.match(@host, u.rhost, true) ||\n Match.match(@host, u.ip, true))\n ((u.certfp && @certfp && u.certfp == @certfp) ||\n (u.su && @account && u.su == @account)) &&\n # Invalid O:line\n !(!@account && !@certfp)\n end",
"def user\n guest # inherits from guest\n can :launch, Challenge\n can :complete, Challenge\n can :show_hint, Challenge\n can :destroy, ChallengeFlag, user_id: @user.id\n\n # Messages\n #can [:read, :destroy], UserMessage, :user_id=>@user.id\n #can :create, UserMessage\n #cannot :multi_send, UserMessage # Send multiple to multiple users\n #cannot :system_send, UserMessage # Send messages from \"System\" users\n end",
"def authorize?(person)\n person.is_admin?\n end",
"def authorized(destination, source)\n # for now added the global phone numbers as phones for Brownell\n global_list = User.where(:email => '[email protected]').phones\n return true if !global_list.index(\"authorizeall\").nil?\n access_list = destination.authorized_phones + global_list\n return !access_list.index(source).nil?\n end",
"def basic\n # Any user can create a new Thesis.\n can :create, Thesis\n can :start, Thesis\n can :confirm, Thesis\n\n # Only the Thesis author can view their Thesis.\n can :read, Thesis, users: { id: @user.id }\n can :update, Thesis, users: { id: @user.id }\n end",
"def authorize(name, addresses=[], ports=[], protocols=[], &each_group)\n modify_rules(:authorize, name, addresses, ports, protocols, &each_group)\n end",
"def can?(*args)\n permissions.can?(*args)\n end",
"def test_credit_card_authorize_and_void\n assert auth = @gateway.authorize(@amount, @credit_card, @options)\n assert_success auth\n assert_equal 'Approved', auth.message\n assert void = @gateway.void(@amount, auth.authorization, @credit_card, @options)\n assert_success void\n assert_equal 'Approved', void.message\n end",
"def can_authorize?(user, a)\n user != self and may_authorize and\n (abilities | ADMIN_TASKS).include?(a)\n end",
"def authorization\n authorization = 'participant'\n authorization = 'reader' if !can_submit && can_review && can_take_quiz\n authorization = 'submitter' if can_submit && !can_review && !can_take_quiz\n authorization = 'reviewer' if !can_submit && can_review && !can_take_quiz\n authorization\n end",
"def authorize_net_valid(options)\n transaction = AuthorizeNet::AIM::Transaction.new($api_login, $api_key, :gateway => $gateway.to_s.to_sym,\n :encapsulation_character => \"|\",\n :allow_split => true)\n\n # Find a state\n if params[:state].blank?\n state = \"--\"\n else\n state = State.find_by_state(options[:state]).state_abbr\n end \n\n # Add address to request\n address = AuthorizeNet::Address.new(:first_name => options[:first_name],\n :last_name => options[:last_name],\n :street_address => options[:address],\n :city => options[:city],\n :state => state,\n :zip => options[:zip],\n :country => options[:country])\n transaction.set_address(address)\n\n # Convert a date expired\n expired_date = params[:expires_date_months].[](0..1).strip.concat(params[:expires_date_years].[](2..3))\n if expired_date.length == 3\n expired_date = \"0\".concat(expired_date)\n end\n\n # Add credit card to request\n credit_card = AuthorizeNet::CreditCard.new(options[:cc_number], expired_date, :card_code => options[:cvv])\n # Execute a request\n response = transaction.authorize(0.0, credit_card)\n\n # Get a result of request\n @authorize_transaction_id = response.transaction_id\n #@authorize_gateway = transaction.gateway\n @authorize_gateway = response.raw.body\n @authorize_code = response.authorization_code\n @response_code = response.response_code\n @response_reason_code = response.response_reason_code\n\n # Generate user message\n if @response_code.to_i == 1 && @response_reason_code.to_i == 1\n user_message = \"Billing information changed\"\n else\n user_message = get_user_message(@response_code, @response_reason_code)\n end\n\n unless response.success?\n # Card is invalid(authorize.net)\n flash[:error_card] = 'Can\\'t authorize credit card'\n\n # Block in session\n block_ip_in_session\n\n # Add transaction\n add_transaction(:i_account => @account.i_account, \n :type => \"payment_refund\",\n :transaction_id => @authorize_transaction_id,\n :gw_string => @authorize_gateway,\n :user_message => user_message,\n :ip => request.remote_ip.to_s,\n :authorization_code => @authorize_code)\n \n false\n else\n true\n end\n end",
"def initialize(user)\n\n # guest user (not logged in) \n user ||= User.new \n\n # Alias to give proper abilities to the owner of his own course and profile\n alias_action :create, :update, :destroy, :mycourses, :myprofil, :to => :cud\n\n # Everyone can read all courses but only the owner can alter it\n can :read, Course\n can :cud, Course, :owner => user.id\n\n # Everyone can read all profiles but only the owner can alter it\n can :read, Profil\n can :cud, Profil, :user_id => user.id\n\n end",
"def test_authorization_and_capture\n return if Base.mode == :test # only tests in production mode\n assert_equal Base.mode, :production\n assert authorization = @gateway.authorize(@amount, @credit_card, @options)\n assert_success authorization\n \n assert capture = @gateway.capture(@amount, authorization.authorization)\n assert_success capture\n assert_match(/This transaction has been approved/, capture.message)\n end",
"def restrict_access \n \t# Não sei o porque, mas é precisa instanciar esse objeto\n \tresponse = nil\n \t\n \t# Verifica se o TOKEN existe\n \t# TODO: Fazer uma validação do TOKEN quando for chamá-lo\n \t# ao invés de fazer isso aqui, pois economiza uma chamada\n \tif params[:token].nil?\n \t\t# bloqueia o acesso\n \t\thead :unauthorized # retirar no futuro quando melhorar a analise do token\n \telse\n \t\t# Faz a chamada pro API da Arich mediante parâmetros no CONFIG da aplicação Rails\n\t\tNet::HTTP.start(Rails.application.config.authentication_location, Rails.application.config.authentication_port) {|http|\n\t\t\t\tresponse = http.head(Rails.application.config.authentication_complement + params[:token])\n\t\t}\n\n\t\t# Analisa o retorno da chamada da API, se algo diferente de\n\t\t# 200 ele rejeita a autenticação\n\t\tif response.code != \"200\"\n\t\t\thead :unauthorized\n\t\tend \n\tend\n end",
"def authorize(money, card, options = {})\n # Ignore params for basic_auth\n init.basic_auth\n end",
"def initialize(user)\n if user.role == \"member\"\n can :index, :all\n can :create, :all\n cannot :index, Passenger\n #cannot :index, Home\n # Jeder Member kann jede Übersicht außer der Übersicht der User sehen\n # und kann alle Elemente erstellen\n can [:show, :update, :destroy], Car do |car|\n car && car.user == user \n end\n can :show, user.get_visible_cars\n # Member können eigene Autos erstellen, editieren und zerstören und alle eigenen und bei teilzunehmenden Fahrten genutzten Autos anschauen \n can [:outbox, :show, :update], Message do |message|\n message && message.writer == user\n end\n can [:show, :update], Message do |message|\n message && message.receiver == user\n end\n cannot [:edit], Message do |message|\n message && message.receiver == user\n end\n # Member können alle mit ihnen in Verbindung stehenden Messages lesen und editieren\n can [:show, :update, :destroy], Request do |request|\n request && request.user == user\n end\n # Member haben kompletten Zugriff auf die eigenen Anfragen\n can :show, Trip\n can [:update, :destroy], Trip do |trip|\n trip && trip.user == user\n end\n # Member können alle Fahrten sehen, jedoch nur die eigenen verändern\n can [:update, :destroy], Rating do |rating|\n rating && rating.author == user\n end\n # Member können nur selbstgeschriebene Ratings verändern\n can :show, user.get_visible_users\n can [:show, :update, :destroy], User do |user1|\n user1 && user1 == user\n end\n # Member können alle User sehen mit denen sie eine Fahrt antreten wollen und ihren eigenen Account verändern\n\n # Rechte der Member\n elsif user.role == \"admin\"\n can :manage, :all\n # Der Admin hat vollständige Zugriffsrechte\n end\n end",
"def permit_unprotected_actions\n # Allow clients to download packages\n can [:download, :icon], Package\n # Allow client computer requests\n can :checkin, Computer\n can [:show_plist, :show_resource], Computer\n # Allow any request to retrieve catalogs\n can :read, Catalog\n # Allow everyone to edit their user record\n can [:read, :update], User, :id => @user.id\n # Allow anyone to login and logout\n can [:create, :destroy], :session\n # Allow anyone to view their dashboard\n can :manage, :dashboard\n end",
"def verify_rights\n access_allowed?(params.slice(:controller, :action)) || permission_denied\n end",
"def initialize(user)\n # Define abilities for the passed in user here. For example:\n #\n user ||= User.new # guest user (not logged in)\n # if user.admin?\n # can :manage, :all\n # else\n # can :read, :all\n # end\n #\n # The first argument to `can` is the action you are giving the user\n # permission to do.\n # If you pass :manage it will apply to every action. Other common actions\n # here are :read, :create, :update and :destroy.\n #\n # The second argument is the resource the user can perform the action on.\n # If you pass :all it will apply to every resource. Otherwise pass a Ruby\n # class of the resource.\n #\n # The third argument is an optional hash of conditions to further filter the\n # objects.\n # For example, here the user can only update published articles.\n #\n # can :update, Article, :published => true\n #\n # See the wiki for details:\n # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities\n\n\n # To define a permission for a user, use the 'can' method inside\n # of this classes, initialize method. It takes the following args\n # (in order):\n # - The name of the action you are testing for as a symbol\n # - The class of an object we are testing against.\n # - A block that is used to determine whether or not a user can perform said action\n \n # If the block returns true, the user can perform the action, otherwise they can't\n\n if user.is_admin?\n can :manage, :all \n # manage means they can do everything (not just CRUD)\n end\n\n alias_action :create, :read, :edit, :update, :destroy, to: :crud\n\n can :crud, Question do |question|\n question.user == user\n end\n\n # We can also write abilities like:\n # can :crud, Question, use_id: user.id\n\n can :crud, Answer do |answer|\n answer.user == user\n end\n\n can :crud, JobPost do |job_post|\n job_post.user == user\n # check that if it matched\n end\n\n can :like, Question do |question|\n user.persisted? && user != question.user\n end\n\n can :destroy, Like do |like|\n like.user == user\n end\n end",
"def authorized(authorization)\n if (ENV['SECRET_NAME'])\n creds = get_secret(ENV['SECRET_NAME'])\n calculated = \"Basic \" + Base64.encode64(\"#{creds['a2user'] || creds['A2USER']}:#{creds['a2pass'] || creds['A2PASS']}\")\n return (authorization || \"\").strip == (calculated || \"\").strip\n end\n if (ENV['A2USER'] && ENV['A2PASS'])\n calculated = \"Basic \" + Base64.encode64(\"#{ENV['A2USER']}:#{ENV['A2PASS']}\")\n return (authorization || \"\").strip == (calculated || \"\").strip\n end\n return false\nend",
"def ckeditor_authenticate\n authorize! action_name, @asset\n end",
"def initialize(user)\n user ||= User.new # guest user (not logged in)\n\n if user.is_role? \"Administrator\"\n can [:manage], :all\n can [:read, :create, :update, :destroy], :all\n can [:reset_password], User\n\n cannot [:destroy], User do |user_object|\n user_object == user || user_object.is_last_admin? || !user_object.is_active?\n end\n\n can [:hmo_patients_index], Hmo\n\n cannot [:edit, :destroy, :process_csv], PatientUpload do |pu|\n pu.state == \"processed\"\n end\n end\n\n if user.is_role? \"Doctor\"\n can [:show], User do |user_object|\n user_object == user\n end\n can [:create, :update, :destroy, :uploaded_patients_index, :read, :download_image, :upload_picture], Patient\n can [:hmo_patients_index], Hmo\n can [:update], User do |user_object|\n user_object == user\n end\n can [:manage], Surgeon\n can [:manage], ProcedureType\n end\n\n if user.is_role? \"Encoder\"\n can [:show], User do |user_object|\n user_object == user\n end\n can [:update, :make_payment, :check_available, :uploaded_patients_index, :read, :download_image], Patient\n can [:hmo_patients_index], Hmo\n\n can [:manage], Hmo\n can [:manage], Hospital\n can [:manage], Surgeon\n can [:manage], ProcedureType\n\n can [:manage], PatientUpload\n cannot [:edit, :destroy, :process_csv], PatientUpload do |pu|\n pu.state == \"processed\"\n end\n\n can [:update], User do |user_object|\n user_object == user\n end\n end\n end",
"def test_successful_authorize_and_capture\n response = @gateway.authorize(@amount, @credit_card, @options)\n assert_success response\n\n response = @gateway.capture(@amount, response.authorization)\n assert_success response\n end",
"def show\n authorize @brass\n end",
"def administrator\n can :manage, :all\n end",
"def authorize?(_user)\n true\n end",
"def authorize?(_user)\n true\n end"
] | [
"0.6434051",
"0.6434051",
"0.6285173",
"0.62677944",
"0.6244",
"0.6204572",
"0.6159169",
"0.59875715",
"0.59875715",
"0.5979078",
"0.5934815",
"0.59343946",
"0.5895101",
"0.5873449",
"0.58611006",
"0.5849073",
"0.5793801",
"0.578262",
"0.57717574",
"0.5756642",
"0.5748051",
"0.57371145",
"0.57272464",
"0.5723508",
"0.5712605",
"0.5687193",
"0.568262",
"0.5666529",
"0.5662937",
"0.5662937",
"0.5661148",
"0.5658279",
"0.56424075",
"0.56407046",
"0.56407046",
"0.5632014",
"0.5628826",
"0.5624564",
"0.5602235",
"0.55968684",
"0.5590669",
"0.5578348",
"0.5577587",
"0.55686486",
"0.5560035",
"0.5556182",
"0.55500114",
"0.5547742",
"0.5544575",
"0.5541948",
"0.5537272",
"0.5531932",
"0.5525227",
"0.5514369",
"0.550588",
"0.550588",
"0.5505024",
"0.550436",
"0.5502607",
"0.5502054",
"0.5499671",
"0.54911083",
"0.54881555",
"0.5485358",
"0.5484745",
"0.54783314",
"0.54770356",
"0.54700583",
"0.54610074",
"0.54606056",
"0.5453743",
"0.54440165",
"0.5438999",
"0.5429228",
"0.5428094",
"0.5425752",
"0.542192",
"0.5417018",
"0.5414651",
"0.5414204",
"0.5404975",
"0.53998137",
"0.5395291",
"0.5394945",
"0.5389861",
"0.5388736",
"0.53874356",
"0.53840166",
"0.53828967",
"0.53820485",
"0.5377769",
"0.5375078",
"0.5373558",
"0.53704476",
"0.5367149",
"0.5365869",
"0.5365315",
"0.5363253",
"0.5360656",
"0.53593725",
"0.53593725"
] | 0.0 | -1 |
used when little 'x' image is clicked to close. | def remove_id(object_id)
i = @docs.index { |doc| doc.object_id == object_id }
destroy_tab(i) if @docs[i].try_to_save()
# remove_tab(i) #if not i.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_image\n @p.close_image(self)\n end",
"def close\n @graphic.ungetch(?q.ord)\n end",
"def button_down(id)\r\n if id == Gosu::KB_ESCAPE\r\n close\r\n else\r\n super\r\n end\r\n end",
"def button_down(id)\r\n if id == Gosu::KB_ESCAPE\r\n close\r\n else\r\n super\r\n end\r\n end",
"def close_window\n end",
"def cookie_popup_close\n get_elem_and_click(:xpath, \"//core-icon[@icon-id='glyphs.close']\")\n end",
"def close_avatar\n @avatar_window.smooth_move(0 - @avatar_window.width, @avatar_window.y)\n @command_window.activate\n update_registration_ready\n end",
"def unclicked(mouse_event)\n end",
"def button_down(id)\n\t\tcase id\n\t\twhen Gosu::KbEscape\n\t\t\tclose\n\t\tend\n\tend",
"def close_menu\n pending\n perform_action('drag', 20, 0, 10, 10, 10)\n end",
"def button_down(id)\n if id == Gosu::Button::KbEscape\n close\n end\n end",
"def button_down(id)\r\n case id\r\n when Gosu::KbEscape\r\n close\r\n end\r\n end",
"def active_remove_icon()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_active_remove_icon(@handle.ptr)\n end",
"def button_up(key)\n self.close if key == Gosu::KbEscape\n end",
"def close\r\n command 'close'\r\n end",
"def close\r\n command 'close'\r\n end",
"def closing?\n action == 'closed'\n end",
"def close\n\t remove_common_event_handlers\n\t remove_specific_event_handlers\n\t sleep 0.2\n Phidgets::FFI::Common.close(@handle) \n\t delete\n true\n end",
"def close_graphics\n @p.close_graphics(self)\n end",
"def cancel_button_clicked\n\t\t\t@path = nil\n\t\t\tclose_and_cleanup\n\t\tend",
"def unclicked(e)\n puts \"Unclicked!\"\n end",
"def closeeye()\n\t\t@opened_eye = false\n\tend",
"def update\n\t\tif self.button_down?(Gosu::KbLeft)\n \t\tclose\n \tend\n end",
"def onClose(sender, sel, event)\n $app.exit(0)\n end",
"def onClose(sender, sel, event)\n $app.exit(0)\n end",
"def closeeye()\n\t\t@pintar = false\n\tend",
"def close_popup\n popup.deactivate\n x = Graphics.width\n y = @help_window.height\n if $imported[\"H87_SmoothMovements\"]\n @option_window.smooth_move(0, y)\n popup.smooth_move(x, y)\n else\n @option_window.x = 0\n popup.x = x\n end\n @option_window.activate\n @popup_index = nil\n end",
"def close_popup\n popup.deactivate\n x = Graphics.width\n y = @help_window.height\n if $imported[\"H87_SmoothMovements\"]\n @option_window.smooth_move(0, y)\n popup.smooth_move(x, y)\n else\n @option_window.x = 0\n popup.x = x\n end\n @option_window.activate\n @popup_index = nil\n end",
"def Animate_Close(hwnd)\r\n Animate_Open(hwnd, nil)\r\n end",
"def close\n if self.openness > 0\n @duration = self.animationSpeed\n @closing = true \n @opening = false\n @animationType = OPEN\n end\n end",
"def closeOverlay _args\n \"closeOverlay _args;\" \n end",
"def exit\n stop\n $window.deleteAllWidgets\n $window.createWidgets\n $window.deleteAllImages\n $window.cursor.unforceVisible\n terminate\n end",
"def close_notification\n self.div(:class=>\"gritter-item\").hover\n self.div(:class=>\"gritter-close\").fire_event \"onclick\"\n end",
"def close_menu\n touch_screen_element 'Close menu Button', close_menu_button\n end",
"def on_buy_cancel\n @command_window.activate\n #@dummy_window.show\n @buy_window.hide\n @status_window.hide\n @status_window.item = nil\n @help_window.clear\n end",
"def remove_game_icon()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_remove_game_icon(@handle.ptr)\n end",
"def close\n Window.functions[__method__] ||= AU3_Function.new(\"WinClose\", 'SS', 'L')\n Window.functions[__method__].call(@title.wide, @text.wide)\n nil\n end",
"def mouse_quit\n $game_system.se_play($data_system.cancel_se)\n if display_message(ext_text(8997, 40), 1, ext_text(8997, 33), ext_text(8997, 34)) == 0\n @return_data = false\n @running = false\n end\n end",
"def check_forced_close\n return if @esc_counter > 0 or !open?\n if Input.legacy_trigger?(:B)\n Sound.play_cancel\n close\n end\n end",
"def close\n Highgui.release_capture(FFI::MemoryPointer.new(:pointer).write_pointer(@capture_handler))\n @capture_handler = nil\n end",
"def cancel_frame\n end",
"def can_close?; end",
"def mouse_quit\n $game_system.se_play($data_system.cancel_se)\n if display_message(ext_text(8997, 42), 1, ext_text(8997, 33), ext_text(8997, 34)) == 0\n @return_data = false\n @running = false\n end\n end",
"def ui_close\n\t\t\t\t#puts \"CursesApp->ui_close\"\n\t\t\t\t\n\t\t\t\traise 'ui already closed' if @ui_closed\n\t\t\t\t@ui_closed = true\n\t\t\t\t\n\t\t\t\t# Curses.setpos(10, 0)\n\t\t\t\t# Curses.addstr('CLOSE ')\n\t\t\t\t# Curses.refresh\n\t\t\t\t# sleep(2)\n\t\t\t\t\n\t\t\t\tCurses.refresh\n\t\t\t\tCurses.stdscr.clear\n\t\t\t\tCurses.stdscr.refresh\n\t\t\t\tCurses.stdscr.close\n\t\t\t\tCurses.close_screen\n\t\t\tend",
"def close_game\n show\n Ncurses.mvaddstr(MAXY - 1, 0, 'Press any key to exit')\n Ncurses.getch\n Ncurses.curs_set(1)\n Ncurses.endwin\n end",
"def close_popups\n return if driver.doc.at('.cb_close').nil?\n driver.first('.cb_close').click\n end",
"def closeEvent(p_event)\n\t\t\tparentWidget.close\n\t\tend",
"def should_close?\n @window.should_close?\n end",
"def onsig(sig)\n close_screen\n @exit = true\n end",
"def close_fries_link\n fries_popup.find(:span_class, 'close').find(:link_href, '#')\n end",
"def close\n @window.close\n end",
"def mouse_out(mouse_event)\n end",
"def close_icon(options = {})\n # Deep merge and join values\n options.deep_merge!(close_icon_default_options) do |_, this_val, other_val|\n [this_val, other_val].join(' ').strip\n end\n\n tag.button(options) do\n tag.span('×', aria: { hidden: true })\n end\n end",
"def close_event\n \tself.update_attribute(:closed, true)\n end",
"def on_close\n\tend",
"def disable_close()\n #This is a stub, used for indexing\n end",
"def button_down(id)\n case id\n when Gosu::KbEscape\n exit\n end\n end",
"def on_category_cancel\n @command_window.activate\n #@dummy_window.show\n @category_window.hide\n @sell_window.hide\n end",
"def quit_command()\n @subSceneScan.hide_windows()\n @target_enemy_window.active = true\n end",
"def back\n self.view.window.removeGestureRecognizer(@recognizer)\n @delegate.close_toybox\n end",
"def buttonCancel__clicked(*a)\n @builder[:window1].destroy\n end",
"def close \n #Self trigger window lost focus, since we are going to home\n focus_changed false, @screen_width, @screen_height\n @showing = false\n @activity.moveTaskToBack(true)\n end",
"def test_openClose\n @w_openToggle = Window_Base.new(400, 250, 100, 50)\n @w_openToggle.animationSpeed = 2000\n openToggle()\n return true\n end",
"def closeDisplay _obj, _args\n \"_obj closeDisplay _args;\" \n end",
"def close_lid()\n \"Click the <b>Close Lid</b> button\"\n end",
"def xbutton\n content_tag :span, '×'.html_safe, aria: { hidden: true }\n end",
"def unload_image(image_handle)\n end",
"def windowWillClose(notification)\n OSX::NSApp.terminate(self)\n end",
"def windowWillClose(notification)\n OSX::NSApp.terminate(self)\n end",
"def close_nx\n return @dialog.setCompleted unless @dialog.abortWasRequested\n\n @dialog.setMainStatusAndLogIt('Aborted')\n end",
"def cancel_attack\n @windows[Win_Status].clear_dmg_preview\n @cursor.active = true \n end",
"def close_lid\n 'Click the <b>Close Lid</b> button'\n end",
"def close_lid\n 'Click the <b>Close Lid</b> button'\n end",
"def sigExit(eventName,callerName,event,caller)\n\t\thideAll\n\t\[email protected]\n\tend",
"def close_game\r\n $window.close\r\n end",
"def execImage(img)\n @window = img[1]\n if !img[2]\n\n if @window.child.children[0].child != nil\n @window.child.children[0].remove(@window.child.children[0].child)\n end\n @window.child.children[0].child = (Gtk::Image.new(:file =>img[0]))\n @window.child.children[0].child.show_all\n\n @window.child.children[0].signal_connect(\"button_press_event\"){\n @window.hide\n Gtk.main_quit\n }\n\n @window.show_all\n Gtk.main\n\n else\n Gtk.main_quit\n end\n end",
"def close\n @window.destroy if @window\n VER::stop_ncurses\n end",
"def on_click\n @status_window_tb.hide\n $game_map.clear_next_highlights\n reset_aoe_follows\n #@spriteset.remove_group(DISPLAY_TB) # @spriteset.dispose_highlights_tb\n remove_show_hls\n end",
"def on_close\n\t\tend",
"def close; true; end",
"def close; true; end",
"def clicked;end",
"def clicked\n # @cancel.clicked\n end",
"def close\n return if closed?\n\n nocbreak\n close_screen\n end",
"def close\n close_filehandles\n close_keydir\n end",
"def on_window_window_state_event(win, win_state)\n if win_state.new_window_state == 130\n @ui[\"window\"].hide\n @ui[\"window\"].deiconify\n end\n end",
"def close_cvv_help_popup\n close_cvv_help_link.click\n end",
"def clicked\n @cancel.clicked\n end",
"def on_item_cancel2; item_cancel(@item_window2, @category_window2); end",
"def on_close\n on :close\n close\n end",
"def closing?; end",
"def pop_frame()\n CLI::UI::Frame.close(\"Pop!\")\n end",
"def close_internal_frame(title)\n append_to_script \"close_internal_frame \\\"#{title}\\\"\"\n end",
"def on_item_cancel; item_cancel(@item_window, @category_window); end",
"def close_search\n close_search_bar.click\n end",
"def close_toybox\n p 'close_toybox'\n dismissModalViewControllerAnimated(true, completion: nil) \n end",
"def exit\n @window.pause = true\n @window.close\n end",
"def close\n render :text => \"\"\n end",
"def close\n \"<body onload='window.close();'/>\"\n end",
"def close\n # ..\n end",
"def hide_window\n end"
] | [
"0.69468194",
"0.68555856",
"0.6595714",
"0.65661836",
"0.6563526",
"0.64277756",
"0.64153403",
"0.6397302",
"0.63582796",
"0.62889075",
"0.62867963",
"0.6263157",
"0.6126303",
"0.60624874",
"0.60486305",
"0.60486305",
"0.5987918",
"0.59743",
"0.5971885",
"0.59637344",
"0.59617907",
"0.59368926",
"0.59318423",
"0.58917755",
"0.58917755",
"0.58764094",
"0.58758366",
"0.58758366",
"0.58687764",
"0.5842713",
"0.58324313",
"0.57938385",
"0.5790654",
"0.5735899",
"0.5731202",
"0.57118344",
"0.5711355",
"0.5705253",
"0.57011014",
"0.5697842",
"0.56973124",
"0.56951445",
"0.5685907",
"0.56727225",
"0.56680286",
"0.56621116",
"0.56619227",
"0.5655099",
"0.5643383",
"0.5642553",
"0.56407535",
"0.56319517",
"0.56282276",
"0.5605246",
"0.5600273",
"0.5598918",
"0.5596068",
"0.55939883",
"0.5587594",
"0.5585565",
"0.558282",
"0.55826676",
"0.5573103",
"0.55725706",
"0.55699915",
"0.55632",
"0.5556119",
"0.55440223",
"0.55440223",
"0.55335903",
"0.551838",
"0.551821",
"0.551821",
"0.5509441",
"0.5497063",
"0.54951555",
"0.5486059",
"0.54852945",
"0.54827285",
"0.54747725",
"0.54747725",
"0.5466919",
"0.5465017",
"0.545598",
"0.5447975",
"0.54411685",
"0.5435009",
"0.5426361",
"0.542511",
"0.5419772",
"0.5415777",
"0.541053",
"0.54045814",
"0.5386021",
"0.5384095",
"0.53743327",
"0.53692806",
"0.5363183",
"0.53599274",
"0.53481525",
"0.5342013"
] | 0.0 | -1 |
if its there, destroys it | def destroy_file_tab(file_name)
destroy_tab() if switch_to(file_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy!; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy\n nil\n end",
"def cleanup!; end",
"def cleanup!; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def destroy\n result = nil\n obj = self.inst_strip_braces(self.object)\n if obj\n # first delete the record from viewable list\n result = Rhom::RhomDbAdapter::delete_from_table(Rhom::TABLE_NAME,\n {\"object\"=>obj})\n # now add delete operation\n result = Rhom::RhomDbAdapter::insert_into_table(Rhom::TABLE_NAME,\n {\"source_id\"=>self.get_inst_source_id,\n \"object\"=>obj,\n \"update_type\"=>'delete'})\n end\n result\n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def destroy! #TODO\n destroy || raise(ActiveRecord::RecordNotDestroyed)\n end",
"def destroy; delete end",
"def cleanup\r\n end",
"def destroy!\n if exists?\n run_callbacks :destroy do\n #destroy main object\n RedisModelExtension::Database.redis {|r| r.del(redis_key) }\n destroy_aliases!\n end\n end\n end",
"def destroy\n delete_object\n true\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def destroy!\n self.destroy\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def ensure_destroy\n ensure_stop\n destroy if exist?\n end",
"def cleanup\n self.profile.destroy if self.profile\n end",
"def _destroy\n marked_for_destruction?\n end",
"def remove!; end",
"def destroy\n\t\t\n\tend",
"def cleanup\n true\n end",
"def cleanup\n\tend",
"def cleanup\n\tend",
"def remove!\n zombie_check\n self.class.remove(@name)\n end",
"def destroy!\n orchio_purge\n end",
"def destroy\n @graphic.destroy\n end",
"def cleanup!\n # This method may be left unimplemented if that is applicable\n end",
"def _destroy\n !!@destroy\n end",
"def destroy\r\n end",
"def destroy\r\n end",
"def cleanup_old_person\n\t\tself.person_was.destroy if self.person_was && self.person_was.show_positions.count == 0 && self.person_was.netid.blank?\n\tend",
"def destroy\n object_data.each {|o| ObjectDatum.find_by_guid(o.guid).destroy if o && ObjectDatum.find_by_guid(o.guid)}\n super\n end",
"def destroy!\n destroy || raise(ActiveRecord::RecordNotDestroyed)\n end",
"def destroy\n self.class.destroy(self.hash)\n self\n end",
"def destroy\n #primitives in structs are without parent\n parent and parent.children.delete self\n end",
"def destroy\n clear\n save\n end",
"def remove!\n destroy\n end",
"def destroy\n self.littles.each do | little|\n little.big_id = nil;\n end\n self.positions.each do | pos |\n pos.dke_info_id = nil;\n end\n return super\n end",
"def destroy\r\n end",
"def destroy\n self.destroyed = true\n save\n end",
"def teardown\n @p.destroy\n end",
"def destroy\n kill\n reset\n end",
"def delete(o); removeObject o end",
"def destroy\n @messy.destroy\n end",
"def destroy()\n\n super()\n end",
"def destroy\n self.delete_\n end",
"def destroy_attached\n destroy if destroy?\n end",
"def destroy\n @good.destroy\n end",
"def cleanup\n return unless @dst\n\n @dst.unlink\n @dst = nil\n end",
"def destroy!\n destroy || raise(RecordNotDestroyed)\n end",
"def destroy_self\n \tdestroy_record_of_self\n \t@db_alive = false\n \treturn nil\n end",
"def cleanup\n self.objectives.destroy_all\n end",
"def destroy\r\n do_without_exception(:destroy!)\r\n end",
"def cleanup\n true\nend",
"def destroy(_ = nil)\n OneProvisionLogger.info('(Destroy skipped)')\n end",
"def destroy\n delete ''\n end",
"def destroy\n if @summary.destroy\n \n end\n end",
"def delete\n object.destroy rescue nil\n end",
"def destroy \r\n\r\n end",
"def cleanup\n super\n end",
"def destroy\n @_destroyed = true\n _owner.update_attribute(embedded_as, nil) if _owner\n end",
"def destroy!\n destroy || _raise_record_not_destroyed\n end",
"def destroy\n return super if deletable?\n\n puts_destroy_help\n\n false\n end",
"def destroy\n self.deactivate\n if @affects\n @affects.dup.each do |affect|\n affect.clear(true)\n end\n end\n # clear affects that have this object as a source and require a source\n if @source_affects\n @source_affects.each do |source_affect|\n\n end\n end\n if @keywords\n @keywords.decrement_use_count\n end\n if @model && @model.temporary\n @model.decrement_use_count\n end\n @affects = nil\n @source_affects = nil\n Game.instance.remove_gameobject(self)\n return\n end",
"def destroy\r\n\r\n end",
"def nuke\n self.open_graph_event.destroy unless self.open_graph_event.nil?\n self.teamsheet_entries.destroy_all\n self.messages.destroy_all\n self.activity_items.destroy_all\n self.result.destroy unless self.result.nil?\n self.destroy\n end",
"def destroy\n\n end",
"def destroy\n false\n end",
"def destroy_orphaned_location\n self.location.destroy if self.description && self.description.location != self.location\n end",
"def destroy\n if @origin\n @origin.remove_exit(self)\n @origin = nil\n end\n if @destination\n @destination.remove_entrance(self)\n @destination = nil\n end\n super\n return\n end",
"def _destroy(*)\n fail NotImplementedError\n end",
"def destroy\n\t\tend",
"def destroy\n sivel2_gen_destroy\n end",
"def destroy \n\t\traise 'This feature is not supported'\n\tend",
"def destroy\n end",
"def destroy\n end"
] | [
"0.6996546",
"0.6960219",
"0.6960219",
"0.6960219",
"0.6960219",
"0.6960219",
"0.6960219",
"0.6960219",
"0.6960219",
"0.6960219",
"0.6960219",
"0.6902436",
"0.6836801",
"0.6836801",
"0.6815666",
"0.6815666",
"0.6815666",
"0.6815666",
"0.6781785",
"0.6766722",
"0.6766722",
"0.6766419",
"0.6766419",
"0.6766419",
"0.6766419",
"0.6761221",
"0.67527753",
"0.6748855",
"0.6710522",
"0.6707951",
"0.6687",
"0.6687",
"0.6687",
"0.6687",
"0.66704154",
"0.6662292",
"0.6662292",
"0.6662292",
"0.665449",
"0.665449",
"0.6654342",
"0.6615446",
"0.66049755",
"0.6598844",
"0.65945494",
"0.65889436",
"0.6585785",
"0.6585785",
"0.6570176",
"0.65434927",
"0.651959",
"0.65119475",
"0.6500031",
"0.64978313",
"0.64978313",
"0.6494691",
"0.64929926",
"0.6476477",
"0.6459454",
"0.64560485",
"0.6450771",
"0.644493",
"0.64304906",
"0.6419709",
"0.64189965",
"0.64033353",
"0.64032984",
"0.63973635",
"0.6394238",
"0.63777345",
"0.6377719",
"0.6375563",
"0.63699204",
"0.63623977",
"0.6350012",
"0.63416535",
"0.6323285",
"0.632186",
"0.6315532",
"0.6312691",
"0.630753",
"0.6307076",
"0.6296319",
"0.62925345",
"0.62925315",
"0.629243",
"0.6287921",
"0.62853736",
"0.6284173",
"0.6264101",
"0.62621844",
"0.6253948",
"0.62438864",
"0.62415445",
"0.6241534",
"0.6240994",
"0.6239432",
"0.6236169",
"0.62295973",
"0.6224944",
"0.6224944"
] | 0.0 | -1 |
Methods for completing quests show the player his completed quests | def get_completed_quests
#check if the player has actually completed any quests
#if he has not, tell him
if self.quests.size == 0
puts "You have not completed any quests!!!".red
#otherwise, pull the completed quest objects and print the quest titles
else
puts "Completed Quests:".underline
self.quests.each_with_index do |quest, i|
puts "#{i+1}: #{quest.title}"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @quest = Quest.find(params[:id])\n quest_objectives = @quest.locations\n completed_objectives = []\n quest_objectives.each do |obj|\n if @current_user.locations.exists?(obj)\n completed_objectives << obj\n end\n end\n if completed_objectives.length == quest_objectives.length\n unless @quest.winner_id\n @quest.update(winner_id: @current_user.id)\n end\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n end\n\n if(@quest.owner_id == @current_user.id)\n redirect_to edit_quest_path(@quest)\n elsif @quest.start_date > DateTime.current\n flash[:warning] = \"Quest has not yet begun!\"\n redirect_to user_path(@current_user) and return\n elsif @quest.end_date < DateTime.current\n flash[:warning] = \"Quest has ended. Womp womp\"\n\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n elsif @quest.users.exists?(@current_user.id)\n gon.track = true\n locations = @quest.locations\n gon.remaining_locations = []\n gon.completed_locations = []\n locations.each do |loc|\n if loc.users.exists?(@current_user.id)\n gon.completed_locations << loc\n else\n gon.remaining_locations << loc\n end\n end\n @remaining_locations = gon.remaining_locations\n @completed_locations = gon.completed_locations\n else\n gon.track = false\n flash[:danger] = \"You are not a member of this quest! Please contact the quest owner for an invite.\"\n redirect_to quests_path and return\n end\n end",
"def completeQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.completeQuest(quest,color,story)\nend",
"def quest_interface\n\n#obtain the difficulty level for the given player\n difficulty = self.get_difficulty\n\n#see if the player has any quests left to complete\n if self.get_recommended_quests(difficulty).size == 0\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"You have completed all recommended quests!!!\".bold\n puts \"=====================================\".red\n puts \"=====================================\".red\n\n#show the player the available quests\n else\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Recommended Quests for Player Attack: #{self.power}\".blue.on_light_green.bold\n puts \"\"\n self.print_quests(difficulty)\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Select a quest number\".bold.white.on_light_blue\n puts \"Number:\".bold.white.on_light_blue\n\n#selection prompt the player to actually choose a quest\n selection = gets.chomp\n\n#check for invalid input\n if selection.to_i > self.get_recommended_quests(difficulty).size || selection.to_i < 1\n puts \"Invalid input, please try again!\".red.bold\n\n#if input is valid, show the player that he has completed the quest\n else\n puts\"*******************************************\"\n puts \"You have completed: #{self.get_recommended_quests(difficulty)[selection.to_i-1].title}\".bold\n puts\"*******************************************\"\n puts \" \"\n puts\"#####################################\".blink\n puts \"Time For Your Reward Adventurer!!!\".bold.blue.on_light_yellow\n\n #obtain the available weapons based on player difficulty\n available_weapons = self.get_available_weapons(difficulty)\n\n #create the new characterquest instance to show that player has completed the quest\n self.quest_selection(selection, difficulty)\n\n #run the weapon_reward method to get reward for the quest\n self.weapon_reward(available_weapons)\n end\n end\n end",
"def completed_quests; $game_variables[17]; end",
"def quest_footer_for_show_dash(quest)\n if current_user.user_quests.include?(quest)\n render 'quests/complete_button', object: quest, url: '/complete_quest'\n end\n end",
"def complete_quests(options={})\n options.reverse_merge!(:count => 1)\n\n @objectives.push([\n Objective::CompleteQuests,\n {:key => Objective::CompleteQuests::KEY, :count => options[:count]}\n ])\n end",
"def quest; end",
"def manually_complete_quest(quest_id)\n quest(quest_id).prime_objectives.clear\n quest(quest_id).manual_status = :complete\n end",
"def find_completed\n completed = self.user_quests.where(complete: true)\n completed.map do |x|\n x.quest_id\n end\n end",
"def quest_book\n GamePlay::QuestBookMenu.new.main\n Graphics.transition\n @wait_count = 2\n end",
"def completed\n end",
"def quest(id) \n\tsys('quest')\n\t$progress.add_quest(id) \n\tpop_quest(id)\n\t$scene.hud.quest_sparkle(\"misc/profile\")\nend",
"def game_complete_text\n slow_type(\"\\nCongratulations, #{@new_player_name}! You have found your way out!\")\n pause(0.3)\n slow_type(\"Written, developed and coded by Adam Vaughan and Danny Smith.\")\n pause(0.3)\n slow_type(\"Stayed tuned for more levels!\")\n end",
"def finish!\n send_results()\n self.current_question_index = nil\n save()\n end",
"def new_completed(questions, user)\n @user = User.last\n @responses = @user.responses\n @questions = questions\n mail( :to => \"[email protected]\",\n :cc => \"[email protected]\",\n :subject => \"Coding Challenge Submission\" )\n end",
"def complete!\n self.update_attribute(:is_completed, true)\n # TODO: send an email to teacher about taks completion\n end",
"def completed?(step)\n case step\n when :begin\n true\n when :waiver\n @player.signed_waiver?\n when :squad\n @player.joined_squad?\n when :off_campus\n [email protected]_campus.nil?\n when :confirm\n true\n when :done\n @player.registered == true\n end\n end",
"def completed()\n end",
"def contest_complete\n contest = pet_contests.where(workflow_state: 'in_arena').last\n apply_experience!(contest)\n end",
"def completed?\n if self.completed == true\n true\n end\n\n if( self.user_quiz_answers.count == self.quiz.quiz_phases.collect{ |p| p.quiz_questions }.size )\n self.completed = true\n true\n else\n false\n end\n end",
"def view_completed_question\n nil\n end",
"def view_completed_question\n nil\n end",
"def index\n # TODO: Find personal quests\n quests = UsersQuest.where(:assignor_id => @current_user.id).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n end",
"def run\n\t\t\tputs name\n\t\t\tquestions.each do |q|\n\t\t\t\tputs q\n\t\t\t\tprint \"Su respuesta: \"\n\t\t\t\tresp = gets.chomp.to_i\n\t\t\t\traise IndexError, \"La respuesta debe estar entre 1 y #{q.answers.size}.\" unless resp <= q.answers.size and resp > 0\n\t\t\t\tif q.answers[resp-1].state\n\t\t\t\t\tputs \"Correcto!\"\n\t\t\t\t\t@aciertos += 1\n\t\t\t\telse\n\t\t\t\t\tcorrecta = q.answers.select { |ans| ans.state }.first\n\t\t\t\t\tputs \"Fallo, la respuesta correcta era #{correcta}\"\n\t\t\t\tend\n\t\t\t\tputs\n\t\t\tend\n\t\t\tputs \"Has acertado el #{(@aciertos/questions.size.to_f)*100}% de las preguntas [#{@aciertos} de #{questions.size}].\"\n\t\tend",
"def general_quests\n quests = UsersQuest.where(:assignee_id => @current_user.id,:is_accepted => true).where.not(:assignor_id => @current_user.id).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n end",
"def complete(count, answer = nil, questionnaire_min, questionnaire_max, dropdown_or_scale)\n html = '<div><label for=\"responses_' + count.to_s + '\">' + txt + '</label></div>'\n question_advices = QuestionAdvice.where(question_id: id).sort_by(&:id)\n advice_total_length = 0\n question_advices.each do |question_advice|\n advice_total_length += question_advice.advice.length if question_advice.advice && question_advice.advice != ''\n end\n # show advice given for different questions\n html += advices_criterion_question(count, question_advices) if !question_advices.empty? && (advice_total_length > 0)\n # dropdown options to rate a project based on the question\n html += dropdown_criterion_question(count, answer, questionnaire_min, questionnaire_max) if dropdown_or_scale == 'dropdown'\n # scale options to rate a project based on the question\n html += scale_criterion_question(count, answer, questionnaire_min, questionnaire_max) if dropdown_or_scale == 'scale'\n safe_join([''.html_safe, ''.html_safe], html.html_safe)\n end",
"def complete\n case self.completed\n when EVENT_COMPLETED\n self.make_done_event if self.event.event_rep_type != SpecialCode.get_code('event_rep_type','unlimited')\n self.event.completes(self.player_character)\n LogQuestExplore.complete_req(self.player_character_id, event_id) #probably should happen through \n when EVENT_FAILED\n return [nil,nil]\n #when EVENT_SKIPPED\n when EVENT_INPROGRESS\n return [self.priority, self.event]\n end\n return self.next_event\n end",
"def complete\n unless options[:quiet]\n puts \"*\" * 75\n puts \" \"\n puts \">> Questionnaire has been installed successfully.\"\n puts \">> You're all ready to go!\"\n puts \" \"\n puts \">> Enjoy!\"\n end\n end",
"def print_quests(difficulty)\n self.get_recommended_quests(difficulty).each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end",
"def getCompletedQuests\n completed = []\n $PokemonGlobal.quests.completed_quests.each do |s|\n completed.push(s.id)\n end\n return completed\nend",
"def quest_params\n params.require(:quest).permit(:user_id, :quest, :result)\n end",
"def show\n @completed_quest = CompletedQuest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @completed_quest }\n end\n end",
"def view_completed_question(count, answer,questionnaire_max)\n\t\thtml = '<big><b>Question '+count.to_s+\":</b> <I>\"+self.txt+\"</I></big><BR/><BR/>\"\n if !answer.answer.nil?\n\t\t html += '<TABLE CELLPADDING=\"5\"><TR><TD valign=\"top\"><B>Score:</B></TD><TD><FONT style=\"BACKGROUND-COLOR:gold\">'+answer.answer.to_s+'</FONT> out of <B>'+questionnaire_max.to_s+'</B></TD></TR>'\n else\n html += '<TABLE CELLPADDING=\"5\"><TR><TD valign=\"top\"><B>Score:</B></TD><TD><FONT style=\"BACKGROUND-COLOR:gold\">--</FONT> out of <B>'+questionnaire_max.to_s+'</B></TD></TR>'\n end\n\t\tif answer.comments != nil\n\t\t\thtml += '<TR><TD valign=\"top\"><B>Response:</B></TD><TD>' + answer.comments.gsub(\"<\", \"<\").gsub(\">\", \">\").gsub(/\\n/, '<BR/>')\n\t\tend\n\t\thtml += '</TD></TR></TABLE><BR/>'\n\t\thtml.html_safe\n end",
"def complete!\n @completed = true\n @completed_at = Time.now\n end",
"def pending_quests\n quests = UsersQuest.where(:assignee_id => @current_user.id,:is_accepted => false,:is_rejected =>false).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n by_me_quests = UsersQuest.where(:assignor_id => @current_user.id,:is_accepted => false,:is_rejected =>false).pluck(:quest_id)\n @by_me_quests = Quest.where(:id => by_me_quests).order('due_date')\n end",
"def completed\n @status = 'complete'\n end",
"def quest_revealed?(quest_id)\n $game_party.quests.revealed?(quest_id)\n end",
"def timeis_up\n current_user.submit_answers\n render text: true\n end",
"def quest(quest_id); $game_party.quests[quest_id]; end",
"def finish\n\n @play = Play.find(params[:id])\nif @play.player.group.participations.find(:first, :conditions => {:leader => 1}).registration.user.id == session[:user]\n\n \n answer = params[:play][:answer].to_i\n answer = Answer.find(answer)\n @play.answer = answer\n\n respond_to do |format|\n if @play.save\n flash[:notice] = 'Play was successfully updated.'\n format.html { redirect_to play_url(@play) }\n format.xml { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @play.errors.to_xml }\n\n end\nend\n\n\n end\n end",
"def update_quest_tbl\n\t\t\tbegin\n\t\t\t\t@player_data_db.execute (\"DELETE from quests\")\n\t\t\trescue\n\t\t\t\tputs \"Searching for jobs\"\n\t\t\tend\n\t\t\t# Execute inserts\n\t\t\t#[ db_name, quest_name, descrip, k_g_goal, k_g_name, exp_reward, silver_reward, gold_reward, loot_reward, k_g_count, q_status] ** q_tatus A = Active, C = Completed, D = Dropped\n\t\n\t\t\t[\t\t\t\t\n\t\t\t\t#[\"kill_rats\", \"eRATicate\", \"Kill 10 small rats\",1, \"small_rat\",25,0,3,\"apple_basket\",0,\"A\"],\n\t\t\t\t[\"get_wood\", \"Woody\", \"Gather 15 soft wood\",1, \"soft_wood\",25,0,3,\"none\",0,\"A\"]\n\t\t\t\t\n\t\t\t].each do |dbn,n,d,kgg,kgn,exp,sr,gr,loot,kgc,qs|\n\t\t\t\t@player_data_db.execute \"insert into quests values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\", nil,dbn,n,d,kgg,kgn,exp,sr,gr,loot,kgc,qs\n\t\t\tend\n\t\tend",
"def view_completed_question(count, answer, questionnaire_max, tag_prompt_deployments = nil, current_user = nil)\n html = '<b>' + count.to_s + '. ' + txt + ' [Max points: ' + questionnaire_max.to_s + ']</b>'\n score = answer && !answer.answer.nil? ? answer.answer.to_s : '-'\n score_percent = score != '-' ? answer.answer * 1.0 / questionnaire_max : 0\n score_color = if score_percent > 0.8\n 'c5'\n elsif score_percent > 0.6\n 'c4'\n elsif score_percent > 0.4\n 'c3'\n elsif score_percent > 0.2\n 'c2'\n else\n 'c1'\n end\n\n html += '<table cellpadding=\"5\"><tr><td>'\n html += '<div class=\"' + score_color + '\" style=\"width:30px; height:30px;' \\\n ' border-radius:50%; font-size:15px; color:black; line-height:30px; text-align:center;\">'\n html += score + '</div></td>'\n\n if answer && !answer.comments.nil?\n html += '<td style=\"padding-left:10px\"><br>' + answer.comments.html_safe + '</td>'\n #### start code to show tag prompts ####\n if !tag_prompt_deployments.nil? && tag_prompt_deployments.count > 0\n # show check boxes for answer tagging\n question = Question.find(answer.question_id)\n html += '<tr><td colspan=\"2\">'\n tag_prompt_deployments.each do |tag_dep|\n tag_prompt = TagPrompt.find(tag_dep.tag_prompt_id)\n if tag_dep.question_type == question.type && answer.comments.length > tag_dep.answer_length_threshold.to_i\n html += tag_prompt.html_control(tag_dep, answer, current_user)\n end\n end\n html += '</td></tr>'\n end\n #### end code to show tag prompts ####\n end\n html += '</tr></table>'\n safe_join([''.html_safe, ''.html_safe], html.html_safe)\n end",
"def success_case\n\tputs \" - Ok #{@name}, c'est ton choix #{@answer_play}\" \n\tputs \" \"\n end",
"def completed()\n @completed=true\n @tCompleted=Time.now\n end",
"def actions\n answer = @prompt.select(\"Where will you go?\", %w(Foward Back Status Items), cycle:true, per_page:4)\n if answer == \"Foward\"\n if @zone_cur == 10\n narrate(\"you leave the #{self.name}\")\n leave(self.exit_name)\n else\n @zone_cur += 1\n narrate(\"you continue foward\")\n encounter_check\n end\n elsif answer == \"Back\"\n if @zone_cur == 0\n narrate(\"you leave the #{self.name}\")\n leave(self.entrance_name)\n else\n @zone_cur -= 1\n narrate(\"you retreat backwards\")\n encounter_check\n end\n elsif answer == 'Status'\n narrate(\"#{@player.name} has #{@player.hp} hp, #{@player.attack} attack, and #{@player.defence} defence\")\n str = \"\"\n a = @player.equipment.map do |el|\n el.name\n end\n b = a.join(\", \")\n narrate(\"#{@player.name} has the following items equipped: #{b}\")\n here\n elsif answer == 'Items'\n answer = @prompt.select(\"Items Menu\", %w(Equip_item Look_item), cycle:true, per_page:4)\n if answer == 'Equip_item'\n #list inventory\n stuff = @player.items.map do |el|\n el.name\n end\n #select an item from inventory\n answer = @prompt.select(\"Items Menu\", stuff, cycle:true, per_page:4)\n #find that item again\n to_eq = @player.items.find do |el|\n el.name == answer\n end\n binding.pry\n #equip that item\n @player.equip(to_eq)\n narrate( \"You have equipped the #{to_eq.name}!\")\n actions\n end\n end\n end",
"def complete!(_outcome = nil)\n @playground.logger.info \"vanity: completed experiment #{id}\"\n return unless @playground.collecting?\n\n connection.set_experiment_completed_at @id, Time.now\n @completed_at = connection.get_experiment_completed_at(@id)\n end",
"def completed_it\n self.complete = true\n end",
"def complete!\n @completed_at = Time.now\n end",
"def complete!\n @completed_at = Time.now\n end",
"def trivia_end\n @config[:mode] = \"normal\"\n @trivia[:cur_quest] = 0\n self.say \"\\00310Trivia mode is over.\"\n end",
"def get_uncompleted_quests()\n Quest.all.select do |quest|\n quest.characters.include?(self) == false\n end\n\n end",
"def therapist_quest; end",
"def complete!\n self.is_completed = true\n self.save\n end",
"def continue_game\n\t\thandle_no_set\n\t\tuntil @is_end\n\t\t\tshow_progress\n\t\t\tshow_hand\n\t\t\tuser_input = get_user_cards\n\t\t\tupdate user_input\n\t\t\thandle_no_set\n\t\tend\n\tend",
"def run_quest\n original_power = @todays_hero.power\n system \"clear\"\n subtitle_print('Start Quest')\n power_update = Quest.find_new\n @todays_hero.increase_power_by(power_update)\n system \"clear\"\n if @todays_hero.power > original_power\n puts \"Congrats! Your power increased by #{power_update}.\"\n puts \"Your power is now #{@todays_hero.power}.\"\n elsif @todays_hero.power == original_power\n puts \"Evil doesn't wait for the slow and idle.\"\n puts \"Your power remains at #{@todays_hero.power}.\"\n elsif @todays_hero.power < original_power\n puts \"The world weeps for the strong and courageous.\"\n puts \"Your power has decreased to #{@todays_hero.power}.\"\n end\n @todays_hero.save\n end",
"def display_question(player)\n puts \"#{player.name}'s turn:\"\n print \"Evaluate the following expression: \"\n puts create_question\n get_response\n puts \"The answer was #{validate_response(player)}.\"\n end",
"def seekit\n\t\tuser = User.find_by_id(params[:user_id])\n\t\tunless user\n\t\t\trender json: {error: \"user not found\"} and return\n\t\tend\n\t\tquest = Quest.find_by_id(params[:quest_id])\n\t\tunless quest\n\t\t\trender json: {error: \"quest not found\"} and return\n\t\tend\n\t\tif CompletedQuest.exists?(user_id: user.id, quest_id: quest.id)\n\t\t\trender json: {error: \"user already completed this quest\"} and return\n\t\tend\n\t\t\n\t\tulat = params[:latitude] || 0\n\t\tulon = params[:longitude] || 0\n\t\tif quest.get_distance_to_point(ulat.to_d, ulon.to_d) > 0.03\n\t\t\trender json: {error: \"You are not there yet\"} and return\n\t\tend\n\n\t\tcq = CompletedQuest.new\n\t\tcq.user = user\n\t\tcq.quest = quest\n\t\tif cq.save\n\t\t\tuser.exp += quest.difficulty * 10\n\t\t\tuser.save\n\t\t\trender json: {msg: \"quest completed\"} and return \n\t\telse\n\t\t\trender json: {error: \"could not complete quest\"} and return\n\t\tend\n\tend",
"def index\n @quest_items = QuestItem.all\n end",
"def activateQuest(questID)\n if questID.is_a?(String)\n questID = $quest_data.getIDFromName(questID)\n end\n for i in 0...@active_quests.length\n if @active_quests[i].id==questID\n Kernel.pbMessage(\"You have already started this quest\")\n return\n end\n end\n for i in 0...@completed_quests.length\n if @completed_quests[i].id==questID\n Kernel.pbMessage(\"You have already complete this quest\")\n return\n end\n end\n for i in 0...@failed_quests.length\n if @failed_quests[i].id==questID\n Kernel.pbMessage(\"You have already failed this quest\")\n return\n end\n end\n @active_quests.push(Quest.new(questID))\n end",
"def quest_duration\n Objective.find_by_id(self.objective_id).duration.capitalize\n end",
"def update\n @tutorial_quest = Tutorial::Quest.find(params[:id])\n \n attributes_sent = params[:tutorial_quest]\n attributes_to_update = {}\n \n raise ForbiddenError.new (\"Access to quest state forbidden.\") unless admin? || staff? || @tutorial_quest.tutorial_state.owner == current_character\n \n if admin? || staff?\n attributes_to_update = attributes_sent\n else\n attributes_to_update[:status] = attributes_sent[:status] if attributes_sent.has_key?(:status)\n end\n \n if attributes_to_update.has_key?(:status) && attributes_to_update[:status] == Tutorial::Quest::STATE_DISPLAYED.to_s\n attributes_to_update[:displayed_at] = Time.now\n\n # Send Mail if required\n #quest_message = @tutorial_quest.quest[:message]\n #\n #if !quest_message.nil? && @tutorial_quest.status < Tutorial::Quest::STATE_DISPLAYED\n # Messaging::Message.create_tutorial_message(current_character, quest_message[I18n.locale][:subject], quest_message[I18n.locale][:body])\n #end\n end\n \n if attributes_sent.has_key?(:reward_displayed)\n attributes_to_update[:reward_displayed_at] = Time.now\n end\n\n respond_to do |format|\n if @tutorial_quest.update_attributes(attributes_to_update)\n format.html { redirect_to @tutorial_quest, notice: 'Quest was successfully updated.' }\n format.json { render json: {}, status: :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tutorial_quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def finish\n\t\t@frame = @frame + 1\n\t\tdone = false\n\t\tif @frame % 120 == 0 \n\t\t\tdone = [email protected]\n\t\tend\n\t\tif done\n\t\t\t@frame = 0\n\t\t\t@nextGameState = @map\n\t\telse\n\t\t\[email protected]\n\t\tend\n\tend",
"def update\n @completed_quest = CompletedQuest.find(params[:id])\n\n respond_to do |format|\n if @completed_quest.update_attributes(params[:completed_quest])\n format.html { redirect_to @completed_quest, notice: 'Completed quest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @completed_quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mark_program_as_completed_if_it_is\n if self.passed? and !self.program_player.completed? and self.program_budge.level >= self.program_player.program.last_level\n self.program_player.update_attributes(:completed => true, :victorious => (self.program_player.victorious == false ? nil : self.program_player.victorious))\n # self.program_player.user.contact_them(:email, :completed_program_congrats, self.program_player)\n Mailer.message_for_habit_labbers(\"#{self.program_player.user.name} completed #{self.program_player.program.name}!\",\n \"One of you Labbers should take a look at their progress through the program and \"+\n \"congratulate them on Twitter! \\n\\nhttp://#{DOMAIN}/dash/user/#{self.program_player.user.id}\").deliver rescue nil\n end\n end",
"def finishQuestion()\n # Compares the arrays of correct answers and user's selected answers\n # and creates another array with correct (true) answers\n arrTrueAnswers = $arrUserAnswers.zip($arrCorrectAnswers).map { |x, y| x == y}\n x = arrTrueAnswers.count(true)\n msgBox = Tk.messageBox(\n 'type' => \"ok\",\n 'icon' => \"info\",\n 'title' => \"GemQuiz - Stats\",\n 'message' => \"You have \" + x.to_s + \" correct answers out of \" + $intTotalQuestions.to_s + \".\n That's \" + ((x.to_f / $intTotalQuestions.to_f) * 100).round(2).to_s + \"%.\")\nend",
"def completed\n proptime 'COMPLETED'\n end",
"def quest\n @quest ||= Quest.find(params[:id])\n end",
"def completed?\n completed\n end",
"def run\n aciertos = 0\n puts name\n questions.each do |q|\n puts q\n print \"Su respuesta: \"\n resp = gets.chomp.to_i\n raise IndexError, \"Answer must be between 1 and #{q.answers.size}.\" unless resp <= q.answers.size and resp > 0\n if q.answers[resp-1].state\n puts \"Correcto!\".colorize(:light_green)\n @aciertos += 1\n else\n correcta = q.answers.select { |ans| ans.state }.first\n puts \"Fallo, la respuesta correcta era #{correcta}\".colorize(:red)\n end\n puts\n end\n puts \"Has acertado el #{(@aciertos/questions.size.to_f)*100}% de las preguntas [#{@aciertos} de #{questions.size}].\"\n end",
"def show\n calculate_progress\n ##complete_goal\n end",
"def complete\n end",
"def destroy\n @completed_quest = CompletedQuest.find(params[:id])\n @completed_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to completed_quests_url }\n format.json { head :ok }\n end\n end",
"def complete\n # check if an individual rep, complete reps of day if not\n if self.rep_parent.nil?\n self.repititions.\n where(:show_date => Date.current).each do |rep|\n rep.complete\n end\n return\n end\n\n if self.state != Activity::COMPLETE\n self.state = Activity::COMPLETE\n self.completed_date = DateTime.current\n self.save!\n self.rep_parent.count = self.rep_parent.count + 1\n self.rep_parent.save!\n end\n end",
"def complete_activity\n if self.activity.status != \"accepted and completed\"\n puts \"\"\n puts Rainbow(\"*\").blue * 70\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"Okay, now get busy!\" + Rainbow(\" (#{self.possibility.name})\").bright\n puts \"\"\n puts \"When you are finished, come back and press:\"\n puts \"\"\n puts \"\"\n puts \"1. If you have completed this activity\"\n puts \"2. If you got distracted and failed to complete the activity\"\n puts \"\"\n puts \"\"\n self.completed_activity = gets.strip\n self.quit if self.completed_activity == \"quit\"\n if [\"1\", \"2\"].all? { |i| self.completed_activity != i}\n self.what_was_that?\n self.complete_activity\n end\n if self.completed_activity == \"1\"\n self.activity.status = \"accepted and completed\"\n self.activity.save\n puts \"\"\n self.get_rating\n puts \"\"\n puts Rainbow(\"*\").blue * 70\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"Thanks for your rating!\"\n puts \"\"\n puts \"\"\n self.activity.activity_stats\n puts \"\"\n self.suggest_new_possibility?\n elsif self.completed_activity == \"2\"\n self.activity.status = \"accepted but not completed\"\n self.activity.save\n puts \"\"\n puts Rainbow(\"*\").blue * 70\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n self.suggest_new_possibility?\n end\n end\n end",
"def completed?\n completed == '1'\n end",
"def index\n @quests = Quest.all\n end",
"def index\n @quests = Quest.all\n end",
"def complete!\n update_attributes(completed_at: Time.now)\n pause! if running?\n end",
"def done?\n if @complete == \"Item complete\"\n return \"Item complete\"\n else\n return \"Item incomplete\"\n end\n end",
"def finished\n @tasks = @project.tasks.finished(true).paginate(:page => params[:page])\n @allow_reordering = false\n @final = true\n \n respond_to do |format|\n format.html # finished.html.erb\n end\n end",
"def activateQuest(quest,color,story)\n if !quest.is_a?(Symbol)\n raise _INTL(\"The 'quest' argument should be a symbol, e.g. ':Quest1'.\")\n end\n for i in 0...@active_quests.length\n if @active_quests[i].id == quest\n pbMessage(\"You have already started this quest.\")\n return\n end\n end\n for i in 0...@completed_quests.length\n if @completed_quests[i].id == quest\n pbMessage(\"You have already completed this quest.\")\n return\n end\n end\n for i in 0...@failed_quests.length\n if @failed_quests[i].id == quest\n pbMessage(\"You have already failed this quest.\")\n return\n end\n end\n @active_quests.push(Quest.new(quest,color,story))\n pbMessage(_INTL(\"\\\\se[{1}]<ac><c2=#{colorQuest(\"red\")}>New quest discovered!</c2>\\nCheck your quest log for more details!</ac>\",QUEST_JINGLE))\n end",
"def show_completed_items\n return @to_do_item.select { |x| x.is_done? == true }\n end",
"def incomplete!\n self.update_attribute(:is_completed, false)\n # TODO: send an email to teacher about tasks reopening\n end",
"def complete\n insert_completion @completer.current_completion\n @completer.popup.hide\n end",
"def new\n @completed_quest = CompletedQuest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @completed_quest }\n end\n end",
"def reveal_quest(quest_id); quest(quest_id).concealed = false; end",
"def completed\n @completed ||= count('completed')\n end",
"def index\n @completeds = current_user.completeds\n end",
"def set_mission_as_done\n mission = Mission.find(params[:id].to_i)\n entr_missions = mission.entr_mission_users\n\n # No users attached to the mission\n if entr_missions.empty?\n flash[:success] = \"<h2>La mission < #{mission.title} > <span style='color:red'>ne peut pas être terminée (aucun utilisateur)</span></h2>\".html_safe\n redirect_to :back\n return\n end\n \n # Set each user link as done\n entr_missions.each do |entr|\n # If the user was doing the mission\n if entr.state == EntrMissionUser::Status::CONFIRMED\n # Credit him\n entr.user.credit_user mission\n MissionMailer.delay.mission_finished(entr.user, mission)\n end\n entr.state = EntrMissionUser::Status::DONE\n entr.save\n end\n \n # Set mission state as finished\n mission.state = Mission::Status::FINISHED\n mission.save\n\n # End\n flash[:success] = \"<h2>La mission < #{mission.title} > a bien été terminée</h2>\".html_safe\n redirect_to :back\n end",
"def complete\n @todo_item.update_attribute(:completed_at, Time.now)\n redirect_to @todo_list, notice: \"Todo item completed\"\n end",
"def complete\n @project.complete!\n respond_to do |format|\n format.html { redirect_to request.referer||project_path(@project), notice: 'Project completed successfully!' }\n format.json { head :no_content }\n end\n end",
"def complete\n\t\tflash[:notice] = \"Donation completed. Thank you!\"\n\t\tredirect_to :controller => :projects, :action => :show, :id => params[:project_id]\n\tend",
"def finish_commands\n for i in 0..4\n if @mode_rdo[i].selected?\n $glob.game_mode = i - 1\n break\n end \n end\n if $glob.game_mode == -1\n $player = Players.new(Player.new,Player.new)\n else\n $player = Players.new(Player.new,CPU.new)\n end\n if !$player.act_p.human?\n choiced = $player.act_p.turn\n choiced.label_widget.set_markup($player.act_p.mark_markup)\n $player.switch_player\n end\n self.hide\n end",
"def check_completed\n\t\tend",
"def questions\n \n end",
"def quiz\n end",
"def run_round\n switch_player!\n question = Question.new\n puts \"----- NEW TURN -----\"\n puts \"#{@active_player.name} : #{question.display_question} \"\n answer = gets.chomp.to_i\n\n if question.correct?(answer)\n puts \"#{@active_player.name} : YES! You are correct.\"\n puts \"P#{@players[0].name[-1,1]} : #{@players[0].life}/3 vs P#{@players[1].name[-1,1]} : #{@players[1].life}/3\"\n else\n puts \"#{@active_player.name} : Seriously? No!\"\n @active_player.minuslife\n puts \"P#{@players[0].name[-1,1]} : #{@players[0].life}/3 vs P#{@players[1].name[-1,1]} : #{@players[1].life}/3\"\n end\n end",
"def perform(user, questions)\n \n end",
"def find_selected\n selected_quests = self.user_quests.where(complete: false)\n selected_quests.map do |x|\n x.quest_id\n end\n end",
"def complete(to_do_item)\n response = to_do_item\n response[:complete] = true\n response\n end"
] | [
"0.67578393",
"0.6722168",
"0.67007244",
"0.66515607",
"0.6633203",
"0.6424803",
"0.64002126",
"0.6333337",
"0.6324548",
"0.63061446",
"0.6277629",
"0.62245256",
"0.6198071",
"0.61739576",
"0.6167319",
"0.6144824",
"0.6123756",
"0.60783225",
"0.60393655",
"0.59907323",
"0.5916076",
"0.5916076",
"0.5905892",
"0.5892694",
"0.5881833",
"0.58765614",
"0.58751947",
"0.5873202",
"0.5862056",
"0.5860893",
"0.5837918",
"0.58376545",
"0.5823795",
"0.5819355",
"0.57983446",
"0.5761127",
"0.5739473",
"0.57349724",
"0.5721475",
"0.5718197",
"0.5694332",
"0.56754106",
"0.56639844",
"0.5660541",
"0.5651561",
"0.56311417",
"0.563109",
"0.5624341",
"0.5624341",
"0.56141776",
"0.56127185",
"0.5608453",
"0.559663",
"0.55954",
"0.5592827",
"0.559219",
"0.5592023",
"0.5587353",
"0.558649",
"0.5582565",
"0.5582443",
"0.55795985",
"0.55793965",
"0.55790704",
"0.55787253",
"0.55676",
"0.55557925",
"0.5555236",
"0.5553461",
"0.5541861",
"0.5536437",
"0.5533744",
"0.55304605",
"0.5524716",
"0.55075103",
"0.55023235",
"0.55023235",
"0.54919875",
"0.54882306",
"0.548717",
"0.5476885",
"0.5472604",
"0.5466084",
"0.5463746",
"0.54598397",
"0.5452077",
"0.5450778",
"0.54494935",
"0.54325265",
"0.54195815",
"0.541752",
"0.5416047",
"0.54158205",
"0.54140216",
"0.5413596",
"0.5405799",
"0.54046106",
"0.5401844",
"0.5385569",
"0.5383251"
] | 0.7854303 | 0 |
method for obtaining the uncompleted quests for a given player returns quest instances | def get_uncompleted_quests()
Quest.all.select do |quest|
quest.characters.include?(self) == false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_completed_quests\n\n#check if the player has actually completed any quests\n#if he has not, tell him\n if self.quests.size == 0\n puts \"You have not completed any quests!!!\".red\n\n#otherwise, pull the completed quest objects and print the quest titles\n else\n puts \"Completed Quests:\".underline\n self.quests.each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end\n end",
"def getFailedQuests\n failed = []\n $PokemonGlobal.quests.failed_quests.each do |s|\n failed.push(s.id)\n end\n return failed\nend",
"def getCompletedQuests\n completed = []\n $PokemonGlobal.quests.completed_quests.each do |s|\n completed.push(s.id)\n end\n return completed\nend",
"def general_quests\n quests = UsersQuest.where(:assignee_id => @current_user.id,:is_accepted => true).where.not(:assignor_id => @current_user.id).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n end",
"def get_recommended_quests(difficulty)\n self.get_uncompleted_quests.select do |quest|\n quest.difficulty == difficulty\n end\n end",
"def pending_quests\n quests = UsersQuest.where(:assignee_id => @current_user.id,:is_accepted => false,:is_rejected =>false).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n by_me_quests = UsersQuest.where(:assignor_id => @current_user.id,:is_accepted => false,:is_rejected =>false).pluck(:quest_id)\n @by_me_quests = Quest.where(:id => by_me_quests).order('due_date')\n end",
"def getActiveQuests\n active = []\n $PokemonGlobal.quests.active_quests.each do |s|\n active.push(s.id)\n end\n return active\nend",
"def index\n # TODO: Find personal quests\n quests = UsersQuest.where(:assignor_id => @current_user.id).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n end",
"def find_completed\n completed = self.user_quests.where(complete: true)\n completed.map do |x|\n x.quest_id\n end\n end",
"def completed_quests; $game_variables[17]; end",
"def find_selected\n selected_quests = self.user_quests.where(complete: false)\n selected_quests.map do |x|\n x.quest_id\n end\n end",
"def uncompleted_items\n new? ? Array.new : Item.uncompleted(@id)\n end",
"def unanswered_check_in_questions\n action_items.where(component_type:Check::COMPONENT_TYPE, day:1..day.to_i).select{|i| !i.complete?}\n end",
"def show\n @quest = Quest.find(params[:id])\n quest_objectives = @quest.locations\n completed_objectives = []\n quest_objectives.each do |obj|\n if @current_user.locations.exists?(obj)\n completed_objectives << obj\n end\n end\n if completed_objectives.length == quest_objectives.length\n unless @quest.winner_id\n @quest.update(winner_id: @current_user.id)\n end\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n end\n\n if(@quest.owner_id == @current_user.id)\n redirect_to edit_quest_path(@quest)\n elsif @quest.start_date > DateTime.current\n flash[:warning] = \"Quest has not yet begun!\"\n redirect_to user_path(@current_user) and return\n elsif @quest.end_date < DateTime.current\n flash[:warning] = \"Quest has ended. Womp womp\"\n\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n elsif @quest.users.exists?(@current_user.id)\n gon.track = true\n locations = @quest.locations\n gon.remaining_locations = []\n gon.completed_locations = []\n locations.each do |loc|\n if loc.users.exists?(@current_user.id)\n gon.completed_locations << loc\n else\n gon.remaining_locations << loc\n end\n end\n @remaining_locations = gon.remaining_locations\n @completed_locations = gon.completed_locations\n else\n gon.track = false\n flash[:danger] = \"You are not a member of this quest! Please contact the quest owner for an invite.\"\n redirect_to quests_path and return\n end\n end",
"def index\n @quest_items = QuestItem.all\n end",
"def quest(quest_id); $game_party.quests[quest_id]; end",
"def get_quest\n\t\tget_data\n\n\t\t$finish = false\n\t\tunless $finish == true\n\t\t\t$randId = rand(0...(@data.length-1))\n\t\t\twhile $quiz_arr.include?(@data[$randId]['id'])\n\t\t\t\t$randId = rand(0...(@data.length-1))\n\t\t\tend\n\t\t\t$quiz_arr.push(@data[$randId]['id'])\n\t\t\t$i += 1\n\n\t\t\tif $i == 7\n\t\t\t\t$finish = true\n\t\t\tend\n\n\t\t\t@quest = @data[$randId]['question_name']\n\t\t\t@c_answer = @data[$randId]['c_answer']\n\t\t\t@alt1 = @data[$randId]['alt1']\n\t\t\t@alt2 = @data[$randId]['alt2']\n\t\t\t@alt3 = @data[$randId]['alt3']\n\t\t\t@imgurl = @data[$randId]['imgurl']\n\t\t\t@url = @data[$randId]['news_url']\n\t\t\t@cat = @data[$randId]['category_id']\n\t\t\t@hex = @data[$randId]['category_hex_code']\n\t\t\tget_descriptions(@url)\n\t\t\t@image = @desc_data['image']\n\n\t\t\t$answer_array = Array.new()\n\t \tend\n\tend",
"def unavailable_players\n players = []\n self.cached_teamsheet_entries.each do |teamsheet_entry|\n if teamsheet_entry.response_status == InviteResponseEnum::UNAVAILABLE\n players << teamsheet_entry.user\n end\n end\n players\n end",
"def quest_interface\n\n#obtain the difficulty level for the given player\n difficulty = self.get_difficulty\n\n#see if the player has any quests left to complete\n if self.get_recommended_quests(difficulty).size == 0\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"You have completed all recommended quests!!!\".bold\n puts \"=====================================\".red\n puts \"=====================================\".red\n\n#show the player the available quests\n else\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Recommended Quests for Player Attack: #{self.power}\".blue.on_light_green.bold\n puts \"\"\n self.print_quests(difficulty)\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Select a quest number\".bold.white.on_light_blue\n puts \"Number:\".bold.white.on_light_blue\n\n#selection prompt the player to actually choose a quest\n selection = gets.chomp\n\n#check for invalid input\n if selection.to_i > self.get_recommended_quests(difficulty).size || selection.to_i < 1\n puts \"Invalid input, please try again!\".red.bold\n\n#if input is valid, show the player that he has completed the quest\n else\n puts\"*******************************************\"\n puts \"You have completed: #{self.get_recommended_quests(difficulty)[selection.to_i-1].title}\".bold\n puts\"*******************************************\"\n puts \" \"\n puts\"#####################################\".blink\n puts \"Time For Your Reward Adventurer!!!\".bold.blue.on_light_yellow\n\n #obtain the available weapons based on player difficulty\n available_weapons = self.get_available_weapons(difficulty)\n\n #create the new characterquest instance to show that player has completed the quest\n self.quest_selection(selection, difficulty)\n\n #run the weapon_reward method to get reward for the quest\n self.weapon_reward(available_weapons)\n end\n end\n end",
"def missing_answers\n return @missing_answers if @missing_answers\n answer_for_qing(:rebuild => true)\n @missing_answers = visible_questionings.collect do |qing|\n (answer_for(qing).nil? && qing.required?) ? qing : nil\n end.compact\n end",
"def unanswered_questions\n Question.all.reject do |question|\n responsers_id = question.responses.pluck(:user_id)\n responsers_id.include?(self.id)\n end\n end",
"def index\n @quests = Quest.all\n end",
"def index\n @quests = Quest.all\n end",
"def show\n @thisAccount = Account.find(params[:id])\n\n @readyQuests = Quest.where('attack <= ?', @thisAccount.attack)\n .where('strength <= ?', @thisAccount.strength)\n .where('defence <= ?', @thisAccount.defence)\n .where('ranged <= ?', @thisAccount.ranged)\n .where('prayer <= ?', @thisAccount.prayer)\n .where('magic <= ?', @thisAccount.magic)\n .where('runecrafting <= ?', @thisAccount.runecrafting)\n .where('construction <= ?', @thisAccount.construction)\n .where('hitpoints <= ?', @thisAccount.hitpoints)\n .where('agility <= ?', @thisAccount.agility)\n .where('herblore <= ?', @thisAccount.herblore)\n .where('thieving <= ?', @thisAccount.thieving)\n .where('crafting <= ?', @thisAccount.crafting)\n .where('fletching <= ?', @thisAccount.fletching)\n .where('slayer <= ?', @thisAccount.slayer)\n .where('hunter <= ?', @thisAccount.hunter)\n .where('mining <= ?', @thisAccount.mining)\n .where('smithing <= ?', @thisAccount.smithing)\n .where('fishing <= ?', @thisAccount.fishing)\n .where('cooking <= ?', @thisAccount.cooking)\n .where('firemaking <= ?', @thisAccount.firemaking)\n .where('woodcutting <= ?', @thisAccount.woodcutting)\n\n @notReadyQuests = Quest.where('attack >= ?', @thisAccount.attack)\n .where('strength > ?', @thisAccount.strength)\n .where('defence > ?', @thisAccount.defence)\n .where('ranged > ?', @thisAccount.ranged)\n .where('prayer > ?', @thisAccount.prayer)\n .where('magic > ?', @thisAccount.magic)\n .where('runecrafting > ?', @thisAccount.runecrafting)\n .where('construction > ?', @thisAccount.construction)\n .where('hitpoints > ?', @thisAccount.hitpoints)\n .where('agility > ?', @thisAccount.agility)\n .where('herblore > ?', @thisAccount.herblore)\n .where('thieving > ?', @thisAccount.thieving)\n .where('crafting > ?', @thisAccount.crafting)\n .where('fletching > ?', @thisAccount.fletching)\n .where('slayer > ?', @thisAccount.slayer)\n .where('hunter > ?', @thisAccount.hunter)\n .where('mining > ?', @thisAccount.mining)\n .where('smithing > ?', @thisAccount.smithing)\n .where('fishing > ?', @thisAccount.fishing)\n .where('cooking > ?', @thisAccount.cooking)\n .where('firemaking > ?', @thisAccount.firemaking)\n .where('woodcutting > ?', @thisAccount.woodcutting)\n end",
"def quest; end",
"def complete_quests(options={})\n options.reverse_merge!(:count => 1)\n\n @objectives.push([\n Objective::CompleteQuests,\n {:key => Objective::CompleteQuests::KEY, :count => options[:count]}\n ])\n end",
"def quest\n @quest ||= Quest.find(params[:id])\n end",
"def get_available_weapons(difficulty)\n\n#if the difficulty of the quest is 1\n#only select weapons with attack power less than or equal to 3\n# and that the player has not yet obtained\n if difficulty == 1\n available_weapons = Weapon.all.where(\"attack_power <=3\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n#if the difficulty of the quest is 2\n#only select weapons with attack power greater than 3 and less than or equal to 6\n# and that the player has not yet obtained\n elsif difficulty == 2\n available_weapons = Weapon.all.where(\"attack_power >3 and attack_power <= 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n\n#if the difficulty of the quest is 3\n#only select weapons with attack power greater than 6\n# and that the player has not yet obtained\n else\n available_weapons = Weapon.all.where(\"attack_power > 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n end\n end",
"def universal_questions()\n assigned_questions = Question.scoped\n assigned_questions =assigned_questions.where(:rotation => nil) unless rotation == nil\n assigned_questions =assigned_questions.where(:year => nil) unless year == nil\n return assigned_questions\n end",
"def get_unanswered_questions_for_user(user)\n raise 'user is nil' if user.nil?\n \n # Get questions the user has answered.\n user_answered_questions = QuestionResponse.where(:user_id => user.id).map(&:question)\n \n # Subtract those from the full set of questions to get the set of any that\n # have not been answered.\n questions - user_answered_questions\n end",
"def init_quest\n @quest = Quest.find_by_id(params[:id])\n @quest ||= Quest.draft(params[:id])\n end",
"def index\n @computers_quests = ComputersQuest.all\n end",
"def completeQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.completeQuest(quest,color,story)\nend",
"def unanswered_questions\n answered_ids = self.responses.map(&:beta_question_id)\n BetaQuestion.where.not(id: answered_ids)\n end",
"def start_player_quest_line(player_id)\n quest_ids = without_locking do\n Quest.select(\"`id`\").where(parent_id: nil)\n end.c_select_values\n quest_progresses = quest_ids.map do |quest_id|\n QuestProgress.new(player_id: player_id, quest_id: quest_id)\n end\n BulkSql::QuestProgress.save(quest_progresses)\n\n objective_ids = without_locking do\n Objective.select(\"`id`\").where(quest_id: quest_ids)\n end.c_select_values\n objective_progresses = objective_ids.map do |objective_id|\n ObjectiveProgress.new(player_id: player_id, objective_id: objective_id)\n end\n BulkSql::ObjectiveProgress.save(objective_progresses)\n end",
"def remaining_players\n\t\tself.players.where(:rank => nil)\n\tend",
"def in_progress_games(other_player)\n games.where(\n 'complete = ? AND (challenger_id = ? OR challenged_id = ?)',\n false,\n other_player.id,\n other_player.id\n )\n end",
"def in_progress_games(other_player)\n games.where(\n 'complete = ? AND (challenger_id = ? OR challenged_id = ?)',\n false,\n other_player.id,\n other_player.id\n )\n end",
"def index\n \n last_modified = nil\n\n if params.has_key?(:character_id) # request using character_id \n \n state = Tutorial::State.find_by_character_id(params[:character_id])\n raise NotFoundError.new('No quests found for character id.') if state.nil?\n raise ForbiddenError.new('Access forbidden.') if state.owner != current_character && !staff? && !admin?\n \n @tutorial_quests = if api_request? # send only the relevant quests (those, that have not been finished yet)\n state.quests.non_closed \n else # display all quests in backend\n state.quests.paginate(:page => params[:page], :per_page => 50) \n end\n last_modified = state.updated_at.utc # the state is touched on changed on the quests\n \n else # request all \n raise ForbiddenError.new('Access forbidden.') if !staff? && !admin? \n @tutorial_quests = Tutorial::Quest.paginate(:page => params[:page], :per_page => 50)\n end\n \n if stale?(:last_modified => last_modified, :etag => @tutorial_quests)\n respond_to do |format|\n format.html \n format.json { render json: @tutorial_quests }\n end\n end\n end",
"def index\n @unavailable_players = UnavailablePlayer.all\n end",
"def incomplete_tasks\n\t\ttasks.select{ |t| !t.completed? }\n\tend",
"def candidates\n players = []\n players += Player.where(:position => \"QB\").first(20)\n players += Player.where(:position => \"RB\").first(20)\n players += Player.where(:position => \"WR\").first(20)\n players\n end",
"def unanswered_questions; questions_not_matching_query(answered_questions_query); end",
"def civ_unsubmitted_players\n return if !@daemon\n\n status = @daemon.status\n if status['civ']\n Set.new status['civ']['players_unsubmitted']\n end\n end",
"def unanswered_questionnaires\r\n (Questionnaire.by_language_published(I18n.locale).all - answered_questionnaires) rescue []\r\n end",
"def find_completed\n self.all(\n :completed_at.not => nil, \n :order => [:title])\n end",
"def print_quests(difficulty)\n self.get_recommended_quests(difficulty).each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end",
"def player_pokemon_entities\n player_mon = (0...pokemon_count).map { |i| $actors[i] }\n player_mon.compact!\n player_mon.reject!(&:dead?)\n return player_mon\n end",
"def get_unfinished_todos\n return Todo.where({\"user_id\" => self.id, \"completed\" => false})\n end",
"def therapist_quest; end",
"def questions\n result = []\n 1.upto(@@max_questions) { |i| result << question(i) }\n result.select { |q| !q.empty? }\n end",
"def get_tasks_from_todoist\n return Todoist::Task.uncompleted(PROGRAMMING_PROJECT_ID)\n end",
"def get_trial_suggestions\n case @last_played.size\n when 0\n load_trials({\n 'San Francisco' => :very_easy,\n 'The Bunker' => :very_easy,\n 'Caravel Ships' => :easy,\n })\n when 1\n load_trials({\n 'San Francisco' => :very_easy,\n 'The Bunker' => :very_easy,\n 'Caravel Ships' => :easy,\n 'Tower in the Castle' => :medium,\n })\n when 2\n load_trials({\n 'San Francisco' => :very_easy,\n 'Caravel Ships' => :very_easy,\n 'Tower in the Castle' => :easy,\n 'Cat Mountain Climb' => :medium,\n 'Moonlit Woods' => :medium,\n })\n when 3\n load_trials({\n 'San Francisco' => :very_easy,\n 'Tower in the Castle' => :easy,\n 'Cat Mountain Climb' => :easy,\n 'Moonlit Woods' => :easy,\n 'Egypt Pyramid' => :medium,\n 'The Cave' => :medium,\n })\n when 4\n load_trials({\n 'Tower in the Castle' => :very_easy,\n 'Cat Mountain Climb' => :easy,\n 'Moonlit Woods' => :easy,\n 'Egypt Pyramid' => :medium,\n 'The Cave' => :medium,\n 'Cyberpunk Ruins' => :hard,\n 'Steamport Town' => :hard,\n })\n when 5\n load_trials({\n 'Cat Mountain Climb' => :very_easy,\n 'Moonlit Woods' => :easy,\n 'Egypt Pyramid' => :easy,\n 'The Cave' => :easy,\n 'Cyberpunk Ruins' => :medium,\n 'Steamport Town' => :medium,\n 'Find the Dragon' => :hard,\n 'Star Hopping' => :hard,\n })\n when 6\n load_trials({\n 'Cat Mountain Climb' => :very_easy,\n 'Moonlit Woods' => :very_easy,\n 'Egypt Pyramid' => :easy,\n 'The Cave' => :easy,\n 'Cyberpunk Ruins' => :medium,\n 'Steamport Town' => :medium,\n 'Find the Dragon' => :hard,\n 'Star Hopping' => :hard,\n 'Shadow of Valus' => :very_hard,\n 'The Cube' => :very_hard,\n })\n when 7\n load_trials({\n 'Tower in the Castle' => :easy,\n 'Moonlit Woods' => :very_easy,\n 'Egypt Pyramid' => :easy,\n 'The Cave' => :easy,\n 'Cyberpunk Ruins' => :medium,\n 'Steamport Town' => :medium,\n 'Find the Dragon' => :hard,\n 'Star Hopping' => :hard,\n 'Shadow of Valus' => :very_hard,\n 'The Cube' => :very_hard,\n 'Temple City' => :very_hard,\n })\n else\n nil # if user already played more than 6 games, then return nil (will get delegated to get_standard_suggestions)\n end\n end",
"def getQuestStages(quest)\n arr = []\n for key in QuestModule.const_get(quest).keys\n arr.push(key) if key.to_s.include?(\"Stage\")\n end\n return arr\n end",
"def alive_players\n @players.reject{|p| p.dead? }\n end",
"def init_maqj_data\n @quests = Game_Quests.new # Initialize @quests\n end",
"def retrieve_unanswered(parameters = {})\n hash, url = request('questions/unanswered', parameters)\n Questions.new hash, url\n end",
"def dm_unplayed\n question = game.current_round.question.print\n m = []\n m << \"`[#{game.name}]` | \"\\\n \"Round ##{game.rounds.count} Question: **#{question}**\"\n m << \"**Your Cards:**\"\n unplayed_cards.each_with_index do |c, i|\n m << \"**#{i+1}.** ▫ #{c.answer.text}\"\n end\n m << 'Respond with `pick [number]` to pick a card for this round. '\\\n 'Do one `pick` for each card!'\n discord_user.pm(m.join(\"\\n\"))\n end",
"def answerable_questions\n answerable = []\n\n unanswered_questions.each do |question|\n answerable.push(question) if precondition_met(question)\n end\n\n return answerable\n end",
"def check_questions\n response = Request.get_request(URL_QUESTION)\n questions = []\n if response.success?\n data = Request.manage_response(response)\n end\n data.each do |question|\n questions << Question.new(question)\n end\n questions\nend",
"def remaining_player\n @players.select {|player| !player.dead?}\n end",
"def index\n @quest_stats = QuestStat.all\n end",
"def index\n @quests=Quest.all\n\n end",
"def unplayed_cards\n player_cards.select { |c| c.unplayed? }\n end",
"def quest_params\n params.require(:quest).permit(:user_id, :quest, :result)\n end",
"def show_not_completed_items\n return @to_do_item.select { |x| x.is_done? == false }\n end",
"def failQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.failQuest(quest,color,story)\nend",
"def getPlayers(position,type)\n if type == \"postdraft\"\n begin\n if position == \"Full\"\n @response = (RestClient.get \"https://fantasysports.yahooapis.com/fantasy/v2/league/nhl.l.#{params[:leagueid]}/players;status=W;start=0;count=25;sort=AR;\", :authorization => \"Bearer #{params[:token]}\")\n else\n @response = (RestClient.get \"https://fantasysports.yahooapis.com/fantasy/v2/league/nhl.l.#{params[:leagueid]}/players;status=W;start=0;count=25;sort=AR;position=#{position}\", :authorization => \"Bearer #{params[:token]}\")\n end\n @waivers.push(*Hash.from_xml(@response.body)['fantasy_content']['league']['players']['player']) \n for i in 0..2 do\n if position == \"Full\"\n @response = (RestClient.get \"https://fantasysports.yahooapis.com/fantasy/v2/league/nhl.l.#{params[:leagueid]}/players;status=FA;start=#{i*25};count=25;sort=AR;\", :authorization => \"Bearer #{params[:token]}\")\n else\n @response = (RestClient.get \"https://fantasysports.yahooapis.com/fantasy/v2/league/nhl.l.#{params[:leagueid]}/players;status=FA;start=#{i*25};count=25;sort=AR;position=#{position}\", :authorization => \"Bearer #{params[:token]}\")\n end\n @freeagents.push(*Hash.from_xml(@response.body)['fantasy_content']['league']['players']['player']) \n end\n getFAInfo(\"Yes\",@waivers)\n getFAInfo(\"No\",@freeagents)\n rescue\n @freeagents = []\n for i in 0..3 do\n if position == \"Full\"\n @response = (RestClient.get \"https://fantasysports.yahooapis.com/fantasy/v2/league/nhl.l.#{params[:leagueid]}/players;status=A;start=#{i*25};count=25;sort=AR;\", :authorization => \"Bearer #{params[:token]}\")\n else\n @response = (RestClient.get \"https://fantasysports.yahooapis.com/fantasy/v2/league/nhl.l.#{params[:leagueid]}/players;status=A;start=#{i*25};count=25;sort=AR;position=#{position}\", :authorization => \"Bearer #{params[:token]}\")\n end\n @freeagents.push(*Hash.from_xml(@response.body)['fantasy_content']['league']['players']['player']) \n end\n getFAInfo(\"No\",@freeagents)\n end\n else\n @freeagents = []\n for i in 0..5 do\n if position == \"Full\"\n @response = (RestClient.get \"https://fantasysports.yahooapis.com/fantasy/v2/league/nhl.l.#{params[:leagueid]}/players;status=A;start=#{i*25};count=25;sort=OR;\", :authorization => \"Bearer #{params[:token]}\")\n else\n @response = (RestClient.get \"https://fantasysports.yahooapis.com/fantasy/v2/league/nhl.l.#{params[:leagueid]}/players;status=A;start=#{i*25};count=25;sort=OR;position=#{position}\", :authorization => \"Bearer #{params[:token]}\")\n end\n @freeagents.push(*Hash.from_xml(@response.body)['fantasy_content']['league']['players']['player']) \n end\n getFAInfo(\"N/A\",@freeagents)\n end\nend",
"def get_choices(question)\n puts 'get_choices()'\n choices = Choice.select('id, prompt').find(question.correct_choice_id, question.close_choice_id)\n choices += Choice.select('id, prompt').where.not(id: question.correct_choice_id).where.not(id: question.close_choice_id).where(choice_type:0).shuffle.first(3)\n choices.shuffle!\n end",
"def each_quest(&block)\r\n @quests.each(&block)\r\n end",
"def index\n if logged_as_teacher?\n @sidequest= Sidequest.new\n @sidequests = Sidequest.where(teacher_id: session[:user_id])\n end\n if logged_as_student?\n student = Student.find(session[:user_id])\n progres = student.progre\n @sidequests = Sidequest.where(level: progres.lvl, finished: false)\n end\n end",
"def generate_questions(room)\n mastered_questions_id = room.mastered_questions.collect{ |q| q.id}\n unmastered_questions = mastered_questions_id.empty? ? Question.scoped : Question.where(\"id NOT IN (?)\", mastered_questions_id)\n # If the room_mode's name is one the the categories' names\n if categories = CategoryType.where(category_name: self.title) and categories != []\n # Find all the question types associated with that category\n question_types = categories[0].question_types.select(:id)\n output = unmastered_questions.where(:question_type_id => question_types)\n elsif self.namespace == \"replay\"\n output = room.users[0].failed_questions\n elsif self.namespace == \"smart\"\n profile_array=room.users.map {|user| user.profile}\n exp_array = profile_array.map {|profile| profile.exp}.sort\n min_exp = exp_array.first\n max_exp = exp_array.last\n output = unmastered_questions.where(exp: (min_exp-50)..(max_exp+50))\n elsif self.namespace == \"shuffled\"\n output = Question.scoped\n end\n return shuffle(output)\n end",
"def uncompleted\n if params.has_key?(:project_id) && is_numeric?(params[:project_id]) && params[:project_id] != '0'\n work_orders = WorkOrder.uncompleted(params[:project_id])\n else\n work_orders = WorkOrder.uncompleted\n end\n if !work_orders.blank?\n render json: serialized_work_orders(work_orders)\n else\n render json: :not_found, status: :not_found\n end\n end",
"def hasAnyQuests?\n if $PokemonGlobal.quests.active_quests.length >0 || \n $PokemonGlobal.quests.completed_quests.length >0 ||\n $PokemonGlobal.quests.failed_quests.length >0\n return true\n end\n return false \nend",
"def completed_items\n new? ? Array.new : Item.completed(@id)\n end",
"def get_unowned_snippets\r\n admin = User.find_by admin: true\r\n admin_snippets = Snippet.where(:default => true).where(:user => admin)\r\n users_default_snippets = Snippet.accessible_by(current_ability).where(:default => true)\r\n\r\n unowned_snippets = admin_snippets\r\n user_snippets = users_default_snippets.pluck(:default_id).uniq\r\n if !user_snippets.empty?\r\n unowned_snippets = unowned_snippets.where('id NOT IN (?)', user_snippets)\r\n else\r\n unowned_snippets = admin_snippets\r\n end\r\n unowned_snippets.each do |unowned_snippet|\r\n p unowned_snippet.inspect\r\n end\r\n unowned_snippets\r\n end",
"def skipped_questions\n @questions.each do |number, question|\n if @user_answers[number] == 'no answer'\n puts \"Question #{number}: #{question}\"\n print \"> \"\n response = gets.strip\n @user_answers[number] = response\n end\n end\n end",
"def members_not_paid_tithe\n members.where.not(id: payments.completed.where(goal: 'tithe', payment_at: Time.current.beginning_of_month..Time.current).pluck(:user_id))\n end",
"def incomplete_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :pending\n end\n end",
"def players\n [player_one, player_two].compact\n end",
"def incompleteItemsWithAndWithoutDates\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select!{|item| item.done? == 'Item incomplete'}\n @to_do_items.select!{|item| item.done? == 'Item incomplete'}\n @incomplete_array = @due_items.concat(@to_do_items)\n end",
"def start_child_quests(parent_id, player_id)\n without_locking do\n Quest.where(:parent_id => parent_id).all\n end.each do |quest|\n begin\n quest_progress = QuestProgress.new(:quest_id => quest.id,\n :player_id => player_id, :status => QuestProgress::STATUS_STARTED)\n quest_progress.save!\n rescue ActiveRecord::RecordNotUnique => e\n # WTF, this should not be happening!\n LOGGER.warn \"QuestProgress not unique for player id #{player_id\n }, quest #{quest}.\\n\\n#{e.to_s}\"\n end\n end\n end",
"def players\n return [User.find_by(id: player1_id), User.find_by(id: player2_id),\n User.find_by(id: player3_id), User.find_by(id: player4_id)].compact\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def all_competitor_results\n nil\n end",
"def quest(id) \n\tsys('quest')\n\t$progress.add_quest(id) \n\tpop_quest(id)\n\t$scene.hud.quest_sparkle(\"misc/profile\")\nend",
"def make_item_list\n @data = @category ? $game_party.quests.list(@category) : []\n end",
"def unreplied_surveys\n unreplied_survey_ids = Survey.surveys_for(self).collect{|s| s.id if s.try(:id)}.compact - completed_surveys.ids\n unreplied_survey_ids.empty? ? nil : unreplied_survey_ids\n end",
"def get_all_completed_items(params = {})\n if params[\"until\"]\n params[\"until\"] = ParseHelper.format_time(params[\"until\"])\n end\n if params[\"since\"]\n params[\"since\"] = ParseHelper.format_time(params[\"since\"])\n end\n \n result = @client.api_helper.get_response(Config::TODOIST_COMPLETED_GET_ALL_COMMAND, params)\n items = ParseHelper.make_objects_as_array(result[\"items\"])\n projects = ParseHelper.make_objects_as_array(result[\"projects\"])\n return {\"items\" => items, \"projects\" => projects}\n end",
"def quest_book\n GamePlay::QuestBookMenu.new.main\n Graphics.transition\n @wait_count = 2\n end",
"def unpaid_line_items\n @unpaid_line_items ||= line_items.find_all_by_paid(false)\n end",
"def players_remaining\n\t\tself.players.where(:rank => nil)\n\tend",
"def destroy\r\n @quest = @kingdom.quests.find(params[:id])\r\n unless verify_quest_not_in_use(@quest)\r\n redirect_to :action => 'index', :page => params[:page]\r\n return\r\n end\r\n \r\n @quest.reqs.each{|r| r.destroy} \r\n flash[:notice] = 'Deleted all requirements.<br/>'\r\n \r\n if @quest.destroy\r\n flash[:notice] += 'Destroyed the quest.'\r\n redirect_to :action => 'index', :page => params[:page]\r\n else\r\n flash[:notice] += 'Failed to destroy the quest.'\r\n redirect_to :action => 'show', :id => params[:id]\r\n end\r\n end",
"def all_quests(adventure_hash)\n adventure_hash[:knights].collect do |details| # collect *returns* an array, which is what we need. \n details[:quest]\n end\nend",
"def quest_selection(input, difficulty)\n quest_id = self.get_recommended_quests(difficulty)[input.to_i-1].id\n CharacterQuest.new_character_quest(self.id, quest_id)\n end",
"def players\n @players.select(&:playing)\n end",
"def competition_results\n results.select(&:competition_result?)\n end"
] | [
"0.698155",
"0.65838313",
"0.6568926",
"0.6389885",
"0.6305128",
"0.6293106",
"0.6238996",
"0.6164167",
"0.6066384",
"0.5897755",
"0.58861184",
"0.5831168",
"0.5784433",
"0.5762329",
"0.56853086",
"0.56280303",
"0.5556631",
"0.55530924",
"0.5545699",
"0.5541987",
"0.5539793",
"0.5504405",
"0.5504405",
"0.5475496",
"0.5450525",
"0.54203975",
"0.54045635",
"0.53464216",
"0.5345359",
"0.5272852",
"0.5261126",
"0.5242943",
"0.5238803",
"0.5238655",
"0.52338785",
"0.5231821",
"0.5231478",
"0.5231478",
"0.52198327",
"0.5212957",
"0.521217",
"0.52088326",
"0.5208438",
"0.51967716",
"0.51769376",
"0.5173333",
"0.51730686",
"0.5171201",
"0.5170844",
"0.5157756",
"0.5153966",
"0.514381",
"0.5137498",
"0.5132611",
"0.5127655",
"0.5127428",
"0.5113861",
"0.5090884",
"0.50886285",
"0.50772977",
"0.50707364",
"0.5067664",
"0.50661695",
"0.50591445",
"0.50512046",
"0.5035638",
"0.5014573",
"0.49944273",
"0.4992006",
"0.4991151",
"0.4975525",
"0.49669853",
"0.4947115",
"0.49413484",
"0.4928748",
"0.49282548",
"0.4925687",
"0.49179992",
"0.49118054",
"0.48959768",
"0.48935026",
"0.48920327",
"0.48876977",
"0.48815778",
"0.48815778",
"0.48815778",
"0.48815778",
"0.48815778",
"0.48757476",
"0.48714986",
"0.48708192",
"0.48648226",
"0.48604923",
"0.48594072",
"0.4851476",
"0.48474908",
"0.4835827",
"0.48328146",
"0.48307282",
"0.48269713"
] | 0.7651346 | 0 |
use the uncompleted quest instances to obtain those that are of a certain difficulty | def get_recommended_quests(difficulty)
self.get_uncompleted_quests.select do |quest|
quest.difficulty == difficulty
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_uncompleted_quests()\n Quest.all.select do |quest|\n quest.characters.include?(self) == false\n end\n\n end",
"def print_quests(difficulty)\n self.get_recommended_quests(difficulty).each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end",
"def get_available_weapons(difficulty)\n\n#if the difficulty of the quest is 1\n#only select weapons with attack power less than or equal to 3\n# and that the player has not yet obtained\n if difficulty == 1\n available_weapons = Weapon.all.where(\"attack_power <=3\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n#if the difficulty of the quest is 2\n#only select weapons with attack power greater than 3 and less than or equal to 6\n# and that the player has not yet obtained\n elsif difficulty == 2\n available_weapons = Weapon.all.where(\"attack_power >3 and attack_power <= 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n\n#if the difficulty of the quest is 3\n#only select weapons with attack power greater than 6\n# and that the player has not yet obtained\n else\n available_weapons = Weapon.all.where(\"attack_power > 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n end\n end",
"def general_quests\n quests = UsersQuest.where(:assignee_id => @current_user.id,:is_accepted => true).where.not(:assignor_id => @current_user.id).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n end",
"def get_completed_quests\n\n#check if the player has actually completed any quests\n#if he has not, tell him\n if self.quests.size == 0\n puts \"You have not completed any quests!!!\".red\n\n#otherwise, pull the completed quest objects and print the quest titles\n else\n puts \"Completed Quests:\".underline\n self.quests.each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end\n end",
"def getFailedQuests\n failed = []\n $PokemonGlobal.quests.failed_quests.each do |s|\n failed.push(s.id)\n end\n return failed\nend",
"def find_selected\n selected_quests = self.user_quests.where(complete: false)\n selected_quests.map do |x|\n x.quest_id\n end\n end",
"def quest(quest_id); $game_party.quests[quest_id]; end",
"def find_completed\n completed = self.user_quests.where(complete: true)\n completed.map do |x|\n x.quest_id\n end\n end",
"def getActiveQuests\n active = []\n $PokemonGlobal.quests.active_quests.each do |s|\n active.push(s.id)\n end\n return active\nend",
"def completed_quests; $game_variables[17]; end",
"def pending_quests\n quests = UsersQuest.where(:assignee_id => @current_user.id,:is_accepted => false,:is_rejected =>false).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n by_me_quests = UsersQuest.where(:assignor_id => @current_user.id,:is_accepted => false,:is_rejected =>false).pluck(:quest_id)\n @by_me_quests = Quest.where(:id => by_me_quests).order('due_date')\n end",
"def getCompletedQuests\n completed = []\n $PokemonGlobal.quests.completed_quests.each do |s|\n completed.push(s.id)\n end\n return completed\nend",
"def quest_selection(input, difficulty)\n quest_id = self.get_recommended_quests(difficulty)[input.to_i-1].id\n CharacterQuest.new_character_quest(self.id, quest_id)\n end",
"def index\n # TODO: Find personal quests\n quests = UsersQuest.where(:assignor_id => @current_user.id).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n end",
"def show\n @quest = Quest.find(params[:id])\n quest_objectives = @quest.locations\n completed_objectives = []\n quest_objectives.each do |obj|\n if @current_user.locations.exists?(obj)\n completed_objectives << obj\n end\n end\n if completed_objectives.length == quest_objectives.length\n unless @quest.winner_id\n @quest.update(winner_id: @current_user.id)\n end\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n end\n\n if(@quest.owner_id == @current_user.id)\n redirect_to edit_quest_path(@quest)\n elsif @quest.start_date > DateTime.current\n flash[:warning] = \"Quest has not yet begun!\"\n redirect_to user_path(@current_user) and return\n elsif @quest.end_date < DateTime.current\n flash[:warning] = \"Quest has ended. Womp womp\"\n\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n elsif @quest.users.exists?(@current_user.id)\n gon.track = true\n locations = @quest.locations\n gon.remaining_locations = []\n gon.completed_locations = []\n locations.each do |loc|\n if loc.users.exists?(@current_user.id)\n gon.completed_locations << loc\n else\n gon.remaining_locations << loc\n end\n end\n @remaining_locations = gon.remaining_locations\n @completed_locations = gon.completed_locations\n else\n gon.track = false\n flash[:danger] = \"You are not a member of this quest! Please contact the quest owner for an invite.\"\n redirect_to quests_path and return\n end\n end",
"def quest\n @quest ||= Quest.find(params[:id])\n end",
"def exercise_instances\n Workout.all.select{|workout_instance| workout_instance.gym_id == self.id}\n end",
"def all_quests(adventure_hash)\n adventure_hash[:knights].collect do |details| # collect *returns* an array, which is what we need. \n details[:quest]\n end\nend",
"def show\n @thisAccount = Account.find(params[:id])\n\n @readyQuests = Quest.where('attack <= ?', @thisAccount.attack)\n .where('strength <= ?', @thisAccount.strength)\n .where('defence <= ?', @thisAccount.defence)\n .where('ranged <= ?', @thisAccount.ranged)\n .where('prayer <= ?', @thisAccount.prayer)\n .where('magic <= ?', @thisAccount.magic)\n .where('runecrafting <= ?', @thisAccount.runecrafting)\n .where('construction <= ?', @thisAccount.construction)\n .where('hitpoints <= ?', @thisAccount.hitpoints)\n .where('agility <= ?', @thisAccount.agility)\n .where('herblore <= ?', @thisAccount.herblore)\n .where('thieving <= ?', @thisAccount.thieving)\n .where('crafting <= ?', @thisAccount.crafting)\n .where('fletching <= ?', @thisAccount.fletching)\n .where('slayer <= ?', @thisAccount.slayer)\n .where('hunter <= ?', @thisAccount.hunter)\n .where('mining <= ?', @thisAccount.mining)\n .where('smithing <= ?', @thisAccount.smithing)\n .where('fishing <= ?', @thisAccount.fishing)\n .where('cooking <= ?', @thisAccount.cooking)\n .where('firemaking <= ?', @thisAccount.firemaking)\n .where('woodcutting <= ?', @thisAccount.woodcutting)\n\n @notReadyQuests = Quest.where('attack >= ?', @thisAccount.attack)\n .where('strength > ?', @thisAccount.strength)\n .where('defence > ?', @thisAccount.defence)\n .where('ranged > ?', @thisAccount.ranged)\n .where('prayer > ?', @thisAccount.prayer)\n .where('magic > ?', @thisAccount.magic)\n .where('runecrafting > ?', @thisAccount.runecrafting)\n .where('construction > ?', @thisAccount.construction)\n .where('hitpoints > ?', @thisAccount.hitpoints)\n .where('agility > ?', @thisAccount.agility)\n .where('herblore > ?', @thisAccount.herblore)\n .where('thieving > ?', @thisAccount.thieving)\n .where('crafting > ?', @thisAccount.crafting)\n .where('fletching > ?', @thisAccount.fletching)\n .where('slayer > ?', @thisAccount.slayer)\n .where('hunter > ?', @thisAccount.hunter)\n .where('mining > ?', @thisAccount.mining)\n .where('smithing > ?', @thisAccount.smithing)\n .where('fishing > ?', @thisAccount.fishing)\n .where('cooking > ?', @thisAccount.cooking)\n .where('firemaking > ?', @thisAccount.firemaking)\n .where('woodcutting > ?', @thisAccount.woodcutting)\n end",
"def get_quest\n\t\tget_data\n\n\t\t$finish = false\n\t\tunless $finish == true\n\t\t\t$randId = rand(0...(@data.length-1))\n\t\t\twhile $quiz_arr.include?(@data[$randId]['id'])\n\t\t\t\t$randId = rand(0...(@data.length-1))\n\t\t\tend\n\t\t\t$quiz_arr.push(@data[$randId]['id'])\n\t\t\t$i += 1\n\n\t\t\tif $i == 7\n\t\t\t\t$finish = true\n\t\t\tend\n\n\t\t\t@quest = @data[$randId]['question_name']\n\t\t\t@c_answer = @data[$randId]['c_answer']\n\t\t\t@alt1 = @data[$randId]['alt1']\n\t\t\t@alt2 = @data[$randId]['alt2']\n\t\t\t@alt3 = @data[$randId]['alt3']\n\t\t\t@imgurl = @data[$randId]['imgurl']\n\t\t\t@url = @data[$randId]['news_url']\n\t\t\t@cat = @data[$randId]['category_id']\n\t\t\t@hex = @data[$randId]['category_hex_code']\n\t\t\tget_descriptions(@url)\n\t\t\t@image = @desc_data['image']\n\n\t\t\t$answer_array = Array.new()\n\t \tend\n\tend",
"def therapist_quest; end",
"def getQuestStages(quest)\n arr = []\n for key in QuestModule.const_get(quest).keys\n arr.push(key) if key.to_s.include?(\"Stage\")\n end\n return arr\n end",
"def difficulty\n request('getdifficulty')\n end",
"def show\n @tutorial_quest = Tutorial::Quest.find(params[:id])\n raise ForbiddenError.new ('Access forbidden.') unless staff? || admin? || @tutorial_quest.tutorial_state.owner == current_character\n\n if stale?(:last_modified => @tutorial_quest.updated_at.utc, :etag => @tutorial_quest)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tutorial_quest }\n end\n end\n end",
"def choose_problems(competition)\n\t\tusers=competition.users\n\t\tcase competition.target\n\t\twhen 1\n\t\t\tproblems=Problem.all.where(target: 1)\n\t\twhen 2\n\t\t\tproblems=Problem.all.where(target: 2)\n\t\twhen 3\n\t\t\tproblems=Problem.all.where(target: 3)\n\t\telse\n\t\t\tproblems=Problem.all\n\t\tend\t\n\t\tchecked_problems=problems.where(checked: true) #<-- add checked\n\t\tunseen_problems=checked_problems\n\t\tusers.each do |u|\n\t\t\tunseen_problems=unseen_problems.select{ |p| !p.viewers.include?(u)}\n\t\tend \n\t\tproblems_length=0\n\t\tproblem=nil\n\t\twhile problems_length < competition.length do\n\t\t\tmax_length=competition.length-problems_length\n\t\t\tproblem=nil\n\t\t\tproblem=unseen_problems.select{ |p| p.length <= max_length && !competition.problems.include?(p)}.sample #balta6tina\n\t\t\tif problem.present?\n\t\t\t\tproblems_length += problem.length\n\t\t\t\tcompetition.competition_problems.create!(problem_id: problem.id)\n\t\t\telse\n\t\t\t\tproblem=checked_problems.select{ |p| p.length <= max_length && !competition.problems.include?(p)}.sample\n\t\t\t\tproblems_length += problem.length\n\t\t\t\tcompetition.competition_problems.create!(problem_id: problem.id)\n\t\t\tend\n\t\tend\t\n end",
"def unanswered_check_in_questions\n action_items.where(component_type:Check::COMPONENT_TYPE, day:1..day.to_i).select{|i| !i.complete?}\n end",
"def index\n \n last_modified = nil\n\n if params.has_key?(:character_id) # request using character_id \n \n state = Tutorial::State.find_by_character_id(params[:character_id])\n raise NotFoundError.new('No quests found for character id.') if state.nil?\n raise ForbiddenError.new('Access forbidden.') if state.owner != current_character && !staff? && !admin?\n \n @tutorial_quests = if api_request? # send only the relevant quests (those, that have not been finished yet)\n state.quests.non_closed \n else # display all quests in backend\n state.quests.paginate(:page => params[:page], :per_page => 50) \n end\n last_modified = state.updated_at.utc # the state is touched on changed on the quests\n \n else # request all \n raise ForbiddenError.new('Access forbidden.') if !staff? && !admin? \n @tutorial_quests = Tutorial::Quest.paginate(:page => params[:page], :per_page => 50)\n end\n \n if stale?(:last_modified => last_modified, :etag => @tutorial_quests)\n respond_to do |format|\n format.html \n format.json { render json: @tutorial_quests }\n end\n end\n end",
"def quest_interface\n\n#obtain the difficulty level for the given player\n difficulty = self.get_difficulty\n\n#see if the player has any quests left to complete\n if self.get_recommended_quests(difficulty).size == 0\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"You have completed all recommended quests!!!\".bold\n puts \"=====================================\".red\n puts \"=====================================\".red\n\n#show the player the available quests\n else\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Recommended Quests for Player Attack: #{self.power}\".blue.on_light_green.bold\n puts \"\"\n self.print_quests(difficulty)\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Select a quest number\".bold.white.on_light_blue\n puts \"Number:\".bold.white.on_light_blue\n\n#selection prompt the player to actually choose a quest\n selection = gets.chomp\n\n#check for invalid input\n if selection.to_i > self.get_recommended_quests(difficulty).size || selection.to_i < 1\n puts \"Invalid input, please try again!\".red.bold\n\n#if input is valid, show the player that he has completed the quest\n else\n puts\"*******************************************\"\n puts \"You have completed: #{self.get_recommended_quests(difficulty)[selection.to_i-1].title}\".bold\n puts\"*******************************************\"\n puts \" \"\n puts\"#####################################\".blink\n puts \"Time For Your Reward Adventurer!!!\".bold.blue.on_light_yellow\n\n #obtain the available weapons based on player difficulty\n available_weapons = self.get_available_weapons(difficulty)\n\n #create the new characterquest instance to show that player has completed the quest\n self.quest_selection(selection, difficulty)\n\n #run the weapon_reward method to get reward for the quest\n self.weapon_reward(available_weapons)\n end\n end\n end",
"def find_level\n determine_level(self.experience_points, self.user_quests.where(complete: true))\n end",
"def fetch_type name\n exercises = []\n data.exercises.each do |exe|\n if exe.target === name\n exercises.push(exe.name)\n end\n end\n exercises\n end",
"def difficulty\n if @session_ratio > 85\n @level = 3\n @random = Question.where(difficulty: 'hard')[rand(40)]\n elsif @session_ratio > 60\n @level = 2\n @random = Question.where(difficulty: 'medium')[rand(40)]\n else\n @level = 1\n @random = Question.where(difficulty: 'easy')[rand(40)]\n end\n end",
"def each_quest(&block)\r\n @quests.each(&block)\r\n end",
"def init_quest\n @quest = Quest.find_by_id(params[:id])\n @quest ||= Quest.draft(params[:id])\n end",
"def effects\n results = []\n \n if @difficulty\n results << \"Success\" if result >= @difficulty\n end\n \n @possibilities.each do |poss|\n results.concat(check(poss))\n end\n \n results.compact!\n\n if results.empty?\n results = nil\n end\n results\n end",
"def activateQuest(questID)\n if questID.is_a?(String)\n questID = $quest_data.getIDFromName(questID)\n end\n for i in 0...@active_quests.length\n if @active_quests[i].id==questID\n Kernel.pbMessage(\"You have already started this quest\")\n return\n end\n end\n for i in 0...@completed_quests.length\n if @completed_quests[i].id==questID\n Kernel.pbMessage(\"You have already complete this quest\")\n return\n end\n end\n for i in 0...@failed_quests.length\n if @failed_quests[i].id==questID\n Kernel.pbMessage(\"You have already failed this quest\")\n return\n end\n end\n @active_quests.push(Quest.new(questID))\n end",
"def get_trial_suggestions\n case @last_played.size\n when 0\n load_trials({\n 'San Francisco' => :very_easy,\n 'The Bunker' => :very_easy,\n 'Caravel Ships' => :easy,\n })\n when 1\n load_trials({\n 'San Francisco' => :very_easy,\n 'The Bunker' => :very_easy,\n 'Caravel Ships' => :easy,\n 'Tower in the Castle' => :medium,\n })\n when 2\n load_trials({\n 'San Francisco' => :very_easy,\n 'Caravel Ships' => :very_easy,\n 'Tower in the Castle' => :easy,\n 'Cat Mountain Climb' => :medium,\n 'Moonlit Woods' => :medium,\n })\n when 3\n load_trials({\n 'San Francisco' => :very_easy,\n 'Tower in the Castle' => :easy,\n 'Cat Mountain Climb' => :easy,\n 'Moonlit Woods' => :easy,\n 'Egypt Pyramid' => :medium,\n 'The Cave' => :medium,\n })\n when 4\n load_trials({\n 'Tower in the Castle' => :very_easy,\n 'Cat Mountain Climb' => :easy,\n 'Moonlit Woods' => :easy,\n 'Egypt Pyramid' => :medium,\n 'The Cave' => :medium,\n 'Cyberpunk Ruins' => :hard,\n 'Steamport Town' => :hard,\n })\n when 5\n load_trials({\n 'Cat Mountain Climb' => :very_easy,\n 'Moonlit Woods' => :easy,\n 'Egypt Pyramid' => :easy,\n 'The Cave' => :easy,\n 'Cyberpunk Ruins' => :medium,\n 'Steamport Town' => :medium,\n 'Find the Dragon' => :hard,\n 'Star Hopping' => :hard,\n })\n when 6\n load_trials({\n 'Cat Mountain Climb' => :very_easy,\n 'Moonlit Woods' => :very_easy,\n 'Egypt Pyramid' => :easy,\n 'The Cave' => :easy,\n 'Cyberpunk Ruins' => :medium,\n 'Steamport Town' => :medium,\n 'Find the Dragon' => :hard,\n 'Star Hopping' => :hard,\n 'Shadow of Valus' => :very_hard,\n 'The Cube' => :very_hard,\n })\n when 7\n load_trials({\n 'Tower in the Castle' => :easy,\n 'Moonlit Woods' => :very_easy,\n 'Egypt Pyramid' => :easy,\n 'The Cave' => :easy,\n 'Cyberpunk Ruins' => :medium,\n 'Steamport Town' => :medium,\n 'Find the Dragon' => :hard,\n 'Star Hopping' => :hard,\n 'Shadow of Valus' => :very_hard,\n 'The Cube' => :very_hard,\n 'Temple City' => :very_hard,\n })\n else\n nil # if user already played more than 6 games, then return nil (will get delegated to get_standard_suggestions)\n end\n end",
"def competition_results\n results.select(&:competition_result?)\n end",
"def complete_quests(options={})\n options.reverse_merge!(:count => 1)\n\n @objectives.push([\n Objective::CompleteQuests,\n {:key => Objective::CompleteQuests::KEY, :count => options[:count]}\n ])\n end",
"def quest; end",
"def index\n @quests = Quest.all\n end",
"def index\n @quests = Quest.all\n end",
"def failQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.failQuest(quest,color,story)\nend",
"def [](quest_id)\n reset_quest(quest_id) if !@data[quest_id]\n @data[quest_id]\n end",
"def active_difficulties(*values)\n if values.include? :none\n @difficulties = []\n else\n # Change active difficulties to what the user supplies, but only when they supply a difficulty we already know about\n @difficulties = values.reject { |v| not @difficulties.include? v }\n end\n end",
"def find_possible_solutions(number_of_spells_to_cast)\n self.solutions = {}\n\n start_time = Time.now\n test_spell_combos(number_of_spells_to_cast)\n end_time = Time.now\n\n p \"\"\n p \"Start: #{start_time}\"\n p \"End: #{end_time}\"\n p \"Possible Solutions\"\n pp self.solutions\n end",
"def reveal_quest(quest_id); quest(quest_id).concealed = false; end",
"def index\n if logged_as_teacher?\n @sidequest= Sidequest.new\n @sidequests = Sidequest.where(teacher_id: session[:user_id])\n end\n if logged_as_student?\n student = Student.find(session[:user_id])\n progres = student.progre\n @sidequests = Sidequest.where(level: progres.lvl, finished: false)\n end\n end",
"def get_talents\n\n # skills = [ self.skill_mandatory1, self.skill_mandatory2, self.skill_mandatory3,\n # self.skill_elective1, self.skill_elective2, self.skill_elective3 ]\n\n talents = {}\n\n # skills.each do |skill|\n # # TODO CHECK FOR RANDOM/CAREER SKILL\n # talents[skill] = Talent.where( skill: skill ).find_each\n # end\n\n talents\n\n end",
"def difficulty(n)\n return nil if tournament_counters.empty?\n\n for i in 0..(tournament_counters.size - 1)\n return tournament_counters[i].difficulty if tournament_counters.map(&:counter)[0..i].sum >= n + 1\n end\n\n return tournament_counters.last.difficulty\n end",
"def relatedQuestions(section)\n relQuestions = []\n\n questions = sectionQuestions(pretest())\n questions.each do |question|\n question.getActivityReferences.getVector.each do |reference|\n if section.equals(reference.getReferencedObject)\n relQuestions << question\n break\n end\n end\n end\n \n relQuestions\nend",
"def relatedQuestions(section)\n relQuestions = []\n\n questions = sectionQuestions(pretest())\n questions.each do |question|\n question.getActivityReferences.getVector.each do |reference|\n if section.equals(reference.getReferencedObject)\n relQuestions << question\n break\n end\n end\n end\n \n relQuestions\nend",
"def allied_units\n @game.units.find_all { |u| u.faction == @faction }\n end",
"def part2(clues, aunts)\n result = Array.new aunts\n clues.each do |clue|\n #filter aunts that do not match the key:value in clue\n key = clue.keys.first\n result.reject! do |a|\n a.has_key? key and retroencabulation(key, clue[key], a[key])\n end\n\n #puts \"Using #{key} as the filter, there are now #{aunts.length} remaining possibilities\"\n end\n result[0]\nend",
"def index\n @quest_items = QuestItem.all\n end",
"def questions\n # Get a list of questionnaires that belong to instances of the current race\n if @course\n questionnaire_ids = @course.questionnaire_ids\n elsif @instance\n questionnaire_ids = @instance.questionnaire_ids\n else\n questionnaire_ids = []\n end\n\n # Collect question_ids that are used in those questionnaires\n question_ids = Set.new\n Questionnaire.where(:id => questionnaire_ids).find_each do |questionnaire|\n question_ids.merge(questionnaire.question_ids)\n end\n\n @questions = Question.find(question_ids.to_a)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions.to_json }\n end\n end",
"def accessible_problems(columns)\n return [] if !has_enough_points\n \n return Problems.select(get_problem_columns_string(column)) if current_user.sk.admin?\n \n return Problem.find_by_sql(\"SELECT #{get_problem_columns_string(columns)}\n FROM problems\n WHERE problems.online = #{true_value_sql}\n AND (problems.virtualtest_id IN #{virtualtests_done_request}\n OR (problems.virtualtest_id = 0\n AND #{num_problem_unsolved_prerequisites_request} = 0\n AND #{@no_new_submission ? num_problem_real_submissions_request : 1} > 0\n )\n )\")\n end",
"def completeQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.completeQuest(quest,color,story)\nend",
"def show_solutions\n\t\t@normal_solutions = current_problem.solutions.where(reported: false)\n\t\t@reported_solutions = current_problem.solutions.where(reported: true)\n\tend",
"def getdifficulty\n coind.getdifficulty\n end",
"def getdifficulty\n @api.request 'getdifficulty'\n end",
"def quest_params\n params.require(:quest).permit(:user_id, :quest, :result)\n end",
"def load_trials(names_to_difficulties_map)\n names = names_to_difficulties_map.keys\n maps = Map.trial # only trials\n maps = maps.in(name: names) # filter by name\n maps = maps.nin(_id: @last_played) # take away already played maps\n\n # order by difficulty, depending on the win/loss ratio\n if @last_played.size > 0\n win_loss_ratio = number_of_last_played_wins.to_f / @last_played.size\n maps = maps.order_by(skill_mean: win_loss_ratio > 0.5 ? 'desc' : 'asc')\n end\n\n maps = maps.limit(3).to_a # load 3 trials\n maps.each do |m|\n m.trial_difficulty = names_to_difficulties_map[m.name] # assign relative_difficulty\n end\n maps\n end",
"def index\n @reqdifficulties = Reqdifficulty.all\n end",
"def quest(id) \n\tsys('quest')\n\t$progress.add_quest(id) \n\tpop_quest(id)\n\t$scene.hud.quest_sparkle(\"misc/profile\")\nend",
"def generate_questions difficulty, number_of_questions\n @questions.clear\n random_range = case difficulty\n when 1, 3 then 9\n else 99\n end\n if number_of_questions > 3\n number_of_questions = 3\n elsif number_of_questions < 1\n number_of_questions = 3\n end\n number_of_questions.times do\n @questions.push(Question.new((@number_generator.rand(random_range) + 1), generate_operator(difficulty), (@number_generator.rand(random_range) + 1)))\n end\n end",
"def all_priors()\n #self.bracketgrouping.bracketcontests.bracketcontestants\n #Bracketcontestant.where(bracketgrouping: self.bracketgrouping).select{|bc|bc.priorcontest().id()==self.id()}.collect{|bc|bc.priorcontest()}\n self.bcadvancements.collect {|bcadv| bcadv.bracketcontestant}\n end",
"def mechanic_quest; end",
"def select_word(dif_lvl)\n case dif_lvl\n when 1 # easy difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 0..1000).first\n when 2 # medium difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 1001..100000).first\n when 3 # hard difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 100001..200000).first\n when 4 # super hard difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 200001..400000).first\n when 5 # master difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 400001..Word.maximum(:difficulty)).first\n end\nend",
"def util_targetselection_get_possible(launcher,skill)\n if launcher.position < 0\n arr = []\n util_targetselection_adjacent_pokemon(launcher).each do |target|\n arr << target if seviper_zangoose_detect(launcher, target)\n end\n return arr if arr.size > 0\n end\n case skill.target\n when :adjacent_pokemon # eo eo ex / ux ao ax\n return util_targetselection_adjacent_pokemon(launcher)\n when :adjacent_foe # eo eo ex / ux ax ax\n return util_targetselection_adjacent_foe(launcher)\n when :user_or_adjacent_ally # ex ex ex / uo ao ax\n return [launcher]+util_targetselection_adjacent_ally(launcher)\n when :adjacent_ally # ex ex ex / ux ao ax\n return util_targetselection_adjacent_ally(launcher)\n when :any_other_pokemon # ex ex ex / uo ax ax\n arr = ::BattleEngine.get_enemies!(launcher)\n arr += util_targetselection_adjacent_ally(launcher)\n return arr\n end\n return nil\n end",
"def get_unfiltered_suggestions\n map1 = Map.find_near_dificulty current_user.skill_mean, :easy\n map2 = Map.find_near_dificulty current_user.skill_mean, :medium, exclude: [map1]\n map3 = Map.find_near_dificulty current_user.skill_mean, :hard, exclude: [map1, map2]\n maps = [map1, map2, map3].compact\n maps.empty? ? nil : maps\n end",
"def mechanics\n Mechanic.all.select do |mechanic_ob|\n #binding.pry\n mechanic_ob.specialty == self.classification\n end\nend",
"def get_new_skills(level)\n self.skills.select do |skill|\n skill.min_level == level\n end\n end",
"def init_maqj_data\n @quests = Game_Quests.new # Initialize @quests\n end",
"def select_word(dif_lvl)\n case dif_lvl\n when 1 # easy difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 0..1000).first\n when 2 # medium difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 1001..100000).first\n when 3 # hard difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 100001..200000).first\n when 4 # expert difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 200001..400000).first\n when 5 # master difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 400001..Word.maximum(:difficulty)).first\n end\nend",
"def retrieve( answer_id )\n answers = @all_answers[ answer_id ]\n ( answers && answers.possibilities ) || []\n end",
"def get_difficulty\n if self.power < 3\n difficulty = 1\n elsif self.power >= 3 && self.power < 6\n difficulty = 2\n else\n difficulty = 3\n end\n end",
"def solved(user)\n Problem.includes({:completed_problems => :user}).where('users.id = ?', user.id).where(:id => self.id).present?\n end",
"def return_solution_found\n @open.select(&:goal).first\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def index\n @exercise = Exercise.find(params[:exercise_id])\n load_course\n\n if @course.has_teacher(current_user)\n @available_groups = Group.where('course_instance_id=?', @course_instance.id).joins(:users).order(:name).all.select { |group| group.users.size <= @exercise.groupsizemax }\n else\n @available_groups = Group.where('course_instance_id=? AND user_id=?', @course_instance.id, current_user.id).joins(:users).order(:name).all.select { |group| group.users.size <= @exercise.groupsizemax }\n end\n end",
"def getdifficulty\n request :getdifficulty\n end",
"def exam_details(ex)\n exams_data = ex.exams.all\n flag = false\n exams_data.each do |exam|\n exam.exam_scores.each do |es|\n flag = true if es.is_failed?\n end\n exams << exam if flag == true\n end\n exams\n end",
"def get_candidate_questions(knowledge, quizze_instance)\n # TODO include the pre-condition\n knowledge.questions.find_all { |question| !quizze_instance.user_last_answer(question.idurl) }\n end",
"def get_choices(question)\n puts 'get_choices()'\n choices = Choice.select('id, prompt').find(question.correct_choice_id, question.close_choice_id)\n choices += Choice.select('id, prompt').where.not(id: question.correct_choice_id).where.not(id: question.close_choice_id).where(choice_type:0).shuffle.first(3)\n choices.shuffle!\n end",
"def relatedQuestions(section)\n relQuestions = []\n \n questions = sectionQuestions(pretest())\n questions.each do |question|\n question.getActivityReferences.getVector.each do |reference|\n if section.equals(reference.getReferencedObject)\n relQuestions << question\n break\n end\n end\n end\n \n relQuestions\n end",
"def show\n @attempted_questions = AttemptedQuestion.where(subject: @subject)\n end",
"def accessible_problems_from_section(section, columns)\n return [] if !has_enough_points\n \n return section.problems.select(get_problem_columns_string(columns)).order(\"level, number\") if current_user.sk.admin?\n \n return Problem.find_by_sql(\"SELECT #{get_problem_columns_string(columns)}\n FROM problems\n WHERE problems.section_id = #{section.id}\n AND problems.online = #{true_value_sql}\n AND (problems.virtualtest_id IN #{virtualtests_done_request}\n OR (problems.virtualtest_id = 0\n AND #{num_problem_unsolved_prerequisites_request} = 0\n AND #{@no_new_submission ? num_problem_real_submissions_request : 1} > 0\n )\n )\n ORDER BY problems.level, problems.number\")\n end",
"def update_phase3_enemy_select\n pkmn = @actors[@actor_actions.size]\n skill = pkmn.skills_set[@atk_index]\n if skill.id == 174 and !pkmn.type_ghost? #> Malédiction\n return [pkmn]\n end\n #>Choix automatique en 1v1\n if $game_temp.vs_type == 1 or (@enemy_party.pokemon_alive==1 and $pokemon_party.pokemon_alive==1) or skill.is_no_choice_skill?\n return util_targetselection_automatic(pkmn, skill)\n #>Choix 2v2\n elsif $game_temp.vs_type == 2\n data = update_phase3_pokemon_select_2v2(pkmn, skill)\n return -1 if data == -1\n if data < 2\n return [@enemies[data]]\n end\n return [@actors[data-2]]\n else\n return -1\n end\n\n end",
"def run_quest\n original_power = @todays_hero.power\n system \"clear\"\n subtitle_print('Start Quest')\n power_update = Quest.find_new\n @todays_hero.increase_power_by(power_update)\n system \"clear\"\n if @todays_hero.power > original_power\n puts \"Congrats! Your power increased by #{power_update}.\"\n puts \"Your power is now #{@todays_hero.power}.\"\n elsif @todays_hero.power == original_power\n puts \"Evil doesn't wait for the slow and idle.\"\n puts \"Your power remains at #{@todays_hero.power}.\"\n elsif @todays_hero.power < original_power\n puts \"The world weeps for the strong and courageous.\"\n puts \"Your power has decreased to #{@todays_hero.power}.\"\n end\n @todays_hero.save\n end",
"def teacher_availability\n @problem.never{ \n conjunct{ [\n Timetable::Entry.asp(:course_component_id => \"C\",\n :weekday_id => \"WD\",\n :timeframe_id => \"TF\"),\n Course::Component.asp(:id => \"C\",\n :teacher_id => \"T\"),\n Teacher::Unavailability.asp(:teacher_id => \"T\",\n :weekday_id => \"WD\",\n :timeframe_id => \"TF\")\n\n ]}\n }\n end",
"def equips_for_enchant\n return [] if @enchant_item.nil?\n $game_party.items.select { |item|\n item.enchantable? && item.tier == @enchant_item.enchant_tier\n }\n end",
"def check_questions\n response = Request.get_request(URL_QUESTION)\n questions = []\n if response.success?\n data = Request.manage_response(response)\n end\n data.each do |question|\n questions << Question.new(question)\n end\n questions\nend",
"def get_questionnaires\n @get_questionnaires ||= questionnaire_service.search('context-type-value': get_use_context)\n end",
"def index\n @quests=Quest.all\n\n end",
"def part1(clues, aunts)\n result = Array.new aunts\n clues.each do |clue|\n #filter aunts that do not match the key:value in clue\n key = clue.keys.first\n result.reject! {|a| a.has_key? key and clue[key] != a[key] }\n\n #puts \"Using #{key} as the filter, there are now #{aunts.length} remaining possibilities\"\n end\n result[0]\nend",
"def setup_quest(quest_id)\n return if @data[quest_id]\n @data[quest_id] = Game_Quest.new(quest_id)\n # Open to this quest next time the QJ is opened\n $game_system.last_quest_id = quest_id if QuestData::OPEN_TO_LAST_REVEALED_QUEST\n # Save sorting order in separate arrays to avoid re-sorting every time\n @sort_arrays.keys.each { |sym| add_to_sort_array(sym, quest_id) }\n end"
] | [
"0.7222176",
"0.67014384",
"0.6627774",
"0.6614985",
"0.6581597",
"0.6512667",
"0.6476362",
"0.63532734",
"0.6347757",
"0.6318947",
"0.6225621",
"0.6163819",
"0.61155415",
"0.6069113",
"0.60141456",
"0.601292",
"0.598062",
"0.5955003",
"0.5917984",
"0.5905793",
"0.58614385",
"0.5720097",
"0.5686714",
"0.56527054",
"0.56429595",
"0.560459",
"0.5548154",
"0.5535835",
"0.55327415",
"0.55256975",
"0.54555345",
"0.54505914",
"0.54123706",
"0.5410552",
"0.5402549",
"0.5386503",
"0.53622764",
"0.5362119",
"0.5354763",
"0.5344869",
"0.5314745",
"0.5314745",
"0.53143215",
"0.5304744",
"0.5300906",
"0.5299509",
"0.52941835",
"0.529067",
"0.52904177",
"0.528353",
"0.5280204",
"0.5280204",
"0.52713776",
"0.5257482",
"0.52493906",
"0.5245228",
"0.5242207",
"0.5240247",
"0.5236588",
"0.523324",
"0.5228235",
"0.5227216",
"0.52266026",
"0.52230865",
"0.52002484",
"0.5196728",
"0.51935476",
"0.51797825",
"0.5173807",
"0.51702976",
"0.51660866",
"0.51555216",
"0.5154472",
"0.5153656",
"0.5149554",
"0.5146612",
"0.51454526",
"0.51406276",
"0.5138799",
"0.5122582",
"0.5122582",
"0.5122582",
"0.5122582",
"0.5115841",
"0.51047385",
"0.5103752",
"0.510024",
"0.5100031",
"0.50854963",
"0.5085359",
"0.50841594",
"0.5070463",
"0.5066516",
"0.5063427",
"0.5060795",
"0.5056804",
"0.50536597",
"0.5048828",
"0.50417703",
"0.50415295"
] | 0.77815104 | 0 |
print the quest titles of the uncompleted quests that are of a specified difficulty | def print_quests(difficulty)
self.get_recommended_quests(difficulty).each_with_index do |quest, i|
puts "#{i+1}: #{quest.title}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_completed_quests\n\n#check if the player has actually completed any quests\n#if he has not, tell him\n if self.quests.size == 0\n puts \"You have not completed any quests!!!\".red\n\n#otherwise, pull the completed quest objects and print the quest titles\n else\n puts \"Completed Quests:\".underline\n self.quests.each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end\n end",
"def get_uncompleted_quests()\n Quest.all.select do |quest|\n quest.characters.include?(self) == false\n end\n\n end",
"def display_questions\n @questions.each do |number, question|\n puts \"\"\n puts \"Question #{number}: #{question}\"\n puts \"\"\n option_to_skip_case(number)\n puts \"\"\n end\n end",
"def get_recommended_quests(difficulty)\n self.get_uncompleted_quests.select do |quest|\n quest.difficulty == difficulty\n end\n end",
"def completed_quests; $game_variables[17]; end",
"def difficulty_intro\n print \"\\nWhat difficulty would you like to play? (e)asy, (m)edium, or (h)ard? \"\n end",
"def skipped_questions_explanation\n puts \"\"\n puts \"Now you can answer the questions that you skipped.\"\n puts \"If you can't think of an answer, just hit enter/return to pass.\"\n puts \"Once you've answered or passed these questions we'll go over the answers.\"\n puts \"\"\n end",
"def quest(quest_id); $game_party.quests[quest_id]; end",
"def getFailedQuests\n failed = []\n $PokemonGlobal.quests.failed_quests.each do |s|\n failed.push(s.id)\n end\n return failed\nend",
"def difficulty_menu\n medium_rainbow_typer 'Select your desired difficulty'\n br\n TTY::Prompt.new.select('?') do |menu|\n menu.choice 'Easy', :d1\n menu.choice 'Medium', :d2\n menu.choice 'Hard', :d3\n menu.choice 'Insane', :d4\n end\n end",
"def show_all_weapons\n if self.weapons.size == 0\n puts \"\"\n puts \"You have no weapons, try completing some quests first :)\"\n else\n puts \"\"\n puts \"Here Are Your Weapons:\".bold.white.on_light_black\n puts \" \"\n self.weapons.each do |weapon|\n puts \"**** #{weapon.name} **** Weapon Power: #{weapon.attack_power} ****\".italic\n end\n end\n end",
"def completeQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.completeQuest(quest,color,story)\nend",
"def getQuestDescription(quest)\n return \"#{QuestModule.const_get(quest)[:QuestDescription]}\"\n end",
"def general_quests\n quests = UsersQuest.where(:assignee_id => @current_user.id,:is_accepted => true).where.not(:assignor_id => @current_user.id).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n end",
"def failQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.failQuest(quest,color,story)\nend",
"def get_question_text(part_number, question_number)\n frm.table(:id=>\"assesssmentForm:parts:#{part_number.to_i-1}:parts\").div(:class=>\"tier3\", :index=>question_number.to_i-1).text\n end",
"def print_game_progress(count)\n puts \"#{\".\" * 50}\"\n puts \"\\nWord : #{@incomplete_word}\"\n puts \"Attempts Left: #{@limit - count}\"\n unless @incorrect_guesses.empty?\n puts \"Incorrect inputs: #{@incorrect_guesses.join(\", \")}\"\n end\n puts \"#{\".\" * 50}\"\n end",
"def description\n case @wrong_guesses\n when 1\n puts \"The head has been drawn.\"\n when 2\n puts \"The head and body have been drawn.\"\n when 3\n puts \"The head, body, and one arm have been drawn.\"\n when 4\n puts \"The head, body, and arms have been drawn.\"\n when 5\n puts \"The head, body, arms, and one leg have been drawn.\"\n when 6\n puts \"The head, body, arms, and legs have been drawn.\"\n when 7\n puts \"The head, body, arms, legs, and one eye have been drawn.\"\n puts \"One more wrong move, and he's dead!\"\n when 8\n puts \"The head, body, arms, legs, and eyes have been drawn.\"\n puts \"The hangman's dead, and you've lost!\"\n end\n puts \"\\n\"\n end",
"def find_completed\n completed = self.user_quests.where(complete: true)\n completed.map do |x|\n x.quest_id\n end\n end",
"def index\n # TODO: Find personal quests\n quests = UsersQuest.where(:assignor_id => @current_user.id).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n end",
"def look\n puts \"*#{@short_description}*\"\n puts \"#{@long_description}\"\n puts\n to_show = contents.reject{|o| o.name == 'self'}\n room_descr_items = to_show.select{|o| o.room_description} #items that have a special room_description value, which is prose overriding \n #the simple behavior of just listing the name of an item during room description.\n to_show.reject! {|x| room_descr_items.include?(x) }\n room_descr_items.each do |item|\n puts item.room_description\n end\n if not to_show.empty?\n print \"You can see \"\n to_show.each do |obj|\n print \"and \" if obj == to_show.last && obj != to_show.first\n print \"#{obj.name} \"\n end\n puts \"here.\"\n end\n end",
"def quest_interface\n\n#obtain the difficulty level for the given player\n difficulty = self.get_difficulty\n\n#see if the player has any quests left to complete\n if self.get_recommended_quests(difficulty).size == 0\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"You have completed all recommended quests!!!\".bold\n puts \"=====================================\".red\n puts \"=====================================\".red\n\n#show the player the available quests\n else\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Recommended Quests for Player Attack: #{self.power}\".blue.on_light_green.bold\n puts \"\"\n self.print_quests(difficulty)\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Select a quest number\".bold.white.on_light_blue\n puts \"Number:\".bold.white.on_light_blue\n\n#selection prompt the player to actually choose a quest\n selection = gets.chomp\n\n#check for invalid input\n if selection.to_i > self.get_recommended_quests(difficulty).size || selection.to_i < 1\n puts \"Invalid input, please try again!\".red.bold\n\n#if input is valid, show the player that he has completed the quest\n else\n puts\"*******************************************\"\n puts \"You have completed: #{self.get_recommended_quests(difficulty)[selection.to_i-1].title}\".bold\n puts\"*******************************************\"\n puts \" \"\n puts\"#####################################\".blink\n puts \"Time For Your Reward Adventurer!!!\".bold.blue.on_light_yellow\n\n #obtain the available weapons based on player difficulty\n available_weapons = self.get_available_weapons(difficulty)\n\n #create the new characterquest instance to show that player has completed the quest\n self.quest_selection(selection, difficulty)\n\n #run the weapon_reward method to get reward for the quest\n self.weapon_reward(available_weapons)\n end\n end\n end",
"def phase_one\n\t#Intro\n\n\t\[email protected] do |tribe|\n\t\tputs \"Welcome #{tribe}\".green\n\t\tend\n\nprint_header(\"For Phase 1, you will now compete in 8 challenges for immunity. Good luck!\")\n\n\t8.times do\n\t\timmunity_challenge_losing_tribe = @borneo.immunity_challenge\n\t\tputs \"#{immunity_challenge_losing_tribe}\".green + \" has lost the immunity challenge and must now vote out 1 member.\"\n\t\tmember_voted_off = immunity_challenge_losing_tribe.tribal_council\n\tend\t\nend",
"def ask_question(num = @trivia[:cur_quest])\n self.say \"\\0036 #{@questions[num][:question]}\"\n STDOUT.puts \"\\n :#{@questions[@trivia[:cur_quest]][:answer]}: \\n\"\n end",
"def printNotDone\n notDoneList = \"\"\n @toDoListArray.each do |e|\n if !e.status\n notDoneList = notDoneList + e.printItem + \" \"\n end\n end\n notDoneList\n end",
"def quest_name_colour(quest = @quest)\n return if !quest\n quest = $game_party.quests[quest] if quest.is_a?(Integer)\n s = [:failed, :complete, :active].find { |status| quest.status?(status) }\n text_color(QuestData::COLOURS[s])\n end",
"def skipped_questions\n @questions.each do |number, question|\n if @user_answers[number] == 'no answer'\n puts \"Question #{number}: #{question}\"\n print \"> \"\n response = gets.strip\n @user_answers[number] = response\n end\n end\n end",
"def get_scenarios\n return [\n \"You and your friend are at the bar. Your friend accidentally spills his drink on a group of large drunk men. They demand an apology but your friend refuses. An argument begins. He squares up as if to fight them all, then looks to you.\" + \" What do you do?\".colorize(:yellow) + \"\\n\\nOptions:\\n1. Stand with your friend no matter what\\n2. Convince your friend to back down\\n3. What friend? I don't even know this guy!\",\n \"You are at a party with a few friends, and many people you don't know.\" + \" What do you do?\".colorize(:yellow) + \"\\n\\nOptions:\\n1. Hang out with the people you already know\\n2. Meet some new people\",\n \"You are playing a casual game of mario kart with your spouse. You are winning until you are hit by a blue shell right before the finish line and end up losing. Your spouse points at you, laughs, and jumps up in glee.\" + \" What do you do?\".colorize(:yellow) + \"\\n\\nOptions:\\n1. Demand a rematch to reclaim your honour\\n2. Let your spouse known that gloating is not an appropriate way to celebrate a win\\n3. Congratulate them on their win\",\n \"Your neighbour plays music loudly in the middle of the night. It disturbs your sleep and you are unable to focus in the next day's Ruby class, getting many answers wrong in the Kahoot. This continues for several nights.\" + \" What do you do?\".colorize(:yellow) + \"\\n\\nOptions:\\n1. Knock on your neighbour's door to ask them face-to-face to stop\\n2. Leave a note asking them to stop\\n3. Accept it and buy some earplugs\"\n ]\nend",
"def all_quests(adventure_hash)\n adventure_hash[:knights].collect do |details| # collect *returns* an array, which is what we need. \n details[:quest]\n end\nend",
"def display(dead_man)\n puts @letters_guessed_array.join(\" \")\n puts \"\\n\"\n dead_man.show_wrong_letters unless dead_man.wrong_letters.empty?\n dead_man.description unless dead_man.wrong_guesses == 0\n end",
"def inactive_assessment_titles\n titles =[]\n inactive_table = frm.div(:class=>\"tier2\", :index=>2).table(:id=>\"authorIndexForm:inactivePublishedAssessments\")\n 1.upto(inactive_table.rows.size-1) do |x|\n titles << inactive_table[x][1].span(:id=>/inactivePublishedAssessmentTitle/).text\n end\n return titles\n end",
"def questions_explanation\n puts \"Time to do the quiz!.\"\n puts \"\"\n puts \"Each question will be printed to the screen.\"\n puts \"Once you see it, simply type in your answer and hit the enter/return key.\"\n puts \"If you can't think of an answer right away, you can skip the question and return to it at the end.\"\n puts \"\"\n puts \"Ok, let's go! (Hit enter/return when you're ready)\"\n gets\n end",
"def display_cohort_info\n puts '=========================================='\n puts @name\n puts \"Start Phase 0: #{@p0_start_date}\"\n puts \"Start Immersive: #{immersive_start_date}\"\n puts \"Graduate: #{graduation_date}\"\n puts \"Enrollment: #{self.num_of_students}\"\n puts \"Current Phase: #{currently_in_phase}\"\n end",
"def printtree(n, t)\n if t.question==nil\n n.times {print \" \"}\n puts t.name\n else\n puts t.question\n printtree n+1, t.yes\n printtree n+1, t.no\n end\n end",
"def vampire_questions\n \tputs @prompt\n vampire_name\n vampire_age\n vampire_birth_year\n garlic_bread\n health_insurance\n allergie_checker\n end",
"def getQuestStages(quest)\n arr = []\n for key in QuestModule.const_get(quest).keys\n arr.push(key) if key.to_s.include?(\"Stage\")\n end\n return arr\n end",
"def print_all(type)\n\n #Prints the names of all exercises in exercise_list\n if type == \"exercise\"\n\n #Stops if the exercise list is empty\n if @exercise_list.empty? == true\n puts \"Database Empty.\"\n return -1\n #Iterates over array and prints\n else\n for i in 0..@exercise_list.size-1 do\n puts @exercise_list[i].name\n end\n return 0\n end\n\n #Prints the name of all workouts in workout_routines\n elsif type == \"workout\"\n\n #Stops if the workout list is empty\n if @workout_routines.empty? == true\n puts \"Database Empty.\"\n return -1\n #Iterates over array and prints\n else\n for i in 0..@workout_routines.size-1 do\n puts @workout_routines[i].name\n end\n return 0\n end\n #Error handling\n else\n return -1\n end\n end",
"def pending_assessment_titles\n titles =[]\n pending_table = frm.table(:id=>\"authorIndexForm:coreAssessments\")\n 1.upto(pending_table.rows.size-1) do |x|\n titles << pending_table[x][1].span(:id=>/assessmentTitle/).text\n end\n return titles\n end",
"def print_hangman\n puts \"------------------------------------------------\"\n puts \"\"\n hangman_partial = @incorrect_letters.size - 1\n puts \"#{@hangman[hangman_partial]}\" if hangman_partial >= 0\n puts \"\"\n print \"Incorrect letters: \"\n @incorrect_letters.each { |letter| print \"#{letter} \" }\n print \"\\n\\n\"\n puts \"#{@progress}\"\n puts \"\"\n end",
"def quest; end",
"def quest\n @quest ||= Quest.find(params[:id])\n end",
"def getCompletedQuests\n completed = []\n $PokemonGlobal.quests.completed_quests.each do |s|\n completed.push(s.id)\n end\n return completed\nend",
"def show\n @quest = Quest.find(params[:id])\n quest_objectives = @quest.locations\n completed_objectives = []\n quest_objectives.each do |obj|\n if @current_user.locations.exists?(obj)\n completed_objectives << obj\n end\n end\n if completed_objectives.length == quest_objectives.length\n unless @quest.winner_id\n @quest.update(winner_id: @current_user.id)\n end\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n end\n\n if(@quest.owner_id == @current_user.id)\n redirect_to edit_quest_path(@quest)\n elsif @quest.start_date > DateTime.current\n flash[:warning] = \"Quest has not yet begun!\"\n redirect_to user_path(@current_user) and return\n elsif @quest.end_date < DateTime.current\n flash[:warning] = \"Quest has ended. Womp womp\"\n\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n elsif @quest.users.exists?(@current_user.id)\n gon.track = true\n locations = @quest.locations\n gon.remaining_locations = []\n gon.completed_locations = []\n locations.each do |loc|\n if loc.users.exists?(@current_user.id)\n gon.completed_locations << loc\n else\n gon.remaining_locations << loc\n end\n end\n @remaining_locations = gon.remaining_locations\n @completed_locations = gon.completed_locations\n else\n gon.track = false\n flash[:danger] = \"You are not a member of this quest! Please contact the quest owner for an invite.\"\n redirect_to quests_path and return\n end\n end",
"def unanswered_check_in_questions\n action_items.where(component_type:Check::COMPONENT_TYPE, day:1..day.to_i).select{|i| !i.complete?}\n end",
"def quest(id) \n\tsys('quest')\n\t$progress.add_quest(id) \n\tpop_quest(id)\n\t$scene.hud.quest_sparkle(\"misc/profile\")\nend",
"def quest_selection(input, difficulty)\n quest_id = self.get_recommended_quests(difficulty)[input.to_i-1].id\n CharacterQuest.new_character_quest(self.id, quest_id)\n end",
"def quest_book\n GamePlay::QuestBookMenu.new.main\n Graphics.transition\n @wait_count = 2\n end",
"def print_unfinished(db)\n\ttodo_list = db.execute(\"SELECT * FROM todo JOIN activities \n\t\tON activities.id = todo.activity_id AND todo.done='false'\")\n\tputs \"\\nUnfinished Activities for Today:\"\n\tputs '*~'*20+'*'\n\tputs \"ALL ACTIVITIES HAVE BEEN COMPLETED\" if todo_list.empty?\n\ttodo_list.each { |act| puts \"#{act['id']} - #{act['name']}\" }\nend",
"def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if (!@outfit[:weapon].nil?)\n puts \"#{@outfit[:weapon].name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if (!@outfit[:helmet].nil?)\n puts \"#{@outfit[:helmet].name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end",
"def print_status(game)\n cls\n\n puts game.version\n\n # Print the word with underscores instead of not guessed letters\n puts \"\\nWord: #{get_word_for_print(game.letters, game.good_letters)}\"\n # Print wrong letters separated with commas\n puts \"Mistakes: #{game.bad_letters.join(\", \")}\"\n\n # Print the image for the current number of made mistakes\n print_hangman(game.mistakes)\n\n if game.status == :lost\n # If player lost - print a message about it and show the word\n puts \"\\nGame over :(\"\n puts \"The word was: \" + game.letters.join(\"\")\n elsif game.status == :won\n # If player won - congratulate\n puts \"\\nYou won! Congratulations! :)\"\n else\n # If the game is not over, print the number of mistakes that are available to make\n if game.mistakes != 6\n puts \"You have left: #{game.mistakes_left} mistakes\"\n else\n puts \"You have left: 1 mistake. Be careful! \"\n end\n end\n end",
"def show_result\n real_answers = @answer_list.collect {|i| @answers[i]}\n @story_parts.zip(real_answers).flatten.compact.join\n end",
"def generate_results\n !(@incomplete_word.include? \"_\") ?\n puts(\"Congratulations, you won.\") :\n puts(\"\\nYou failed to guess the words.\")\n end",
"def show\n @attempted_questions = AttemptedQuestion.where(subject: @subject)\n end",
"def show\n @completed_quest = CompletedQuest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @completed_quest }\n end\n end",
"def find_selected\n selected_quests = self.user_quests.where(complete: false)\n selected_quests.map do |x|\n x.quest_id\n end\n end",
"def quest_duration\n Objective.find_by_id(self.objective_id).duration.capitalize\n end",
"def print_specific_lttr student_arr\n\tputs \"Please enter a letter to display all students whose name begins with that letter\"\n\tchoice = gets.chomp.upcase\n\tstudent_arr.each do |student|\n\t\tif student[:name].chars.first == choice\n\t\t\tputs \"#{student[:name]} (#{student[:cohort]} cohort)\"\n\t\tend\n\tend\nend",
"def print_contrived_while student_arr\n\ti = 0\n\twhile i < student_arr.length\n\t\tputs student_arr[i][:name] + \" \" + \"(\" + student_arr[i][:cohort].to_s + \")\"\n\t\ti += 1\n\tend\nend",
"def activateQuest(quest,color,story)\n if !quest.is_a?(Symbol)\n raise _INTL(\"The 'quest' argument should be a symbol, e.g. ':Quest1'.\")\n end\n for i in 0...@active_quests.length\n if @active_quests[i].id == quest\n pbMessage(\"You have already started this quest.\")\n return\n end\n end\n for i in 0...@completed_quests.length\n if @completed_quests[i].id == quest\n pbMessage(\"You have already completed this quest.\")\n return\n end\n end\n for i in 0...@failed_quests.length\n if @failed_quests[i].id == quest\n pbMessage(\"You have already failed this quest.\")\n return\n end\n end\n @active_quests.push(Quest.new(quest,color,story))\n pbMessage(_INTL(\"\\\\se[{1}]<ac><c2=#{colorQuest(\"red\")}>New quest discovered!</c2>\\nCheck your quest log for more details!</ac>\",QUEST_JINGLE))\n end",
"def assignments_titles\n titles = []\n a_table = frm.table(:class=>\"listHier lines nolines\")\n 1.upto(a_table.rows.size-1) do |x|\n titles << a_table[x][1].h4(:index=>0).text\n end\n return titles\n end",
"def display_question(player)\n puts \"#{player.name}'s turn:\"\n print \"Evaluate the following expression: \"\n puts create_question\n get_response\n puts \"The answer was #{validate_response(player)}.\"\n end",
"def destroy\r\n @quest = @kingdom.quests.find(params[:id])\r\n unless verify_quest_not_in_use(@quest)\r\n redirect_to :action => 'index', :page => params[:page]\r\n return\r\n end\r\n \r\n @quest.reqs.each{|r| r.destroy} \r\n flash[:notice] = 'Deleted all requirements.<br/>'\r\n \r\n if @quest.destroy\r\n flash[:notice] += 'Destroyed the quest.'\r\n redirect_to :action => 'index', :page => params[:page]\r\n else\r\n flash[:notice] += 'Failed to destroy the quest.'\r\n redirect_to :action => 'show', :id => params[:id]\r\n end\r\n end",
"def pt_print\n @task = Task.includes(:assignment).find(params[:task_id])\n @assignment = @task.assignment\n @titles = Title.build_paragraph_title_collection(@task.id,current_user.id)\n end",
"def index\n @quests = Quest.all\n end",
"def index\n @quests = Quest.all\n end",
"def display_findings(prospect)\n return nil if prospect <= 0\n\n puts \"After #{@turns} days, Rubyist ##{prospect} found:\"\n print \"\t#{@total_rubies} \"\n\n # Format singular and plurals\n if @total_rubies == 1\n puts 'ruby.'\n else\n puts 'rubies.'\n end\n\n print \"\t#{@total_fake_rubies} fake \"\n if @total_fake_rubies == 1\n puts 'ruby.'\n else\n puts 'rubies.'\n end\n\n # Display message depending on rubies found\n if @total_rubies >= 10\n print 'Going home victorious!'\n elsif @total_rubies.between?(1, 9)\n print 'Going home sad.'\n elsif @total_rubies.zero?\n print 'Going home empty-handed.'\n end\n # Return 1 if successfully displayed\n 1\n end",
"def help\r\n @quantities.each do |dim|\r\n\r\n dim[1].each do |quan|\r\n names=quan.quantity_name\r\n if quan.synonyms.length>0\r\n names += ', ' + quan.synonyms.join(', ')\r\n end\r\n\r\n puts names\r\n puts '---------------------------------------------------------------------------------------'\r\n puts '[' + dim[0].to_s + ']'\r\n puts quan.units_sorted\r\n puts ''\r\n end\r\n end\r\n end",
"def list_details\n puts \"Name: \" + @name\n puts \"Description: \" + @details\n puts \"Exercise Time: \" + @duration\n end",
"def list_my_words\n games = GameSession.where(user_id: self.id)\n games = games.select {|game| game.word_id != nil}\n words = games.map {|gs| Word.find(gs.word_id).word}\n wins = games.map {|gs| gs.win}\n h = {true => [], false => []}\n for i in 0..words.length-1\n wins[i] ? h[true] << words[i].green : h[false] << words[i].red\n end\n puts \"Puzzles Won\".green.underline\n if h[true].empty? \n puts \"(no puzzles won)\".black\n else\n puts h[true]\n end\n puts \"\\n\\n\"\n \n puts \"Puzzles Lost\".red.underline\n if h[false].empty?\n puts \"(no puzzles lost)\".black\n else\n puts h[false]\n end\n puts \"\\n\\n\\n\"\n end",
"def show_all_full_tests\n @quizzes = Quiz.scoped_for_user(current_user).full.not_in_account_of_user(current_user).order('id ASC')\n @quizzes += current_user.quizzes.full\n @quizzes = load_words_for_quizzes(@quizzes)\n \n @name = \"Full length tests\"\n render \"show_all_tests\"\n end",
"def print_problems\n report(@problems)\n end",
"def print\n blank = \"#{Tty.yellow}[no description]#{Tty.reset}\"\n @descriptions.keys.sort.each do |name|\n description = @descriptions[name] || blank\n puts \"#{Tty.white}#{name}:#{Tty.reset} #{description}\"\n end\n end",
"def good_pokemon # :not_very_effective AND :no_effect_on\n good_pokemon = []\n @type.not_very_effective.each {|pokemon| good_pokemon << pokemon}\n @type.no_effect_on.each {|pokemon| good_pokemon << pokemon if !good_pokemon.include?(pokemon)}\n \n if good_pokemon.count > 0\n puts \"\"\n puts \"USE POKEMON OF THESE TYPE(S)\"\n good_pokemon.each_with_index {|pokemon, index| puts \"#{index +1}. #{pokemon.name}\"}\n end\n end",
"def show_not_completed_items\n return @to_do_item.select { |x| x.is_done? == false }\n end",
"def print_needed_ingredients\n puts \"\\n\\n\\s\\e[4m#{self.name} Recipe\\e[0m\"\n self.ingredients.each { |ingredient| puts \"\\s- #{ingredient.name}: #{RecipeIngredient.find_by(recipe_id: self.id, ingredient_id: ingredient.id).amount} cl\" }\n if self.recipe_specials.collect{|x| x.special if x.special}.uniq != [nil]\n self.recipe_specials.collect{|x| x.special if x.special}.uniq.each{|y| puts \"\\s- Special: #{y}\"}\n elsif self.recipe_specials.collect{|x| x.garnish if x.garnish}.uniq != [nil]\n puts \"\\s- Garnish: #{self.recipe_specials.collect{|x| x.garnish if x.garnish}.uniq[0]}\"\n end\n puts \"\\s- Preparation: #{self.preparation}\"\n end",
"def output_missing(missing)\n puts \"\"\n puts \"ERROR: Missing input parameters for steps:\"\n output = missing.collect {|step, miss| \" #{step} is missing #{miss}\"}\n output.each {|o| puts o}\n puts \"\"\n end",
"def print_instructions\n puts \"Type 'find 1' to display candidate with id 1.\"\n puts \"Type 'all' to see all candidates.\"\n puts \"Type 'qualified' to print only qualified candidates.\"\n puts \"Type 'quit' to exit.\"\n puts \"Type 'help' to see these instructions again.\"\nend",
"def display_list(questions)\n input = nil\n puts \"How many questions would you like to see? (1-50)\"\n puts @@divider\n input = gets.strip.to_i\n if input.to_i > 0 && input.to_i < @questions.length + 1\n questions.each.with_index(1) do |question, index|\n puts \"#{index}. #{question.question}\".red\n puts \"#{question.description_short}\"\n puts @@divider\n break if index == input\n end\n elsif input == \"exit\"\n goodbye\n else\n puts \"Please make a valid selection.\"\n list_questions\n end\n end",
"def difficulty \n \"difficulty\" \n end",
"def reason\n res = \"Selected correctly:\\n\\n\"\n res << make_list(@correct_choices, @points_per_choice.round(1))\n res << \"\\n\"\n res << \"Selected incorrectly:\\n\\n\"\n res << make_list(@incorrect_choices, -@points_per_choice.round(1))\n end",
"def print(names)\n# exercise 6 - added in center to print option 1 to align all fields into the center\n# exercise 8 - added in option to print by cohort, can print out each cohort in one go, or specific cohort.\n# exercise 9 - fixed printing statments for singular/plural of student/students\n\n puts \"Do you want: \nThe full list of names (enter 1) \nNames beginning with a specific letter (enter 2)\nNames with less than 12 characters (enter 3)\nPrint by cohort (enter 4)\"\nchoice_possibilities = [1, 2, 3, 4]\n choice = gets.chomp.to_i\n while !choice_possibilities.include?(choice) \n puts \"Please select #{choice_possibilities}.\"\n choice = gets.chomp.to_i\n end\n\n print_header\n\n if choice == 1\n counter = 0\n while counter < names.length\n print_array = \"\"\n\tnames[counter].map{ |y, z| print_array << \"#{y}: #{z}, \"} \n\tputs \"#{counter + 1}. #{print_array.to_s}\".center(100) \n\tcounter += 1\n end\n\n elsif choice == 2\n puts \"what letter would you like?\"\n letter = gets.chomp.downcase\n while letter.length != 1\n puts \"Please enter a single letter\"\n letter = gets.chomp.downcase\n end\n counter = 0\n names.each_with_index do |name, index|\n if name[:name][0].downcase == letter\n\tputs \"#{index + 1}. #{name[:name]} (#{name[:cohort]} cohort)\"\n counter += 1\n end\n end\n puts \"We have #{counter} #{counter == 1 ? \"student\" : \"students\"} with a name starting with #{letter.upcase}.\"\n\n elsif choice == 3\n counter = 0\n names.each_with_index do |name, index|\n if name[:name].length < 12\n puts \"#{index + 1}. #{name[:name]} (#{name[:cohort]} cohort)\"\n counter += 1\n end\n end\n puts \"We have #{counter} #{counter == 1 ? \"student\" : \"students\"}} with a name of less than 12 character.\"\n \n elsif choice == 4\n puts \"Do you want to print all cohorts or a specific cohort? Type all or specific\"\n choice_poss = ['all', 'specific']\n choice = gets.chomp.downcase\n while !choice_poss.include?(choice)\n\tputs \"please enter all or specific\"\n choice = gets.chomp.downcase\n end\n cohorts = []\n names.each do |name|\n cohorts << name[:cohort]\n end\n cohorts.uniq!\n if choice == 'all'\n cohorts.each do |cohort|\n puts \"Cohort: #{cohort}\"\n names.each_with_index { |name, index| puts \"#{index + 1}. Name: #{name[:name]}, Age: #{name[:age]}, Hobby: #{name[:hobby]}\" if name[:cohort] == cohort}\n end \n elsif choice == 'specific'\n puts \"Please choose a cohort\"\n cohorts.each {|x| puts x }\n choice = gets.chomp.to_sym\n while !cohorts.include?(choice)\n\tputs \"Please type an available cohort\"\n\tcohorts.each {|x| puts x}\n\tchoice = gets.chomp.to_sym\n end\n puts \"Cohort: #{choice}\"\n names.each_with_index { |name, index| puts \"#{index + 1}. Name: #{name[:name]}, Age: #{name[:age]}, Hobby: #{name[:hobby]}\" if name[:cohort] == choice}\n end\n end\nend",
"def published_assessment_titles\n titles =[]\n published_table = frm.div(:class=>\"tier2\", :index=>2).table(:class=>\"listHier\", :index=>0)\n 1.upto(published_table.rows.size-1) do |x|\n titles << published_table[x][1].span(:id=>/publishedAssessmentTitle/).text\n end\n return titles\n end",
"def display_status\n exam_state = (all_questions_answered? ? FINISHED_STATE : UNFINISHED_STATE).titleize\n \"#{exam_state} Subject\"\n end",
"def find_completed\n self.all(\n :completed_at.not => nil, \n :order => [:title])\n end",
"def pending_quests\n quests = UsersQuest.where(:assignee_id => @current_user.id,:is_accepted => false,:is_rejected =>false).pluck(:quest_id)\n @quests = Quest.where(:id => quests).order('due_date')\n by_me_quests = UsersQuest.where(:assignor_id => @current_user.id,:is_accepted => false,:is_rejected =>false).pluck(:quest_id)\n @by_me_quests = Quest.where(:id => by_me_quests).order('due_date')\n end",
"def show\n @people = @game.people\n @questions = @game.questions\n @answers = @game.answers\n\n @number_of_present = 0\n if @questions.length > @answers.length\n @answer_yes = Answer.new\n @answer_no = Answer.new\n @current_question = @questions.unshift[0]\n @number_of_present -= 1\n else\n @question = Question.new\n end\n\n if @current_question.present?\n @questions = @questions.first(9)\n @answers = @answers.first(9)\n else\n @questions = @questions.first(10)\n @answers = @answers.first(10)\n end\n\n @number_of_present += @questions.length\n @number_of_blank = [0, 10 - @number_of_present].max\n end",
"def difficulty\n request('getdifficulty')\n end",
"def txt_from_answer\n search_result = QueryForKeywords.new(skills_in_request).call\n answer = search_result.to_array # Here we can decide what output we need\n\n \"\".tap do |str|\n if answer[0].present?\n people = answer[0].map(&:full_name).join(\", \")\n skills = answer[1].map(&:title).join(\", \")\n str << \"Your first choice(s): #{people}. They know about: #{skills}.\"\n end\n\n if answer[2].present?\n people = answer[2].map(&:full_name).join(\", \")\n skills = answer[3].map(&:title).join(\", \")\n str << \"\\nYour second choice(s): #{people}. They know about: #{skills}.\"\n end\n\n if answer[4].present?\n people = answer[4].map(&:full_name).join(\", \")\n skills = answer[5].map(&:title).join(\", \")\n str << \"\\nYour third choice(s): #{people}. They know about: #{skills}.\"\n end\n\n str << \"No results, maybe try another combination of keywords?\" if str.blank?\n end\n end",
"def dm_unplayed\n question = game.current_round.question.print\n m = []\n m << \"`[#{game.name}]` | \"\\\n \"Round ##{game.rounds.count} Question: **#{question}**\"\n m << \"**Your Cards:**\"\n unplayed_cards.each_with_index do |c, i|\n m << \"**#{i+1}.** ▫ #{c.answer.text}\"\n end\n m << 'Respond with `pick [number]` to pick a card for this round. '\\\n 'Do one `pick` for each card!'\n discord_user.pm(m.join(\"\\n\"))\n end",
"def print_cohort\n puts \"These are the current active cohorts:\".center(70)\n active_cohorts = @students.uniq { |student| student[:cohort] }\n active_cohorts.each do |entry|\n puts \"#{entry[:cohort]}\".center(70)\n end\n puts \"Enter a cohort start month to print students in that cohort\".center(70)\n cohort_to_print = STDIN.gets.strip.downcase.to_sym\n single_cohort = @students.select { |student| student[:cohort] == cohort_to_print }\n single_cohort.each do |student| \n puts \"#{student[:name]} (#{student[:cohort]} cohort)\".center(70)\n end\nend",
"def list_details(list = \"all\")\n\n #Iterates over the arrays\n for i in [email protected] do\n\n #In the case of all, it will list all details of the exercise\n if list == \"all\"\n exercise_info = \"Name: \" + @exercises[i].name + \" | Number of Repeats: \" + @repititions[i] + \" | Rest Time (sec): \" + break_time[i]\n\n #In the case of exercise, it will just list the name of the exercise\n elsif list == \"exercise\"\n exercise_info = \"Name: \" + @exercises[i].name\n end\n\n #outputs the information\n puts exercise_info\n\n end\n end",
"def index\n @quest_stats = QuestStat.all\n end",
"def display_choices(monster) \n monster.display_moves << \"or type (Q)uit to give up.\"\n end",
"def dictator_Iraq\n puts \"Saddam formally rose to power in 1979, although he had been the de facto head\n of Iraq for several years prior. Within his own country, he suppressed\n his own citizens, particularly the Shi'a and Kurdish people. He also maintained\n power during the Iran–Iraq War and the Gulf War, and was accused of using\n chemical weapons. To alleviate the threat of revolution, Saddam afforded\n certain benefits to the potentially hostile population. Membership in the\n Ba'ath Party remained open to all Iraqi citizens regardless of background.\n However, repressive measures were taken against its opponents. The major\n instruments for accomplishing this control were the paramilitary and police\n organizations. Saddam was notable for using terror against his own people.\n Saddam's regime was responsible for the deaths of at least 250,000\n Iraqis and committed war crimes in Iran, Kuwait, and Saudi Arabia. Human\n Rights Watch and Amnesty International issued regular reports of widespread\n imprisonment and torture.\"\n\n crazy_acts\n\nend",
"def view_completed_question(count, answer,questionnaire_max)\n\t\thtml = '<big><b>Question '+count.to_s+\":</b> <I>\"+self.txt+\"</I></big><BR/><BR/>\"\n if !answer.answer.nil?\n\t\t html += '<TABLE CELLPADDING=\"5\"><TR><TD valign=\"top\"><B>Score:</B></TD><TD><FONT style=\"BACKGROUND-COLOR:gold\">'+answer.answer.to_s+'</FONT> out of <B>'+questionnaire_max.to_s+'</B></TD></TR>'\n else\n html += '<TABLE CELLPADDING=\"5\"><TR><TD valign=\"top\"><B>Score:</B></TD><TD><FONT style=\"BACKGROUND-COLOR:gold\">--</FONT> out of <B>'+questionnaire_max.to_s+'</B></TD></TR>'\n end\n\t\tif answer.comments != nil\n\t\t\thtml += '<TR><TD valign=\"top\"><B>Response:</B></TD><TD>' + answer.comments.gsub(\"<\", \"<\").gsub(\">\", \">\").gsub(/\\n/, '<BR/>')\n\t\tend\n\t\thtml += '</TD></TR></TABLE><BR/>'\n\t\thtml.html_safe\n end",
"def complete_quests(options={})\n options.reverse_merge!(:count => 1)\n\n @objectives.push([\n Objective::CompleteQuests,\n {:key => Objective::CompleteQuests::KEY, :count => options[:count]}\n ])\n end",
"def play\n# \tThere are 3 players in Knuckleheads: \n\t\tputs \"There are #{to_s} players in #{@title}\"\n# \tI'm Moe with a health of 100 and a score of 103.\n# \tI'm Larry with a health of 60 and a score of 65.\n# \tI'm Curly with a health of 125 and a score of 130.\n\t\[email protected] do |spieler|\n\t\t\tputs \"I'm #{spieler} with a health of #{@health} and a score of #{score}\"\n\t\t\tend\n# \tMoe got blammed!\n# \tMoe got w00ted!\n# \tMoe got w00ted!\n# \tI'm Moe with a health of 120 and a score of 123.\n# \tLarry got blammed!\n# \tLarry got w00ted!\n# \tLarry got w00ted!\n# \tI'm Larry with a health of 80 and a score of 85.\n# \tCurly got blammed!\n# \tCurly got w00ted!\n# \tCurly got w00ted!\n# \tI'm Curly with a health of 145 and a score of 150.\n\t\tend",
"def printAnswersOnScreen()\n $lblAnswerA['text'] = $arrAnswerA[$intQuestionOnScreen - 1]\n $lblAnswerB['text'] = $arrAnswerB[$intQuestionOnScreen - 1]\n $lblAnswerC['text'] = $arrAnswerC[$intQuestionOnScreen - 1]\n $lblAnswerD['text'] = $arrAnswerD[$intQuestionOnScreen - 1]\nend",
"def quest_params\n params.require(:quest).permit(:user_id, :quest, :result)\n end",
"def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if ([email protected]?)\n puts \"#{weapon.name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if ([email protected]?)\n puts \"#{helmet.name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end"
] | [
"0.730667",
"0.6421022",
"0.6139971",
"0.6088218",
"0.60317516",
"0.5855628",
"0.584459",
"0.56226474",
"0.5541372",
"0.5456466",
"0.5450909",
"0.5439021",
"0.5424928",
"0.54177433",
"0.5417137",
"0.5398977",
"0.53792864",
"0.53462696",
"0.5344046",
"0.53439444",
"0.53080463",
"0.5290861",
"0.5288554",
"0.52786386",
"0.5255669",
"0.52544093",
"0.5250682",
"0.52495277",
"0.52493906",
"0.524441",
"0.52422976",
"0.52302736",
"0.522421",
"0.5208124",
"0.5203849",
"0.5185543",
"0.51654196",
"0.5156238",
"0.5146856",
"0.51423824",
"0.5141037",
"0.51354355",
"0.51312476",
"0.51232874",
"0.51188445",
"0.51132333",
"0.51067036",
"0.51046747",
"0.51035696",
"0.51032126",
"0.50738263",
"0.5067409",
"0.50566894",
"0.50559276",
"0.5050257",
"0.50493735",
"0.504778",
"0.5044567",
"0.5039466",
"0.5038243",
"0.50312173",
"0.50266117",
"0.5014325",
"0.5014048",
"0.5014048",
"0.500956",
"0.5005604",
"0.5005177",
"0.50026596",
"0.4997786",
"0.4996106",
"0.49940762",
"0.49871427",
"0.49852425",
"0.49840954",
"0.4982053",
"0.49786928",
"0.49724296",
"0.49710473",
"0.49710238",
"0.49701923",
"0.49604997",
"0.49556148",
"0.4945773",
"0.4937642",
"0.49349758",
"0.49330494",
"0.493089",
"0.49284437",
"0.4927078",
"0.49255615",
"0.49175975",
"0.4910841",
"0.49106908",
"0.49082237",
"0.48986852",
"0.48968247",
"0.4894202",
"0.48902392",
"0.48898512"
] | 0.78221 | 0 |
after the player selects a quest instantiate a new CharacterQuest object to show that player has actually completed the quest | def quest_selection(input, difficulty)
quest_id = self.get_recommended_quests(difficulty)[input.to_i-1].id
CharacterQuest.new_character_quest(self.id, quest_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quest_interface\n\n#obtain the difficulty level for the given player\n difficulty = self.get_difficulty\n\n#see if the player has any quests left to complete\n if self.get_recommended_quests(difficulty).size == 0\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"You have completed all recommended quests!!!\".bold\n puts \"=====================================\".red\n puts \"=====================================\".red\n\n#show the player the available quests\n else\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Recommended Quests for Player Attack: #{self.power}\".blue.on_light_green.bold\n puts \"\"\n self.print_quests(difficulty)\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Select a quest number\".bold.white.on_light_blue\n puts \"Number:\".bold.white.on_light_blue\n\n#selection prompt the player to actually choose a quest\n selection = gets.chomp\n\n#check for invalid input\n if selection.to_i > self.get_recommended_quests(difficulty).size || selection.to_i < 1\n puts \"Invalid input, please try again!\".red.bold\n\n#if input is valid, show the player that he has completed the quest\n else\n puts\"*******************************************\"\n puts \"You have completed: #{self.get_recommended_quests(difficulty)[selection.to_i-1].title}\".bold\n puts\"*******************************************\"\n puts \" \"\n puts\"#####################################\".blink\n puts \"Time For Your Reward Adventurer!!!\".bold.blue.on_light_yellow\n\n #obtain the available weapons based on player difficulty\n available_weapons = self.get_available_weapons(difficulty)\n\n #create the new characterquest instance to show that player has completed the quest\n self.quest_selection(selection, difficulty)\n\n #run the weapon_reward method to get reward for the quest\n self.weapon_reward(available_weapons)\n end\n end\n end",
"def quest(id) \n\tsys('quest')\n\t$progress.add_quest(id) \n\tpop_quest(id)\n\t$scene.hud.quest_sparkle(\"misc/profile\")\nend",
"def quest_book\n GamePlay::QuestBookMenu.new.main\n Graphics.transition\n @wait_count = 2\n end",
"def quest; end",
"def activateQuest(quest,color=colorQuest(nil),story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.activateQuest(quest,color,story)\nend",
"def activateQuest(quest,color,story)\n if !quest.is_a?(Symbol)\n raise _INTL(\"The 'quest' argument should be a symbol, e.g. ':Quest1'.\")\n end\n for i in 0...@active_quests.length\n if @active_quests[i].id == quest\n pbMessage(\"You have already started this quest.\")\n return\n end\n end\n for i in 0...@completed_quests.length\n if @completed_quests[i].id == quest\n pbMessage(\"You have already completed this quest.\")\n return\n end\n end\n for i in 0...@failed_quests.length\n if @failed_quests[i].id == quest\n pbMessage(\"You have already failed this quest.\")\n return\n end\n end\n @active_quests.push(Quest.new(quest,color,story))\n pbMessage(_INTL(\"\\\\se[{1}]<ac><c2=#{colorQuest(\"red\")}>New quest discovered!</c2>\\nCheck your quest log for more details!</ac>\",QUEST_JINGLE))\n end",
"def activateQuest(questID)\n if questID.is_a?(String)\n questID = $quest_data.getIDFromName(questID)\n end\n for i in 0...@active_quests.length\n if @active_quests[i].id==questID\n Kernel.pbMessage(\"You have already started this quest\")\n return\n end\n end\n for i in 0...@completed_quests.length\n if @completed_quests[i].id==questID\n Kernel.pbMessage(\"You have already complete this quest\")\n return\n end\n end\n for i in 0...@failed_quests.length\n if @failed_quests[i].id==questID\n Kernel.pbMessage(\"You have already failed this quest\")\n return\n end\n end\n @active_quests.push(Quest.new(questID))\n end",
"def init_quest\n @quest = Quest.find_by_id(params[:id])\n @quest ||= Quest.draft(params[:id])\n end",
"def run\n welcome\n main_menu_selection #choose to create a character or login to pre-existing character\n player_options #a list of options the selected player from 'selection_menu' can accomplish\nend",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def quest\n @quest ||= Quest.find(params[:id])\n end",
"def completeQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.completeQuest(quest,color,story)\nend",
"def setup_quest(quest_id)\n return if @data[quest_id]\n @data[quest_id] = Game_Quest.new(quest_id)\n # Open to this quest next time the QJ is opened\n $game_system.last_quest_id = quest_id if QuestData::OPEN_TO_LAST_REVEALED_QUEST\n # Save sorting order in separate arrays to avoid re-sorting every time\n @sort_arrays.keys.each { |sym| add_to_sort_array(sym, quest_id) }\n end",
"def quest(quest_id); $game_party.quests[quest_id]; end",
"def start\n setPlayers\n question\nend",
"def run_quest\n original_power = @todays_hero.power\n system \"clear\"\n subtitle_print('Start Quest')\n power_update = Quest.find_new\n @todays_hero.increase_power_by(power_update)\n system \"clear\"\n if @todays_hero.power > original_power\n puts \"Congrats! Your power increased by #{power_update}.\"\n puts \"Your power is now #{@todays_hero.power}.\"\n elsif @todays_hero.power == original_power\n puts \"Evil doesn't wait for the slow and idle.\"\n puts \"Your power remains at #{@todays_hero.power}.\"\n elsif @todays_hero.power < original_power\n puts \"The world weeps for the strong and courageous.\"\n puts \"Your power has decreased to #{@todays_hero.power}.\"\n end\n @todays_hero.save\n end",
"def get_completed_quests\n\n#check if the player has actually completed any quests\n#if he has not, tell him\n if self.quests.size == 0\n puts \"You have not completed any quests!!!\".red\n\n#otherwise, pull the completed quest objects and print the quest titles\n else\n puts \"Completed Quests:\".underline\n self.quests.each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end\n end",
"def finish_commands\n for i in 0..4\n if @mode_rdo[i].selected?\n $glob.game_mode = i - 1\n break\n end \n end\n if $glob.game_mode == -1\n $player = Players.new(Player.new,Player.new)\n else\n $player = Players.new(Player.new,CPU.new)\n end\n if !$player.act_p.human?\n choiced = $player.act_p.turn\n choiced.label_widget.set_markup($player.act_p.mark_markup)\n $player.switch_player\n end\n self.hide\n end",
"def create\n @quest = Quest.new(params[:quest])\n @quest.creator_id=Profile.where(:users_id=>current_user.id)[0].id\n if iAmQuestMaster @quest.speciality_id\n if (getMyQuestMasterLevel (@quest.speciality_id))>(@quest.level)\n respond_to do |format|\n if @quest.save\n format.html { redirect_to @quest, notice: 'Quest was successfully created.' }\n format.json { render json: @quest, status: :created, location: @quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to \"/\", notice: 'No tienes el nivel suficiente para crear esta quest!'\n end\n else\n redirect_to \"/\", notice: 'No tienes la especialdidad necesaria para crear esta quest!'\n end\n end",
"def ask_question\n @question = Question.new\n puts \"#{@current_player.name}: #{@question.show}\"\n end",
"def create\n @quest = Quest.new(params[:quest])\n\t@categories = find_all_categories\n\n respond_to do |format|\n if @quest.save\n\t\tcurrent_user.join!(@quest)\n format.html { redirect_to @quest, notice: 'Quest was successfully created.' }\n format.json { render json: @quest, status: :created, location: @quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @quest = Quest.find(params[:id])\n quest_objectives = @quest.locations\n completed_objectives = []\n quest_objectives.each do |obj|\n if @current_user.locations.exists?(obj)\n completed_objectives << obj\n end\n end\n if completed_objectives.length == quest_objectives.length\n unless @quest.winner_id\n @quest.update(winner_id: @current_user.id)\n end\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n end\n\n if(@quest.owner_id == @current_user.id)\n redirect_to edit_quest_path(@quest)\n elsif @quest.start_date > DateTime.current\n flash[:warning] = \"Quest has not yet begun!\"\n redirect_to user_path(@current_user) and return\n elsif @quest.end_date < DateTime.current\n flash[:warning] = \"Quest has ended. Womp womp\"\n\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n elsif @quest.users.exists?(@current_user.id)\n gon.track = true\n locations = @quest.locations\n gon.remaining_locations = []\n gon.completed_locations = []\n locations.each do |loc|\n if loc.users.exists?(@current_user.id)\n gon.completed_locations << loc\n else\n gon.remaining_locations << loc\n end\n end\n @remaining_locations = gon.remaining_locations\n @completed_locations = gon.completed_locations\n else\n gon.track = false\n flash[:danger] = \"You are not a member of this quest! Please contact the quest owner for an invite.\"\n redirect_to quests_path and return\n end\n end",
"def begin_character_selection combined_arguments\n player_list, @my_character_locations = combined_arguments\n\n @players = player_list\n $LOGGER.debug \"Game is moving into character selection phase. Other players are #{@players.inspect}\"\n @mode = :select_characters\n @finalized_players.clear_players\n\n #this is the part where you choose players\n @players.each do |p|\n @finalized_players.set_player_finalized p, false\n end\n end",
"def ask_question\n question = Question.new\n puts \"\\nPlayer 1: #{question.text}\"\n end",
"def actions\n answer = @prompt.select(\"Where will you go?\", %w(Foward Back Status Items), cycle:true, per_page:4)\n if answer == \"Foward\"\n if @zone_cur == 10\n narrate(\"you leave the #{self.name}\")\n leave(self.exit_name)\n else\n @zone_cur += 1\n narrate(\"you continue foward\")\n encounter_check\n end\n elsif answer == \"Back\"\n if @zone_cur == 0\n narrate(\"you leave the #{self.name}\")\n leave(self.entrance_name)\n else\n @zone_cur -= 1\n narrate(\"you retreat backwards\")\n encounter_check\n end\n elsif answer == 'Status'\n narrate(\"#{@player.name} has #{@player.hp} hp, #{@player.attack} attack, and #{@player.defence} defence\")\n str = \"\"\n a = @player.equipment.map do |el|\n el.name\n end\n b = a.join(\", \")\n narrate(\"#{@player.name} has the following items equipped: #{b}\")\n here\n elsif answer == 'Items'\n answer = @prompt.select(\"Items Menu\", %w(Equip_item Look_item), cycle:true, per_page:4)\n if answer == 'Equip_item'\n #list inventory\n stuff = @player.items.map do |el|\n el.name\n end\n #select an item from inventory\n answer = @prompt.select(\"Items Menu\", stuff, cycle:true, per_page:4)\n #find that item again\n to_eq = @player.items.find do |el|\n el.name == answer\n end\n binding.pry\n #equip that item\n @player.equip(to_eq)\n narrate( \"You have equipped the #{to_eq.name}!\")\n actions\n end\n end\n end",
"def create\n return\n @quest = Quest.new(quest_params)\n\n respond_to do |format|\n if @quest.save\n format.html { redirect_to @quest, notice: 'Quest was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quest }\n else\n format.html { render action: 'new' }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def seleccion\n case @selection\n when 1\n push_game_state(EnterName.new(callback: method(:enter_name)))\n when 2\n if @token_difficulty.zero?\n @difficulty_message.text = \"Dificultad: #{@difficulty[1]}\"\n @token_difficulty = 1\n @select_sound = 0\n elsif @token_difficulty == 1\n @difficulty_message.text = \"Dificultad: #{@difficulty[2]}\"\n @token_difficulty = 2\n @select_sound = 1\n @sound_tracks_list[@select_sound].play if @music_playing\n else\n @difficulty_message.text = \"Dificultad: #{@difficulty[0]}\"\n @token_difficulty = 0\n @select_sound = 0\n @sound_tracks_list[@select_sound].play if @music_playing\n end\n when 3\n if @music_playing\n @music_message.text = 'Musica: OFF'\n @music_playing = false\n @sound_tracks_list[@select_sound].pause\n else\n @music_message.text = 'Musica: ON'\n @music_playing = true\n @sound_tracks_list[@select_sound].play\n end\n when 4\n push_game_state(Acerca)\n when 5\n exit\n end\n\n end",
"def init_maqj_data\n @quests = Game_Quests.new # Initialize @quests\n end",
"def manually_complete_quest(quest_id)\n quest(quest_id).prime_objectives.clear\n quest(quest_id).manual_status = :complete\n end",
"def choose_character\n char_move = CharacterMove.all \n characters = Character.all \n move = Move.all\n # puts status_bar\n\n # puts \"1) Wolverine 2)Jean Grey 3)Quick-Silver\"\n \n # puts \"Choose Your Character..\"\n # user_input = gets.chomp\n ch = @prompt.select(\"Choose Your Character..\", %w(Martian-Manhunter Superman Flash Help))\n \n if ch == \"Martian-Manhunter\"\n # binding.pry\n @current_character = characters[0]\n first = characters[0].name\n @life_count = characters[0].lives\n puts \"You Have Chosen #{first}. You have #{@life_count} lives\"\n if char_move[0].char_id == characters[0].id\n @special_move = move[0].name\n end\n system('clear')\n\n \n elsif ch == \"Superman\"\n @current_character = characters[1]\n second = characters[1].name\n @life_count = characters[1].lives\n puts \"You Have Chosen #{second}. You have #{@life_count} lives\"\n if char_move[1].char_id == characters[1].id\n @special_move = move[1].name\n end\n \n elsif ch == \"Flash\"\n @current_character = characters[2]\n third = characters[2].name\n @life_count = characters[2].lives\n puts \"You Have Chosen #{third} You have #{@life_count} lives\"\n if char_move[2].char_id == characters[2].id\n @special_move = move[2].name\n \n end\n \n \n \n elsif ch == \"Help\" \n help \n puts \"\\n\"\n \n choose_character\n \n \n \n \n else\n puts \"Invalid Command\"\n end\n \n end",
"def set_quest_item\n @quest_item = QuestItem.find(params[:id])\n end",
"def create_player_choice\n @player_choice_ui = BattleUI::PlayerChoice.new(@viewport_sub)\n end",
"def call_quest_journal\n @quest_journal_calling = false\n Sound.play_ok\n SceneManager.call(Scene_Quest)\n end",
"def quest_footer_for_show_dash(quest)\n if current_user.user_quests.include?(quest)\n render 'quests/complete_button', object: quest, url: '/complete_quest'\n end\n end",
"def target_choice\n launcher, skill, target_bank, target_position = @visual.show_target_choice\n if launcher\n # The player made a choice we store the action and check if he can make other choices\n @player_actions << { type: :attack, launcher: launcher, skill: skill, target_bank: target_bank, target_position: target_position }\n log_debug(\"Action : #{@player_actions.last}\") if debug? # To prevent useless overhead outside debug\n @next_update = can_player_make_another_action_choice? ? :player_action_choice : :trigger_all_AI\n else\n # If the player canceled we return to the player action\n @next_update = :player_action_choice\n end\n ensure\n @skip_frame = true\n end",
"def on_skill_ok\n @skill = @skill_window.item\n BattleManager.actor.input.set_skill(@skill.id)\n action = BattleManager.actor.input\n BattleManager.actor.last_skill.object = @skill\n if @skill.target_type[0] == :one then select_target_selection\n else\n case @skill.target_type[0]\n when :all\n BattleManager.actor.input.set = SES::TargetManager.make_targets(action)\n when :rand\n targets, set = [], SES::TargetManager.make_targets(action)\n (@skill.target_type[1][0] + rand(@skill.target_type[1][1])).times do\n targets << set[rand(set.size)]\n end\n BattleManager.actor.input.set = set\n end\n @skill_window.hide\n next_command\n end\n end",
"def update_command_selection\n if Input.trigger?(Input::B)\n Sound.play_cancel\n $scene = Scene_Map.new\n elsif Input.trigger?(Input::C)\n if $game_party.members.size == 0 and @command_window.index < 4\n Sound.play_buzzer\n return\n elsif $game_system.save_disabled and @command_window.index == 4\n Sound.play_buzzer\n return\n end\n Sound.play_decision\n case @command_window.index\n when 0 # Item\n $scene = Scene_Item.new\n when 1,2,3 # Skill, equipment, status\n start_actor_selection\n when 4 # Save\n $scene = Scene_File.new(true, false, false, 4)\n when 5 # Save\n $scene = Scene_File.new(false, false, false, 5)\n when 6 # End Game\n $scene = Scene_End.new\n end\n end\n end",
"def completed_quests; $game_variables[17]; end",
"def select_player_choice (player)\n puts \"\\n#{player.name}, it's your turn.\\n\\nHere are your options:\\n\"\n @acceptable_choices.each { |e| puts e}\n player.select_choice(self)\n end",
"def mechanic_quest; end",
"def update_phase3_skill_select\r\n # Make skill window visible\r\n @skill_window.visible = true\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # End skill selection\r\n end_skill_select\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the skill window\r\n @skill = @skill_window.skill\r\n # If it can't be used\r\n if @skill == nil or not @active_battler.skill_can_use?(@skill.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.skill_id = @skill.id\r\n # Make skill window invisible\r\n @skill_window.visible = false\r\n @skill_window.active = false\r\n # If effect scope is single enemy\r\n if @skill.scope == 1\r\n # Start enemy selection\r\n start_enemy_select\r\n # If effect scope is single ally\r\n elsif @skill.scope == 3 or @skill.scope == 5\r\n # Start actor selection\r\n start_actor_select\r\n # If effect scope is not single\r\n else\r\n # End skill selection\r\n end_skill_select\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end\r\n return\r\n end\r\n end",
"def therapist_quest; end",
"def fence_quest; end",
"def reveal_quest(quest_id); quest(quest_id).concealed = false; end",
"def create_skill_choice\n @skill_choice_ui = BattleUI::SkillChoice.new(@viewport_sub)\n end",
"def new_game\n\t\tclear\n\t\tget_username\n\t\tselect_level\n\t\tget_deck\n\t\tshuffle\n\t\tget_hand\n\t\tcontinue_game\n\tend",
"def create_quest_label_window\n @quest_label_window = Window_QuestLabel.new(0, 0, $game_system.quest_scene_label)\n end",
"def update_phase3_skill_select\n # Make skill window visible\n @skill_window.visible = true\n # Update skill window\n @skill_window.update\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # End skill selection\n end_skill_select\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Get currently selected data on the skill window\n @skill = @skill_window.skill\n # If it can't be used\n if @skill == nil or not @active_battler.skill_can_use?(@skill.id)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.skill_id = @skill.id\n # Make skill window invisible\n @skill_window.visible = false\n # If effect scope is single enemy\n if @skill.scope == 1\n # Start enemy selection\n start_enemy_select\n # If effect scope is single ally\n elsif @skill.scope == 3 or @skill.scope == 5\n # Start actor selection\n start_actor_select\n # If effect scope is not single\n else\n # End skill selection\n end_skill_select\n # Go to command input for next actor\n phase3_next_actor\n end\n return\n end\n end",
"def decision_for_new_turn(player)\n choices = @actions.select { |a| a.timing == :main_action }.map { |action|\n choice = Choice.new(action.name_and_effect, action.arguments) { |args| cb_action(player, action, args) }\n last_player = @turns.size >= 2 ? @turns[-2].active_player : nil\n\n if player.coins >= 10 && action != Action::Coup\n choice.unavailable!('You must Coup when you have at least 10 coins.')\n elsif player.coins < action.cost + tax_for(player, action)\n choice.unavailable!(\"Need #{format_costs(player, action).join(' and ')}\")\n elsif last_player == player && action.another_turn?\n choice.unavailable!('Would cause three turns in a row')\n end\n\n [action.slug, choice]\n }.to_h\n\n # If player has a disappear token, add the block option.\n if (disappear_action = @disappear_players[player])\n action_class = disappear_action.class\n tax = tax_for(player, action_class)\n name = action_class.flavor_name\n choice = Choice.new(\"Block #{name}#{\" (tax of #{tax} coin)\" if tax > 0}\") {\n cb_block_disappear(player, disappear_action, start_turn: true)\n }\n choice.unavailable!(\"Need #{format_costs(player, action_class)}\") if player.coins < tax\n choices['block'] = choice\n end\n\n Decision.single_player(\n current_turn.id, player, \"#{player}'s turn to choose an action\",\n choices: choices,\n )\n end",
"def create\n @quest = Quest.new(quest_params)\n respond_to do |format|\n if @quest.save\n format.html { redirect_to @quest, notice: 'Quest was successfully created.' }\n format.json { render :show, status: :created, location: @quest }\n else\n format.html { render :new }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def on_unit_ok\n @select_text_win.text=\"Choose items to take from #{@actor.name}\"\n @select_text_win.show\n @unit_item_list.show\n @unit_category_list.show\n deactivate_all_but(@unit_category_list)\n @unit_category_list.activate\n @party_or_unit_win.hide\n end",
"def initialize player\n @player = player\n @question = Question.new()\n end",
"def start_new_game\n\n if @level == 3 #if max level, choose new type\n @level = 0\n @type = choose_type\n puts \"Great job, #{@player.name}! Now try to evolve a #{@type} type pokémon.\"\n end\n @secret_word = Faker::Pokemon.name.upcase\n @user_progress = Array.new(@secret_word.length,\"_\")\n @character = @@characters[@type][@level]\n @scenes = @@scenes[@type][@level]\n @color = @@colors[@type]\n @current_index = 0\n @bad_guesses = []\n @remaining_guesses = 5\n puts \"You're at level #{@level+1}\"\n end",
"def create\n @completed_quest = CompletedQuest.new(params[:completed_quest])\n\n respond_to do |format|\n if @completed_quest.save\n format.html { redirect_to @completed_quest, notice: 'Completed quest was successfully created.' }\n format.json { render json: @completed_quest, status: :created, location: @completed_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @completed_quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def on_category_ok; @quest_list_window.activate; end",
"def set_computers_quest\n @computers_quest = ComputersQuest.find(params[:id])\n end",
"def complete_quests(options={})\n options.reverse_merge!(:count => 1)\n\n @objectives.push([\n Objective::CompleteQuests,\n {:key => Objective::CompleteQuests::KEY, :count => options[:count]}\n ])\n end",
"def item_choice\n item_id, target = @visual.show_item_choice\n if item_id\n # The player made a choice we store the action and we check if he can make other choices\n @player_actions << { type: :item, item_id: item_id, target: target, bag: @logic.bags[0] }\n log_debug(\"Action : #{@player_actions.last}\") if debug? # To prevent useless overhead outside debug\n @next_update = can_player_make_another_action_choice? ? :player_action_choice : :trigger_all_AI\n else\n # If the player canceled we return to the player action\n @next_update = :player_action_choice\n end\n end",
"def add_quest(dbn,n,d,kgg,kgn,exp,sr,gr,loot,kgc,qs)\n\t\t\t@player_data_db.execute \"insert into quests values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\", nil,dbn,n,d,kgg,kgn,exp,sr,gr,loot,kgc,qs\n\t\tend",
"def new\n @questionnaire = Questionnaire.new\n @quest = Quest.new\n 5.times do\n question = @questionnaire.quests.build\n 4.times { question.choices.build }\n end\n end",
"def skill_choice\n if @visual.show_skill_choice(@player_actions.size)\n # The player choosed a move\n @next_update = :target_choice\n else\n # The player canceled\n @next_update = :player_action_choice\n end\n ensure\n @skip_frame = true\n end",
"def select_character(action_array)\n\n cards = action_array.drop(1)\n card = Card.find(cards[0])\n card.update_attribute(:player_id, id)\n\n update_attribute(:state, 'WAITING_TURN')\n\n party.game_messages.create(:message => 'message.select_character', :actor_player => user.name.capitalize)\n\n end",
"def update_phase3_item_select\r\n # Make item window visible\r\n @item_window.visible = true\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # End item selection\r\n end_item_select\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If it can't be used\r\n unless $game_party.item_can_use?(@item.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.item_id = @item.id\r\n # Make item window invisible\r\n @item_window.visible = false\r\n @item_window.active = false\r\n # If effect scope is single enemy\r\n if @item.scope == 1\r\n # Start enemy selection\r\n start_enemy_select\r\n # If effect scope is single ally\r\n elsif @item.scope == 3 or @item.scope == 5\r\n # Start actor selection\r\n start_actor_select\r\n # If effect scope is not single\r\n else\r\n # End item selection\r\n end_item_select\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end\r\n return\r\n end\r\n end",
"def create\n @user_quest = UserQuest.new(params[:user_quest])\n\n respond_to do |format|\n if @user_quest.save\n format.html { redirect_to @user_quest, notice: 'User quest was successfully created.' }\n format.json { render json: @user_quest, status: :created, location: @user_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tutorial_quest = Tutorial::Quest.new(params[:tutorial_quest])\n\n respond_to do |format|\n if @tutorial_quest.save\n format.html { redirect_to @tutorial_quest, notice: 'Quest was successfully created.' }\n format.json { render json: @tutorial_quest, status: :created, location: @tutorial_quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutorial_quest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def start_player_quest_line(player_id)\n quest_ids = without_locking do\n Quest.select(\"`id`\").where(parent_id: nil)\n end.c_select_values\n quest_progresses = quest_ids.map do |quest_id|\n QuestProgress.new(player_id: player_id, quest_id: quest_id)\n end\n BulkSql::QuestProgress.save(quest_progresses)\n\n objective_ids = without_locking do\n Objective.select(\"`id`\").where(quest_id: quest_ids)\n end.c_select_values\n objective_progresses = objective_ids.map do |objective_id|\n ObjectiveProgress.new(player_id: player_id, objective_id: objective_id)\n end\n BulkSql::ObjectiveProgress.save(objective_progresses)\n end",
"def set_character_goal\n @character_goal = CharacterGoal.find(params[:id])\n end",
"def update_party_command_selection\n if Input.trigger?(Input::C)\n case @party_command_window.command\n when :fight # Fight\n Sound.play_decision\n @status_window.index = @actor_index = -1\n next_actor\n when :escape # Escape\n if $game_troop.can_escape == false\n Sound.play_buzzer\n return\n end\n Sound.play_decision\n process_escape\n when :formation\n Sound.play_decision\n @party_command_window.setup_commands(:formation)\n @party_command_window.refresh\n when :for_forward\n $game_party.do_mass_move(:formation, :forward)\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n when :for_backward\n $game_party.do_mass_move(:formation, :backward)\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n when :for_invert\n $game_party.do_mass_move(:formation, :invert)\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n when :for_reverse\n $game_party.do_mass_move(:formation, :reverse)\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n when :for_cancel\n Sound.play_decision\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n end\n elsif Input.trigger?(Input::B)\n case @party_command_window.last_setup\n when :formation\n Sound.play_cancel\n @party_command_window.setup_commands(:standard)\n @party_command_window.refresh\n end\n end\n end",
"def save!\n quest = Quest.new\n quest.parent_id = @parent_id\n quest.main_quest_slides = @main_quest_slides.try(:join, \",\")\n quest.rewards = @achievement ? nil : @rewards\n quest.achievement = @achievement\n quest.id = @quest_id\n quest.save!\n\n @objectives.each do |klass, options|\n objective = klass.new(options)\n objective.quest = quest\n objective.save!\n end\n\n quest\n end",
"def process_enchant_scene\n Sound.play_ok\n $game_temp.item_selected = @item.id\n SceneManager.call(Scene_Enchant)\n end",
"def update_phase3_item_select\n # Make item window visible\n @item_window.visible = true\n # Update item window\n @item_window.update\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # End item selection\n end_item_select\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Get currently selected data on the item window\n @item = @item_window.item\n # If it can't be used\n unless $game_party.item_can_use?(@item.id)\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.item_id = @item.id\n # Make item window invisible\n @item_window.visible = false\n # If effect scope is single enemy\n if @item.scope == 1\n # Start enemy selection\n start_enemy_select\n # If effect scope is single ally\n elsif @item.scope == 3 or @item.scope == 5\n # Start actor selection\n start_actor_select\n # If effect scope is not single\n else\n # End item selection\n end_item_select\n # Go to command input for next actor\n phase3_next_actor\n end\n return\n end\n end",
"def make_character\n system \"clear\"\n font_big = TTY::Font.new(:doom)\n font_col = Pastel.new\n puts font_col.red(font_big.write(\"Character Creation\"))\n puts \"Create a new character!\"\n user_character = $prompt.select(\"What character class would you like to choose?\", [\"Barbarian\", \"Wizard\", \"Thief\", \"Random\"])\n if user_character != \"Random\"\n puts \"Enter character name: \"\n char_name = gets.chomp\n end\n # Error check if player doesn't enter any name\n while char_name == \"\"\n puts \"Please enter a name:\"\n char_name = gets.chomp\n end\n case user_character\n when \"Barbarian\"\n new_player = BarbarianClass.new(char_name)\n when \"Wizard\"\n new_player = WizardClass.new(char_name)\n when \"Thief\"\n new_player = ThiefClass.new(char_name)\n else\n random_character\n end\n character_check(new_player)\nend",
"def quest=(value)\n return if @quest == value\n @quest = value\n @layout = (@quest && @quest.layout) ? @quest.layout : @default_layout\n refresh\n end",
"def add_question\n @event.respond('Enter a new question: ')\n ques = @event.user.await!(timeout: 60)\n return open_channel if ques.nil?\n\n ques = ques.content\n @event.respond('Enter the answer: ')\n ans = @event.user.await!(timeout: 60)\n return open_channel if ans.nil?\n\n ans = ans.content.gsub(/\\W/, '').downcase # Clean up the answer by removing caps and non [a-z] [0-9] chars\n @event.respond('Commit to database? (y/n): ')\n prompt = @event.user.await!(timeout: 60)\n unless prompt.nil? || prompt.content != 'y'\n begin\n @@trivia_db.prepare('INSERT INTO trivia(question, answer, addedby) VALUES(?, ?, ?)').execute(ques, ans, @event.user.id)\n rescue SQLite3::Exception\n @event.respond('Unable to write to database!')\n else\n @event.respond('Changes saved')\n end\n end\n open_channel\n end",
"def character_check(character)\n system \"clear\"\n puts character\n user_happy = $prompt.select(\"Are you happy with this character?\", [\"Yes\", \"No\"])\n if user_happy == \"Yes\"\n $player = character\n pick_difficulty\n else\n sleep(1)\n make_character\n end\nend",
"def create_selection_window\r\r\n @command_window = CSCA_Window_AchievementSelect.new(0,@head_window.height,\r\r\n Graphics.width/2,Graphics.height-@head_window.height-48)\r\r\n @command_window.viewport = @viewport\r\r\n @command_window.help_window = @achievement_window\r\r\n @command_window.set_handler(:cancel, method(:return_scene))\r\r\n @command_window.activate\r\r\n end",
"def activate\r\n @quest = @kingdom.quests.find(params[:id])\r\n \r\n if @kingdom.quests.where(quest_status: '1').size > 16\r\n flash[:notice] = 'A kingdom can have only 16 active quests at a time.'\r\n elsif @quest.reqs.size == 0\r\n flash[:notice] = \"Quest must have at least one requirement in order to be activated\"\r\n else\r\n @quest.quest_status = SpecialCode.get_code('quest_status','active')\r\n quest_status_change_update\r\n end\r\n redirect_to :action => 'index', :page => params[:page]\r\n end",
"def control_combatant\n\t\t\t@playercombatant = @combatants.sample\n\t\t\tputs \"\\nFor this game of Eschaton, you've been designated to be represent #{@playercombatant.nation}. (press Enter)\\n \"\n\t\t\[email protected] '*'\n\t\t\[email protected]_player = true\n\t\tend",
"def set_questao\n @questao = Questao.find(params[:id])\n end",
"def new\n @completed_quest = CompletedQuest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @completed_quest }\n end\n end",
"def update_command_selection\n if Input.trigger?(Input::B)\n Sound.play_cancel\n $scene = Scene_Map.new\n elsif Input.trigger?(Input::C)\n cwi = @cm_list[@command_window.index]\n if $game_party.members.size == 0 && !CP::MENU_COMMANDS.COMMANDS[cwi].include?(:no1)\n Sound.play_buzzer\n return\n elsif $game_system.save_disabled && CP::MENU_COMMANDS.COMMANDS[cwi].include?(:save)\n Sound.play_buzzer\n return\n end\n Sound.play_decision\n if CP::MENU_COMMANDS.COMMANDS[cwi].size == 2\n $menu_index = @command_window.index\n create_submenu(cwi)\n else\n if CP::MENU_COMMANDS.COMMANDS[cwi][2]\n start_actor_selection\n else\n $menu_index = @command_window.index\n $scene = CP::MENU_COMMANDS.COMMANDS[cwi][1]\n end\n end\n end\n end",
"def create_quest_category_window\n @quest_category_window = Window_QuestCategory.new(0, 0, $game_system.quest_categories)\n @quest_category_window.category = @init_category if @init_category\n @quest_category_window.set_handler(:cancel, method(:on_category_cancel))\n @quest_category_window.set_handler(:ok, method(:on_category_ok)) \n end",
"def character_menu\n choice = select_prompt(\"Choose a File\", Farmer.pluck(\"name\"))\n self.farmer = Farmer.find_by(name: choice)\n notice(\"Welcome back, Farmer #{self.farmer.name}!\", :magenta)\n puts \"\"\n sleep(1.seconds)\n\n stop_audio\n sleep(1.seconds)\n start_audio(\"./audio/02.mp3\")\n game_menu\n end",
"def set_teamquest\n @teamquest = Teamquest.find(params[:id])\n end",
"def quest_params\n params.require(:quest).permit(:user_id, :quest, :result)\n end",
"def game_complete_text\n slow_type(\"\\nCongratulations, #{@new_player_name}! You have found your way out!\")\n pause(0.3)\n slow_type(\"Written, developed and coded by Adam Vaughan and Danny Smith.\")\n pause(0.3)\n slow_type(\"Stayed tuned for more levels!\")\n end",
"def phase3_command_item\r\n # Set action\r\n @active_battler.current_action.kind = 2\r\n # Start item selection\r\n start_item_select\r\n end",
"def new\n \tsession[:state]= 3\n \t\n \t@playground = Playground.find(session[:playground_id]) \t\n \t@player = Player.find(session[:player_id])\n\n\t#If the playground doesn't have a question, create new, otherwise find the question\n\t@question = Question.where(:playground_id => @playground.id)\n\tif @question.count == 0\n\t \t\n\t \t@question = Question.new\n\t\[email protected] = \"What is ?\"\n\t #t.string \"image_url\"\n\t a = (0..100).to_a\n\t p1 = a.sample\n\t\[email protected] = p1\n\t\tb = (0..100).to_a\n\t p2 = b.sample\n\t\[email protected] = p2\n\t\[email protected]_response = p1 + p2\n\t \[email protected] = (@playground)\n\t \t\n\t \[email protected]\n\t \t\n \telse \n \t\t @question = @question[0]\n \tend\n \t\n \tsession[:qid][email protected]\n \n \[email protected]_attribute(:state, 3)\n @q_response = QResponse.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.js\n format.json { render json: @q_response }\n end\n end",
"def switch_choice\n pokemon_to_send = @visual.show_pokemon_choice\n if pokemon_to_send\n pokemon_to_switch = @logic.battler(0, @player_actions.size)\n # The player made a choice we store the action and we check if he can make other choices\n @player_actions << { type: :switch, who: pokemon_to_switch, with: pokemon_to_send }\n pokemon_to_send.switching = true\n pokemon_to_switch.switching = true\n log_debug(\"Action : #{@player_actions.last}\") if debug? # To prevent useless overhead outside debug\n @next_update = can_player_make_another_action_choice? ? :player_action_choice : :trigger_all_AI\n else\n # If the player canceled we return to the player action\n @next_update = :player_action_choice\n end\n end",
"def start_phase3\n @phase = 3\n actor=@actors[@actor_actions.size]\n #>Test du forçage de lutte\n if(BattleEngine::_lutte?(actor))\n @actor_actions.push([0,nil,util_targetselection_automatic(actor, phase3_struggle_move),actor])\n update_phase2_next_act\n return\n elsif(actor.battle_effect.has_encore_effect?)\n @actor_actions.push([0,actor.skills_set.index(actor.battle_effect.encore_skill).to_i,\n util_targetselection_automatic(actor, actor.battle_effect.encore_skill),actor])\n end\n @mega_evolve_window.show if BattleEngine.can_pokemon_mega_evolve?(actor, $bag)\n\n #>Récupération de l'index d'une attaque \"valide\"\n @atk_index = 0\n if USE_ALPHA_25_UI\n @skill_choice_ui.reset(@actors[@actor_actions.size])\n @skill_choice_ui.visible = true\n @message_window.visible = false\n else\n 4.times do |i|\n skill=actor.skills_set[i]\n @atk_index=i if skill and skill.id==actor.last_skill.to_i.abs\n end\n @skill_selector.update_text(@atk_index, @actors[@actor_actions.size])\n @skill_selector.visible = true\n end\n #@message_window.visible = false\n 0 while get_action\n\n launch_phase_event(3, true)\n end",
"def draw_item(index)\n quest = @data[index]\n if quest\n rect = item_rect_for_text(index)\n if QuestData::SHOW_QUEST_ICONS\n draw_icon(quest.icon_index, rect.x, rect.y, enable?(quest))\n rect.x += 24\n rect.width -= 24\n end\n change_color(quest_name_colour(quest), enable?(quest))\n draw_text(rect, quest.name)\n end\n end",
"def show\n @user_quest = UsersQuest.find(params[:id])\n @assignor_id = @user_quest.assignor_id\n @assignee_id = @user_quest.assignee_id\n @is_accepted = @user_quest.is_accepted\n @is_rejected = @user_quest.is_rejected\n @name = User.find(@user_quest.assignee_id)\n @Quest = Quest.find(@user_quest)\n @photos = @Quest.quest_images\n if QuestVideo.find_by_quest_id(@Quest.id).url != \"\"\n @video = QuestVideo.find_by_quest_id(@Quest.id).url.split('/').last\n else\n @video = \"\"\n end\n @tasks = @Quest.tasks\n @comments = @Quest.comments.all\n @comment = @Quest.comments.build\n end",
"def new\n\t\tall_questions = Question.select('short_name,text').all\n\t\t@question_names = \"[#{all_questions.collect { |q| \"\\\"#{q.short_name}\\\"\" }.compact.join(',')}]\"\n\t\t@question_texts = \"[#{all_questions.collect { |q| \"\\\"#{q.text}\\\"\" }.compact.join(',')}]\"\n\t\t\n\t\t@all_choices = \"[#{Choice.select('value').order('value ASC').all.collect { |c| \"\\\"#{c.value}\\\"\" }.compact.join(',')}]\" # construct list for typeahead\n\t\t@new_question = Question.new\n\tend",
"def new_target\n @proposal_type = params[:proposal_type]\n @other_characters = @character.world.characters.reject{|other_character| other_character==@character}\n end",
"def initialize(viewport, name, is_new, index)\n super(viewport, 0, BASE_Y + index * OFFSET_Y)\n @background = add_background('quest/quest_bg')\n @background.opacity = 0\n text = ext_text(9000, is_new ? 147 : 148)\n @info_text = add_text(0, 3, 0, 16, text, 0, 0, color: is_new ? 13 : 12)\n @name_text = add_text(@info_text.real_width + OFFSET_TEXT_X, 3, 0, 16, name, 0, 0)\n @max_x = (viewport.rect.width - @name_text.real_width) / 2\n @info_ini_x = @info_text.x = -(@max_x * 2 + @name_text.x)\n @name_ini_x = @name_text.x = -(@max_x * 2)\n @counter = 0\n play_sound(index)\n end",
"def play\n\n while @game_complete == false\n\n # starting game text to help the player create a mental picture of the environment\n @new_player_name = \"Mr Developer\" if @debug\n player_set_up unless @debug || @starting_game_text == false\n puts starting_game_text unless @debug || @starting_game_text == false\n @starting_game_text = false\n \n slow_type(\"\\nYou are in #{find_room_by_id(@current_room_id).name}\")\n main_menu = TTY::Prompt.new\n\n choices = [\n { name: 'Move Player', value: 1 },\n { name: 'Look At', value: 2 },\n { name: 'Pick Up', value: 3 },\n { name: 'Use Item', value: 4 },\n { name: 'Talk To', value: 5 },\n { name: 'Quit', value: 6 },\n ]\n attr = main_menu.select(slow_type(\"What would you like to do?\"), choices)\n\n # gets user input\n \n if attr == 1\n player_move\n \n elsif attr == 2\n look_at\n\n elsif attr == 3\n pick_up\n\n elsif attr == 4\n use_item\n\n elsif attr == 5\n talk_to\n \n else attr == 6\n @game_complete = true\n end\n\n end\n end",
"def create\n @computers_quest = ComputersQuest.new(computers_quest_params)\n\n respond_to do |format|\n if @computers_quest.save\n format.html { redirect_to @computers_quest, notice: 'Computers quest was successfully created.' }\n format.json { render :show, status: :created, location: @computers_quest }\n else\n format.html { render :new }\n format.json { render json: @computers_quest.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6867418",
"0.6529618",
"0.6497493",
"0.6401473",
"0.63501173",
"0.6275192",
"0.61856294",
"0.61458117",
"0.6103134",
"0.6101079",
"0.6101079",
"0.6101079",
"0.6101079",
"0.60768604",
"0.6063554",
"0.5990301",
"0.5901015",
"0.5897365",
"0.58694714",
"0.58549243",
"0.5852714",
"0.58405846",
"0.5837333",
"0.5835325",
"0.580491",
"0.5789066",
"0.57242554",
"0.56978536",
"0.56966984",
"0.5690248",
"0.56693935",
"0.56458664",
"0.5641268",
"0.5622877",
"0.5620875",
"0.5617236",
"0.55815804",
"0.5569098",
"0.5562941",
"0.5556285",
"0.5556174",
"0.5556174",
"0.5546949",
"0.55423176",
"0.5533324",
"0.5531845",
"0.5530237",
"0.5509876",
"0.55098355",
"0.5495117",
"0.5485822",
"0.5479853",
"0.54788053",
"0.546573",
"0.546425",
"0.545703",
"0.54523504",
"0.5443132",
"0.5442771",
"0.5436644",
"0.5434757",
"0.5429599",
"0.542895",
"0.54220897",
"0.54184496",
"0.54144615",
"0.5414338",
"0.5409908",
"0.5403982",
"0.5378218",
"0.5365664",
"0.5355213",
"0.53494406",
"0.5346757",
"0.53456986",
"0.5344803",
"0.53395456",
"0.5314561",
"0.53145075",
"0.53068274",
"0.52825236",
"0.5281236",
"0.5270445",
"0.5264482",
"0.52613896",
"0.5253083",
"0.5247944",
"0.5240952",
"0.52326643",
"0.5220117",
"0.5218342",
"0.5213414",
"0.52132666",
"0.5205626",
"0.5205457",
"0.5201091",
"0.51986325",
"0.5196456",
"0.5195486",
"0.5194227"
] | 0.68937546 | 0 |
print all of the acquired weapons for a certain player | def show_all_weapons
if self.weapons.size == 0
puts ""
puts "You have no weapons, try completing some quests first :)"
else
puts ""
puts "Here Are Your Weapons:".bold.white.on_light_black
puts " "
self.weapons.each do |weapon|
puts "**** #{weapon.name} **** Weapon Power: #{weapon.attack_power} ****".italic
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_stats\n puts \"*********************************\"\n\n #check to see if the player has any weapons\n #display stats\n if self.weapons.size == 0\n puts \"Current Health:\".red + \" #{self.hp}\".bold\n puts \"Current Power:\".blue + \" #{self.power}\".bold\n\n #display\n else\n puts \"Current Health:\".red + \" #{self.hp}\".bold\n puts \"Current Power:\".blue + \" #{self.power}\".bold\n puts \"Equipped Weapon:\".green + \" #{self.highest_attack_power_weapon.name}\".bold\n end\n puts \"*********************************\"\n end",
"def print_name_and_health(player)\n puts \"#{player.name.ljust(20,'.')}#{player.score}\"\n player.each_treasure do |treasure|\n puts \"#{treasure.points} points from #{treasure.name}\"\n end\n puts \"...for a grand total of #{player.points} points.\"\n end",
"def print_inventory\n @player.print_inventory\n end",
"def weapons _args\n \"weapons _args;\" \n end",
"def print_player(player)\n\t\tputs (\"-player #{player}-\")\n\t\tfor j in 0...5\n\t\t\tputs(\"#{@value_names[@values[@players[player].hand[j]]]} #{@suit_names[@suits[@players[player].hand[j]]]}\")\n\t\tend\n\t\tputs (\"-----------\")\n\tend",
"def inventory\n\t\tputs \"Items: #{@player.getItemsName}\" \n\t\tputs \"Food: #{@player.getFoodName}\" \n\tend",
"def weapons\n @weapons.join(\", \")\n end",
"def weapons\n broadsword = header_for_id('F4 65 03 01')\n two_handed_sword = header_for_id('01 66 03 01')\n war_sword = header_for_id('02 66 03 01')\n daggers = header_for_id('1B 66 03 01')\n avengers = header_for_id('1C 66 03 01')\n filler_array = [broadsword] * 99 +\n [two_handed_sword] * 99 +\n [war_sword] * 99 +\n [daggers] * 99 +\n [avengers] * 99\n raise 'invalid length' unless filler_array.length == 5 * 99\n type = WEAPONS\n\n code_for_weapon_or_accessory(filler_array: filler_array, type: type)\n end",
"def search_weapon\n\t\t@weapon = rand(1..6)\n\t\tputs \"Tu as trouvé une arme de niveau #{@weapon}\"\n\t\tif @weapon <= @weapon_level # Si le niveau est inférieur ou égal au niveau de l'ancienne arme, on garde l'ancienne.\n\t\t\tputs \" M@*#$ l'arme trouvée est vraiment bidon, tu gardes l'ancienne\"\n\t\telse \n\t\t\tputs \"De la frappe frere !\\n\\n\"\n\t\t\t@weapon_level = @weapon # Si meilleure arme, on la prend\n\t\tend\n\tend",
"def show_players\n puts \"#{@human_player.name} a #{@human_player.life_points} points de vies\"\n @enemies.each do |mechant|\n puts \"#{mechant.name} a #{mechant.life_points} points de vies\"\n end #end of \"\".each do\" that show mechant name and life points\n end",
"def search_weapon\n dice = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n if dice > weapon_level\n @weapon_level = dice\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end\n puts\"////////////////////////////////////////////////\"\n puts\" \"\n end",
"def attacks(player)\r\n puts \"#{@name} attaque le joueur #{player.name}\"\r\n player.gets_damage(compute_damage)\r\n end",
"def swing_weapons(att_id)\n\t@swing = att_id\n\tweapon_power(@swing)\t\t\t\t\t\t\t\t\t\t# COUNT ATTACK ROLLS\n\tmulti_success(@swing, @attack_power[@swing],@swing_chance,@dice_faces) # RESOLVE ATTACK ROLLS (default is 5)\n # puts \"***********************\"\nend",
"def status\n monster = @game.current_room_model.monster\n return unless monster\n\n weapons = @game.player.weapons\n\n output = \"Fighting against #{monster.name}\\n\"\n weapons.each_with_index do |weapon, i|\n output << \"#{i + 1} - #{weapon}\\n\"\n end\n\n output\n end",
"def search_weapon\n weapon = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n if dice > weapon_level\n @weapon_level = weapon\n puts 'Youhou ! elle est meilleure que ton arme actuelle : tu la prends.'\n else\n puts \" M@*!$... elle n'est pas mieux que ton arme actuelle...\"\n end\n end",
"def print_players()\n\t\tfor i in 0...@num_players\n\t\t\tprint_player(i)\n\t\tend\n\tend",
"def weaponsItems _args\n \"weaponsItems _args;\" \n end",
"def print_player_outcomes\n @players.each{ |p|\n puts \"#{p.name}:\"\n p.hands.each_with_index{ |h, i|\n print \"Hand #{i+1}: \"\n eval_hand(p, h)\n }\n puts \"#{p.name} total: $#{p.wallet}\"\n linebreak\n }\n end",
"def all_player_status\n linebreak\n @players.each{ |p| puts p; linebreak; }\n puts \"Dealer showing #{@dealer.hand.public_show}\"\n linebreak\n end",
"def weapon_reward(available_weapons)\n\n #reward is 1 random choice from this array\n reward = available_weapons.sample\n\n #create to CharacterWeapon object to show that player obtains weaopn\n CharacterWeapon.new_character_weapon(self.id, reward.id)\n\n #print weapon details to player\n puts \"#{reward.name}\".bold.blue\n puts \"Weapon Power: #{reward.attack_power}\"\n puts\"#####################################\".blink\n\n #actually equip the weapon, if it will increase this player's attack power\n if reward.attack_power > self.power - 1 || self.power == 1\n #increase the player's attack power\n self.update(power: 1+reward.attack_power)\n end\n end",
"def print_items\n if @items.empty?\n print NO_ITEMS_MESSAGE\n else\n print WARES_MESSAGE\n @items.each { |item| puts \"#{item.name} (#{item.price} gold)\" }\n print \"\\n\"\n end\n end",
"def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}\"\n \tdamage = compute_damage\n \tputs \"Il lui inflige #{damage} points de dommage\"\n \tplayer.gets_damage(damage)\n end",
"def attacks(player)\n\t\tputs \"#{@name} attaque #{player.name} !\"\n\t\tdamage = compute_damage\n player.gets_damage(damage)\n \n\t\tif player.life_points > 0\n\t\tputs \"#{@name} lui inflige #{damage} points de dommage.\\n\\n\"\n\t\telse \n\t\t\tputs \"Oups, #{player.name} c'est fait décapité...\\n\\n\"\n end\n\n end",
"def search_weapon\r\n lvl = rand(1..6)\r\n puts \"Tu as trouvé une arme de niveau #{lvl}\"\r\n if @weapon_level >= lvl\r\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\r\n else\r\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\r\n @weapon_level = lvl\r\n end\r\n end",
"def search_weapon\n\t\tnew_weapon_level = rand(1..6)\n\t\tputs \"Tu as trouvé une arme de niveau #{new_weapon_level}\"\n\t\tif new_weapon_level > @weapon_level\n\t\t\tputs \"Youhou ! Elle est meilleure que ton arme actuelle : tu la prends.\"\n\t\t\t@weapon_level = new_weapon_level\n\t\telse\n\t\t\tputs \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n\t\tend\n\tend",
"def show_players\r\n puts \"Tu as #{human_player.life_points}\"\r\n puts \"il reste #{@enemies.length} bots, courage!!\"\r\n end",
"def print_dealers_play\n puts \"-------------\"\n puts \"Dealer's turn\"\n puts \"-------------\"\n end",
"def melee_weapon; end",
"def weapon; end",
"def weapon; end",
"def weapon; end",
"def print_inventory\n print \"Current gold in pouch: #{@gold}.\\n\\n\"\n\n if (@inventory.empty?)\n puts \"#{@name}'s inventory is empty!\"\n else\n puts \"#{@name}'s inventory:\"\n\n @inventory.each do |couple|\n puts couple.first.name + \" (#{couple.second})\"\n end\n end\n\n print \"\\n\"\n end",
"def print_inventory\n print \"Current gold in pouch: #{@gold}.\\n\\n\"\n\n if @inventory.empty?\n print \"#{@name}'s inventory is empty!\\n\\n\"\n return\n end\n\n puts \"#{@name}'s inventory:\"\n @inventory.each do |couple|\n puts \"* #{couple.first.name} (#{couple.second})\"\n end\n print \"\\n\"\n end",
"def player_info(player, pot)\n system 'clear'\n puts \"#{player.player_name},\".light_green + ' it is your turn to act.'\n puts ''\n puts 'You have ' + player.chip_stack.to_s.light_green + ' chips.'\n puts 'The total pot size (including current bets) is ' + pot.to_s.light_red + ' chips.'\nend",
"def attacks(player)\n puts \"#{@name} attaque #{player.name}\"\n damage = compute_damage\n puts \" il lui inflige #{damage} points dommages\"\n player.gets_damage(damage)\n end",
"def print_attacks_with_stats\n @battle_commands.each do |command|\n\n # Simple way to check for both damage and success rate attributes.\n # Prevents the name from being displayed for non-attacks.\n unless command.damage.nil?\n puts command.name + \"\\n Damage: #{command.damage}\"\n\n unless command.success_rate.nil?\n puts \" Success Rate: #{command.success_rate}\"\n end\n\n end\n end\n\n print \"\\n\"\n end",
"def search_weapon\n \t\t\t new_weapon = rand(1..6)\n \t\t\t puts \"Tu as trouvé une arme de niveau #{new_weapon} !\"\n \t\t\t if new_weapon > @weapon_level\n \t\t\t \t@weapon_level = new_weapon\n \t\t\t \tputs \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n \t\t\t else\n \t\t\t \tputs \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n \t\t\t end\n \t\tend",
"def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if ([email protected]?)\n puts \"#{weapon.name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if ([email protected]?)\n puts \"#{helmet.name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end",
"def show\n @weapon = Weapon.find(params[:id])\n end",
"def print_gold_and_greeting(player)\n puts \"Current gold in your pouch: #{player.gold}.\"\n print 'Would you like to buy, sell, or exit?: '\n input = player_input doublespace: false\n print \"\\n\"\n input\n end",
"def show_players\n puts\n @humanplayer.show_state\n puts \"2) #{@ennemies.size} enemies are still fighting\"\n puts\n end",
"def list_inventory\n\n # print the table header\n @gc.d_print(\"Inventory:\")\n\n # print each item with some indent\n @inventory.each do |object|\n @gc.display(\" > #{object.get_name}\")\n end\n\n # if there is nothing in the player's inventory, say so\n if @inventory.length == 0\n @gc.display(\" - Nothing\")\n end\n\n end",
"def examine \n\t\tputs \"Your Description: #{@player.desc}\" \n\t\tputs \"Health Status: #{@player.health}\" \n\tend",
"def carried_weapons\n CharacterWeapon.where(:character_id => self.id, :carried => :true).order('equipped desc')\n end",
"def attacks(attacked_player)\n # puts player1.name \n # print \"attacks\"\n # puts \"#{attacked_player}\"\n attacked_player.gets_damage(compute_damage)\n # puts \"He loses #{compute_damage} points\"\n end",
"def update_weapon_stats\n weapons = fetch_weapons(@career)\n weapons = weapons.sort {|a,b| b[1] <=> a[1]}\n 5.times do |i|\n self[\"weapon#{i+1}_name\"] = weapons[i][0][0] rescue \"Not Enough Data\"\n self[\"weapon#{i+1}_url\"] = weapons[i][0][1] rescue \"http://www.bungie.net/images/halo3stats/weapons/unknown.gif\"\n self[\"weapon#{i+1}_num\"] = weapons[i][1] rescue 0\n end\n end",
"def play\n# \tThere are 3 players in Knuckleheads: \n\t\tputs \"There are #{to_s} players in #{@title}\"\n# \tI'm Moe with a health of 100 and a score of 103.\n# \tI'm Larry with a health of 60 and a score of 65.\n# \tI'm Curly with a health of 125 and a score of 130.\n\t\[email protected] do |spieler|\n\t\t\tputs \"I'm #{spieler} with a health of #{@health} and a score of #{score}\"\n\t\t\tend\n# \tMoe got blammed!\n# \tMoe got w00ted!\n# \tMoe got w00ted!\n# \tI'm Moe with a health of 120 and a score of 123.\n# \tLarry got blammed!\n# \tLarry got w00ted!\n# \tLarry got w00ted!\n# \tI'm Larry with a health of 80 and a score of 85.\n# \tCurly got blammed!\n# \tCurly got w00ted!\n# \tCurly got w00ted!\n# \tI'm Curly with a health of 145 and a score of 150.\n\t\tend",
"def print_all_players(print_title, players)\r\n puts\r\n puts(print_title)\r\n players.each do |player|\r\n puts(\"\\t >> #{player}\")\r\n end\r\n puts\r\nend",
"def select_weapon(att_id)\n\t\t\t@cid = att_id\n\t\t\tsw = Rollem.new\n\t\t\t@weapon = sw.roll(12)\n\t#\t\tputs \"#{@gladiator[@cid]} rolled weapon slot #{@weapon} a #{@stat_name[@cid][@weapon]} type with a skill of #{@stat[@cid][@weapon]}\"\n\t\tend",
"def index\n @weapons = Weapon.all\n end",
"def index\n @weapons = Weapon.all\n end",
"def print_items\n @items.each do |item|\n puts item.name + \" (#{item.price} gold)\"\n end\n print \"\\n\"\n end",
"def to_s\n puts \"Character Name: #{@name}\"\n puts \"Character Race: #{@race}\"\n puts \"Character Hit Points: #{@hit_points}\"\n print \"Character Weapons: \"\n for weapon in @weapons\n print weapon\n print \" , \"\n end\n puts \"\"\n puts \"Character Gold: #{@gold}\"\n print \"Character Clothing: \"\n for cloth in @clothing\n print cloth\n print \" , \"\n end\n puts \"\"\n end",
"def give_bonus player\n player.add_weapon(Vibrant_Weapon.new(@window, player))\n end",
"def weapons_hash()\n return @weapons\n end",
"def choose_weapon\n\t# stores weapons in array\n\t# have an annoying bug where the weapons don't cycle correctly edit; fixed\n\tweapons = ['dagger', 'wand', 'gun', 'crossbow', 'sickle']\n\n\t# player is asked to choose a weapon\n\tputs \"Choose your starting weapon by typing it's designated number: \"\n\n\t# Simple and basic looping through array\n\n\t(0...weapons.length).each do |i|\n\t\tputs \"#{i+1} - #{weapons[i]}\"\n\tend\n\tprint \">> \"\n\n\tchoice = gets.chomp.to_i - 1\n\t@selected_weapon = weapons[choice]\n\n\tputs \"You selected: #{@selected_weapon}\"\n\tstart_game\nend",
"def currentWeapon _args\n \"currentWeapon _args;\" \n end",
"def player_info\n if @health <= 0\n puts \"#{@name} has 0 health remaining!\"\n puts \"\"\n else \n puts \"#{@name} has #{@health} health remaining.\"\n puts \"\"\n \n end\n\n end",
"def search_weapon\n new_weapon_level = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{new_weapon_level}\"\n if new_weapon_level > @weapon_level\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n @weapon_level = new_weapon_level\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end\n end",
"def attacks (player)\n damage = compute_damage\n\n puts \">>> Le joueur #{self.name} attaque le joueur #{player.name}\"\n\n puts \">>> Il lui inflige #{damage} points de dommages\"\n\n # Give damages to the \"player\" in argument\n player.gets_damage(damage)\n end",
"def fight enemy, weapon\n if life <= 0\n return \"You are dead.\"\n end\n \n out = ''\n\n # Attack the opponent\n your_hit = rand(strength + weapon)\n out << \"[You hit the #{enemy.name} with #{your_hit} points of damage!]\\n\"\n out << enemy.hit(your_hit)\n\n # Retaliation\n if enemy.life > 0\n enemy_hit = rand(enemy.strength + enemy.weapon)\n out << \"[The #{enemy.name} hit with #{enemy_hit} points of damage!]\\n\"\n out << self.hit(enemy_hit)\n end\n out\n end",
"def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if (!@outfit[:weapon].nil?)\n puts \"#{@outfit[:weapon].name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if (!@outfit[:helmet].nil?)\n puts \"#{@outfit[:helmet].name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end",
"def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}.\"\n # On récupère le nombre de points de dommage correspondant au lancer de dé via la méthode compute_damage\n damage_points = compute_damage\n puts \"Il lui inflige #{damage_points} points de dommage.\"\n # Ces points de dommage sont infligés à player. Si player n'a plus de points de vie, le programme affiche qu'il est mort.\n player.get_damage(damage_points)\n end",
"def melee_weapon\n fetch('dnd.melee_weapons')\n end",
"def show_inventory\n\t\tempty = String.new\n\t\tempty = \"empty pockets\" if @player.inventory.size == 0\n\t\tputs \"\\nYou have: \" + @player.inventory.join(\", \") + empty\n\tend",
"def weapon_stats\n return unless public?\n\n if @weapon_stats.nil?\n @weapon_stats = {}\n WEAPONS.each do |weapon_node|\n weapon_data = @xml_data['stats']['weapons'][weapon_node]\n weapon = AlienSwarmWeapon.new(weapon_data)\n @weapon_stats[weapon.name] = weapon\n end\n end\n\n @weapon_stats\n end",
"def ranged_weapon; end",
"def print_all_players(players)\n players.each {|player|\n print_player(player)\n }\n end",
"def search_weapon\n new_weapon = rand(1..6)\n puts \"Tu as obtenu une nouvelle arme de niveau #{new_weapon}\"\n if new_weapon > self.weapon_level\n self.weapon_level = new_weapon\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end #if\n end",
"def players; [@hunter, @prey] end",
"def draw_weapon_kind\n item.w_types.each do |tipo|\n next if Vocab.wtype(tipo).nil?\n draw_detail(Vocab::EQUIP_KIND, Vocab.wtype(tipo))\n end\n end",
"def toString\r\n\t\thp = @health + @weapon.health\r\n\t\tstr = @strength + @weapon.strength\r\n\t\tinte = @intelligence + @weapon.intelligence\r\n\t\tsp = @speed + @weapon.speed\r\n\t\tputs \"=================== HERO STATS ===================\"\r\n\t\tputs \"\t\tWeapon: #{@weapon.class.name}\"\r\n\t\tputs \"\t\tHealth: #{hp}\"\r\n\t\tputs \"\t\tStrength: #{str}\"\r\n\t\tputs \"\t\tIntelligence:#{inte}\"\r\n\t\tputs \"\t\tSpeed: #{sp}\"\r\n\t\tputs \"\t\tLuck: #{luck}\"\r\n\t\tputs \"=================== ===================\"\r\n\tend",
"def look(player)\n return \"You cannot see while you are blind\" if player.blind?\n players = Array.new\n mobs = Array.new\n things = Array.new\n exits = Array.new\n add_to_desc = String.new\n\n @inventory.each do |item|\n\n #some objects can modify the rooms description as well.\n if item.show_in_look\n add_to_desc << \" \" << item.show_in_look if item.show_in_look != \"\"\n end\n\n if item.is_a?(Player) and item != player and item.visible\n if item.pose\n players << \"<player>#{item.name}</player>, #{item.pose}#{item.short_desc ? ' - ' + item.short_desc : ''}\"\n else\n players << \"<player>#{item.name}</player>#{item.short_desc ? ' - ' + item.short_desc : ''}\"\n end\n elsif item.is_a?(Exit) and item.visible\n if item.can? :open and item.closed?\n exits << \"<exit>#{item.alt_names[0]}</exit> (closed)\"\n elsif item.can? :open and item.open?\n exits << \"<exit>#{item.alt_names[0]}</exit> (open)\"\n else\n exits << (\"<exit>#{item.alt_names[0]}</exit>\" || \"[Improperly named exit]\")\n end\n elsif item != player and item.visible\n if not item.quantity.nil? and item.quantity > 1\n quantity = item.quantity\n else\n quantity = item.article\n end\n\n idents = [\"<identifier>#{item.generic}</identifier>\"]\n idents += item.alt_names.map() {|e| \"<identifier>\" + e + \"</identifier>\"}\n idents = idents.join(', ')\n if item.can? :alive and item.alive\n mobs << \"<mob>#{item.name}</mob> [#{idents}]\"\n elsif item.can? :pose and item.pose\n things << \"<object>#{item.name}</object> [#{idents}] (#{item.pose})#{item.short_desc ? ' - ' + item.short_desc : ''}\"\n else\n things << \"<object>#{item.name}</object> [#{idents}]#{item.short_desc ? ' - ' + item.short_desc : ''}\"\n end\n end\n end\n\n #What to show if there are no exits.\n if exits.empty?\n exits << \"none\"\n else\n exits.sort!\n end\n\n if players.empty?\n players = \"\"\n else\n players = \"The following #{players.length <= 1 ? 'player is' : 'players are'} here:\\n#{players.list(@inventory, :expanded)}\\n\"\n end\n\n if mobs.empty?\n mobs = \"\"\n else\n mobs = \"The following #{mobs.length <= 1 ? 'mob is' : 'mobs are'} here:\\n#{mobs.list(@inventory, :expanded)}\\n\"\n end\n\n if things.empty?\n things = \"\"\n else\n things = \"There are the following items in the room:\\n#{things.list(@inventory, :expanded)}\\n\"\n end\n\n info = \"You find some things unusual about this place:\\n\"\n info += \" Type: \" + self.terrain_type.name + \"\\n\"\n self.flags.values.each do |f|\n if f.can_see? player\n info += \" #{f.affect_desc}\\n\"\n end\n end\n info += \"\\n\"\n\n \"<roomtitle>#{@name}</roomtitle>\\n\\n#{(@short_desc || '') + add_to_desc}\\n\\n[Exits: #{exits.list}]\\n\\n#{info}#{players}#{mobs}#{things}\"\n end",
"def show_wielding(wearer = \"You\")\n pronoun = nil\n output = nil\n if wearer == \"You\"\n output = \"You are wielding \"\n pronoun = \"your\"\n else\n output = \"#{wearer.pronoun.capitalize} is wielding \"\n pronoun = wearer.pronoun(:possessive)\n end\n\n wielding = []\n [:dual_wield, :left_wield, :right_wield].each do |pos|\n if @equipment[pos] and @equipment[pos][0]\n wielding << \"#{@inventory[@equipment[pos][0]].name} in #{pronoun} #{nice(pos)}\"\n end\n end\n\n if wielding.empty?\n if wearer == \"You\"\n output = [\"You are not wielding anything.\"]\n else\n output = [\"#{wearer.pronoun.capitalize} is not wielding anything.\"]\n end\n else\n [output << wielding.simple_list << \".\"]\n end\n end",
"def weaponAccessories _obj, _args\n \"_obj weaponAccessories _args;\" \n end",
"def get_available_weapons(difficulty)\n\n#if the difficulty of the quest is 1\n#only select weapons with attack power less than or equal to 3\n# and that the player has not yet obtained\n if difficulty == 1\n available_weapons = Weapon.all.where(\"attack_power <=3\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n#if the difficulty of the quest is 2\n#only select weapons with attack power greater than 3 and less than or equal to 6\n# and that the player has not yet obtained\n elsif difficulty == 2\n available_weapons = Weapon.all.where(\"attack_power >3 and attack_power <= 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n\n#if the difficulty of the quest is 3\n#only select weapons with attack power greater than 6\n# and that the player has not yet obtained\n else\n available_weapons = Weapon.all.where(\"attack_power > 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n end\n end",
"def report\r\n\t\tputs \"You have picked up the #{@name} of #{@type}!\"\r\n\t\tputs \" \"\r\n\t\tsleep 1\r\n\t\tputs \"Item Number #@@item_number\"\r\n\t\tputs \"Level : #@level\"\r\n\t\tputs \"Strength = #@strength\"\r\n\t\tputs \"Agility = #@agility\"\r\n\t\tputs \"Health = #@health\"\r\n\t\tputs \"Mana = #@mana\"\r\n\t\tputs\" \"\r\n\t\treturn\r\n\tend",
"def show_players\n\t\tputs @human_player.show_state\n\t\tputs \"Il reste #{@enemies.length} ennemies !\"\n\tend",
"def attack #basic attack for now\r\n attack_value = strength + rand(25..50)\r\n puts \"#{@name} SWINGS his Weapon for #{attack_value} Points of Damage!\"\r\n end",
"def display_last_attr(weapon)\n add_speed, add_strength, add_intelligence, add_health = weapon.get_attributes()\n puts\n puts \"Speed: #@speed+#{add_speed}\" \n puts \"Strength #@strength+#{add_strength}\"\n puts \"Intelligence #@intelligence+#{add_intelligence}\"\n puts \"health #@health+#{add_health}\"\n end",
"def reset_player_weapons()\n set_weapon()\n set_other_weapon()\n end",
"def search_weapon\n new_weapon = rand(1..6)\n puts \">>> Tu as trouvé une arme de niveau #{new_weapon}\"\n\n # Get a random value for the weapon. If the actual weapon has more power, keep the value\n # if it's lower it change the value to the best weapon value\n if new_weapon > @weapon_level\n puts \">>> Cette arme est plus puissante !\"\n @weapon_level = new_weapon\n else\n puts \">>> Cette arme est moins puissante !\"\n end\n end",
"def print_all_hands(players)\n players.each { |player| \n self.print_hand(player, player.get_initial_hand)\n }\n end",
"def show_table_of players, dealer\r\n hit_stay = ['RANDOM']\r\n bet_pattern = ['RANDOM', 'KELLY']\r\n \r\n puts 'Dealer: ' + players[dealer][:name] + '($' + players[dealer][:total_chips].to_s + ')'\r\n puts ''\r\n \r\n turn = (dealer + 1) % players.length\r\n \r\n name_width = 10\r\n hit_stay_width = 15\r\n bet_pattern_width = 20\r\n chips_width = 15\r\n rate_width = 15\r\n puts 'Name'.ljust(name_width) + 'Hit/Stay'.rjust(hit_stay_width) + 'Bet Pattern'.rjust(bet_pattern_width) + 'Chips'.rjust(chips_width) + 'Rate'.rjust(rate_width)\r\n while turn != dealer\r\n player = players[turn]\r\n\tname = player[:name] + ((if_bankrupt(player))? ' (X)' : '')\r\n\thit_stay_string = (player[:is_human] == 1)? 'x' : hit_stay[player[:hit_stay]]\r\n\tbet_pattern_string = (player[:is_human] == 1)? 'x' : bet_pattern[player[:bet_pattern]]\r\n\tchips_string = player[:total_chips].to_s\r\n\trate_string = (player[:rate] * 100.0).round(2).to_s + '%' \r\n\t\r\n\tputs name.ljust(name_width) + hit_stay_string.rjust(hit_stay_width) + bet_pattern_string.rjust(bet_pattern_width) + chips_string.rjust(chips_width) + rate_string.rjust(rate_width)\r\n\t\r\n\tturn = (turn + 1) % players.length\r\n end\r\n puts ''\r\nend",
"def status\n puts \"Player #{@playerNo}\".center(60)\n puts \"Name: #{@name}\".center(60)\n puts \"Class: #{@fightClass[:name]}\".center(60)\n puts \"Race: #{@race[:name]}\".center(60)\n puts \"HP: #{@hp}\".center(60)\n puts \"Level: #{@level}\".center(60)\n puts \"Actions: #{@actions.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Attacks: #{@attacks.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Inventory: #{@inventory.join(', ')}\".center(60)\n puts \"\"\n end",
"def show_state\n return puts \"#{super} et une arme de niveau \\\"#{@weapon_level}\\\"\"\n end",
"def showHands\n @players.times do |p|\n i=p + 1\n print \"\\nPlayer #{i}:\"\n # DJBHERE DJB HERE str = \"file_\" + i.to_s.rjust(n, \"0\")\n @playersCards[i].each do |c|\n print \" #{c.visible}\"\n end\n end\n end",
"def attack(weapon)\n rand(10) + weapon.power\n end",
"def printGameState(hide_dealer_card=true)\n puts \"--- TABLE STATE ---\"\n puts @dealer.printHands(hide_dealer_card)\n @players.each do |player|\n puts player.printHands\n end\n pressKeyToContinue\nend",
"def search_weapon\n\n #LANCER DE DE\n dice = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n\n #SI LE RESULTAT DU DE EST INFERIEUR AU NIVEAU DE L ARME, AFFICHER...\n if dice <= @weapon_level\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n\n #SINON, AFFICHER... \n else\n @weapon_level = dice\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n end\n end",
"def select_weapon\n\t# Store weapons in new array\n\tweapons = [\n \"\\u{1F52B}\" + \" \" + \"gun\",\n \"\\u{1F526}\" + \" \" + \"flashlight\",\n \"\\u{1F525}\" + \" \" + \"torch\",\n \"\\u{1F528}\" + \" \" + \"hammer\",\n \"\\u{1F52A}\" + \" \" + \"knife\"]\n\n# Ask user to choose a starting weapon\n\tputs \"Choose your weapon by typing its associated number: \\n\\n\"\n\n# Loop through weapons array and print options to console\n# prints the weapons and its value\n\t(0...weapons.length).each do |i|\n\t\tputs \"#{i+1} - #{weapons[i]}\"\n\tend\n\n# user input placeholder\n\tprint \"> \"\n\n# getting the users choice\n\tchoice = $stdin.gets.chomp.to_i - 1\n\t@selected_weapon = weapons[choice]\n\n#switch case for output of weapon choice\n case choice\n when 0\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n when 1\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n when 2\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n when 3\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n when 4\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n else\n puts \"\\nChoose again\\n\\n\"\n select_weapon\n end\nend",
"def handle(weapon)\n weapon = weapon.to_sym if weapon\n output = \"\"\n return \"No monster here\\n\" unless @game.current_room_model.monster\n # Get the input for the user\n\n player = @game.player\n items = @game.player.items\n weapons = items[:weapons]\n # Omitted double ask for key line 740\n new_ferocity = @game.current_room_model.monster.ferocity\n\n if items.has_key? :suit\n output << \"Your armor increases your chance of success.\\n\"\n new_ferocity = 3 * (@game.current_room_model.monster.ferocity / 4).to_i\n end\n\n has_sword = weapons.include? :sword\n has_axe = weapons.include? :axe\n\n has_two_weapons = has_axe && has_sword\n if not has_two_weapons\n output << \"You must fight with bare hands.\\n\"\n new_ferocity = (new_ferocity + new_ferocity / 5).to_i\n end\n\n has_just_axe = has_axe && !has_sword\n if has_just_axe\n output << \"You has only an axe to fight.\\n\"\n new_ferocity = 4 * (new_ferocity / 5).to_i\n end\n\n has_just_sword = has_sword && !has_axe\n\n if has_just_sword\n output << \"You must fight with your sword.\\n\"\n new_ferocity = 3 * (new_ferocity / 4).to_i\n end\n\n #change to face 2\n #store first axe before sword\n unless weapons.empty?\n new_ferocity = 4 * (new_ferocity / 5).to_i if weapon == :axe\n new_ferocity = 3 * (new_ferocity / 4).to_i if weapon == :sword\n end\n\n #change to face 3 THE BATTLE\n # TODO loop do line 940\n if rand() > 0.5\n output << \"Attacks.\\n\"\n else\n output << \"You attack.\\n\"\n end\n\n if rand() > 0.5 && player.has_torch?\n output << \"Your Torch was knocked from your hand.\\n\"\n items.delete :torch\n end\n\n if rand() > 0.5 && items.has_key?(:axe)\n output << \"You drop your ace in the heat of battle\\n\"\n items.delete :axe\n new_ferocity = 5 * (new_ferocity / 4).to_i\n end\n\n if rand() > 0.5 && items.has_key?(:sword)\n output << \"Your Sword is knocked from your hand!!!\\n\"\n items.delete :sword\n new_ferocity = 4 * (new_ferocity / 3).to_i\n end\n\n if rand() > 0.5\n output << \"You manage to wound it\\n\"\n new_ferocity = (5 * new_ferocity / 6).to_i\n end\n\n if rand() > 0.95\n output << \"Aaaaargh!!\\n\"\n output << \"Rip! Tear! Rip!\\n\"\n end\n\n output << \"You Want to run but you stand your ground...\\n\" if rand() > 0.9\n\n output << '*&%%$#$% $%# !! @ #$$# #$@! #$ $#$' if rand() > 0.9\n\n output << \"Will this be a battle to the death?\\n\" if rand() > 0.7\n\n output << \"His eyes flash fearfully\\n\" if rand() > 0.7\n\n output << \"Blood drips from his claws\\n\" if rand() > 0.7\n\n output << \"You smell the sulphur on his breath\\n\" if rand() > 0.7\n\n output << \"He strikes wildly, madly......\\n\" if rand() > 0.7\n\n output << \"You have never fought and opponent like this!!\\n\" if rand() > 0.7\n\n if rand() > 0.5\n output << \"The monster wounds you!!!\\n\"\n player.strength -= 5\n end\n\n #if the condition of the loop do is false\n if rand() * 16 > new_ferocity\n # TODO implement the to_s from monster\n output << \"And you managed to kill the #{@game.current_room_model.monster.name}\\n\"\n player.monsters_killed += 1\n # TODO update game room status\n else\n output << \"The #{@game.current_room_model.monster.name} defeated you\\n\"\n player.strength /= 2\n end\n @game.state = ExploringState.new @game\n\n output << \"\\n\"\n output << @game.state.status\n\n output\n end",
"def show_state\n\t\tputs \"#{@name} a #{life_points} de points de vie et une arme de niveau #{weapon_level}\"\n\tend",
"def display_weapon_choice(hero, type = 'purchase')\n if type == 'purchase'\n shop = WeaponShop.new get_items_of_type(:weapon, hero.base_class.downcase)\n display_formatted_weapon_choice_header(hero.base_class.capitalize)\n shop.display_formatted_weapons\n item = select_item(shop.weapons)\n purchase_item(hero, item)\n elsif type == 'sell'\n if hero.current_inventory_weapons.any?\n hero.display_inventory_weapons\n item = select_item(hero.current_inventory_weapons)\n sell_item(hero, item)\n else\n error 'You do not have any weapons to sell!'\n end\n else\n error \"Undefined type #{type} for trying to display weapons\"\n end\n end",
"def index\n @weapon_slots = WeaponSlot.all\n end",
"def on_player_walk\n for actor in members\n if actor.slip_damage?\n actor.hp -= 1 if actor.hp > 1 # Poison damage\n $game_map.screen.start_flash(Color.new(255,0,0,64), 4)\n end\n if actor.auto_hp_recover and actor.hp > 0\n actor.hp += 1 # HP auto recovery\n end\n end\n end",
"def get_tie_confirmation()\n return \"Both players tie with #{@player.get_weapon()}!\"\n end",
"def search_weapon\n new_weapon_level = rand(1..6)\n puts \"#{name} a trouve une arme de niveau #{new_weapon_level}\"\n if new_weapon_level > @weapon_level\n @weapon_level = new_weapon_level\n puts \"il fait un changement d arme\"\n puts \"\"\n else\n puts \"pas de changement d arme\"\n puts \"\"\n end\n end",
"def show_hand\n puts \"Player Score: #{player.score}: [#{player.dealt.join(\"][\")}]\"\n puts \"Dealer Score: #{dealer.score}: [#{dealer.dealt.join(\"][\")}]\"\n end",
"def battlers\n return (@actors + @pets + @monsters)\n end"
] | [
"0.6611604",
"0.6549918",
"0.6513331",
"0.6506434",
"0.6467202",
"0.6384377",
"0.63677734",
"0.6310053",
"0.6301107",
"0.62826234",
"0.6269984",
"0.62510866",
"0.6239163",
"0.6206391",
"0.61899996",
"0.6178642",
"0.61378664",
"0.61276823",
"0.61235607",
"0.6113446",
"0.6097997",
"0.60976756",
"0.6056321",
"0.6050465",
"0.60322016",
"0.6031463",
"0.6027166",
"0.6011915",
"0.60058826",
"0.60058826",
"0.60058826",
"0.59969896",
"0.59786046",
"0.59719074",
"0.59661126",
"0.5959746",
"0.5937419",
"0.59301907",
"0.59287745",
"0.59280956",
"0.59064424",
"0.59052706",
"0.58970493",
"0.58830863",
"0.58747286",
"0.5873483",
"0.58705175",
"0.58689326",
"0.58626205",
"0.5848338",
"0.5848338",
"0.5845045",
"0.5842169",
"0.5832906",
"0.5827793",
"0.58244616",
"0.5821745",
"0.58187777",
"0.5816014",
"0.5814537",
"0.5811595",
"0.5793182",
"0.5776202",
"0.5773552",
"0.5772331",
"0.5769869",
"0.57679796",
"0.57661176",
"0.5764803",
"0.5763493",
"0.57548624",
"0.5751098",
"0.5748204",
"0.57425815",
"0.5731536",
"0.5729722",
"0.57260925",
"0.572309",
"0.5715871",
"0.5701986",
"0.5699977",
"0.56925493",
"0.5684026",
"0.56805587",
"0.5678929",
"0.5655768",
"0.5646046",
"0.5645005",
"0.5639006",
"0.5632197",
"0.56206924",
"0.5616636",
"0.5616568",
"0.56147796",
"0.5614347",
"0.56040365",
"0.5601565",
"0.55971205",
"0.55889684",
"0.55872214"
] | 0.771655 | 0 |
obtain the weapon instance with the highest attack power for a certain player | def highest_attack_power_weapon
weapon = self.weapons.sort_by do |weapon|
weapon.attack_power
end.last
weapon
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_weapon\n new_weapon = rand(1..6)\n puts \">>> Tu as trouvé une arme de niveau #{new_weapon}\"\n\n # Get a random value for the weapon. If the actual weapon has more power, keep the value\n # if it's lower it change the value to the best weapon value\n if new_weapon > @weapon_level\n puts \">>> Cette arme est plus puissante !\"\n @weapon_level = new_weapon\n else\n puts \">>> Cette arme est moins puissante !\"\n end\n end",
"def player_w_biggest_feet\n all_players[1].max_by { |stats| stats[:shoe] }\n end",
"def biggestShoes\n players.max_by do|name, stats|\n stats[:shoe]\n end\nend",
"def find_pickaxe\r\n weapon = mob.get_equipment.get Equipment::WEAPON\r\n if !weapon.nil?\r\n PICKAXES.each do |name, pickaxe|\r\n return pickaxe if (weapon.id == pickaxe.item_id && get_mining_lvl >= pickaxe.lvl_req)\r\n end\r\n end\r\n best_pickaxe = nil\r\n PICKAXES.each do |name, pickaxe|\r\n next if(!best_pickaxe.nil? && pickaxe.speed < best_pickaxe.speed)\r\n (best_pickaxe = pickaxe) if (mob.get_inventory.slot_of(pickaxe.item_id) > -1 && get_mining_lvl >= pickaxe.lvl_req)\r\n end\r\n best_pickaxe\r\n end",
"def attack(weapon)\n rand(10) + weapon.power\n end",
"def chose_weapon\n if @class == 'Water'\n chosen_weapon = Weapon.new \n return chosen_weapon.water_weapons\n end\n end",
"def mostSteals\n players.max_by do|name, stats|\n stats[:steals]\n end\nend",
"def weapon_reward(available_weapons)\n\n #reward is 1 random choice from this array\n reward = available_weapons.sample\n\n #create to CharacterWeapon object to show that player obtains weaopn\n CharacterWeapon.new_character_weapon(self.id, reward.id)\n\n #print weapon details to player\n puts \"#{reward.name}\".bold.blue\n puts \"Weapon Power: #{reward.attack_power}\"\n puts\"#####################################\".blink\n\n #actually equip the weapon, if it will increase this player's attack power\n if reward.attack_power > self.power - 1 || self.power == 1\n #increase the player's attack power\n self.update(power: 1+reward.attack_power)\n end\n end",
"def player_with_most_steal\n most_steals = nil\n most_steal_player = nil\n\n all_players(game_hash).each do |player|\n if most_steals == nil || player[:steals] > most_steals\n most_steals = player[:steals]\n most_steal_player = player[:player_name]\n end\n end\n\n most_steal_player\nend",
"def mostPoints\n players.max_by do|name, stats|\n stats[:points]\n end\nend",
"def base_maxhp\n return enemy.maxhp\n end",
"def base_maxhp\n return $data_enemies[@enemy_id].maxhp\n end",
"def melee_weapon; end",
"def base_atk\n weapon = $data_weapons[@weapon_id]\n return weapon != nil ? weapon.atk : 0\n end",
"def weaponDamage \n damage = self.weapon.damage\n if( self.weapon.type == :versatile && @shield.value == 0 )\n damage += 2\n end\n damage\n end",
"def search_weapon\n \t\t\t new_weapon = rand(1..6)\n \t\t\t puts \"Tu as trouvé une arme de niveau #{new_weapon} !\"\n \t\t\t if new_weapon > @weapon_level\n \t\t\t \t@weapon_level = new_weapon\n \t\t\t \tputs \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n \t\t\t else\n \t\t\t \tputs \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n \t\t\t end\n \t\tend",
"def search_weapon\n new_weapon = rand(1..6)\n puts \"Tu as obtenu une nouvelle arme de niveau #{new_weapon}\"\n if new_weapon > self.weapon_level\n self.weapon_level = new_weapon\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end #if\n end",
"def weapon\n fetch('supernatural.weapon')\n end",
"def search_weapon\n new_weapon_level = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{new_weapon_level}\"\n if new_weapon_level > @weapon_level\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n @weapon_level = new_weapon_level\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end\n end",
"def melee_weapon\n fetch('dnd.melee_weapons')\n end",
"def highest_player_score\n players.max_by{|player| player.score}.score\n end",
"def max_buy\n max = $game_party.max_item_number(@item) - $game_party.item_number(@item) \n max_crafts = HudellBazaar::get_max_crafts(@item)\n max = [max, max_crafts].min\n\n buying_price == 0 ? max : [max, money / buying_price].min\n end",
"def highest_match_value\n values = @hand.select { |dice| @hand.count(dice) == highest_match_count }\n values.max\n end",
"def compute_damage\r\n return rand(1..6) * @weapon_level\r\n end",
"def search_weapon\n new_weapon_level = rand(1..6)\n puts \"#{name} a trouve une arme de niveau #{new_weapon_level}\"\n if new_weapon_level > @weapon_level\n @weapon_level = new_weapon_level\n puts \"il fait un changement d arme\"\n puts \"\"\n else\n puts \"pas de changement d arme\"\n puts \"\"\n end\n end",
"def compute_damage\n return rand(1..6) * @weapon_level\n end",
"def compute_damage\n return rand(1..6) * @weapon_level\n end",
"def attack()\r\n\t\tweaponPower = @weapon.offensiveWeapon()\r\n\t\tif(@weapon.name == \"Shield\")\r\n\t\t\treturn (weaponPower*@strength)/2\r\n\t\telse\r\n\t\t\treturn weaponPower*@strength\r\n\t\tend\r\n\tend",
"def compute_damage\n\t\treturn rand(1..6) * @weapon_level\n\tend",
"def max_health(level)\n (self.health + self.health*0.1*(level-1)).to_i\n end",
"def search_weapon\n\t\tnew_weapon_level = rand(1..6)\n\t\tputs \"Tu as trouvé une arme de niveau #{new_weapon_level}\"\n\t\tif new_weapon_level > @weapon_level\n\t\t\tputs \"Youhou ! Elle est meilleure que ton arme actuelle : tu la prends.\"\n\t\t\t@weapon_level = new_weapon_level\n\t\telse\n\t\t\tputs \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n\t\tend\n\tend",
"def most_expensive_player_on_team \n\n the_club = choose_club #user chooses club they want to see most expensive player for\n my_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n club_players = my_club.players.sort_by do |player| #loops through instance of club and sorts the players by their market value (remember to change market_value from string to integer)\n player.market_value.to_i\n end\n\n most_expensive_player = club_players.last #in ascending order the last item of the sorted array is the player with the highest market value\n puts \"#{the_club}'s most expensive player is #{most_expensive_player.name}. He is worth £#{most_expensive_player.market_value}M\"\n #the_club --> user choice of club name\n #most_expensive_player.name --> use the_club name to find the specific instance of Club class. \n #Use \".players\" method to find all player instances of that specifc club (the instances of players that \n #belong to that instance of club). Use \".name\" method to retrieve attribute \"name\" of player instance. \n #Use \".market_value\" to retrieve attribute \"market_value\" of the player instance. \n\nend",
"def compute_damage\n super * @weapon_level\n end",
"def search_weapon\n weapon = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n if dice > weapon_level\n @weapon_level = weapon\n puts 'Youhou ! elle est meilleure que ton arme actuelle : tu la prends.'\n else\n puts \" M@*!$... elle n'est pas mieux que ton arme actuelle...\"\n end\n end",
"def skill_effect_power(user, skill)\r\n power = skill.power + user.atk * skill.atk_f / 100\r\n if power > 0\r\n power -= self.pdef * skill.pdef_f / 200\r\n power -= self.mdef * skill.mdef_f / 200\r\n power = [power, 0].max\r\n end\r\n return power\r\n end",
"def search_weapon\n\t\t@weapon = rand(1..6)\n\t\tputs \"Tu as trouvé une arme de niveau #{@weapon}\"\n\t\tif @weapon <= @weapon_level # Si le niveau est inférieur ou égal au niveau de l'ancienne arme, on garde l'ancienne.\n\t\t\tputs \" M@*#$ l'arme trouvée est vraiment bidon, tu gardes l'ancienne\"\n\t\telse \n\t\t\tputs \"De la frappe frere !\\n\\n\"\n\t\t\t@weapon_level = @weapon # Si meilleure arme, on la prend\n\t\tend\n\tend",
"def weapon; end",
"def weapon; end",
"def weapon; end",
"def compute_damage\n rand(1..6) * @weapon_level\n end",
"def compute_damage\n rand(1..6) * @weapon_level\n end",
"def item_max\n $game_party.battle_members.size\n end",
"def max_withdraw\n case @category_window.current_symbol\n when :item, :weapon, :armor\n if $game_party.storage_item_number(@item) > 99\n return 99\n else\n $game_party.storage_item_number(@item)\n end\n when :gold\n if $game_party.storage_gold > 999\n return 999\n else\n $game_party.storage_gold\n end\n end\n end",
"def max_buy\r\n max = $game_party.max_item_number(@item) - $game_party.item_number(@item)\r\n buying_price == 0 ? max : [max, money / buying_price].min\r\n end",
"def big_shoe_rebounds\n all_players = game_hash[:home][:players].merge(game_hash[:home][:players])\n big_object = all_players.max_by do |key,value|\n value[:shoe]\n end \n big_object[1][:rebounds]\nend",
"def max_store\n case @category_window.current_symbol\n when :item, :weapon, :armor\n if $game_party.item_number(@item) > 99\n return 99\n else\n $game_party.item_number(@item)\n end\n when :gold\n if $game_party.gold > 999\n return 999\n else\n $game_party.gold\n end\n end\n end",
"def most_steal\n steals_array = []\n \n game_hash.each do |key, value|\n players = value[:players]\n players.each do |element|\n steals_array << element[:steals]\n end\n end\n steals_array.max\nend",
"def ranged_weapon; end",
"def max_sell\n $game_party.item_number(@item)\n end",
"def compute_damage\nreturn rand(1..6) * @weapon_lvl\nend",
"def item_max() SES::Bestiary.get_enemy_list.size end",
"def getSpecialValue\n maxBonus\n end",
"def search_weapon\r\n lvl = rand(1..6)\r\n puts \"Tu as trouvé une arme de niveau #{lvl}\"\r\n if @weapon_level >= lvl\r\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\r\n else\r\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\r\n @weapon_level = lvl\r\n end\r\n end",
"def skill_exp_max(skill)\n result = skill.skl_exp_list[skill.skl_maxlevel] + 10\n return result\n end",
"def energy\n combatant.maximum_energy\n end",
"def search_weapon\n dice = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n if dice > weapon_level\n @weapon_level = dice\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end\n puts\"////////////////////////////////////////////////\"\n puts\" \"\n end",
"def worst_defense\n @teams.max_by { |team| team.average_goals_allowed }.team_name\n end",
"def max_sell\r\n $game_party.item_number(@item)\r\n end",
"def most_steals\r\n result={}\r\n game_hash.each do |k, v|\r\n v.each do| p, d|\r\n if p==:players\r\n d.each do |t, s|\r\n result[t]=s[:steals]\r\n end\r\n end\r\n end\r\n end \r\n result.max_by {|name, steal| steal}[0]\r\nend",
"def mult_weapon_level (damagetype, user)\n if user == @attacker\n array = @attacker_level\n else\n array = @defender_level\n end\n mult = 0\n case damagetype\n when 1\n mult = array[2]\n when 2\n mult = array[3]\n when 3\n mult = array[4]\n end\n return mult\n end",
"def mult_weapon_level (damagetype, user)\n if user == @attacker\n array = @attacker_level\n else\n array = @defender_level\n end\n mult = 0\n case damagetype\n when 1\n mult = array[2]\n when 2\n mult = array[3]\n when 3\n mult = array[4]\n end\n return mult\n end",
"def give_bonus player\n player.add_weapon(Vibrant_Weapon.new(@window, player))\n end",
"def base_maxmp\n return enemy.maxmp\n end",
"def base_maxhp\n return $data_actors[@actor_id].parameters[0, @level]\n end",
"def get_available_weapons(difficulty)\n\n#if the difficulty of the quest is 1\n#only select weapons with attack power less than or equal to 3\n# and that the player has not yet obtained\n if difficulty == 1\n available_weapons = Weapon.all.where(\"attack_power <=3\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n#if the difficulty of the quest is 2\n#only select weapons with attack power greater than 3 and less than or equal to 6\n# and that the player has not yet obtained\n elsif difficulty == 2\n available_weapons = Weapon.all.where(\"attack_power >3 and attack_power <= 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n\n#if the difficulty of the quest is 3\n#only select weapons with attack power greater than 6\n# and that the player has not yet obtained\n else\n available_weapons = Weapon.all.where(\"attack_power > 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n end\n end",
"def big_shoe_rebounds\n players[player_with_most(:shoe)][:rebounds]\nend",
"def equip_weapon(weapon)\n remove_weapon\n if weapon.hands_used > free_hands\n remove_weapon(true)\n end\n add_weapon(weapon)\n end",
"def player_with_most(stat)\n value = nil\n owner = nil\n players.each do |player, stats|\n if value == nil || stats[stat] > value\n value = stats[stat]\n owner = player\n end\n end\n owner\nend",
"def max_player\n return 1\n end",
"def sprite_max\r\n (@power * 10).to_i\r\n end",
"def best_defense\n @teams.min_by { |team| team.average_goals_allowed }.team_name\n end",
"def max_gold\n MAX_GOLD_VARIABLE == -1 ? MAX_GOLD : $game_variables[MAX_GOLD_VARIABLE]\n end",
"def item_max() @item_max end",
"def get_difficulty\n if self.power < 3\n difficulty = 1\n elsif self.power >= 3 && self.power < 6\n difficulty = 2\n else\n difficulty = 3\n end\n end",
"def skill_power(skillname, player, usage)\n p \"==>calc #{player.name} skill power of #{skillname} for #{usage}:\"\n skill = player.query_skill(skillname)\n if (skill == nil)\n #logger.info(\"user #{player[:id]}-#{player.ext[:name]} doesn't have skill '#{skillname}'\")\n return 1\n end\n # p = skill.power(context)\n level = skill.data[:level]\n p \"=>level=#{level} apply_attack=#{player.tmp[:apply_attack]} apply_dodge=#{player.tmp[:apply_dodge]}\"\n \n if (usage == \"attack\" && player.tmp[:apply_attack] != nil)\n level += player.tmp[:apply_attack]\n end\n \n if (usage == \"dodge\" && player.tmp[:apply_dodge] != nil)\n # level += player.tmp[:apply_dodge]\n level = level * ( (100 + player.tmp[:apply_dodge]/10 ).to_f / 100 )\n end \n \n # if (usage == \"parry\" && player.tmp[:apply_defense] != nil)\n # level += player.tmp[:apply_dodge]\n # end \n jingli_bonus = 50 + player.tmp[:jingli]/ (player.tmp[:max_jl]+1) * 50\n if (jingli_bonus > 150)\n jingli_bonus = 150\n end\n \n total_exp = calc_total_exp(player.tmp[:level])\n p \"level=#{level} jingli_bonus=#{jingli_bonus}, total exp #{total_exp}\"\n if( level<1 ) \n return (total_exp/20.0 * (jingli_bonus/10) ).to_i\n end\n\n \n p =level**3/3 \n str = player.tmp[:str]\n dext = player.tmp[:dext]\n # p \"===>#{player.tmp.inspect}\"\n \n p \"==>p=#{p}, level=#{level} str=#{str} dext=#{dext} \"\n if (usage == \"attack\" || usage == \"parry\")\n p = (p + total_exp +1) / 30 * (( str+1)/10)\n else\n p = (p + total_exp +1) / 30 * (( dext+1)/10)\n end\n \n p = p.to_i\n p \"==>skill power=#{p}\"\n \n if p <= 1\n return 1\n else\n return p\n end\n end",
"def biggest_blowout\n score_difference = games.map { |game| (game.home_goals - game.away_goals).abs}\n score_difference.max\n end",
"def get_exp\n exp = 0\n exp = (((@hero.max_health - @hero.cur_health) * 0.85) * @monster.level).round if @winner\n return exp\n end",
"def gain_chest_item\n $game_party.gain_item(online_chest.item, 1)\n end",
"def winner\n @players.max_by{ |player| player.score}\n end",
"def damage\n @damage ||= [(@power * (rand + 0.5)).to_i - @defender.toughness, 0].max\n end",
"def get_most_expensive(type,inventory,most_expensive)\n\t\tmost_expensive[type] = Array.new\n\t\tordered_list = inventory.sort {|x,y| y[:price] <=> x[:price] }\n\t\tordered_list[0..4].each do |item|\n\t\t\tmost_expensive[type].push(item)\n\t\tend\n\n\t\treturn most_expensive\n\tend",
"def players_with_highest_score\n players.select{|player| player.score >= highest_player_score}\n end",
"def winner\n @hash.key(@hash.values.max)\n end",
"def get_max_over(stat)\n max = 0\n $data_enemies.each { |enemy|\n next if enemy.nil?\n next if enemy.hidden_best\n next unless $game_party.known_enemy?(enemy.id)\n value = enemy.get_stat(stat)\n max = value if value > max\n }\n max\n end",
"def attack()\n return @level + rand(3) - rand(3)\n end",
"def search_weapon\n\n #LANCER DE DE\n dice = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n\n #SI LE RESULTAT DU DE EST INFERIEUR AU NIVEAU DE L ARME, AFFICHER...\n if dice <= @weapon_level\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n\n #SINON, AFFICHER... \n else\n @weapon_level = dice\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n end\n end",
"def native_maxhp\n actor.parameters[0, @level] + @maxhp_plus\n end",
"def winner\n @players.max_by do |player|\n player.score\n end\n end",
"def item_max\r\n $game_troop.alive_members.size\r\n end",
"def to_hit(armor_class)\n result = 21 - armor_class - [@level, 20].min\n result -= 5 if result > 20\n # Maybe refactor this, it's potentially confusing.\n result -= 1 if @strength > 16\n result\n end",
"def big_shoe_rebounds\n game_hash.values.each do |attribute|\n hash = attribute[:players]\n hash.values.each do |h|\n h.select { |k, v| k == :shoe }.sort.max\n return h[:rebounds]\n end\n end\nend",
"def search_weapon\n#lancer de dé\n new_weapon_level = dice_launch\n puts \"Tu as trouvé une arme de niveau #{new_weapon_level}\"\n#condition de changement d'arme\n if new_weapon_level > @weapon_level\n \n @weapon_level = new_weapon_level\n puts \"Youhou! elle est meilleur que ton arme actuelle : tu la prends\"\n \n else \n \n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n \n end\n\n end",
"def isBestPlayer(player,stats,gl)\n if stats[\"Value\"].to_f > @dropValue\n @dropValue = stats[\"Value\"].to_f\n @dropRec = \"#{player[\"name\"][\"first\"]} #{player[\"name\"][\"last\"]}\"\n end\n if stats[\"Value\"].to_f*gl > @dropValueW\n @dropValueW = stats[\"Value\"].to_f*gl\n @dropRecW = \"#{player[\"name\"][\"first\"]} #{player[\"name\"][\"last\"]}\"\n end\nend",
"def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end",
"def required_gold(equip)\n equip.price / 4\n end",
"def base_maxsp\n return $data_enemies[@enemy_id].maxsp\n end",
"def max_charging_power; end",
"def weapon?\n melee_weapon? or ranged_weapon?\n end",
"def highest_price\n menu_items.map {|item| item.price}.max\n end",
"def biggest_shoe\r\n player_name= []\r\n game_hash.each do |team, data|\r\n data.each do |team_info, value|\r\n if team_info == \"players\".to_sym\r\n obj=value.max_by {|key, value| value[:shoe]}\r\n player_name<< obj.first\r\n end\r\n end\r\n end\r\n player_name.first\r\nend"
] | [
"0.6935373",
"0.68641955",
"0.6706536",
"0.66506845",
"0.65389234",
"0.6536086",
"0.644866",
"0.6369459",
"0.63611096",
"0.6346393",
"0.63452154",
"0.6335168",
"0.633251",
"0.63033986",
"0.6251758",
"0.62285405",
"0.62152255",
"0.6198436",
"0.61759293",
"0.61667114",
"0.6153146",
"0.61411387",
"0.6137724",
"0.6129751",
"0.612085",
"0.6109729",
"0.6109729",
"0.60976785",
"0.60875744",
"0.6086043",
"0.6080994",
"0.6070848",
"0.60591906",
"0.60417706",
"0.6038999",
"0.6034341",
"0.603294",
"0.603294",
"0.603294",
"0.6027832",
"0.6000571",
"0.5993821",
"0.5982903",
"0.59435236",
"0.59385824",
"0.5933061",
"0.59276295",
"0.5924168",
"0.59209484",
"0.5917968",
"0.59130365",
"0.5895371",
"0.58938813",
"0.58908534",
"0.588511",
"0.58835775",
"0.5883534",
"0.5880121",
"0.58629435",
"0.5856873",
"0.58559024",
"0.58552855",
"0.5850696",
"0.5842395",
"0.5830091",
"0.58193636",
"0.5817711",
"0.5809065",
"0.5804237",
"0.58023906",
"0.5798109",
"0.5789386",
"0.57686114",
"0.5763113",
"0.5750921",
"0.573969",
"0.5738841",
"0.57325464",
"0.57188797",
"0.57037526",
"0.5690257",
"0.56836075",
"0.5682238",
"0.5665423",
"0.5652211",
"0.56435436",
"0.5636798",
"0.56359154",
"0.5635098",
"0.5630247",
"0.56300634",
"0.5624686",
"0.5612217",
"0.5611105",
"0.56081706",
"0.56035507",
"0.55983114",
"0.55866057",
"0.55709755",
"0.5563735"
] | 0.86811703 | 0 |
this method obtains all of the weapons available to a certain player argument passed in is difficulty level, so this will only show weapons of certain attack powe | def get_available_weapons(difficulty)
#if the difficulty of the quest is 1
#only select weapons with attack power less than or equal to 3
# and that the player has not yet obtained
if difficulty == 1
available_weapons = Weapon.all.where("attack_power <=3").select do |weapon|
weapon.characters.include?(self) == false
end
#if the difficulty of the quest is 2
#only select weapons with attack power greater than 3 and less than or equal to 6
# and that the player has not yet obtained
elsif difficulty == 2
available_weapons = Weapon.all.where("attack_power >3 and attack_power <= 6").select do |weapon|
weapon.characters.include?(self) == false
end
#if the difficulty of the quest is 3
#only select weapons with attack power greater than 6
# and that the player has not yet obtained
else
available_weapons = Weapon.all.where("attack_power > 6").select do |weapon|
weapon.characters.include?(self) == false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_all_weapons\n if self.weapons.size == 0\n puts \"\"\n puts \"You have no weapons, try completing some quests first :)\"\n else\n puts \"\"\n puts \"Here Are Your Weapons:\".bold.white.on_light_black\n puts \" \"\n self.weapons.each do |weapon|\n puts \"**** #{weapon.name} **** Weapon Power: #{weapon.attack_power} ****\".italic\n end\n end\n end",
"def weapons\n broadsword = header_for_id('F4 65 03 01')\n two_handed_sword = header_for_id('01 66 03 01')\n war_sword = header_for_id('02 66 03 01')\n daggers = header_for_id('1B 66 03 01')\n avengers = header_for_id('1C 66 03 01')\n filler_array = [broadsword] * 99 +\n [two_handed_sword] * 99 +\n [war_sword] * 99 +\n [daggers] * 99 +\n [avengers] * 99\n raise 'invalid length' unless filler_array.length == 5 * 99\n type = WEAPONS\n\n code_for_weapon_or_accessory(filler_array: filler_array, type: type)\n end",
"def melee_weapon\n fetch('dnd.melee_weapons')\n end",
"def weapons _args\n \"weapons _args;\" \n end",
"def melee_weapon; end",
"def swing_weapons(att_id)\n\t@swing = att_id\n\tweapon_power(@swing)\t\t\t\t\t\t\t\t\t\t# COUNT ATTACK ROLLS\n\tmulti_success(@swing, @attack_power[@swing],@swing_chance,@dice_faces) # RESOLVE ATTACK ROLLS (default is 5)\n # puts \"***********************\"\nend",
"def weaponAccessories _obj, _args\n \"_obj weaponAccessories _args;\" \n end",
"def weapon_reward(available_weapons)\n\n #reward is 1 random choice from this array\n reward = available_weapons.sample\n\n #create to CharacterWeapon object to show that player obtains weaopn\n CharacterWeapon.new_character_weapon(self.id, reward.id)\n\n #print weapon details to player\n puts \"#{reward.name}\".bold.blue\n puts \"Weapon Power: #{reward.attack_power}\"\n puts\"#####################################\".blink\n\n #actually equip the weapon, if it will increase this player's attack power\n if reward.attack_power > self.power - 1 || self.power == 1\n #increase the player's attack power\n self.update(power: 1+reward.attack_power)\n end\n end",
"def search_weapon\n\t\t@weapon = rand(1..6)\n\t\tputs \"Tu as trouvé une arme de niveau #{@weapon}\"\n\t\tif @weapon <= @weapon_level # Si le niveau est inférieur ou égal au niveau de l'ancienne arme, on garde l'ancienne.\n\t\t\tputs \" M@*#$ l'arme trouvée est vraiment bidon, tu gardes l'ancienne\"\n\t\telse \n\t\t\tputs \"De la frappe frere !\\n\\n\"\n\t\t\t@weapon_level = @weapon # Si meilleure arme, on la prend\n\t\tend\n\tend",
"def search_weapon\r\n lvl = rand(1..6)\r\n puts \"Tu as trouvé une arme de niveau #{lvl}\"\r\n if @weapon_level >= lvl\r\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\r\n else\r\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\r\n @weapon_level = lvl\r\n end\r\n end",
"def weapons_hash()\n return @weapons\n end",
"def search_weapon\n\t\tnew_weapon_level = rand(1..6)\n\t\tputs \"Tu as trouvé une arme de niveau #{new_weapon_level}\"\n\t\tif new_weapon_level > @weapon_level\n\t\t\tputs \"Youhou ! Elle est meilleure que ton arme actuelle : tu la prends.\"\n\t\t\t@weapon_level = new_weapon_level\n\t\telse\n\t\t\tputs \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n\t\tend\n\tend",
"def search_weapon\n dice = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n if dice > weapon_level\n @weapon_level = dice\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end\n puts\"////////////////////////////////////////////////\"\n puts\" \"\n end",
"def find_hatchet\n HATCHET_ID.each do |id|\n weapon = character.equipment.get EquipmentConstants::WEAPON\n if weapon.id == id\n return HATCHET[id]\n end\n if character.inventory.contains id\n return HATCHET[id]\n end\n end\n return nil\nend",
"def search_weapon\n weapon = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n if dice > weapon_level\n @weapon_level = weapon\n puts 'Youhou ! elle est meilleure que ton arme actuelle : tu la prends.'\n else\n puts \" M@*!$... elle n'est pas mieux que ton arme actuelle...\"\n end\n end",
"def reduce_weapon_options\n # Here we're simple interested in eliminating weapons, so we care only\n # about combinations, not perumtations. This is more manageable.\n weapon_combinations = @current_level.weapon_combinations.to_a\n guesses_with_answer = []\n\n # Guess until we've narrowed it down to 10 weapons or fewer.\n while weapon_combinations.flatten.uniq.size > 10 do\n weapon_guess = weapon_combinations.sample\n resp = @client.solve_level(@current_level.levelNum, weapon_guess)\n weapon_combinations.select! do |possibility|\n # At the moment, we only care about which weapons are correctly used.\n Mastermind::Game.evaluate(weapon_guess, possibility).first == resp['response'].first\n end\n # Save guesses and full answer to process later.\n guesses_with_answer << [weapon_guess, resp['response']]\n end\n # Now that we've reduced the number of weapons, generate list of all\n # remaining possibilities.\n @remaining_possibilities = @current_level.possible_answers(weapon_combinations.flatten.uniq).to_a\n\n # Loop through prior guesses to eliminate any that can be.\n guesses_with_answer.each do |gwa|\n @remaining_possibilities.select! do |possibility|\n Mastermind::Game.evaluate(gwa[0], possibility) == gwa[1]\n end\n end\n @remaining_possibilities\n end",
"def search_weapon\n \t\t\t new_weapon = rand(1..6)\n \t\t\t puts \"Tu as trouvé une arme de niveau #{new_weapon} !\"\n \t\t\t if new_weapon > @weapon_level\n \t\t\t \t@weapon_level = new_weapon\n \t\t\t \tputs \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n \t\t\t else\n \t\t\t \tputs \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n \t\t\t end\n \t\tend",
"def search_weapon\n new_weapon = rand(1..6)\n puts \">>> Tu as trouvé une arme de niveau #{new_weapon}\"\n\n # Get a random value for the weapon. If the actual weapon has more power, keep the value\n # if it's lower it change the value to the best weapon value\n if new_weapon > @weapon_level\n puts \">>> Cette arme est plus puissante !\"\n @weapon_level = new_weapon\n else\n puts \">>> Cette arme est moins puissante !\"\n end\n end",
"def weaponsItems _args\n \"weaponsItems _args;\" \n end",
"def search_weapon\n new_weapon_level = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{new_weapon_level}\"\n if new_weapon_level > @weapon_level\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n @weapon_level = new_weapon_level\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end\n end",
"def search_weapon\n new_weapon = rand(1..6)\n puts \"Tu as obtenu une nouvelle arme de niveau #{new_weapon}\"\n if new_weapon > self.weapon_level\n self.weapon_level = new_weapon\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n else\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n end #if\n end",
"def carried_weapons\n CharacterWeapon.where(:character_id => self.id, :carried => :true).order('equipped desc')\n end",
"def ranged_weapon; end",
"def weapon; end",
"def weapon; end",
"def weapon; end",
"def chose_weapon\n if @class == 'Water'\n chosen_weapon = Weapon.new \n return chosen_weapon.water_weapons\n end\n end",
"def index\n @weapons = Weapon.all\n end",
"def index\n @weapons = Weapon.all\n end",
"def display_weapon_choice(hero, type = 'purchase')\n if type == 'purchase'\n shop = WeaponShop.new get_items_of_type(:weapon, hero.base_class.downcase)\n display_formatted_weapon_choice_header(hero.base_class.capitalize)\n shop.display_formatted_weapons\n item = select_item(shop.weapons)\n purchase_item(hero, item)\n elsif type == 'sell'\n if hero.current_inventory_weapons.any?\n hero.display_inventory_weapons\n item = select_item(hero.current_inventory_weapons)\n sell_item(hero, item)\n else\n error 'You do not have any weapons to sell!'\n end\n else\n error \"Undefined type #{type} for trying to display weapons\"\n end\n end",
"def search_weapon\n new_weapon_level = rand(1..6)\n puts \"#{name} a trouve une arme de niveau #{new_weapon_level}\"\n if new_weapon_level > @weapon_level\n @weapon_level = new_weapon_level\n puts \"il fait un changement d arme\"\n puts \"\"\n else\n puts \"pas de changement d arme\"\n puts \"\"\n end\n end",
"def attack(weapon)\n rand(10) + weapon.power\n end",
"def skill_power(skillname, player, usage)\n p \"==>calc #{player.name} skill power of #{skillname} for #{usage}:\"\n skill = player.query_skill(skillname)\n if (skill == nil)\n #logger.info(\"user #{player[:id]}-#{player.ext[:name]} doesn't have skill '#{skillname}'\")\n return 1\n end\n # p = skill.power(context)\n level = skill.data[:level]\n p \"=>level=#{level} apply_attack=#{player.tmp[:apply_attack]} apply_dodge=#{player.tmp[:apply_dodge]}\"\n \n if (usage == \"attack\" && player.tmp[:apply_attack] != nil)\n level += player.tmp[:apply_attack]\n end\n \n if (usage == \"dodge\" && player.tmp[:apply_dodge] != nil)\n # level += player.tmp[:apply_dodge]\n level = level * ( (100 + player.tmp[:apply_dodge]/10 ).to_f / 100 )\n end \n \n # if (usage == \"parry\" && player.tmp[:apply_defense] != nil)\n # level += player.tmp[:apply_dodge]\n # end \n jingli_bonus = 50 + player.tmp[:jingli]/ (player.tmp[:max_jl]+1) * 50\n if (jingli_bonus > 150)\n jingli_bonus = 150\n end\n \n total_exp = calc_total_exp(player.tmp[:level])\n p \"level=#{level} jingli_bonus=#{jingli_bonus}, total exp #{total_exp}\"\n if( level<1 ) \n return (total_exp/20.0 * (jingli_bonus/10) ).to_i\n end\n\n \n p =level**3/3 \n str = player.tmp[:str]\n dext = player.tmp[:dext]\n # p \"===>#{player.tmp.inspect}\"\n \n p \"==>p=#{p}, level=#{level} str=#{str} dext=#{dext} \"\n if (usage == \"attack\" || usage == \"parry\")\n p = (p + total_exp +1) / 30 * (( str+1)/10)\n else\n p = (p + total_exp +1) / 30 * (( dext+1)/10)\n end\n \n p = p.to_i\n p \"==>skill power=#{p}\"\n \n if p <= 1\n return 1\n else\n return p\n end\n end",
"def test_twoHandedWeapon\n f = WeaponFilter.new(\"two_handed\", true)\n new_list = @baseItems.find_all{|x| f.apply(x)}\n return new_list.size == 16\n end",
"def find_hatchet\r\n HATCHET_ID.each do |id|\r\n weapon = character.equipment.get EquipmentConstants::WEAPON\r\n if weapon.id == id\r\n return HATCHET[id]\r\n end\r\n if character.inventory.contains id\r\n return HATCHET[id]\r\n end\r\n end\r\n return nil\r\n end",
"def set_enchantable_weapons\n $data_weapons.compact.each { |w| w.setup_enchant_property }\n end",
"def index\n @weapon_types = WeaponType.all\n end",
"def weapon_stats\n return unless public?\n\n if @weapon_stats.nil?\n @weapon_stats = {}\n @xml_data.elements.each('stats/weapons/*') do |weapon_data|\n unless %w{molotov pipes}.include? weapon_data.name\n weapon = L4DWeapon.new(weapon_data)\n else\n weapon = L4DExplosive.new(weapon_data)\n end\n\n @weapon_stats[weapon_data.name] = weapon\n end\n end\n\n @weapon_stats\n end",
"def weapon_stats\n return unless public?\n\n if @weapon_stats.nil?\n @weapon_stats = {}\n WEAPONS.each do |weapon_node|\n weapon_data = @xml_data['stats']['weapons'][weapon_node]\n weapon = AlienSwarmWeapon.new(weapon_data)\n @weapon_stats[weapon.name] = weapon\n end\n end\n\n @weapon_stats\n end",
"def highest_attack_power_weapon\n weapon = self.weapons.sort_by do |weapon|\n weapon.attack_power\n end.last\n weapon\n end",
"def attack(user)\n # Variable to see how many damage instances will be\n damage_instances_count = 0\n\n # Search within weapons for damage bonus\n user.weapons.each do |weapon|\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'damage'\n damage_instances_count = bonus.multiplier\n end\n end\n end\n\n # For each damage bonus we will calculate the attack again\n damage_instances = (1..damage_instances_count).map do\n # Values from weapons\n weapon_attack_points = 0\n weapon_attack_modifiers = 0\n weapon_attack_recoil_modifier = 0\n\n weapon_defense_points = 0\n weapon_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.weapons.each do |weapon|\n weapon_attack_points += weapon.attack_points\n weapon_defense_points += weapon.defense_points\n\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n weapon_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'recoil'\n weapon_attack_recoil_modifier += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n weapon_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from rings\n rings_attack_points = 0\n rings_attack_modifiers = 0\n\n rings_defense_points = 0\n rings_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.rings.each do |ring|\n rings_attack_points += ring.attack_points\n rings_defense_points += ring.defense_points\n\n ring.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n rings_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n rings_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from helmets\n helmet_attack_points = user.helmet.attack_points\n helmet_attack_modifiers = 0\n\n helmet_defense_points = user.helmet.defense_points\n helmet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.helmet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n helmet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n helmet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from body armor\n body_armor_attack_points = user.body_armor.attack_points\n body_armor_attack_modifiers = 0\n\n body_armor_defense_points = user.body_armor.defense_points\n body_armor_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.body_armor.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n body_armor_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n body_armor_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from boots\n boots_attack_points = user.boots.attack_points\n boots_attack_modifiers = 0\n\n boots_defense_points = user.boots.defense_points\n boots_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.boots.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n boots_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n boots_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from gloves\n gloves_attack_points = user.gloves.attack_points\n gloves_attack_modifiers = 0\n\n gloves_defense_points = user.gloves.defense_points\n gloves_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.gloves.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n gloves_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n gloves_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from amulet\n amulet_attack_points = user.amulet.attack_points\n amulet_attack_modifiers = 0\n\n amulet_defense_points = user.amulet.defense_points\n amulet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.amulet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n amulet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n amulet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Making a sum of all the points from the itens\n attack_points_sum = weapon_attack_points + rings_attack_points + helmet_attack_points + body_armor_attack_points + boots_attack_points + gloves_attack_points + amulet_attack_points\n defense_points_sum = weapon_defense_points + rings_defense_points + helmet_defense_points + body_armor_defense_points + boots_defense_points + gloves_defense_points + amulet_defense_points\n\n # Making a sum of all the bonuses from the items\n attack_modifiers_sum = weapon_attack_modifiers + rings_attack_modifiers + helmet_attack_modifiers + body_armor_attack_modifiers + boots_attack_modifiers + gloves_attack_modifiers + amulet_attack_modifiers\n defense_modifiers_sum = weapon_defense_modifiers + rings_defense_modifiers + helmet_defense_modifiers + body_armor_defense_modifiers + boots_defense_modifiers + gloves_defense_modifiers + amulet_defense_modifiers\n\n # Calculating damage, defense and recoil\n attack_total = attack_points_sum * attack_modifiers_sum\n defense_total = defense_points_sum * defense_modifiers_sum\n recoil_total = (attack_total * weapon_attack_recoil_modifier * ((attack_total / (defense_total + (E ** -attack_total))) / 100)).floor\n\n # Creating a new DamageInstance\n DamageInstance.new(attack_total, recoil_total)\n end\n\n # Returning damage instances\n damage_instances\n end",
"def equips_for_enchant\n return [] if @enchant_item.nil?\n $game_party.items.select { |item|\n item.enchantable? && item.tier == @enchant_item.enchant_tier\n }\n end",
"def weapon\n fetch('supernatural.weapon')\n end",
"def weaponLowered _args\n \"weaponLowered _args;\" \n end",
"def test_attackSkill\n f = SkillFilter.new(\"attack\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 44\n end",
"def weapons\n @weapons.join(\", \")\n end",
"def update_weapon_stats\n weapons = fetch_weapons(@career)\n weapons = weapons.sort {|a,b| b[1] <=> a[1]}\n 5.times do |i|\n self[\"weapon#{i+1}_name\"] = weapons[i][0][0] rescue \"Not Enough Data\"\n self[\"weapon#{i+1}_url\"] = weapons[i][0][1] rescue \"http://www.bungie.net/images/halo3stats/weapons/unknown.gif\"\n self[\"weapon#{i+1}_num\"] = weapons[i][1] rescue 0\n end\n end",
"def ranged_weapon\n fetch('dnd.ranged_weapons')\n end",
"def game\n @level = Level.find(params[:id])\n\n @items = []\n @tools = []\n State.all.each do |state| \n if state.state_category.name == \"Tools\"\n @tools << state\n else\n @items << state\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @level }\n end\n end",
"def search_weapon\n\n #LANCER DE DE\n dice = rand(1..6)\n puts \"Tu as trouvé une arme de niveau #{dice}\"\n\n #SI LE RESULTAT DU DE EST INFERIEUR AU NIVEAU DE L ARME, AFFICHER...\n if dice <= @weapon_level\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n\n #SINON, AFFICHER... \n else\n @weapon_level = dice\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\n end\n end",
"def mult_weapon_level (damagetype, user)\n if user == @attacker\n array = @attacker_level\n else\n array = @defender_level\n end\n mult = 0\n case damagetype\n when 1\n mult = array[2]\n when 2\n mult = array[3]\n when 3\n mult = array[4]\n end\n return mult\n end",
"def mult_weapon_level (damagetype, user)\n if user == @attacker\n array = @attacker_level\n else\n array = @defender_level\n end\n mult = 0\n case damagetype\n when 1\n mult = array[2]\n when 2\n mult = array[3]\n when 3\n mult = array[4]\n end\n return mult\n end",
"def weapon?\n melee_weapon? or ranged_weapon?\n end",
"def ty_execute_action_skill\n # Check to see if the current attacker is the actor and is using a weapon that needs ammo\n if @active_battler.is_a?(Game_Actor) && TysAmmoRequirements::Skill_ammo_cost[@active_battler.action.skill_id]\n if TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id].is_a?(Array)\n # Check passed, so now we store the array items\n array_items = TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id]\n # Now we check each ID in array_items and compare to see if we have enough ammo\n for index in array_items\n # Check to see if the actor has enough ammo\n if $game_party.item_number($data_items[index]) >= gather_ammo_cost\n # Check cleared, gather item ID and terminate check loop\n gather_ammo_item = $data_items[index]\n break\n end\n end\n else\n gather_ammo_item = $data_items[TysAmmoRequirements::Weapons_ammo_id[@active_battler.skill_id]]\n end\n # Both checks clear, so perform Ammo adjustments\n # First we collect some end-user options, like ammo cost and ammo ID.\n gather_ammo_cost = TysAmmoRequirements::Skill_ammo_cost[@active_battler.action.skill_id]\n id = @active_battler.action.skill_id\n gather_ammo_item = $data_items[TysAmmoRequirements::Skill_ammo_id[id]]\n if $game_party.item_number(gather_ammo_item) >= gather_ammo_cost\n # The check cleared, so perform ammo adjustments\n # Consume Ammunition\n $game_party.lose_item(gather_ammo_item, gather_ammo_cost)\n # Display text\n text = sprintf(Vocab::ConsumeAmmo, @active_battler.name, gather_ammo_cost, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n else\n # Failed check, go into defense mode\n text = sprintf(Vocab::NoAmmo, @active_battler.name, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 0\n execute_action_guard\n end\n # Perform a check to see if Active_Battler is a enemy and has ammo\n elsif @active_battler.is_a?(Game_Enemy) && $data_enemies[@active_battler.enemy_id].note.include?(TysAmmoRequirements::Enemy_ammo_activate_string) && TysAmmoRequirements::Enemy_skill_cost[@active_battler.action.skill_id]\n # Now we have to isolate the interger in the 'Note' string of the enemies\n # and then store the interger in a new local value for future use.\n enemy_ammo_cost = TysAmmoRequirements::Enemy_skill_cost[@active_battler.action.skill_id]\n enemy_ammo_name = TysAmmoRequirements::Enemy_ammo_name[@active_battler.enemy_id]\n # Check to see if the enemy has enough ammo to attack\n if @enemy_ammo[@enemy_attack] >= enemy_ammo_cost\n # Check cleared, remove enemy ammo.\n text = sprintf(Vocab::EnemyUsedAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @enemy_ammo[@enemy_attack] -= enemy_ammo_cost\n else\n # Check failed, put enemy in guard mode \n text = sprintf(Vocab::EnemyNoAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 0\n execute_action_guard\n end\n end\n end",
"def ty_execute_action_attack\n # Check to see if the current attacker is the actor and is using a weapon that needs ammo\n if @active_battler.is_a?(Game_Actor) && TysAmmoRequirements::Weapons_ammo_cost[@active_battler.weapon_id]\n # Both checks clear, so perform Ammo adjustments\n # First we collect some end-user options, like ammo cost and ammo ID.\n gather_ammo_cost = TysAmmoRequirements::Weapons_ammo_cost[@active_battler.weapon_id]\n # This handles multiple ammunition for the same weapon. First we check if the setting is an array\n if TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id].is_a?(Array)\n # Check passed, so now we store the array items\n array_items = TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id]\n # Now we check each ID in array_items and compare to see if we have enough ammo\n for index in array_items\n # Check to see if the actor has enough ammo\n if $game_party.item_number($data_items[index]) >= gather_ammo_cost\n # Check cleared, gather item ID and terminate check loop\n gather_ammo_item = $data_items[index]\n break\n end\n end\n else\n gather_ammo_item = $data_items[TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id]]\n end\n # Next we check to make sure the attacking actor has enough ammo\n if $game_party.item_number(gather_ammo_item) >= gather_ammo_cost\n # The check cleared, so perform ammo adjustments\n # Consume Ammunition\n $game_party.lose_item(gather_ammo_item, gather_ammo_cost)\n # Display text\n text = sprintf(Vocab::ConsumeAmmo, @active_battler.name, gather_ammo_cost, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n else\n # Failed check, go into defense mode\n if TysAmmoRequirements::Unequip_weapon_NoAmmo\n @active_battler.change_equip_by_id(0,0)\n else\n text = sprintf(Vocab::NoAmmo, @active_battler.name, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 1\n execute_action_guard\n end\n end\n # Perform a check to see if Active_Battler is a enemy and has ammo\n elsif @active_battler.is_a?(Game_Enemy) && $data_enemies[@active_battler.enemy_id].note.include?(TysAmmoRequirements::Enemy_ammo_activate_string)\n # Now we have to isolate the interger in the 'Note' string of the enemies\n # and then store the interger in a new local value for future use.\n enemy_ammo_cost = $data_enemies[@active_battler.enemy_id].note.downcase.match('ammocost:(\\d*)')[1].to_i\n enemy_use_physical = true if $data_enemies[@active_battler.enemy_id].note.include?('usephysical')\n enemy_use_physical = false if $data_enemies[@active_battler.enemy_id].note.include?('usephysical') == false\n enemy_ammo_name = TysAmmoRequirements::Enemy_ammo_name[@active_battler.enemy_id]\n # Check to see if the enemy has enough ammo to attack\n if @enemy_ammo[@enemy_attack] >= enemy_ammo_cost\n # Check cleared, remove enemy ammo.\n text = sprintf(Vocab::EnemyUsedAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @enemy_ammo[@enemy_attack] -= enemy_ammo_cost\n else\n # Check failed, put enemy in guard mode \n if enemy_use_physical == false\n text = sprintf(Vocab::EnemyNoAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 1\n execute_action_guard\n end\n end\n end\n end",
"def search_weapon\n#lancer de dé\n new_weapon_level = dice_launch\n puts \"Tu as trouvé une arme de niveau #{new_weapon_level}\"\n#condition de changement d'arme\n if new_weapon_level > @weapon_level\n \n @weapon_level = new_weapon_level\n puts \"Youhou! elle est meilleur que ton arme actuelle : tu la prends\"\n \n else \n \n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\n \n end\n\n end",
"def attacks(player)\r\n puts \"#{@name} attaque le joueur #{player.name}\"\r\n player.gets_damage(compute_damage)\r\n end",
"def reset_player_weapons()\n set_weapon()\n set_other_weapon()\n end",
"def enchant_items\n $game_party.items.select { |item| item.enchant_scroll? }\n end",
"def show\n @weapon = Weapon.find(params[:id])\n end",
"def give_bonus player\n player.add_weapon(Vibrant_Weapon.new(@window, player))\n end",
"def attack()\r\n\t\tweaponPower = @weapon.offensiveWeapon()\r\n\t\tif(@weapon.name == \"Shield\")\r\n\t\t\treturn (weaponPower*@strength)/2\r\n\t\telse\r\n\t\t\treturn weaponPower*@strength\r\n\t\tend\r\n\tend",
"def handle(weapon)\n weapon = weapon.to_sym if weapon\n output = \"\"\n return \"No monster here\\n\" unless @game.current_room_model.monster\n # Get the input for the user\n\n player = @game.player\n items = @game.player.items\n weapons = items[:weapons]\n # Omitted double ask for key line 740\n new_ferocity = @game.current_room_model.monster.ferocity\n\n if items.has_key? :suit\n output << \"Your armor increases your chance of success.\\n\"\n new_ferocity = 3 * (@game.current_room_model.monster.ferocity / 4).to_i\n end\n\n has_sword = weapons.include? :sword\n has_axe = weapons.include? :axe\n\n has_two_weapons = has_axe && has_sword\n if not has_two_weapons\n output << \"You must fight with bare hands.\\n\"\n new_ferocity = (new_ferocity + new_ferocity / 5).to_i\n end\n\n has_just_axe = has_axe && !has_sword\n if has_just_axe\n output << \"You has only an axe to fight.\\n\"\n new_ferocity = 4 * (new_ferocity / 5).to_i\n end\n\n has_just_sword = has_sword && !has_axe\n\n if has_just_sword\n output << \"You must fight with your sword.\\n\"\n new_ferocity = 3 * (new_ferocity / 4).to_i\n end\n\n #change to face 2\n #store first axe before sword\n unless weapons.empty?\n new_ferocity = 4 * (new_ferocity / 5).to_i if weapon == :axe\n new_ferocity = 3 * (new_ferocity / 4).to_i if weapon == :sword\n end\n\n #change to face 3 THE BATTLE\n # TODO loop do line 940\n if rand() > 0.5\n output << \"Attacks.\\n\"\n else\n output << \"You attack.\\n\"\n end\n\n if rand() > 0.5 && player.has_torch?\n output << \"Your Torch was knocked from your hand.\\n\"\n items.delete :torch\n end\n\n if rand() > 0.5 && items.has_key?(:axe)\n output << \"You drop your ace in the heat of battle\\n\"\n items.delete :axe\n new_ferocity = 5 * (new_ferocity / 4).to_i\n end\n\n if rand() > 0.5 && items.has_key?(:sword)\n output << \"Your Sword is knocked from your hand!!!\\n\"\n items.delete :sword\n new_ferocity = 4 * (new_ferocity / 3).to_i\n end\n\n if rand() > 0.5\n output << \"You manage to wound it\\n\"\n new_ferocity = (5 * new_ferocity / 6).to_i\n end\n\n if rand() > 0.95\n output << \"Aaaaargh!!\\n\"\n output << \"Rip! Tear! Rip!\\n\"\n end\n\n output << \"You Want to run but you stand your ground...\\n\" if rand() > 0.9\n\n output << '*&%%$#$% $%# !! @ #$$# #$@! #$ $#$' if rand() > 0.9\n\n output << \"Will this be a battle to the death?\\n\" if rand() > 0.7\n\n output << \"His eyes flash fearfully\\n\" if rand() > 0.7\n\n output << \"Blood drips from his claws\\n\" if rand() > 0.7\n\n output << \"You smell the sulphur on his breath\\n\" if rand() > 0.7\n\n output << \"He strikes wildly, madly......\\n\" if rand() > 0.7\n\n output << \"You have never fought and opponent like this!!\\n\" if rand() > 0.7\n\n if rand() > 0.5\n output << \"The monster wounds you!!!\\n\"\n player.strength -= 5\n end\n\n #if the condition of the loop do is false\n if rand() * 16 > new_ferocity\n # TODO implement the to_s from monster\n output << \"And you managed to kill the #{@game.current_room_model.monster.name}\\n\"\n player.monsters_killed += 1\n # TODO update game room status\n else\n output << \"The #{@game.current_room_model.monster.name} defeated you\\n\"\n player.strength /= 2\n end\n @game.state = ExploringState.new @game\n\n output << \"\\n\"\n output << @game.state.status\n\n output\n end",
"def fight(user, enemies, player1, player2)\n while user.life_points >0 && (player1.life_points > 0 || player2.life_points >0)\n user.show_state\n puts \"\n Quelle action veux-tu effectuer ?\n\n a - chercher une meilleure arme\n s - chercher à se soigner \n \n attaquer un joueur en vue :\n\n 0 - Josiane a #{player1.life_points} points de vie\n 1 - José a #{player2.life_points} points de vie\"\n puts \"*******************************************************************\" \n choice = gets.chomp \n puts \"***********************************************************************\" \n \n if choice == \"a\" \n user.search_weapon\n elsif choice == \"s\"\n user.search_health_pack\n elsif choice == \"0\"\n user.attacks(player1)\n elsif choice == \"1\"\n user.attacks(player2)\n end\n\n puts \"***********************************************************************\" \n enemies.each do |x|\n break if x.life_points <= 0\n x.attacks(user)\n puts \"Les autres joueurs t'attaquent !\"\n end\n end \n if user.life_points > 0\n puts \"BRAVO ! TU AS GAGNE !\"\n else \n puts \"Loser ! Tu as perdu !\"\n end\nend",
"def fight\n \n \n while @human.life_points >0 && (@player1.life_points > 0 || @player2.life_points >0)\n\n\n puts \"**********Menu**************\"\n puts \"a - find a better weapon\"\n puts \"s - find more points of life\" \n puts \"0 - attack player 1\"\n puts \"1 - attack player 2\"\n puts \"2 - receive attacks\"\n puts \"****************************\"\n puts \"Select an option:\"\n option = gets.chomp.to_s\n\n if option == \"a\"\n @human.search_weapon\n elsif option == \"s\"\n @human.search_health_pack\n elsif option == \"0\"\n @human.attacks(@player1)\n elsif option == \"1\"\n @human.attacks(@player2)\n elsif option == \"2\"\n puts \"You are under attack!\"\n @enemies.each { |i| i.life_points <= 0 ? break : i.attacks(@human)}\n @human.show_state\n else\n end\n end\n puts \"Game over\"\n puts \"You won\"\nend",
"def show\n render :json => @weapon, :include => :special_rules\n end",
"def hook_action\n if tool_canuse?(HweaponId) and not @showing_hook\n unless character_at_playerpos?\n @hookshot.each do |hook| \n hook.direction = @direction\n hook.moveto(@x, @y)\n hook.char_steps = hook.index\n end\n @showing_hook = true\n RPG::SE.new(HookActionSe, 80).play\n @tool_anime = 30\n else\n Sound.play_buzzer\n end\n end\n end",
"def index\n @weapons = Weapon.all\n render :json => @weapons, :include => :special_rules\n \n end",
"def removeAllWeapons _args\n \"removeAllWeapons _args;\" \n end",
"def equip_weapon(weapon)\n remove_weapon\n if weapon.hands_used > free_hands\n remove_weapon(true)\n end\n add_weapon(weapon)\n end",
"def equipe_weapon(weapon)\n #equipe weapon\n #5 weapons to choice from\n #need to cover user's input to actual weapon stored in database\n # 1. blue light sabre\n # 2. blaster\n # 3. flame thrower\n # 4. invisible cloak\n # 5. jumpo jet pack\n\n case weapon\n when weapon == 1\n self.weapon = Weapon.find_by(name: \"Blue Light Saber\")\n when weapon == 2\n self.weapon = Weapon.find_by(name: \"Blaster\")\n when weapon == 3\n self.weapon = Weapon.find_by(name: \"Flame Thrower\")\n when weapon == 4\n self.weapon = Weapon.find_by(name: \"Jumbo Jet Pack\")\n else\n self.weapon = Weapon.find_by(name: \"Invisible Cloak\")\n end\n end",
"def discardWeapon(w)\n if @nWeapons > 0\n @nWeapons -= 1\n end\n end",
"def chooseBestSkill(context, pur, weapon_type, prop)\n p \"choose best skill for #{pur}/#{weapon_type} by #{prop}\"\n # p \"skills #{context[:skills]}(size=#{context[:skills].size})}\"\n attacker_skills = context[:skills]\n \n best_skill = {\n :skill => nil\n }\n best_skill[prop] = 0\n reg2 = Regexp.new(\"#{pur}\", true)\n if (weapon_type and weapon_type.length >0)\n reg = Regexp.new(\"#{weapon_type}\", true)\n else\n reg = /./i\n end\n p \"==>1#{attacker_skills.inspect}\"\n for skill in attacker_skills\n if (!skill || skill.category=='premier')\n next\n end\n skillname = skill.query_data(\"skname\")\n p \"===>skill = #{skill}\"\n p \"===>skill name =#{skillname}\"\n #context[:thisskill] = skill\n# purpose = query_skill(skillname, \"for\", skill, context)\n\n purpose = skill.for # usage: attack parry ...\n type = skill.type # skill type: unarmed, fencing, daofa...\n \n # if skill is for attacking and has correct type with weapon\n if type=~ reg and purpose=~reg2 \n # ret = query_skill(skillname, prop, skill, context)\n # ret = skill.query(prop, context)\n ret = skill_power(skill, context[:user], pur)\n p \"===>#{prop} of #{skillname}: #{ret} \\n\"\n if (ret.to_i > best_skill[prop])\n best_skill[prop] = ret\n best_skill[:skill] = skill\n end\n end\n\n \n #p \"target:\"+@target_class+\", cmd:\"+@cmd+\", param:\"+@cparam\n end\n if ( best_skill[:skill] == nil)\n #if not found, add basic skill for this type of skill\n _skname = weapon_type\n if (pur == 'dodge')\n _skname = 'dodge'\n elsif (pur == 'parry')\n _skname = 'parry'\n end\n if _skname == nil or _skname==\"\"\n raise \"skill name is nil\"\n end\n # us = Userskill.new({\n # :uid => context[:user][:id],\n # :sid => context[:user][:sid],\n # :skid => 0,\n # :skname => _skname,\n # :skdname => \"basic #{weapon_type}\",\n # :level => 0,\n # :tp => 0,\n # :enabled => 1 \n # })\n # us.save!\n us = context[:user].set_skill(_skname, 0, 0)\n attacker_skills.push(us)\n best_skill[:skill] = us\n end\n p \"==>best skill of #{context[:user].name} for #{pur}, skill_type #{weapon_type}: #{best_skill}\"\n return best_skill\n end",
"def test_healingSkill\n f = SkillFilter.new(\"healing\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 11\n end",
"def createWeapon\n weapon1 = Weapon.new(\"W1\",WeaponType::LASER,5)\n weapon2 = Weapon.new(\"W2\",WeaponType::MISSILE,7)\n weapon3 = Weapon.new(\"W3\",WeaponType::PLASMA,10)\n \n weapons = [weapon1,weapon2,weapon3]\n return weapons\n end",
"def weaponsTurret _obj, _args\n \"_obj weaponsTurret _args;\" \n end",
"def weaponDamage \n damage = self.weapon.damage\n if( self.weapon.type == :versatile && @shield.value == 0 )\n damage += 2\n end\n damage\n end",
"def weapons=(*)\n puts \"Error need to use add_weapon(weapon_name) or drop_weapon(weapon_name)\"\n end",
"def show_stats\n puts \"*********************************\"\n\n #check to see if the player has any weapons\n #display stats\n if self.weapons.size == 0\n puts \"Current Health:\".red + \" #{self.hp}\".bold\n puts \"Current Power:\".blue + \" #{self.power}\".bold\n\n #display\n else\n puts \"Current Health:\".red + \" #{self.hp}\".bold\n puts \"Current Power:\".blue + \" #{self.power}\".bold\n puts \"Equipped Weapon:\".green + \" #{self.highest_attack_power_weapon.name}\".bold\n end\n puts \"*********************************\"\n end",
"def fetch_weapons(doc)\n weapons = {}\n weapon_divs = doc.search(\"div.weapon_container\")\n weapon_divs.each do |weapon|\n weapon_stats = weapon/\"div.top\"\n name = (weapon_stats/\"div.title\").inner_html\n total = (weapon_stats/\"div:nth(4) div.number\").inner_html.gsub(\",\",\"\").to_i\n image = \"http://www.bungie.net#{(weapon_stats/\"div.overlay_img img\").first[:src]}\"\n weapons[[name, image]] = total\n end\n return weapons\n end",
"def fight\n return false if gladiators.size != 2\n\n # The names of each gladiator\n n1 = gladiators[0].name\n n2 = gladiators[1].name\n\n # Check for the special case that Maximus is around\n if n1 == \"Maximus\"\n remove(n2)\n return\n end\n\n if n2 == \"Maximus\"\n remove(n1)\n return\n end\n\n # If no Maximus, get weapons for each gladiator\n w1 = gladiators[0].weapon\n w2 = gladiators[1].weapon\n\n # If weapons are the same, remove both gladiators\n if w1 == w2\n remove(n1)\n remove(n2)\n else\n case w1\n when \"Spear\"\n # Spear loses to Trident but beats Club\n (w2 == \"Trident\") ? remove(n1) : remove(n2)\n when \"Trident\"\n # Trident loses to Club but beats Spear\n (w2 == \"Club\") ? remove(n1) : remove(n2)\n when \"Club\"\n # Club loses to Spear but beats Trident\n (w2 == \"Spear\") ? remove(n1) : remove(n2)\n end\n end\n end",
"def decide_which_weapon_token_to_discard weapons\n\t\t\tweapons[0]\n\t\tend",
"def attacks (player)\n damage = compute_damage\n\n puts \">>> Le joueur #{self.name} attaque le joueur #{player.name}\"\n\n puts \">>> Il lui inflige #{damage} points de dommages\"\n\n # Give damages to the \"player\" in argument\n player.gets_damage(damage)\n end",
"def attack #basic attack for now\r\n attack_value = strength + rand(25..50)\r\n puts \"#{@name} SWINGS his Weapon for #{attack_value} Points of Damage!\"\r\n end",
"def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n victory = false\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n emp_phase(@attacker)\n emp_phase(@defender)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n turn_fleet.each do |fleet|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if fleet[1] > 0 && fleet[2] > 0 \n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target==-1)\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if fleet[3] == 2\n mult = DamageType.find(fleet[3]).shield_mult\n end\n damage = fleet[2] * mult\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult = 1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if (fleet[3] == 1)\n mult = DamageType.find(fleet[3]).shell_mult\n end \n if fleet[3] == 3 and !fleet[6]\n mult = DamageType.find(fleet[3]).station_mult\n end\n if fleet[3] == 4 and fleet[0] == @plattform_id\n mult = DamageType.find(fleet[3]).plattform_mult\n end \n # Bestimme welche Einheit getroffen wurde\n victim = target_fleet[target]\n # Schadensberechnung\n damage = fleet[2] * mult\n # Berechne neue HP\n hit_points = victim[-2]\n victim[-2] = hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim, target_user)\n end\n end \n end\n # Füge Runden-Bericht ein\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue = false\n if turn_user == @attacker\n victory = true \n end\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user == @attacker\n @attacker_shield = @fight_shield\n else\n @defender_shield = @fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet = turn_fleet\n tmp_user = turn_user\n turn_fleet = target_fleet\n turn_user = target_user\n target_fleet = tmp_fleet\n target_user = tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n attacker_fleet_ary = []\n defender_fleet_ary = []\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n attacker_fleet_ary = turn_fleet\n defender_fleet_ary = target_fleet\n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n\n attacker_fleet_ary = target_fleet\n defender_fleet_ary = turn_fleet\n end\n update_fighting_fleet(@attacker_fleet, attacker_fleet_ary)\n update_fighting_fleet(@defender_fleet, defender_fleet_ary)\n ary = [@attacker_fleet, @defender_fleet] \n return [@report, @spy_report]\n end",
"def taking_damage_action\n if @warrior.feel(:backward).empty? && @health < 10\n @warrior.walk!(:backward)\n elsif @warrior.feel.empty?\n @warrior.walk!\n elsif @warrior.feel.enemy?\n @warrior.attack!\n end\n end",
"def compute_damage\n super * @weapon_level\n end",
"def discardWeapon(w)\n if @weapons.length != 0\n position = @weapons.index(w.type)\n if position != nil\n @weapons.delete_at(position)\n else\n raise \"WARNING! No weapon type match at Damage.discardWeapon()\"\n end\n end\n end",
"def show_wielding(wearer = \"You\")\n pronoun = nil\n output = nil\n if wearer == \"You\"\n output = \"You are wielding \"\n pronoun = \"your\"\n else\n output = \"#{wearer.pronoun.capitalize} is wielding \"\n pronoun = wearer.pronoun(:possessive)\n end\n\n wielding = []\n [:dual_wield, :left_wield, :right_wield].each do |pos|\n if @equipment[pos] and @equipment[pos][0]\n wielding << \"#{@inventory[@equipment[pos][0]].name} in #{pronoun} #{nice(pos)}\"\n end\n end\n\n if wielding.empty?\n if wearer == \"You\"\n output = [\"You are not wielding anything.\"]\n else\n output = [\"#{wearer.pronoun.capitalize} is not wielding anything.\"]\n end\n else\n [output << wielding.simple_list << \".\"]\n end\n end",
"def draw_weapon_kind\n item.w_types.each do |tipo|\n next if Vocab.wtype(tipo).nil?\n draw_detail(Vocab::EQUIP_KIND, Vocab.wtype(tipo))\n end\n end",
"def weapons_rack\n\t\t@components[ :weapons_rack ]\n\tend",
"def attack(troops)\n troops + self.level * troops\n end",
"def status\n monster = @game.current_room_model.monster\n return unless monster\n\n weapons = @game.player.weapons\n\n output = \"Fighting against #{monster.name}\\n\"\n weapons.each_with_index do |weapon, i|\n output << \"#{i + 1} - #{weapon}\\n\"\n end\n\n output\n end",
"def index\n @weapon_subtypes = WeaponSubtype.all\n end",
"def compute_damage\n rand(1..6) * @weapon_level\n end",
"def attackLoop(home)\n\t\tattacking = true;\n\t\t\n\t\twhile attacking\n\t\t\tputs \"Choose a weapon\";\n\t\t\tfor i in [email protected] do\n\t\t\t\tif(@player.inventory[i-1].uses < 0)\n\t\t\t\t\tputs \"#{i} - #{@player.inventory[i-1].name} Unlimited uses\"\n\t\t\t\telse\n\t\t\t\t\tputs \"#{i} - #{@player.inventory[i-1].name} #{@player.inventory[i-1].uses} uses\"\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tweaponNumber = gets.chomp.to_i;\n\t\t\tweapon = @player.inventory[weaponNumber - 1];\n\n\t\t\t# Player Attacks\n\t\t\thome.monsters.each do |monster|\n\t\t\t\tif(monster.type != \"person\")\n\t\t\t\t\tdamage = @player.attack * weapon.attack_modifier;\n\t\t\t\t\tmonster.takeDamage(damage, home);\n\t\t\t\t\tputs \"You damaged #{monster.type} with #{weapon.name} for #{damage}\";\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs \"\\n\";\n\n\t\t\t# Monsters Attack\n\t\t\thome.monsters.each do |monster|\n\t\t\t\[email protected](monster.attack);\n\t\t\t\tif(monster.type == \"person\")\n\t\t\t\t\tputs \"#{monster.type} gives you candy healing 1 Health Point\";\n\t\t\t\telse\n\t\t\t\t\tputs \"#{monster.type} hit you for #{monster.attack}\";\n\t\t\t\tend\n\n\t\t\t\tif(@player.health == 0)\n\t\t\t\t\treturn nil;\n\t\t\t\tend\n\t\t\tend\n\n\t\t\twait = gets.chomp; # wait so user can read screen before showing monster and player stats\n\t\t\tsystem(\"cls\");\n\t\t\thome.monsterStats();\n\t\t\tputs \"\\n\";\n\t\t\[email protected]();\n\t\t\twait = gets.chomp; # wait so user can read screen\n\t\t\tsystem(\"cls\");\n\n\t\t\tputs \"Do you want to attack again? (y or n)\";\n\t\t\tchoice = gets.chomp;\n\n\t\t\tif(choice == 'n')\n\t\t\t\tattacking = false;\n\t\t\tend\n\t\tend\n\tend",
"def compute_damage\n rand(1..6) * @weapon_level\n end",
"def fillWeaponsFromPool _args\n \"fillWeaponsFromPool _args;\" \n end",
"def power_ups\n @power_ups.map {|pup| Equip_Abilities.new(pup[0], pup[1], pup[2])}\n end",
"def attacks(attacked_player)\n # puts player1.name \n # print \"attacks\"\n # puts \"#{attacked_player}\"\n attacked_player.gets_damage(compute_damage)\n # puts \"He loses #{compute_damage} points\"\n end"
] | [
"0.6821203",
"0.6721752",
"0.63553125",
"0.6343425",
"0.6330356",
"0.632762",
"0.6274297",
"0.6239555",
"0.6230755",
"0.6191013",
"0.6146909",
"0.61043906",
"0.60969764",
"0.6093151",
"0.60868627",
"0.6005764",
"0.59790206",
"0.5972679",
"0.5971301",
"0.5964603",
"0.5951353",
"0.5950705",
"0.5942961",
"0.5908219",
"0.5908219",
"0.5908219",
"0.5905239",
"0.58899105",
"0.58899105",
"0.5876518",
"0.5851816",
"0.58472186",
"0.5835338",
"0.58309776",
"0.581089",
"0.5801311",
"0.5797412",
"0.5785186",
"0.5775451",
"0.57710654",
"0.57533634",
"0.5733984",
"0.5733311",
"0.5731437",
"0.5723304",
"0.5707001",
"0.5702581",
"0.56884795",
"0.5688219",
"0.56786644",
"0.5673427",
"0.56727797",
"0.56723714",
"0.566377",
"0.56613225",
"0.56609434",
"0.5651417",
"0.564487",
"0.56284624",
"0.5613958",
"0.55731946",
"0.556349",
"0.554833",
"0.55374306",
"0.5527133",
"0.5526915",
"0.5519762",
"0.5516088",
"0.5515775",
"0.55130434",
"0.55099076",
"0.5508355",
"0.5502555",
"0.5495964",
"0.5490935",
"0.5488658",
"0.5487419",
"0.54863507",
"0.5485872",
"0.5483044",
"0.5480969",
"0.54764414",
"0.547027",
"0.5458198",
"0.5435605",
"0.54300207",
"0.54255867",
"0.5416726",
"0.54071856",
"0.54069936",
"0.54011655",
"0.5395534",
"0.53925514",
"0.5369611",
"0.5368951",
"0.5367933",
"0.5366888",
"0.5365894",
"0.53629595",
"0.5360509"
] | 0.77990663 | 0 |
method for obtaining a player's difficulty setting this is solely based on the attack power of the current player | def get_difficulty
if self.power < 3
difficulty = 1
elsif self.power >= 3 && self.power < 6
difficulty = 2
else
difficulty = 3
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def difficulty\n request('getdifficulty')\n end",
"def getdifficulty\n coind.getdifficulty\n end",
"def board_difficulty\n Board.new.level\n end",
"def get_difficulty\n print \"Choose a difficulty level from 1 (easiest) to 10 (hardest): \"\n level = gets.chomp.to_i\n if (1..10).include? level\n return level\n else\n puts \"Not a valid difficulty level! Choose again.\\n\\n\"\n self.get_difficulty\n end\n end",
"def get_difficulty\n call_blockchain_api('getdifficulty').to_f\n end",
"def difficulty\n if @session_ratio > 85\n @level = 3\n @random = Question.where(difficulty: 'hard')[rand(40)]\n elsif @session_ratio > 60\n @level = 2\n @random = Question.where(difficulty: 'medium')[rand(40)]\n else\n @level = 1\n @random = Question.where(difficulty: 'easy')[rand(40)]\n end\n end",
"def skill_power(skillname, player, usage)\n p \"==>calc #{player.name} skill power of #{skillname} for #{usage}:\"\n skill = player.query_skill(skillname)\n if (skill == nil)\n #logger.info(\"user #{player[:id]}-#{player.ext[:name]} doesn't have skill '#{skillname}'\")\n return 1\n end\n # p = skill.power(context)\n level = skill.data[:level]\n p \"=>level=#{level} apply_attack=#{player.tmp[:apply_attack]} apply_dodge=#{player.tmp[:apply_dodge]}\"\n \n if (usage == \"attack\" && player.tmp[:apply_attack] != nil)\n level += player.tmp[:apply_attack]\n end\n \n if (usage == \"dodge\" && player.tmp[:apply_dodge] != nil)\n # level += player.tmp[:apply_dodge]\n level = level * ( (100 + player.tmp[:apply_dodge]/10 ).to_f / 100 )\n end \n \n # if (usage == \"parry\" && player.tmp[:apply_defense] != nil)\n # level += player.tmp[:apply_dodge]\n # end \n jingli_bonus = 50 + player.tmp[:jingli]/ (player.tmp[:max_jl]+1) * 50\n if (jingli_bonus > 150)\n jingli_bonus = 150\n end\n \n total_exp = calc_total_exp(player.tmp[:level])\n p \"level=#{level} jingli_bonus=#{jingli_bonus}, total exp #{total_exp}\"\n if( level<1 ) \n return (total_exp/20.0 * (jingli_bonus/10) ).to_i\n end\n\n \n p =level**3/3 \n str = player.tmp[:str]\n dext = player.tmp[:dext]\n # p \"===>#{player.tmp.inspect}\"\n \n p \"==>p=#{p}, level=#{level} str=#{str} dext=#{dext} \"\n if (usage == \"attack\" || usage == \"parry\")\n p = (p + total_exp +1) / 30 * (( str+1)/10)\n else\n p = (p + total_exp +1) / 30 * (( dext+1)/10)\n end\n \n p = p.to_i\n p \"==>skill power=#{p}\"\n \n if p <= 1\n return 1\n else\n return p\n end\n end",
"def getdifficulty\n @api.request 'getdifficulty'\n end",
"def current_difficulty_local\n getinfo = JSON.parse(`bitcoind getinfo`)\n return getinfo[\"difficulty\"].to_f\n end",
"def current_difficulty_online\n difficulty = `curl http://blockexplorer.com/q/getdifficulty`\n return difficulty.to_f\n end",
"def get_available_weapons(difficulty)\n\n#if the difficulty of the quest is 1\n#only select weapons with attack power less than or equal to 3\n# and that the player has not yet obtained\n if difficulty == 1\n available_weapons = Weapon.all.where(\"attack_power <=3\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n#if the difficulty of the quest is 2\n#only select weapons with attack power greater than 3 and less than or equal to 6\n# and that the player has not yet obtained\n elsif difficulty == 2\n available_weapons = Weapon.all.where(\"attack_power >3 and attack_power <= 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n\n#if the difficulty of the quest is 3\n#only select weapons with attack power greater than 6\n# and that the player has not yet obtained\n else\n available_weapons = Weapon.all.where(\"attack_power > 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n end\n end",
"def getSpecialValue\n combatLevel + @levelChangeAgainstCultistPlayer\n end",
"def skill_effect_power(user, skill)\r\n power = skill.power + user.atk * skill.atk_f / 100\r\n if power > 0\r\n power -= self.pdef * skill.pdef_f / 200\r\n power -= self.mdef * skill.mdef_f / 200\r\n power = [power, 0].max\r\n end\r\n return power\r\n end",
"def set_difficulty(choice=nil)\n\n\t\tputs '================================'\n\t\tputs '==== Choose your difficulty ===='\n\t\tputs '================================'\n\t\tputs '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'\n\t\tputs '^^^^^^ Type Your Choice: ^^^^^^^'\n\t\tputs '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'\n\t\tputs '$$$$$$$$$$$ 1. easy $$$$$$$$$$$$'\n\t\tputs '$$$$$$$$$$$ 2. hard $$$$$$$$$$$$'\n\t\tputs '$$$$$$$$$$$ 3. pvp $$$$$$$$$$$$'\n\t\tputs '--------------------------------'\n\n\t\tchoice = gets.chomp.to_i if !choice\n\n\t\tcase \n\n\t\t\twhen choice == 1\n\t\t\t\t@difficulty = \"easy\"\n\t\t\twhen choice == 2\n\t\t\t\t@difficulty = \"hard\"\n\t\t\twhen choice == 3\n\t\t\t\t@difficulty = \"pvp\"\n\t\t\twhen choice != 1 || choice != 2 || choice != 3\n\n\t\t\t\tputs '-------- Invalid Choice! -------'\n\t\t\t\tputs '---------- Pick Again! ---------'\t\n\t\t\t\tputs '--------------------------------'\n\n\t\tend\n\n\t\treturn @difficulty\n\n\tend",
"def pick_difficulty\n user_diff = $prompt.select(\"Pick a difficulty level\", [\"Easy\", \"Medium\", \"Hard\"])\n case user_diff\n when \"Easy\"\n $hide_speed = 3 \n $time_limit = 7\n when \"Medium\"\n $hide_speed = 2\n $time_limit = 6\n when \"Hard\"\n $hide_speed = 1.5\n $time_limit = 5\n end \n pre_game\nend",
"def set_attack_info\n case @attack_type\n when :magic\n @dice_pool = 6\n @opponent_armor = 2\n @opponent_save = 6\n when :ranged\n @dice_pool = @attacker.ranged_dice_pool\n @opponent_armor = @defender.armor_ranged\n @opponent_save = 5\n when :melee\n @last_attack_cac = true\n\n @dice_pool = @attacker.melee_dice_pool\n @opponent_armor = @defender.armor_cac\n @opponent_save = 4\n else\n raise \"Attack type unknown : #{@attack_type}\"\n end\n end",
"def difficulty \n \"difficulty\" \n end",
"def getBasicValue\n combatLevel \n end",
"def getCombatLevel\n combatLevel = @level\n @visibleTreasures.each { |treasure| combatLevel += treasure.getBonus}\n combatLevel\n end",
"def suggestedLevel\r\n minLevel = 1\r\n maxLevel = GameData::GrowthRate.max_level\r\n num = self.suggestedNumber\r\n for rule in @pokemonRules\r\n if rule.is_a?(MinimumLevelRestriction)\r\n minLevel = rule.level\r\n elsif rule.is_a?(MaximumLevelRestriction)\r\n maxLevel = rule.level\r\n end\r\n end\r\n totalLevel = maxLevel * num\r\n for rule in @subsetRules\r\n totalLevel = rule.level if rule.is_a?(TotalLevelRestriction)\r\n end\r\n return [maxLevel, minLevel].max if totalLevel >= maxLevel * num\r\n return [totalLevel / self.suggestedNumber, minLevel].max\r\n end",
"def difficulty\n\t\t\t\tshift = 8 * (((block_nBits >> 24) & 0xff) - 3)\n\t\t\t\tbits = block_nBits & 0x7fffff\n\t\t\t\tsign = block_nBits & 0x800000 ? 1 : -1\n\t\t\t\ttarget = sign * (shift >= 0 ? bits << shift : bits >> -shift)\n\t\t\t\treturn ((1 << 224) - 1) * 1000 / (target + 1) / 1000.0\n\t\t\tend",
"def DifficultySelect()\n puts \"┌─────────────────────────────┐\".center(CONSOLE_WIDTH)\n puts \"│ Select Difficulty │\".center(CONSOLE_WIDTH)\n puts \"├─────────────────────────────┤\".center(CONSOLE_WIDTH)\n puts \"│ (1) Easy - 20 guesses │\".center(CONSOLE_WIDTH)\n puts \"│ (2) Medium - 15 guesses │\".center(CONSOLE_WIDTH)\n puts \"│ (3) Hard - 10 guesses │\".center(CONSOLE_WIDTH)\n puts \"│ (4) Extreme - 5 guesses │\".center(CONSOLE_WIDTH)\n puts \"│ (5) Bullseye- 1 guess │\".center(CONSOLE_WIDTH)\n puts \"└─────────────────────────────┘\".center(CONSOLE_WIDTH)\n print \"Enter your choice: \".rjust(64)\n difficulty = gets.chomp.to_s\n if difficulty == \"1\"\n return 20\n elsif difficulty == \"3\"\n return 10\n elsif difficulty == \"4\"\n return 5\n elsif difficulty == \"5\"\n return 1\n else\n return 15\n end\nend",
"def sw_temp\n return $game_switches[SW_TEMP]\nend",
"def getdifficulty\n request :getdifficulty\n end",
"def effective_level\n level + level_bonus\n end",
"def difficulty(n)\n return nil if tournament_counters.empty?\n\n for i in 0..(tournament_counters.size - 1)\n return tournament_counters[i].difficulty if tournament_counters.map(&:counter)[0..i].sum >= n + 1\n end\n\n return tournament_counters.last.difficulty\n end",
"def mult_weapon_level (damagetype, user)\n if user == @attacker\n array = @attacker_level\n else\n array = @defender_level\n end\n mult = 0\n case damagetype\n when 1\n mult = array[2]\n when 2\n mult = array[3]\n when 3\n mult = array[4]\n end\n return mult\n end",
"def mult_weapon_level (damagetype, user)\n if user == @attacker\n array = @attacker_level\n else\n array = @defender_level\n end\n mult = 0\n case damagetype\n when 1\n mult = array[2]\n when 2\n mult = array[3]\n when 3\n mult = array[4]\n end\n return mult\n end",
"def getCombatLevel()\n sum_bonus=0\n \n while i< @visibleTreasures.size\n i=i+1\n sum_bonus = @visibleTreasures.fetch(i).bonus + sum_bonus\n end\n \n @level = @level + sum_bonus\n end",
"def skl_p_gain(type, target, obj = nil, user = nil)\n result = 0\n case type\n # ---------------------------------------------------------------------- #\n when :attack # type and battler are valid\n result = 5\n result += rand(10)\n # ---------------------------------------------------------------------- #\n when :guard # type and battler are valid\n result = 2\n result += rand(10)\n # ---------------------------------------------------------------------- #\n when :skill # type and battler are valid\n result = (target.action.skill.skl_level+1) * 2 unless target.action.skill.nil?\n result += rand(10)\n # ---------------------------------------------------------------------- #\n when :item # type and battler are valid\n result = 10\n result += rand(10)\n # ---------------------------------------------------------------------- #\n when :use # type, battler, obj, user are all valid\n result = obj.skl_p + 15\n if SKILL_MODE == 1 and obj.is_a?(RPG::Skill) # // If skill mode is exp\n obj.skl_exp += result if obj.skl_skill? # // if skill is a valid skill level\n end\n # ---------------------------------------------------------------------- #\n end\n # ---------------------------------------------------------------------- #\n target.skl_p += result\n # ---------------------------------------------------------------------- #\n return result # Doesn't do anything really, but just for the sake of it\n end",
"def get_exp\n exp = 0\n exp = (((@hero.max_health - @hero.cur_health) * 0.85) * @monster.level).round if @winner\n return exp\n end",
"def init(name, difficulty)\n case difficulty\n when 'easy'\n health = 100\n hunger = 100\n sanity = 100\n when 'medium'\n health = 50\n hunger = 50\n sanity = 50\n when 'hard'\n health = 25\n hunger = 25\n sanity = 25\n when 'arm fighter'\n health = 1\n hunger = 2\n sanity = 3\n end\n player = Player.new(name, health, hunger, sanity)\n game(player)\nend",
"def getCombatLevel\n tr_types = @visibleTreasures.map(&:kind)\n if tr_types.include? TreasureKind::NECKLACE\n return @visibleTreasures.inject(@level){ |sum,x| sum += x.maxBonus }\n else\n return @visibleTreasures.inject(@level){ |sum,x| sum += x.minBonus }\n end\n end",
"def attack()\n return @level + rand(3) - rand(3)\n end",
"def attack()\r\n\t\tweaponPower = @weapon.offensiveWeapon()\r\n\t\tif(@weapon.name == \"Shield\")\r\n\t\t\treturn (weaponPower*@strength)/2\r\n\t\telse\r\n\t\t\treturn weaponPower*@strength\r\n\t\tend\r\n\tend",
"def getOponentLevel(monster)\n monster.getBasicValue\n end",
"def atk_action_lmt\n return 0 if (b=battler).nil?\n b.attack_action_lmt + atk_lmt_equip_mod\n end",
"def get_difficulty\n Gotasku::DifficultyString.new(@doc.css(\"div.difficulty a\").text)\n end",
"def battler_hue\n return 0\n end",
"def getCombatLevel\n super + @myCultistCard.getSpecialValue\n end",
"def difficulty\n 1-correct.to_f/(correct+incorrect)\n end",
"def player_base\n @wealth = 0\n @fame = 0\n @current_exp = 0\n @exp_needed = 100\n @available_attribute_points = 30\n @total_proficiency_points = 1\n @available_proficiency_points = 1\n end",
"def getOponentLevel(m)\n m.getCombatLevel\n end",
"def full_attack_type\n read_attribute(:attack_type)\n end",
"def base_damage(level = @skl_level)\n return @skl_levelcache[level][:base_damage]\n end",
"def set_reqdifficulty\n @reqdifficulty = Reqdifficulty.find(params[:id])\n end",
"def digital_challenge_level\n case self.challenge_level\n when 'Low'\n 1\n when 'Medium'\n 2\n when 'High'\n 3\n end\n end",
"def xp_required\n 750 * ((@level + 1) ** 2)\n end",
"def skill_lmt_equip_mod\n return 0 if battler.nil? || !battler.is_a?(Game_Actor)\n battler.equips.inject(0) do |sum,e| \n mod = e.nil? ? 0 : (e.skill_acts_mod ||= 0)\n sum += mod\n end\n end",
"def skill_mod(player=nil)\n player ||= belongs_to_player\n t = total\n t -= 10\n t > 0 ? (t/2) : t\n end",
"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 player_capacity\n 2\n end",
"def attack_technique\n return @attack_technique\n end",
"def highest_attack_power_weapon\n weapon = self.weapons.sort_by do |weapon|\n weapon.attack_power\n end.last\n weapon\n end",
"def my_jump_strength\n 2.3*th\n end",
"def get_difficulty(difficulty)\n difficulty = Difficulty.find_by_difficulty_value(difficulty.downcase)\n if difficulty.nil? or difficulty.blank?\n difficulty = Difficulty.find_by_difficulty_value(\"not defined\")\n end\n return difficulty.id\n end",
"def calc_def_mod_metal_powder(user, target)\n return 1 unless target.db_symbol == :ditto\n target.moveset.each do |move|\n return 1 if move.db_symbol == :transform && move.used\n end\n return 1.5\n end",
"def difficulty_menu\n medium_rainbow_typer 'Select your desired difficulty'\n br\n TTY::Prompt.new.select('?') do |menu|\n menu.choice 'Easy', :d1\n menu.choice 'Medium', :d2\n menu.choice 'Hard', :d3\n menu.choice 'Insane', :d4\n end\n end",
"def set_power(watts)\n puts \"Setting Watts to #{watts.to_i} watts\" if $verbose\n w='PC'+(('000'+watts.to_i.to_s)[-3..-1])+';'\n puts w if $verbose\n ret=send_cmd(w,'PC;',w,0.25,1.0,3)\n if(ret)\n return(ret.gsub(/^PC/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend",
"def skill_effect_power0(skill)\r\n # If power is 0\r\n if skill.power == 0\r\n # Set damage to an empty string\r\n self.damage = \"\"\r\n # If state is unchanged\r\n unless @state_changed\r\n # Set damage to \"Miss\"\r\n self.damage = 'Miss'\r\n end\r\n end\r\n end",
"def knows? question\n @strength >= question.difficulty\n end",
"def show\n @total = Player.total\n @skill_limits = {\n min: Player.all.cached_minimum(:skill),\n max: Player.all.cached_maximum(:skill)\n }\n end",
"def target_lmt_equip_mod\n return 0 if battler.nil? || !battler.is_a?(Game_Actor)\n battler.equips.inject(0) do |sum,e| \n mod = e.nil? ? 0 : (e.target_acts_mod ||= 0)\n sum += mod\n end\n end",
"def evaluate_damage_power(user, obj, patk, matk, pdef, mdef)\n p_damage = (patk - pdef/2) * obj.atk_f / 100\n m_damage = (matk - mdef/2) * obj.spi_f / 200\n damage = (p_damage + m_damage)\n damage = (damage * XRXSV44::DamageValueRate).to_i\n damage += obj.base_damage.abs\n return damage\n end",
"def strength\n players.map{|p| p.strength}.reduce{|sum,n| sum + n}\n end",
"def level_bonus\n (MAX_LEVEL - level) / MAX_LEVEL\n end",
"def mod_damage_healed(team, v, set = false)\n gen_mod_data(team, v, :damage_healed, set)\n end",
"def attack(troops)\n troops + self.level * troops\n end",
"def calculatePower x,y\n\n # For example, to find the power level of the fuel cell at 3,5 in a grid with serial number 8\n # Find the fuel cell's rack ID, which is its X coordinate plus 10.\n # == The rack ID is 3 + 10 = 13.\n rackID = x + 10\n\n # Begin with a power level of the rack ID times the Y coordinate.\n # Increase the power level by the value of the grid serial number (your puzzle input).\n # Set the power level to itself multiplied by the rack ID.\n # == The power level starts at 13 * 5 = 65.\n # == Adding the serial number produces 65 + 8 = 73.\n # == Multiplying by the rack ID produces 73 * 13 = 949.\n powerLevel = (rackID * y + $serialNumber) * rackID\n\n # Keep only the hundreds digit of the power level (so 12345 becomes 3; numbers with no hundreds digit become 0).\n # The hundreds digit of 949 is 9.\n # Subtract 5 from the power level.\n # Subtracting 5 produces 9 - 5 = 4.\n powerLevel = powerLevel.to_s[-3].to_i-5\n\nend",
"def atk_lmt_equip_mod\n return 0 if battler.nil? || !battler.is_a?(Game_Actor)\n battler.equips.inject(0) do |sum,e| \n mod = e.nil? ? 0 : (e.batk_acts_mod ||= 0)\n sum += mod\n end\n end",
"def exp_lvl\n data = GameData::EXP_TABLE[exp_type]\n v = data[@level + 1]\n return data[@level] if !v || ($pokemon_party&.level_max_limit).to_i <= @level\n\n return v\n end",
"def target_tb_lmt\n return 0 if (b=battler).nil?\n b.target_tb_lmt + target_lmt_equip_mod\n end",
"def max_charging_power; end",
"def min_player\n return 0\n end",
"def weapon_reward(available_weapons)\n\n #reward is 1 random choice from this array\n reward = available_weapons.sample\n\n #create to CharacterWeapon object to show that player obtains weaopn\n CharacterWeapon.new_character_weapon(self.id, reward.id)\n\n #print weapon details to player\n puts \"#{reward.name}\".bold.blue\n puts \"Weapon Power: #{reward.attack_power}\"\n puts\"#####################################\".blink\n\n #actually equip the weapon, if it will increase this player's attack power\n if reward.attack_power > self.power - 1 || self.power == 1\n #increase the player's attack power\n self.update(power: 1+reward.attack_power)\n end\n end",
"def power\n data.power\n end",
"def level_cost(skill, level)\n return Integer((level*10) + (level*16))\n end",
"def human_player_and_ai(size)\n\tif first?()\n @player1 = \"player\"\n @player2 = difficulty(size,\"o\")\n else\n @player1 = difficulty(size,\"x\")\n @player2 = \"player\"\n end\nend",
"def game_set_up\n if mode == HUMAN\n disp_game_instructions\n # get computer generated solution\n @solution_obj.solution\n else\n # get solution player enters if valid\n @human_solution_obj.human_solution(@turn_obj)\n end\n end",
"def attack_bonus(lv)\n (110 * 3 * lv.to_f + 250) / 100 + 5\n end",
"def desired_xp\n return (200 * level * (level + 1)).to_i\n end",
"def ability_used(attack_type, mod_type)\n puts \"You used a #{attack_type} attack with a plus #{mod_type} increase!\"\nend",
"def returnTrainerLevel\r\n if !$Trainer\r\n @trainerLevel=0\r\n elsif $Trainer.party.length<1\r\n @trainerLevel=0\r\n else\r\n level=0; eggs=0\r\n for i in $Trainer.party\r\n if i.isEgg?\r\n eggs+=1\r\n else\r\n level+=i.level\r\n end\r\n end\r\n level=(level/($Trainer.party.length-eggs)).round\r\n if @trainerLevel\r\n if level>@trainerLevel\r\n @trainerLevel=level\r\n end\r\n else\r\n @trainerLevel=1\r\n end\r\n end\r\n return @trainerLevel\r\nend",
"def power\r\n return @access >> 26\r\n end",
"def base_atk\n weapon = $data_weapons[@weapon_id]\n return weapon != nil ? weapon.atk : 0\n end",
"def invention_chance\n\tbase_chance = 0.0\n\tgid = self.item.groupID\n\ttid = self.item.typeID\n\tif gid == 27 || gid == 419 || tid == 22544\n\t\tbase_chance = 0.2\n\telsif gid == 26 || gid == 28 || tid == 22548\n\t\tbase_chance = 0.25\n\telsif gid == 25 || gid == 420 || gid == 513 || tid == 22546\n\t\tbase_chance = 0.3\n\telse\n\t\tbase_chance = 0.4\n\tend\n\n# TODO determine which datacores are needed and the skill level associated with that datacore\n# character = Character.find(char_id)\n# encryption_skill_level = character.skill_level(...)\n# datacore_1_skill_level = character.skill_level(...)\n# datacore_2_skill_level = character.skill_level(...)\n\tencryption_skill_level = 3\n\tdatacore_1_skill_level = 3\n\tdatacore_2_skill_level = 3\n\tmeta_level = 0\n\tdecryptor_modifier = 1.0\n\tbase_chance * (1.0 + (0.01 * encryption_skill_level)) * (1.0 + ((datacore_1_skill_level + datacore_2_skill_level) * (0.1 / (5.0 - meta_level)))) * decryptor_modifier\nend",
"def champion(victorycondition) #algorythmic\n if @win_counter[\"P1\"]==victorycondition\n return @Player1\n elsif @win_counter[\"P2\"]==victorycondition\n return @Player2\n else \n return nil\n end \n end",
"def attack(weapon)\n rand(10) + weapon.power\n end",
"def set_force_power\n @force_power = ForcePower.friendly.find(params[:id])\n end",
"def getSpecialValue\n maxBonus\n end",
"def determine_tactic\n #Override retreat if physical attack\n if attack?\n @tactic = 1\n elsif skill?\n if !item.nil?\n @tactic = 2\n end\n else\n @tactic = 3\n end\n end",
"def levels_away_from_req(user, quest)\n difference = quest.level_requirement - user.total_level\n return difference.to_s\n end",
"def attack(target)\n\n #check to see if there is any target\n if target == nil\n puts \"Invite some friends to play this awesome game.\".blue\n\n else\n #print fighting for the user\n\n puts Artii::Base.new.asciify \"Fight\"\n\n\n\n ###methods for determining probability of victory\n ###and damage to the opponent or current user#####\n\n #if the characters have the same attack power\n if self.power == target.power\n\n #if the player wins the battle\n if rand > 0.5\n\n #reduce the target's hp by 10\n target.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #see if the target is still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a greater attack power than that of the target\n elsif self.power > target.power\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand < (0.4 + ((self.power - target.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-5*(self.power - target.power))\n\n #print outcome of the battle\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a lower attack power than that of the target\n else\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand > (0.45 + ((target.power - self.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-2*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-3*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n end\n end\n end",
"def conform_attack_strength\n rng = rand(0.7..0.9)\n self.attack_strength = (attack_strength > 20 * rng) && new_record? ? (20 * rng).to_i : attack_strength\n end",
"def choose_attack\n\t return @battle_commands[Random.rand(@battle_commands.length)]\n\tend",
"def calculate_points_for_quest(quest)\n diff_pts = quest.difficulty_level * 1.2\n level_scaling = quest.level_requirement\n pts = (diff_pts + level_scaling) * 20\n return pts.to_i\n end",
"def gain_chest_item\n $game_party.gain_item(online_chest.item, 1)\n end",
"def attack_type\n return @attack_type\n end",
"def attack_multiplier(atk_type, def_prim, def_sec)\n mul = type_multiplier(atk_type, def_prim)\n mul *= type_multiplier(atk_type, def_sec) if def_sec\n mul\n end",
"def power_state(action = \"status\")\n connection.fetch(:hosts, :power, \"id\" => manager_ref, \"power_action\" => action).first[\"power\"]\n end"
] | [
"0.68832654",
"0.6792101",
"0.6691086",
"0.66792303",
"0.6627899",
"0.6560039",
"0.63671064",
"0.6296457",
"0.6250317",
"0.62473434",
"0.6165845",
"0.6142915",
"0.6096492",
"0.6067504",
"0.59626585",
"0.59383005",
"0.59337896",
"0.5933285",
"0.5900958",
"0.58601665",
"0.58581966",
"0.5818825",
"0.5800556",
"0.5792544",
"0.5770432",
"0.5728797",
"0.57084715",
"0.5708164",
"0.5690307",
"0.5682428",
"0.56762177",
"0.565987",
"0.56517327",
"0.56407744",
"0.56268775",
"0.56152165",
"0.5611237",
"0.5590722",
"0.55835974",
"0.55494726",
"0.55436814",
"0.5541781",
"0.55317116",
"0.55177075",
"0.5505134",
"0.54902947",
"0.5486534",
"0.54723746",
"0.5455152",
"0.54453206",
"0.5438701",
"0.5435639",
"0.5405088",
"0.53990734",
"0.53859353",
"0.5383803",
"0.53538305",
"0.53384125",
"0.5332585",
"0.5293902",
"0.5292203",
"0.52884024",
"0.52873707",
"0.52865964",
"0.5277949",
"0.5265869",
"0.5265091",
"0.5252667",
"0.52477014",
"0.5243221",
"0.52397853",
"0.523759",
"0.52352285",
"0.5234919",
"0.5223345",
"0.5222994",
"0.5222151",
"0.52104455",
"0.52091587",
"0.52078545",
"0.5205656",
"0.5203642",
"0.5198769",
"0.51957375",
"0.51905715",
"0.518023",
"0.517749",
"0.51699585",
"0.51649386",
"0.5158038",
"0.51544434",
"0.51528525",
"0.5122761",
"0.51133484",
"0.51107264",
"0.51056576",
"0.5103635",
"0.51021844",
"0.51013947",
"0.509663"
] | 0.8061097 | 0 |
method for player executing a quest | def quest_interface
#obtain the difficulty level for the given player
difficulty = self.get_difficulty
#see if the player has any quests left to complete
if self.get_recommended_quests(difficulty).size == 0
puts "=====================================".red
puts "=====================================".red
puts "You have completed all recommended quests!!!".bold
puts "=====================================".red
puts "=====================================".red
#show the player the available quests
else
puts "=====================================".red
puts "=====================================".red
puts "Recommended Quests for Player Attack: #{self.power}".blue.on_light_green.bold
puts ""
self.print_quests(difficulty)
puts "=====================================".red
puts "=====================================".red
puts "Select a quest number".bold.white.on_light_blue
puts "Number:".bold.white.on_light_blue
#selection prompt the player to actually choose a quest
selection = gets.chomp
#check for invalid input
if selection.to_i > self.get_recommended_quests(difficulty).size || selection.to_i < 1
puts "Invalid input, please try again!".red.bold
#if input is valid, show the player that he has completed the quest
else
puts"*******************************************"
puts "You have completed: #{self.get_recommended_quests(difficulty)[selection.to_i-1].title}".bold
puts"*******************************************"
puts " "
puts"#####################################".blink
puts "Time For Your Reward Adventurer!!!".bold.blue.on_light_yellow
#obtain the available weapons based on player difficulty
available_weapons = self.get_available_weapons(difficulty)
#create the new characterquest instance to show that player has completed the quest
self.quest_selection(selection, difficulty)
#run the weapon_reward method to get reward for the quest
self.weapon_reward(available_weapons)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quest; end",
"def run_quest\n original_power = @todays_hero.power\n system \"clear\"\n subtitle_print('Start Quest')\n power_update = Quest.find_new\n @todays_hero.increase_power_by(power_update)\n system \"clear\"\n if @todays_hero.power > original_power\n puts \"Congrats! Your power increased by #{power_update}.\"\n puts \"Your power is now #{@todays_hero.power}.\"\n elsif @todays_hero.power == original_power\n puts \"Evil doesn't wait for the slow and idle.\"\n puts \"Your power remains at #{@todays_hero.power}.\"\n elsif @todays_hero.power < original_power\n puts \"The world weeps for the strong and courageous.\"\n puts \"Your power has decreased to #{@todays_hero.power}.\"\n end\n @todays_hero.save\n end",
"def call_quest_journal\n @quest_journal_calling = false\n Sound.play_ok\n SceneManager.call(Scene_Quest)\n end",
"def quest(id) \n\tsys('quest')\n\t$progress.add_quest(id) \n\tpop_quest(id)\n\t$scene.hud.quest_sparkle(\"misc/profile\")\nend",
"def quest(quest_id); $game_party.quests[quest_id]; end",
"def mechanic_quest; end",
"def fence_quest; end",
"def therapist_quest; end",
"def ai_action()\n # sleep 3\n player = get_player(self.current_player)\n action_info = ai_one_logic(player)\n if player.ai == \"2\"\n action_info = ai_two_logic(player)\n end\n action(action_info[0], action_info[1], player.id) # this progresses current player and may progress round\n self.save\n end",
"def completeQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.completeQuest(quest,color,story)\nend",
"def peacekeeper_quest; end",
"def call_quest_journal(quest_id = nil)\n return if $game_party.in_battle\n $game_system.last_quest_id = quest_id if quest_id\n SceneManager.call(Scene_Quest)\n Fiber.yield\n end",
"def command_use_point\r\r\n if $game_actors[@actor.id].skill_tree[0] == 0 || confirm_skill_add\r\r\n Sound.play_buzzer\r\r\n @confirm.close\r\r\n @confirm.active = false\r\r\n else\r\r\n @skills_icons[@skill_selected].opacity = 255\r\r\n $game_actors[@actor.id].skill_tree[0] -= 1\r\r\n $game_actors[@actor.id].lose_jp(Actor[@actor.id][@skill_selected]['JP'])\r\r\n $game_actors[@actor.id].skill_mult[Actor[@actor.id][@skill_selected]['Skill_id']] += Actor[@actor.id][@skill_selected]['Multiply']\r\r\n $game_actors[@actor.id].skill_tree[Actor[@actor.id][@skill_selected]['Skill_id']] += 1\r\r\n $game_actors[@actor.id].learn_skill(Actor[@actor.id][@skill_selected]['Skill_id'])\r\r\n @info_window.refresh(@actor, @tree)\r\r\n Audio.se_play(\"Audio/SE/Skill3\",75,100)\r\r\n @confirm.close\r\r\n @confirm.active = false\r\r\n if $game_switches[19] # achievement available?\r\r\n #------------------------------------------------------------------------------- \r\r\n # Trophic: Markspony\r\r\n #-------------------------------------------------------------------------------\r\r\n earn_trophic = true\r\r\n for i in 546..561\r\r\n if !$game_actors[@actor.id].skill_learned?(i) && !$ACH_markspony\r\r\n earn_trophic = false\r\r\n break\r\r\n end\r\r\n end\r\r\n \r\r\n if earn_trophic && !$ACH_markspony\r\r\n $ACH_markspony = true\r\r\n GameJolt.award_trophy(\"53491\")\r\r\n p sprintf(\"Achievement unlock - markspony\")\r\r\n $game_system.earn_achievement(:markspony)\r\r\n end\r\r\n #------------------------------------------------------------------------------- \r\r\n # Trophic: Elementalist\r\r\n #------------------------------------------------------------------------------- \r\r\n earn_trophic = true\r\r\n for i in 563..582\r\r\n next if i == 567 || i == 571 || i == 577 || i == 581 \r\r\n if !$game_actors[@actor.id].skill_learned?(i) && !$ACH_elementalist\r\r\n earn_trophic = false\r\r\n break\r\r\n end\r\r\n end\r\r\n \r\r\n if earn_trophic && !$ACH_elementalist\r\r\n $ACH_elementalist = true\r\r\n GameJolt.award_trophy(\"53485\") \r\r\n p sprintf(\"Achievement unlock - elementalist\")\r\r\n $game_system.earn_achievement(:elementalist)\r\r\n end\r\r\n #---------------------------------------------------\r\r\n end\r\r\n end\r\r\n end",
"def prapor_quest; end",
"def actions\n answer = @prompt.select(\"Where will you go?\", %w(Foward Back Status Items), cycle:true, per_page:4)\n if answer == \"Foward\"\n if @zone_cur == 10\n narrate(\"you leave the #{self.name}\")\n leave(self.exit_name)\n else\n @zone_cur += 1\n narrate(\"you continue foward\")\n encounter_check\n end\n elsif answer == \"Back\"\n if @zone_cur == 0\n narrate(\"you leave the #{self.name}\")\n leave(self.entrance_name)\n else\n @zone_cur -= 1\n narrate(\"you retreat backwards\")\n encounter_check\n end\n elsif answer == 'Status'\n narrate(\"#{@player.name} has #{@player.hp} hp, #{@player.attack} attack, and #{@player.defence} defence\")\n str = \"\"\n a = @player.equipment.map do |el|\n el.name\n end\n b = a.join(\", \")\n narrate(\"#{@player.name} has the following items equipped: #{b}\")\n here\n elsif answer == 'Items'\n answer = @prompt.select(\"Items Menu\", %w(Equip_item Look_item), cycle:true, per_page:4)\n if answer == 'Equip_item'\n #list inventory\n stuff = @player.items.map do |el|\n el.name\n end\n #select an item from inventory\n answer = @prompt.select(\"Items Menu\", stuff, cycle:true, per_page:4)\n #find that item again\n to_eq = @player.items.find do |el|\n el.name == answer\n end\n binding.pry\n #equip that item\n @player.equip(to_eq)\n narrate( \"You have equipped the #{to_eq.name}!\")\n actions\n end\n end\n end",
"def add_quest(dbn,n,d,kgg,kgn,exp,sr,gr,loot,kgc,qs)\n\t\t\t@player_data_db.execute \"insert into quests values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\", nil,dbn,n,d,kgg,kgn,exp,sr,gr,loot,kgc,qs\n\t\tend",
"def quest\n @quest ||= Quest.find(params[:id])\n end",
"def quest_params\n params.require(:quest).permit(:user_id, :quest, :result)\n end",
"def completed_quests; $game_variables[17]; end",
"def run_round\n switch_player!\n question = Question.new\n puts \"----- NEW TURN -----\"\n puts \"#{@active_player.name} : #{question.display_question} \"\n answer = gets.chomp.to_i\n\n if question.correct?(answer)\n puts \"#{@active_player.name} : YES! You are correct.\"\n puts \"P#{@players[0].name[-1,1]} : #{@players[0].life}/3 vs P#{@players[1].name[-1,1]} : #{@players[1].life}/3\"\n else\n puts \"#{@active_player.name} : Seriously? No!\"\n @active_player.minuslife\n puts \"P#{@players[0].name[-1,1]} : #{@players[0].life}/3 vs P#{@players[1].name[-1,1]} : #{@players[1].life}/3\"\n end\n end",
"def skier_quest; end",
"def activateQuest(quest,color=colorQuest(nil),story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.activateQuest(quest,color,story)\nend",
"def execute\n if inquisition.buff_remaining == 0\n guardian_of_ancient_kings.attempt\n inquisition.attempt\n end\n\n # Cast Crusader Strike if we dont have 3 HP\n if holy_power < 3\n crusader_strike.attempt\n end\n\n # If I have less than 3 seconds of Inquisition left, refresh regardless\n # of current level of holy power\n if inquisition.buff_remaining < 3\n guardian_of_ancient_kings.attempt\n inquisition.attempt\n end\n\n # Cast TV if we can\n if has_holy_power(3)\n use_trinkets\n avenging_wrath.attempt \n if(zealotry.usable?)\n zealotry.attempt\n heroism.attempt\n end\n templars_verdict.attempt\n end\n\n # If Crusader Strike will be up shortly, just wait for it\n return if crusader_strike.cooldown_remaining <= 0.1\n\n exorcism.attempt\n hammer_of_wrath.attempt \n\n # If Crusader Strike will be up shortly, just wait for it\n return if crusader_strike.cooldown_remaining <= @delay\n\n judgement.attempt \n holy_wrath.attempt\n consecration.attempt if @consecrate\n end",
"def get_completed_quests\n\n#check if the player has actually completed any quests\n#if he has not, tell him\n if self.quests.size == 0\n puts \"You have not completed any quests!!!\".red\n\n#otherwise, pull the completed quest objects and print the quest titles\n else\n puts \"Completed Quests:\".underline\n self.quests.each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end\n end",
"def perform(player)\n puts \"#{player.name} encounters a #{@name}.\"\n puts @art\n puts @encounter_intro\n\n options_index = 0\n for option in options\n puts \"#{options_index + 1}. #{option}\"\n options_index += 1\n end\n\n print \"Enter your choice: \"\n players_choice = gets.strip.to_i - 1 # 0->3\n puts @consequences[players_choice]\n\n\n # Apply the consequence.\n case players_choice \n when 0 \n player.lose_all_gold\n when 1\n when 2\n # if player.stamina >= 5\n player.exert_yourself(5)\n player.take_damage(5)\n player.acquire_gold(10)\n when 3\n # player.health -= 2\n player.take_damage(2)\n end\n end",
"def execute( command, timeout=6 )\n send_question( { type: 'code', message: command }, timeout)\n end",
"def update_call_quest_journal\n if $game_map.interpreter.running?\n @quest_journal_calling = false\n else\n if Input.trigger?(QuestData::MAP_BUTTON)\n $game_system.quest_access_disabled || $game_party.quests.list.empty? ?\n Sound.play_buzzer : @quest_journal_calling = true\n end\n call_quest_journal if @quest_journal_calling && !$game_player.moving?\n end\n end",
"def do_player_turn\n eval_popup_queue\n start_player_turn if !@player_turn_init\n tbs_unit_selection \n \n map = $game_map\n show_unit_hud(map.events[map.tbu_id_xy($game_player.x,$game_player.y)])\n update_all_sh_acts_win\n update_hl_follow if TM.selecting_target?\n hide_skill_disp_win\n preview_effect_tb\n end",
"def ragman_quest; end",
"def perform(cmd, game)\n case cmd\n when :hit\n game.deal_card_to_player\n when :stand\n game.playing = false # conclude player's turn\n dealer = DealerFactory.create( game.dealer_type )\n dealer.play( game )\n end\n \n outcome = solve(game)\n game.playing = false unless outcome[:winner] == :none\n \n outcome\n end",
"def perform\n\tgame_menu\n\tgameplay\nend",
"def quest_book\n GamePlay::QuestBookMenu.new.main\n Graphics.transition\n @wait_count = 2\n end",
"def start\n setPlayers\n question\nend",
"def update_quest_tbl\n\t\t\tbegin\n\t\t\t\t@player_data_db.execute (\"DELETE from quests\")\n\t\t\trescue\n\t\t\t\tputs \"Searching for jobs\"\n\t\t\tend\n\t\t\t# Execute inserts\n\t\t\t#[ db_name, quest_name, descrip, k_g_goal, k_g_name, exp_reward, silver_reward, gold_reward, loot_reward, k_g_count, q_status] ** q_tatus A = Active, C = Completed, D = Dropped\n\t\n\t\t\t[\t\t\t\t\n\t\t\t\t#[\"kill_rats\", \"eRATicate\", \"Kill 10 small rats\",1, \"small_rat\",25,0,3,\"apple_basket\",0,\"A\"],\n\t\t\t\t[\"get_wood\", \"Woody\", \"Gather 15 soft wood\",1, \"soft_wood\",25,0,3,\"none\",0,\"A\"]\n\t\t\t\t\n\t\t\t].each do |dbn,n,d,kgg,kgn,exp,sr,gr,loot,kgc,qs|\n\t\t\t\t@player_data_db.execute \"insert into quests values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\", nil,dbn,n,d,kgg,kgn,exp,sr,gr,loot,kgc,qs\n\t\t\tend\n\t\tend",
"def start_player_quest_line(player_id)\n quest_ids = without_locking do\n Quest.select(\"`id`\").where(parent_id: nil)\n end.c_select_values\n quest_progresses = quest_ids.map do |quest_id|\n QuestProgress.new(player_id: player_id, quest_id: quest_id)\n end\n BulkSql::QuestProgress.save(quest_progresses)\n\n objective_ids = without_locking do\n Objective.select(\"`id`\").where(quest_id: quest_ids)\n end.c_select_values\n objective_progresses = objective_ids.map do |objective_id|\n ObjectiveProgress.new(player_id: player_id, objective_id: objective_id)\n end\n BulkSql::ObjectiveProgress.save(objective_progresses)\n end",
"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 set_quest\n @quest = Quest.find(params[:id])\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def set_quest\n @quest = Quest.find(params[:id])\n end",
"def run\n puts \"------------------ NEW TURN ------------------\"\n ask_question\n get_answer\n validate_answer\n end",
"def do_command0\n data = nil\n call_scene(WantedDataScene) { |scene| data = scene.wanted_data }\n return unless data.is_a?(Array)\n\n list = Core.get_pokemon_list(data)\n return display_message(ext_text(8997, 8)) if list.first == 'nothing'\n\n pokemon_list = list.collect { |i| Core.download_pokemon(i).to_pokemon }\n return display_message(ext_text(8997, 9)) if pokemon_list.include?(nil)\n\n loop do\n break unless (index = select_pokemon(pokemon_list))\n\n wanted_data = Core.download_wanted_data(list[index])\n return display_message(ext_text(8997, 11)) if wanted_data.empty?\n next unless confirm_wanted_data(wanted_data)\n break unless (choice = choose_pokemon)\n\n pkmn = choice >= 31 ? $actors[choice - 31] : $storage.info(choice - 1)\n next display_message(ext_text(8997, 12)) unless pokemon_matching_requirements?(pkmn, wanted_data)\n\n return GTS.finish_trade(pkmn, pokemon_list[index], true, choice, list[index])\n end\n end",
"def turn\n @player_1.new_question\n check_score\n @player_2.new_question\n check_score\n match_stats\n puts \"-----NEW-TURN-----\"\n turn\n end",
"def failQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.failQuest(quest,color,story)\nend",
"def turn_game\n\t\t@player_1.new_question\n\t\tcheck_score\n\t\t@player_2.new_question\n\t\tcheck_score\n\t\tcheck_status\n\t\tputs '------------NEW-TURN-------------'\n\t\tturn_game\n\tend",
"def next_q(nick = @config[:nick])\n self.say \"\\0032Correct\\0033 #{nick}.\\0032 The answer was:\\0034 #{@questions[@trivia[:cur_quest]][:answer]}\"\n if @questions.length > (@trivia[:number] + 1)\n @trivia[:cur_quest] = (rand @questions.length)\n self.ask_question(@trivia[:cur_quest])\n else\n self.trivia_end\n end\n end",
"def other_responses\r\n\tif @user_command.include?(\"hot\") &&\r\n\t\t@user_command.include?(\"dog\")\r\n\t\tif @inventory.include?(\"Hot Dog\")\r\n\t\t\[email protected](\"Hot Dog\")\r\n\t\t\ttake_health_hit(-3)\r\n\t\t\tplayer_update_vitals\r\n\t\t\treload_display\r\n\t\t\tputs \"You ate your hot dog.\"\r\n\t\t\tputs \"Health increased by 3.\"\r\n\t\telse\r\n\t\t\tputs \"You don't have a hot dog.\"\r\n\t\tend\r\n\telse\r\n\t\tputs \"You can't do that.\"\r\n\tend \r\nend",
"def activateQuest(quest,color,story)\n if !quest.is_a?(Symbol)\n raise _INTL(\"The 'quest' argument should be a symbol, e.g. ':Quest1'.\")\n end\n for i in 0...@active_quests.length\n if @active_quests[i].id == quest\n pbMessage(\"You have already started this quest.\")\n return\n end\n end\n for i in 0...@completed_quests.length\n if @completed_quests[i].id == quest\n pbMessage(\"You have already completed this quest.\")\n return\n end\n end\n for i in 0...@failed_quests.length\n if @failed_quests[i].id == quest\n pbMessage(\"You have already failed this quest.\")\n return\n end\n end\n @active_quests.push(Quest.new(quest,color,story))\n pbMessage(_INTL(\"\\\\se[{1}]<ac><c2=#{colorQuest(\"red\")}>New quest discovered!</c2>\\nCheck your quest log for more details!</ac>\",QUEST_JINGLE))\n end",
"def perform(user, questions)\n \n end",
"def turn\n puts display\n # User shooting at NPC board.\n user_shot_location = user_shot_turn\n @npc.board.board_hash[user_shot_location].fire_upon\n # NPC shooting at user board.\n npc_shot_location = npc_shot_turn\n @user_board.board_hash[npc_shot_location].fire_upon\n # Print the results of combat.\n print results(user_shot_location, npc_shot_location)\n end",
"def create\n @quest = Quest.new(params[:quest])\n @quest.creator_id=Profile.where(:users_id=>current_user.id)[0].id\n if iAmQuestMaster @quest.speciality_id\n if (getMyQuestMasterLevel (@quest.speciality_id))>(@quest.level)\n respond_to do |format|\n if @quest.save\n format.html { redirect_to @quest, notice: 'Quest was successfully created.' }\n format.json { render json: @quest, status: :created, location: @quest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to \"/\", notice: 'No tienes el nivel suficiente para crear esta quest!'\n end\n else\n redirect_to \"/\", notice: 'No tienes la especialdidad necesaria para crear esta quest!'\n end\n end",
"def execute actor, target=[nil]\n def himher thing\n multiple = thing.count > 1 \n\n if multiple \n return \"them\"\n end\n\n case thing[0]\n when Player then \"him\"\n when ItemFacade then \"it\"\n else \"\"\n end\n end\n room_msg, self_msg, vict_msg = @ofound.dup, @found.dup, @tfound.dup\n\n\n if target.include?(actor) # if they're the same person then it's an auto\n target = [actor]\n room_msg = @oauto.dup\n self_msg = @auto.dup\n vict_msg = nil\n elsif target[0] == nil\n room_msg = @onoarg.dup\n self_msg = @noarg.dup\n vict_msg = nil\n end\n room_msg.gsub!(\"$n\", \"<%=other.peek(actor)%>\")\n room_msg.gsub!(\"$N\", \"<%=other.peek(if arg[0].include?(other) then arg[0]-[other]+['You'] else arg[0] end)%>\")\n room_msg.gsub!(\"$m\", himher([actor]))\n room_msg.gsub!(\"$M\", himher(target))\n\n self_msg.gsub!(\"$M\", himher(target))\n self_msg.gsub!(\"$m\", himher([actor]))\n if target\n self_msg.gsub!(\"$N\", actor.peek(target))\n end\n actor.view(\"#G\"+self_msg+\"#n\" + ENDL)\n \n room_msg.untaint\n if target[0]\n if target.count > 1 \n actor.in_room.display([:visual, \"other.can_see?(actor) || other.can_see?(arg[0])\"], actor, [actor], \"#G\"+room_msg+\"#n\", target)\n else\n actor.in_room.display([:visual, \"other.can_see?(actor) || other.can_see?(arg[0])\"], actor, [actor, *target], \"#G\"+room_msg+\"#n\", target)\n target.each do |one_targ|\n vm = vict_msg.dup\n vm.gsub!(\"$n\", one_targ.peek(actor))\n one_targ.view(\"#G\"+vm+ \"#n\" + ENDL)\n end\n end\n else\n puts room_msg\n actor.in_room.display([:visual, \"other.can_see?(actor)\"], actor, [actor], \"#G\"+room_msg+\"#n\", \"\")\n end\n end",
"def new_turn(player)\n num1 = random_number\n num2 = random_number\n operation = random_op\n puts generate_question(num1, num2, player, operation)\n player_input = get_answer\n if correct_answer?(num1, num2, player_input,operation)\n puts answer_is_correct\n else\n puts answer_is_incorrect\n lose_life(player)\n end\n game_status(player_lives(player), player)\nend",
"def hit\n @printer = []\n @printer << \"You Hit.\"\n deal_player\n pl_total\n if session[:player].bust? || session[:player].hand_total == 21\n @action = :end\n run_dealer\n else\n @action = :choice\n end\n chat\n end",
"def play(cmd)\n play_game(cmd)\n end",
"def display_question(player)\n puts \"#{player.name}'s turn:\"\n print \"Evaluate the following expression: \"\n puts create_question\n get_response\n puts \"The answer was #{validate_response(player)}.\"\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 advanceQuestToStage(quest,stageNum,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.advanceQuestToStage(quest,stageNum,color,story)\nend",
"def run_round\n increment_round!\n switch_player!\n question = Question.new(@question_cap)\n puts \"________ Question #{@which_round} ________\"\n puts \"#{@active_player.name}, you have #{@active_player.lives} #{(@active_player.lives) == 1 ? \"life\" : \"lives\"} remaining.\\n\"\n print \"#{@active_player.name}, #{question.display_question} \"\n answer = gets.chomp.to_i\n\n if question.correct?(answer)\n puts \"Well done, #{@active_player.name}! #{answer} was the correct answer. You don't die today.\\n...So, let's make the questions HARDER.\\n\\n\"\n @question_cap = (@question_cap*rand(1.0..2.5)).to_i\n else\n puts \"Yegads, #{answer}?! Nope, nope, nope. It was #{question.correct_answer}. You DIE! (Once.)\\n\\n\"\n @active_player.lose_life\n end\n end",
"def reveal_quest(quest_id); quest(quest_id).concealed = false; end",
"def update\n @quest = Quest.find(params[:id])\n if iAmQuestMaster @quest.speciality_id\n if (getMyQuestMasterLevel (@quest.speciality_id))>(@quest.level)\n respond_to do |format|\n if @quest.update_attributes(params[:quest])\n format.html { redirect_to @quest, notice: 'Quest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quest.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to \"/\", notice: 'No tienes el nivel suficiente para editar esta quest!'\n end\n else\n redirect_to \"/\", notice: 'No tienes la especialdidad necesaria para editar esta quest!'\n end\n end",
"def quest_revealed?(quest_id)\n $game_party.quests.revealed?(quest_id)\n end",
"def execute_mission\n puts \"\"\n puts \"Executing mission: #{@mission.name}.\"\n\n @mission.execute_launch_procedure\n update_session_statistics\n\n if @mission.exploded?\n explosion_protocol\n elsif @mission.aborted?\n mission_abort_protocol\n end\n end",
"def execute_action_skill\n # Call a custom battle method\n ty_execute_action_skill\n # Call the original battle method if still attacking\n if @active_battler.action.kind == 1\n ty_ammo_requirements_execute_skill\n end\n end",
"def round_gameplay\n # new question\n self.q.generate_question\n \n question = self.q.questions[-1][:question]\n answer = self.q.questions[-1][:answer]\n questioner = self.players[0]\n # ask question\n puts \"#{questioner.name}: #{question}\"\n input = gets.chomp\n \n if self.answer_correct?(input, answer) == true\n puts \"#{questioner.name}: #{questioner.opponent_correct}\"\n else\n puts \"#{questioner.name}: #{questioner.opponent_incorrect}\"\n self.players[1].lose_life\n end\n\n if self.winner?\n # if there is a winner declare the winner and call game over\n self.declare_winner(self.players[0])\n self.game_over\n else\n # otherwise display both players scores and carry on\n self.display_lives\n end\n end",
"def playMission _args\n \"playMission _args;\" \n end",
"def destroy\n @quest = Quest.find(params[:id])\n if iAmQuestMaster @quest.speciality_id\n if (getMyQuestMasterLevel (@quest.speciality_id))>(@quest.level)\n @quest.destroy\n respond_to do |format|\n format.html { redirect_to quests_url }\n format.json { head :ok }\n end\n else\n redirect_to \"/\", notice: 'No tienes el nivel suficiente para destruir esta quest!'\n end\n else\n redirect_to \"/\", notice: 'No tienes la especialdidad necesaria para destruir esta quest!'\n end\n end",
"def add_question\n @event.respond('Enter a new question: ')\n ques = @event.user.await!(timeout: 60)\n return open_channel if ques.nil?\n\n ques = ques.content\n @event.respond('Enter the answer: ')\n ans = @event.user.await!(timeout: 60)\n return open_channel if ans.nil?\n\n ans = ans.content.gsub(/\\W/, '').downcase # Clean up the answer by removing caps and non [a-z] [0-9] chars\n @event.respond('Commit to database? (y/n): ')\n prompt = @event.user.await!(timeout: 60)\n unless prompt.nil? || prompt.content != 'y'\n begin\n @@trivia_db.prepare('INSERT INTO trivia(question, answer, addedby) VALUES(?, ?, ?)').execute(ques, ans, @event.user.id)\n rescue SQLite3::Exception\n @event.respond('Unable to write to database!')\n else\n @event.respond('Changes saved')\n end\n end\n open_channel\n end",
"def ask_question\n puts \"#{@current_player.name} what is the answer to: #{@a} #{@operator} #{@b} = ?\"\n end",
"def execute_enemy_talk_action\n $game_temp.talking_actor = @subject\n target_index = @subject.current_action.target_index\n target = $game_troop.members[target_index]\n @log_window.display_talk_action(@subject, target)\n $game_troop.setup_talk_event(@subject.current_action.target_index)\n while !scene_changing?\n $game_troop.interpreter.update\n target.sprite_effect_type = :whiten if target.alive?\n break unless $game_troop.interpreter.running?\n update_for_wait\n end\n $game_temp.talking_actor = nil\n end",
"def do_command1\n display_message_and_wait(ext_text(8997, 13))\n return unless (choice = choose_pokemon)\n return unless (pkmn = choice >= 31 ? $actors[choice - 31] : $storage.info(choice - 1))\n\n list = Core.get_pokemon_list_from_wanted(pkmn)\n return display_message(ext_text(8997, 8)) if list.first == 'nothing'\n\n pokemon_list = list.collect { |i| Core.download_pokemon(i).to_pokemon }\n return display_message(ext_text(8997, 9)) if pokemon_list.include?(nil)\n\n loop do\n break unless (index = select_pokemon(pokemon_list))\n\n wanted_data = Core.download_wanted_data(list[index])\n return display_message(ext_text(8997, 11)) if wanted_data.empty?\n\n display_message_and_wait(ext_text(8997, 14))\n break unless confirm_wanted_data(wanted_data)\n\n return GTS.finish_trade(pkmn, pokemon_list[index], true, choice, list[index])\n end\n end",
"def ask_question\n @question = Question.new\n puts \"#{@current_player.name}: #{@question.show}\"\n end",
"def player_action(command)\n case command\n when 'player.wait'\n return true\n when /^player\\.move_/\n direction = get_direction('player.move', command)\n destination = @level.creature_destination(@player, direction)\n if @level.creature_can_move?(@player, destination)\n @level.move_creature(@player, destination)\n return true\n else\n # TODO Try another action on the cell\n return false\n end\n when /^player.open_close/\n direction = get_direction('player.open_close', command)\n target = @level.creature_destination(@player, direction)\n # TODO Ensure that target is reachable\n @level.creature_open_close(@player, target)\n else\n return false\n end\n end",
"def activateQuest(questID)\n if questID.is_a?(String)\n questID = $quest_data.getIDFromName(questID)\n end\n for i in 0...@active_quests.length\n if @active_quests[i].id==questID\n Kernel.pbMessage(\"You have already started this quest\")\n return\n end\n end\n for i in 0...@completed_quests.length\n if @completed_quests[i].id==questID\n Kernel.pbMessage(\"You have already complete this quest\")\n return\n end\n end\n for i in 0...@failed_quests.length\n if @failed_quests[i].id==questID\n Kernel.pbMessage(\"You have already failed this quest\")\n return\n end\n end\n @active_quests.push(Quest.new(questID))\n end",
"def do_command\n if @index == 0\n do_command0\n elsif @index == 1\n @wanted_data[3] = display_message(ext_text(8997, 25), 1, *GTS.genders)\n elsif @index == 2\n do_command2\n elsif @index == 3\n if @wanted_data[0] > 0\n @running = false\n else\n $game_system.se_play($data_system.cancel_se)\n end\n elsif @index == 4\n @wanted_data = -1\n return @running = false\n end\n draw_wanted_data\n end",
"def ask_question\n question = Question.new\n puts \"\\nPlayer 1: #{question.text}\"\n end",
"def play\n\t\twelcome\n\t\task_name\n\t\task_name2 \n\t\task_input\n\t\tturns\n\tend",
"def phase_2(player, bots)\r\n puts \" ----------------------- \"\r\n puts \" -- MENU -- \"\r\n puts \" ----------------------- \"\r\n puts \" ----------------------- \"\r\n puts \" -- ACTION -- \"\r\n puts \"\"\r\n puts \"a > chercher une meuilleure arme\"\r\n puts \"s > chercher à se soigner\"\r\n puts \"\"\r\n puts \">>> attaquer un ennemi en vue :\"\r\n puts \"0 > #{bots[1].name}(#{bots[1].life_points})\"\r\n puts \"1 > #{bots[2].name}(#{bots[2].life_points})\"\r\n puts \"\"\r\n puts \" ----------------------- \"\r\n input = gets.chomp.to_s\r\n menu(input, player, bots)\r\nend",
"def handle\r\n action_klass = Battle.find_action_klass(self.combat_command)\r\n if (!action_klass)\r\n client.emit_failure t(battle.unknown_command)\r\n return\r\n end\r\n\r\n self.names.each do |name|\r\n\r\n Battle.with_a_combatant(name, client, enactor) do |combat, combatant|\r\n if (combatant.is_subdued? && self.combat_command != \"escape\")\r\n client.emit_failure t('battle.must_escape_first')\r\n next\r\n end\r\n Battle.set_action(client, enactor, combat, combatant, action_klass, self.action_args)\r\n end\r\n end\r\n end",
"def do_command1\n if @uploaded\n summary\n refresh_sprites\n else\n return false unless (choice = choose_pokemon)\n\n party = choice >= 31\n pkmn = party ? $actors[choice - 31] : $storage.info(choice - 1)\n if party && $pokemon_party.pokemon_alive == 1 && !pkmn.dead?\n display_message(ext_text(8997, 35))\n return\n end\n data = nil\n call_scene(WantedDataScene) { |scene| data = scene.wanted_data }\n if data.is_a?(Array) && Core.upload_pokemon(pkmn, data)\n $pokemon_party.online_pokemon = pkmn.clone\n party ? $pokemon_party.remove_pokemon(choice - 31) : $storage.remove(choice - 1)\n GamePlay::Save.save\n refresh_sprites\n end\n end\n end",
"def show\n @quest = Quest.find(params[:id])\n quest_objectives = @quest.locations\n completed_objectives = []\n quest_objectives.each do |obj|\n if @current_user.locations.exists?(obj)\n completed_objectives << obj\n end\n end\n if completed_objectives.length == quest_objectives.length\n unless @quest.winner_id\n @quest.update(winner_id: @current_user.id)\n end\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n end\n\n if(@quest.owner_id == @current_user.id)\n redirect_to edit_quest_path(@quest)\n elsif @quest.start_date > DateTime.current\n flash[:warning] = \"Quest has not yet begun!\"\n redirect_to user_path(@current_user) and return\n elsif @quest.end_date < DateTime.current\n flash[:warning] = \"Quest has ended. Womp womp\"\n\n redirect_to \"/quests/\" + @quest.id.to_s + \"/complete\" and return\n elsif @quest.users.exists?(@current_user.id)\n gon.track = true\n locations = @quest.locations\n gon.remaining_locations = []\n gon.completed_locations = []\n locations.each do |loc|\n if loc.users.exists?(@current_user.id)\n gon.completed_locations << loc\n else\n gon.remaining_locations << loc\n end\n end\n @remaining_locations = gon.remaining_locations\n @completed_locations = gon.completed_locations\n else\n gon.track = false\n flash[:danger] = \"You are not a member of this quest! Please contact the quest owner for an invite.\"\n redirect_to quests_path and return\n end\n end",
"def ask_question\n @game_id = params[:game_id]\n @current_game = Game.find(@game_id)\n @bonus = params[:bonus]\n unless @current_game.players_turn?(current_user.id)\n back_to_index and return\n end\n\n if @current_game.normal_round?\n subject_title = params[:subject]\n @subject = subject_title\n @questions = Question.questions_by_user_experience(current_user.experience_level, @subject)\n @question = @questions.sample\n elsif @current_game.challenge_round?\n @challenge = Challenge::get_ongoing_challenge_by_game(@current_game.id)\n if @challenge\n @question = Question.find(@challenge.get_question_id_by_counter)\n @subject = @question.subject_title\n elsif @challenge.nil?\n wager = params[:wager]\n prize = params[:prize]\n if wager && prize\n @challenge = Challenge.create_challenge(@current_game.id, current_user.id, @current_game.opponent_id(current_user.id), wager, prize)\n else\n redirect_to game_challenge_path(:game_id => @current_game.id)\n end\n end\n end\n if @question\n respond_to do |format|\n format.html\n format.xml { render :xml => @question }\n end\n end\n end",
"def ask_question\n puts '---- NEW TURN -----'\n puts \"#{@current_player.name}: what does #{@first_number} plus #{@second_number} equal?\"\n \n end",
"def phase2_command_input \r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Branch by party command window cursor position\r\n case @party_command_window.command\r\n when SDK::Scene_Commands::Scene_Battle::Fight # fight\r\n phase2_command_fight\r\n when SDK::Scene_Commands::Scene_Battle::Escape # escape\r\n phase2_command_escape\r\n end\r\n end",
"def perform\n type = \"#{@target.class}Conquest\"\n type_attr = :\"#{@target.class.name.downcase}\"\n @player.conquests_for(@game).create!(type: type, type_attr => @target).tap do |conquest|\n @undo_statement = \"#{type}.destroy(#{conquest.id})\"\n end\n end",
"def ask_question\n change_player\n Question.new(@players[@turn])\n \"#{@players['p1'].name}: #{@players['p1'].lives_left} vs #{@players['p2'].name}: #{@players['p2'].lives_left}\"\n if @players[@turn].lives.zero?\n change_player\n puts \"#{@players[@turn].name} wins with a score of #{@players[@turn].lives_left}\"\n puts '----- GAME OVER -----'\n else\n puts '----- NEW TURN -----'\n ask_question\n end\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 entered(player)\n actions.each { |action| action.entered(player) }\n end",
"def phase3_basic_command_input\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Branch by actor command window cursor position\r\n case @actor_command_window.command\r\n when SDK::Scene_Commands::Scene_Battle::Attack # attack\r\n phase3_command_attack\r\n when SDK::Scene_Commands::Scene_Battle::Skill # skill\r\n phase3_command_skill\r\n when SDK::Scene_Commands::Scene_Battle::Guard # guard\r\n phase3_command_guard\r\n when SDK::Scene_Commands::Scene_Battle::Item # item\r\n phase3_command_item\r\n end\r\n end",
"def talk\n if current_room.npc\n puts current_room.npc.dialogue[:default]\n else\n puts \"Sorry, no one else is in here!\"\n end\n end",
"def ask(question)\n ui.ask question\n end",
"def prompt_player_for_turn\n\t\t\tputs \"It is Player #{@current_player.player_num}'s turn\"\n\t\t\tputs \"Which column would you like to drop your piece?\"\n\t\t\tputs \"Columns are 1-#{@Col_num.to_i}\"\n\n\t\t\t@current_player.get_player_response\n\n\n\t\tend",
"def success_case\n\tputs \" - Ok #{@name}, c'est ton choix #{@answer_play}\" \n\tputs \" \"\n end",
"def run(player)\n type(\"You open the treasure chest...\\n\\n\")\n sleep(1) unless ENV['TEST']\n player.add_loot(@gold, @treasures)\n @visible = false\n end",
"def menu_choice\n puts \"Votre réponse :\"\n print \">\"\n user_answer = gets.chomp\n\n if(user_answer == \"a\")\n then @human_player.search_weapon\n end\n if(user_answer == \"s\")\n then @human_player.search_health_pack\n end\n if(user_answer == 0.to_s)\n then @human_player.attacks(@player1)\n end\n if(user_answer == 1.to_s)\n then @human_player.attacks(@player2)\n end\n if(user_answer == 2.to_s)\n then @human_player.attacks(@player3)\n end\n if(user_answer == 3.to_s)\n then @human_player.attacks(@player4)\n end\n kill_player\n end",
"def action(input)\n # This will be where the game's moves come from; at the time of writing, it\n # is simply the string 'Random Winning Move'. This is assigned to the action\n # variable\n # input.last will be the time limit in milliseconds to complete a move\n action = @bot.play(@status, input.last)\n # This prints the action to the IO stream\n Io.post(action)\n run\n end",
"def set_quest_item\n @quest_item = QuestItem.find(params[:id])\n end",
"def q\r\n @_done = true\r\n puts\r\n \"Bye bye for now!\"\r\n end",
"def play() \n\n turn()\n\n return \"Game Finished\"\n\nend",
"def Mine(action_hash = {})\n puts 'Mine called! phase = ' + phase + ' action_hash = ' + action_hash.to_s\n if phase == 'Action' and self.played_card_id\n puts 'begin mine execution'\n card = Card.find(played_card_id)\n player = game.players.find(player_turn)\n if action_phase.nil? # first time playing this card\n puts 'Mines initial play!'\n player.add_to_played(card)\n player.mark_hand_type_selectable('Treasure')\n update_attributes(played_card_id: card.id, value: 0, actions: actions - 1, action_phase: 'Trash', prompt: '<b>Played Mine!</b><br />Trash a treasure card from your hand. Gain a treasure card costing up to 3 treasure more and put it into your hand!')\n elsif action_phase == 'Trash' and card and action_hash # Trashing a treasure card\n puts 'Trash array = ' + action_hash['Trash'].to_s\n action_hash['Trash'].each do |card_id|\n trash_card = Card.find(card_id)\n trash_card.unmark_selectable\n player.add_to_trash(trash_card)\n update_attributes(value: trash_card.cost, action_phase: 'Gain')\n end\n update_attributes(prompt: '<b>Played Mine!</b><br />Trash a treasure card from your hand. Gain a treasure card costing up to 3 treasure more and put it into your hand!<br />Gain a treasure card in your hand worth at least ' + (value + 3).to_s + ' treasure!')\n player.unmark_all_hand_selectable\n return game.generate_selectable_supply_array('Treasure', 0, (value + 3), nil)\n elsif action_phase == 'Gain' and card and action_hash # Gaining a treasure card\n puts 'Gain array = ' + action_hash['Gain'].to_s\n action_hash['Gain'].each do |name|\n player.hand.cards.create!( cardmapping_id: Cardmapping.get( name ) )\n decrement_supply_count(name, 1)\n end\n update_attributes(prompt: '<b>Played Mine!</b><br />Trash a treasure card from your hand. Gain a treasure card costing up to 3 treasure more and put it into your hand!<br />Gain a treasure card in your hand worth at least ' + value.to_s + ' treasure!')\n reset_action_variables\n elsif action_phase == 'End' and card # ending card without gaining a card\n reset_action_variables\n end\n end\n end"
] | [
"0.76057154",
"0.6852442",
"0.6841491",
"0.68252397",
"0.6705769",
"0.66427284",
"0.66124445",
"0.65628415",
"0.64983255",
"0.6370336",
"0.62768626",
"0.62623245",
"0.62606645",
"0.6201033",
"0.61695755",
"0.6147737",
"0.61336553",
"0.61322856",
"0.6127557",
"0.6121104",
"0.609006",
"0.60352033",
"0.6004832",
"0.599823",
"0.59919804",
"0.5941538",
"0.59342766",
"0.5931658",
"0.59194815",
"0.5848124",
"0.58041644",
"0.579585",
"0.57924634",
"0.57786655",
"0.57759213",
"0.57543707",
"0.57479566",
"0.57479566",
"0.57479566",
"0.57479566",
"0.57293695",
"0.57233",
"0.5699547",
"0.5686534",
"0.56623334",
"0.5641383",
"0.5626693",
"0.5613004",
"0.56048936",
"0.559339",
"0.5591016",
"0.55763274",
"0.5564287",
"0.5562499",
"0.5560995",
"0.5551894",
"0.5548192",
"0.5548046",
"0.5525994",
"0.5522432",
"0.5515225",
"0.5513913",
"0.55109066",
"0.5494295",
"0.5492122",
"0.54890394",
"0.5485494",
"0.54771227",
"0.5474801",
"0.5469086",
"0.5468855",
"0.54573673",
"0.5453024",
"0.5443654",
"0.5434445",
"0.54294324",
"0.5426857",
"0.5417806",
"0.53919655",
"0.5391353",
"0.5386876",
"0.53813773",
"0.5377719",
"0.53719014",
"0.5364443",
"0.53567016",
"0.5352297",
"0.534989",
"0.53467727",
"0.5345404",
"0.5345387",
"0.5336038",
"0.533384",
"0.53318864",
"0.53297",
"0.5313146",
"0.5293403",
"0.52843016",
"0.5283727",
"0.5279961"
] | 0.6855905 | 1 |
method for getting the reward after completing a quest argument passed in is array of available weapon objects | def weapon_reward(available_weapons)
#reward is 1 random choice from this array
reward = available_weapons.sample
#create to CharacterWeapon object to show that player obtains weaopn
CharacterWeapon.new_character_weapon(self.id, reward.id)
#print weapon details to player
puts "#{reward.name}".bold.blue
puts "Weapon Power: #{reward.attack_power}"
puts"#####################################".blink
#actually equip the weapon, if it will increase this player's attack power
if reward.attack_power > self.power - 1 || self.power == 1
#increase the player's attack power
self.update(power: 1+reward.attack_power)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distribute_quest_reward(reward)\n @params = [reward[1], 0, 0, (reward[2] ? reward[2] : 1)]\n case reward[0]\n when :item, 0 then command_126 # Item\n when :weapon, 1 then command_127 # Weapon\n when :armor, 2 then command_128 # Armor\n when :gold, 3 # Gold\n @params = [0, 0, reward[1] ? reward[1] : 0]\n command_125\n when :exp, 4 # Exp\n @params = [0, 0, 0, 0, reward[1] ? reward[1] : 0, true]\n command_315\n end\n end",
"def quest_interface\n\n#obtain the difficulty level for the given player\n difficulty = self.get_difficulty\n\n#see if the player has any quests left to complete\n if self.get_recommended_quests(difficulty).size == 0\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"You have completed all recommended quests!!!\".bold\n puts \"=====================================\".red\n puts \"=====================================\".red\n\n#show the player the available quests\n else\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Recommended Quests for Player Attack: #{self.power}\".blue.on_light_green.bold\n puts \"\"\n self.print_quests(difficulty)\n puts \"=====================================\".red\n puts \"=====================================\".red\n puts \"Select a quest number\".bold.white.on_light_blue\n puts \"Number:\".bold.white.on_light_blue\n\n#selection prompt the player to actually choose a quest\n selection = gets.chomp\n\n#check for invalid input\n if selection.to_i > self.get_recommended_quests(difficulty).size || selection.to_i < 1\n puts \"Invalid input, please try again!\".red.bold\n\n#if input is valid, show the player that he has completed the quest\n else\n puts\"*******************************************\"\n puts \"You have completed: #{self.get_recommended_quests(difficulty)[selection.to_i-1].title}\".bold\n puts\"*******************************************\"\n puts \" \"\n puts\"#####################################\".blink\n puts \"Time For Your Reward Adventurer!!!\".bold.blue.on_light_yellow\n\n #obtain the available weapons based on player difficulty\n available_weapons = self.get_available_weapons(difficulty)\n\n #create the new characterquest instance to show that player has completed the quest\n self.quest_selection(selection, difficulty)\n\n #run the weapon_reward method to get reward for the quest\n self.weapon_reward(available_weapons)\n end\n end\n end",
"def reward\n display_reward\n rewards = [\"some bandages\", \"a weapon\", \"a piece of armor\"]\n reward = rewards.sample\n case reward\n when \"some bandages\"\n hero.update(current_health: hero.max_health)\n puts \"Found #{reward}. Your health is restored.\"\n when \"a weapon\"\n weapon_power = rand(1..5)\n hero.update(power: hero.power + weapon_power)\n puts \"Found #{reward}. Power increased by #{weapon_power}.\"\n when \"a piece of armor\"\n armor_power = rand(1..10)\n hero.update(max_health: hero.max_health + armor_power)\n puts \"Found #{reward}. Max health increased by #{armor_power}.\"\n end\n sleep(3)\n end",
"def item_reward(hero)\n hero_items = AllItems::all_items(hero.base_class.downcase) # Mix of armor, weapons, and potions baed on hero class\n item =\n case rand(0..100)\n when 0..9 then hero_items.map { |items| items.last(3) }.flatten.sample # One of the last 3 items # 10% chance\n when 10..47 then hero_items.map { |items| items[2...-3] }.flatten.sample # Middle portion of items # 38% chance\n when 48..100 then hero_items.map { |items| items.first(2) }.flatten.sample # One of the first 2 items 52% chance\n end\n { reward: item, type: 'item' }\n end",
"def ty_execute_action_skill\n # Check to see if the current attacker is the actor and is using a weapon that needs ammo\n if @active_battler.is_a?(Game_Actor) && TysAmmoRequirements::Skill_ammo_cost[@active_battler.action.skill_id]\n if TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id].is_a?(Array)\n # Check passed, so now we store the array items\n array_items = TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id]\n # Now we check each ID in array_items and compare to see if we have enough ammo\n for index in array_items\n # Check to see if the actor has enough ammo\n if $game_party.item_number($data_items[index]) >= gather_ammo_cost\n # Check cleared, gather item ID and terminate check loop\n gather_ammo_item = $data_items[index]\n break\n end\n end\n else\n gather_ammo_item = $data_items[TysAmmoRequirements::Weapons_ammo_id[@active_battler.skill_id]]\n end\n # Both checks clear, so perform Ammo adjustments\n # First we collect some end-user options, like ammo cost and ammo ID.\n gather_ammo_cost = TysAmmoRequirements::Skill_ammo_cost[@active_battler.action.skill_id]\n id = @active_battler.action.skill_id\n gather_ammo_item = $data_items[TysAmmoRequirements::Skill_ammo_id[id]]\n if $game_party.item_number(gather_ammo_item) >= gather_ammo_cost\n # The check cleared, so perform ammo adjustments\n # Consume Ammunition\n $game_party.lose_item(gather_ammo_item, gather_ammo_cost)\n # Display text\n text = sprintf(Vocab::ConsumeAmmo, @active_battler.name, gather_ammo_cost, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n else\n # Failed check, go into defense mode\n text = sprintf(Vocab::NoAmmo, @active_battler.name, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 0\n execute_action_guard\n end\n # Perform a check to see if Active_Battler is a enemy and has ammo\n elsif @active_battler.is_a?(Game_Enemy) && $data_enemies[@active_battler.enemy_id].note.include?(TysAmmoRequirements::Enemy_ammo_activate_string) && TysAmmoRequirements::Enemy_skill_cost[@active_battler.action.skill_id]\n # Now we have to isolate the interger in the 'Note' string of the enemies\n # and then store the interger in a new local value for future use.\n enemy_ammo_cost = TysAmmoRequirements::Enemy_skill_cost[@active_battler.action.skill_id]\n enemy_ammo_name = TysAmmoRequirements::Enemy_ammo_name[@active_battler.enemy_id]\n # Check to see if the enemy has enough ammo to attack\n if @enemy_ammo[@enemy_attack] >= enemy_ammo_cost\n # Check cleared, remove enemy ammo.\n text = sprintf(Vocab::EnemyUsedAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @enemy_ammo[@enemy_attack] -= enemy_ammo_cost\n else\n # Check failed, put enemy in guard mode \n text = sprintf(Vocab::EnemyNoAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 0\n execute_action_guard\n end\n end\n end",
"def make_item_action_result\n # Get item\n @item = $data_items[@active_battler.current_action.item_id]\n # If unable to use due to items running out\n unless $game_party.item_can_use?(@item.id)\n # Shift to step 1\n @phase4_step = 1\n return\n end\n # If consumable\n if @item.consumable\n # Decrease used item by 1\n $game_party.lose_item(@item.id, 1)\n end\n # Display item name on help window\n @help_window.set_text(@item.name, 1)\n # Set animation ID\n @animation1_id = @item.animation1_id\n @animation2_id = @item.animation2_id\n # Set common event ID\n @common_event_id = @item.common_event_id\n # Decide on target\n index = @active_battler.current_action.target_index\n target = $game_party.smooth_target_actor(index)\n # Set targeted battlers\n set_target_battlers(@item.scope)\n # Apply item effect\n for target in @target_battlers\n target.item_effect(@item)\n end\n end",
"def completed_quests; $game_variables[17]; end",
"def make_item_action_result\n \n # sorry i didnt work on this...\n # couse i dont have a sprite that uses items....\n # so i just added the standby sprite here...\n # when i get more time for this i'll try what i can do for this one... ^-^\n # its the same as the ones above...\n if @active_battler.is_a?(Game_Actor)\n @spriteset.actor_sprites[@active_battler.index].pose(1)\n else\n @spriteset.enemy_sprites[@active_battler.index].enemy_pose(1)\n end\n \n @item = $data_items[@active_battler.current_action.item_id]\n unless $game_party.item_can_use?(@item.id)\n @phase4_step = 1\n return\n end\n if @item.consumable\n $game_party.lose_item(@item.id, 1)\n end\n @help_window.set_text(@item.name, 1)\n @animation1_id = @item.animation1_id\n @animation2_id = @item.animation2_id\n @common_event_id = @item.common_event_id\n index = @active_battler.current_action.target_index\n target = $game_party.smooth_target_actor(index)\n set_target_battlers(@item.scope)\n for target in @target_battlers\n target.item_effect(@item)\n end\n end",
"def make_item_action_result\r\n # Get item\r\n @item = $data_items[@active_battler.current_action.item_id]\r\n # If unable to use due to items running out\r\n unless $game_party.item_can_use?(@item.id)\r\n # Shift to step 1\r\n @phase4_step = 1\r\n return\r\n end\r\n # If consumable\r\n if @item.consumable\r\n # Decrease used item by 1\r\n $game_party.lose_item(@item.id, 1)\r\n end\r\n # Display item name on help window\r\n @help_window.set_text(@item.name, 1)\r\n # Set animation ID\r\n @animation1_id = @item.animation1_id\r\n @animation2_id = @item.animation2_id\r\n # Set common event ID\r\n @common_event_id = @item.common_event_id\r\n # Decide on target\r\n index = @active_battler.current_action.target_index\r\n target = $game_party.smooth_target_actor(index)\r\n # Set targeted battlers\r\n set_target_battlers(@item.scope)\r\n # Apply item effect\r\n for target in @target_battlers\r\n target.item_effect(@item)\r\n end\r\n end",
"def reward\n @reward ||= 0\n end",
"def draw_reward(r_id, y)\n reward = @quest.rewards[r_id]\n case reward[0]\n when :item, 0 # Item\n draw_item_reward(y, $data_items[reward[1]], reward[2] ? reward[2] : 1)\n when :weapon, 1 # Weapon\n draw_item_reward(y, $data_weapons[reward[1]], reward[2] ? reward[2] : 1)\n when :armor, 2 # Armor\n draw_item_reward(y, $data_armors[reward[1]], reward[2] ? reward[2] : 1)\n when :gold, 3 # Gold\n draw_basic_data(y, QuestData::ICONS[:reward_gold], \n QuestData::VOCAB[:reward_gold], (reward[1] ? reward[1] : 0).to_s)\n when :exp, 4 # Exp\n draw_basic_data(y, QuestData::ICONS[:reward_exp], \n QuestData::VOCAB[:reward_exp], (reward[1] ? reward[1] : 0).to_s)\n when :string, 5 # String\n draw_basic_data(y, reward[1] ? reward[1] : 0, reward[3] ? reward[3].to_s : \"\", \n reward[2] ? reward[2].to_s : \"\")\n end\n end",
"def melee_weapon; end",
"def draw_reward(achievement)\r\r\n reward = achievement.reward\r\r\n currency = $game_party.get_csca_cs_currency(reward.id) if $imported[\"CSCA-CurrencySystem\"] && reward.type == :gold\r\r\n case reward.type\r\r\n when :gold; reward_s = $imported[\"CSCA-CurrencySystem\"] ? currency[:currency_unit] : reward_s = Vocab::currency_unit\r\r\n when :item; reward_s = \" \" + $data_items[reward.id].name\r\r\n when :weapon; reward_s = \" \" + $data_weapons[reward.id].name\r\r\n when :armor; reward_s = \" \" + $data_armors[reward.id].name\r\r\n end\r\r\n draw_text(0,line_height*2,contents.width,line_height,CSCA::ACHIEVEMENTS::REWARD+reward.amount.to_s+reward_s,1)\r\r\n end",
"def make_skill_action_result\n # Gather the current Ammo Cost\n gather_ammo_cost = Ammo::Skill_ammo[@active_battler.current_action.skill_id]\n # Gather Ammo\n gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]\n # Check if the Actor is using a defiend skill\n if Ammo::Skill_ammo.has_key?(@active_battler.current_action.skill_id)\n # Check if Ammo is present\n if $game_party.item_number(gather_ammo) >= gather_ammo_cost\n # Sufficient Ammo, remove item\n $game_party.lose_item(gather_ammo,gather_ammo_cost)\n # Call Default Code\n syn_scene_battle_skill\n else\n # Set Window; Do Nothing\n @help_window.set_text(\"#{@active_battler.name} cannot attack due to insufficient Ammo\", 1)\n end\n # Otherwise SKip the check and call default code\n else\n syn_scene_battle_skill\n end\n end",
"def tbs_evaluate\n #if attack?\n # @effect_preview = tbs_evaluate_attack\n # @targets = @effect_preview.keys\n #elsif item? #no item use for ai controlled unit\n if item? #no item use.. \n @effect_preview = {}\n @targets = []\n else \n @effect_preview = tbs_evaluate_skill\n @targets = @effect_preview.keys\n end\n return if @targets.empty?\n #rate the action regarding the battler strategy\n tbs_tactic_rate \n end",
"def ragman_quest; end",
"def ranged_weapon; end",
"def set_reward\n @product = current_user.products.find(params[:product_id])\n @reward = @product.rewards.find(params[:id])\n end",
"def quest_rewarded?(quest_id)\n quest_revealed?(quest_id) && quest(quest_id).status?(:reward)\n end",
"def distribute_quest_rewards(quest_id)\n if quest_revealed?(quest_id) && !quest_rewarded?(quest_id)\n params = @params.dup\n change_reward_status(quest_id, true)\n quest(quest_id).rewards.each { |reward| distribute_quest_reward(reward) }\n @params = params\n true\n else\n false\n end\n end",
"def actions\n answer = @prompt.select(\"Where will you go?\", %w(Foward Back Status Items), cycle:true, per_page:4)\n if answer == \"Foward\"\n if @zone_cur == 10\n narrate(\"you leave the #{self.name}\")\n leave(self.exit_name)\n else\n @zone_cur += 1\n narrate(\"you continue foward\")\n encounter_check\n end\n elsif answer == \"Back\"\n if @zone_cur == 0\n narrate(\"you leave the #{self.name}\")\n leave(self.entrance_name)\n else\n @zone_cur -= 1\n narrate(\"you retreat backwards\")\n encounter_check\n end\n elsif answer == 'Status'\n narrate(\"#{@player.name} has #{@player.hp} hp, #{@player.attack} attack, and #{@player.defence} defence\")\n str = \"\"\n a = @player.equipment.map do |el|\n el.name\n end\n b = a.join(\", \")\n narrate(\"#{@player.name} has the following items equipped: #{b}\")\n here\n elsif answer == 'Items'\n answer = @prompt.select(\"Items Menu\", %w(Equip_item Look_item), cycle:true, per_page:4)\n if answer == 'Equip_item'\n #list inventory\n stuff = @player.items.map do |el|\n el.name\n end\n #select an item from inventory\n answer = @prompt.select(\"Items Menu\", stuff, cycle:true, per_page:4)\n #find that item again\n to_eq = @player.items.find do |el|\n el.name == answer\n end\n binding.pry\n #equip that item\n @player.equip(to_eq)\n narrate( \"You have equipped the #{to_eq.name}!\")\n actions\n end\n end\n end",
"def make_skill_action_result\n # Get skill\n @skill = $data_skills[@active_battler.current_action.skill_id]\n # If not a forcing action\n unless @active_battler.current_action.forcing\n # If unable to use due to SP running out\n unless @active_battler.skill_can_use?(@skill.id)\n # Clear battler being forced into action\n $game_temp.forcing_battler = nil\n # Shift to step 1\n @phase4_step = 1\n return\n end\n end\n # Use up SP\n @active_battler.sp -= @skill.sp_cost\n # Refresh status window\n @status_window.refresh\n # Show skill name on help window\n @help_window.set_text(@skill.name, 1)\n # Set animation ID\n @animation1_id = @skill.animation1_id\n @animation2_id = @skill.animation2_id\n # Set command event ID\n @common_event_id = @skill.common_event_id\n # Set target battlers\n set_target_battlers(@skill.scope)\n # Apply skill effect\n for target in @target_battlers\n target.skill_effect(@active_battler, @skill)\n end\n end",
"def consume_item(type, id)\n action = eval(type + '_Need_Items.dup')\n equipment = eval(type + '_Need_Equiped.dup')\n if action.include?(id)\n for need in action[id]\n $game_party.lose_item(need[1], need[2]) if need[0] == 'i' \n $game_party.lose_armor(need[1], need[2]) if need[0] == 'a' \n $game_party.lose_weapon(need[1], need[2]) if need[0] == 'w' \n end\n end\n if equipment.include?(id)\n if $atoa_script['Atoa Multi Slot']\n for need in equipment[id]\n equipments = armors.dup if need[0] == 'a'\n equipments = weapons.dup if need[0] == 'w'\n for i in 0...equips.size\n if action_id(equip[i]) == need[1]\n equip(i, 0)\n $game_party.lose_armor(need[1], need[2]) if need[0] == 'a'\n $game_party.lose_weapon(need[1], need[2]) if need[0] == 'w'\n equip(i, equip[i].id)\n end\n end\n end\n else\n for need in equipment[id]\n equipments = armors.dup if need[0] == 'a'\n equipments = weapons.dup if need[0] == 'w'\n for equip in equipments\n if equip.type_name == 'Weapon'\n type = 0\n else\n type = 1 if equip.id == @armor1_id\n type = 2 if equip.id == @armor2_id\n type = 3 if equip.id == @armor3_id\n type = 4 if equip.id == @armor4_id\n end\n if action_id(equip) == need[1]\n equip(type, 0)\n $game_party.lose_armor(need[1], need[2]) if need[0] == 'a'\n $game_party.lose_weapon(need[1], need[2]) if need[0] == 'w'\n equip(type, equip.id)\n end\n end\n end\n end\n end\n end",
"def make_skill_action_result\r\n # Get skill\r\n @skill = $data_skills[@active_battler.current_action.skill_id]\r\n # If not a forcing action\r\n unless @active_battler.current_action.forcing\r\n # If unable to use due to SP running out\r\n unless @active_battler.skill_can_use?(@skill.id)\r\n # Clear battler being forced into action\r\n $game_temp.forcing_battler = nil\r\n # Shift to step 1\r\n @phase4_step = 1\r\n return\r\n end\r\n end\r\n # Use up SP\r\n @active_battler.sp -= @skill.sp_cost\r\n # Refresh status window\r\n @status_window.refresh\r\n # Show skill name on help window\r\n @help_window.set_text(@skill.name, 1)\r\n # Set animation ID\r\n @animation1_id = @skill.animation1_id\r\n @animation2_id = @skill.animation2_id\r\n # Set command event ID\r\n @common_event_id = @skill.common_event_id\r\n # Set target battlers\r\n set_target_battlers(@skill.scope)\r\n # Apply skill effect\r\n for target in @target_battlers\r\n target.skill_effect(@active_battler, @skill)\r\n end\r\n end",
"def weaponAccessories _obj, _args\n \"_obj weaponAccessories _args;\" \n end",
"def weapon; end",
"def weapon; end",
"def weapon; end",
"def reward_unit(klass, options={})\n @rewards.add_unit(klass, options)\n end",
"def skier_quest; end",
"def ty_execute_action_attack\n # Check to see if the current attacker is the actor and is using a weapon that needs ammo\n if @active_battler.is_a?(Game_Actor) && TysAmmoRequirements::Weapons_ammo_cost[@active_battler.weapon_id]\n # Both checks clear, so perform Ammo adjustments\n # First we collect some end-user options, like ammo cost and ammo ID.\n gather_ammo_cost = TysAmmoRequirements::Weapons_ammo_cost[@active_battler.weapon_id]\n # This handles multiple ammunition for the same weapon. First we check if the setting is an array\n if TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id].is_a?(Array)\n # Check passed, so now we store the array items\n array_items = TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id]\n # Now we check each ID in array_items and compare to see if we have enough ammo\n for index in array_items\n # Check to see if the actor has enough ammo\n if $game_party.item_number($data_items[index]) >= gather_ammo_cost\n # Check cleared, gather item ID and terminate check loop\n gather_ammo_item = $data_items[index]\n break\n end\n end\n else\n gather_ammo_item = $data_items[TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id]]\n end\n # Next we check to make sure the attacking actor has enough ammo\n if $game_party.item_number(gather_ammo_item) >= gather_ammo_cost\n # The check cleared, so perform ammo adjustments\n # Consume Ammunition\n $game_party.lose_item(gather_ammo_item, gather_ammo_cost)\n # Display text\n text = sprintf(Vocab::ConsumeAmmo, @active_battler.name, gather_ammo_cost, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n else\n # Failed check, go into defense mode\n if TysAmmoRequirements::Unequip_weapon_NoAmmo\n @active_battler.change_equip_by_id(0,0)\n else\n text = sprintf(Vocab::NoAmmo, @active_battler.name, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 1\n execute_action_guard\n end\n end\n # Perform a check to see if Active_Battler is a enemy and has ammo\n elsif @active_battler.is_a?(Game_Enemy) && $data_enemies[@active_battler.enemy_id].note.include?(TysAmmoRequirements::Enemy_ammo_activate_string)\n # Now we have to isolate the interger in the 'Note' string of the enemies\n # and then store the interger in a new local value for future use.\n enemy_ammo_cost = $data_enemies[@active_battler.enemy_id].note.downcase.match('ammocost:(\\d*)')[1].to_i\n enemy_use_physical = true if $data_enemies[@active_battler.enemy_id].note.include?('usephysical')\n enemy_use_physical = false if $data_enemies[@active_battler.enemy_id].note.include?('usephysical') == false\n enemy_ammo_name = TysAmmoRequirements::Enemy_ammo_name[@active_battler.enemy_id]\n # Check to see if the enemy has enough ammo to attack\n if @enemy_ammo[@enemy_attack] >= enemy_ammo_cost\n # Check cleared, remove enemy ammo.\n text = sprintf(Vocab::EnemyUsedAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @enemy_ammo[@enemy_attack] -= enemy_ammo_cost\n else\n # Check failed, put enemy in guard mode \n if enemy_use_physical == false\n text = sprintf(Vocab::EnemyNoAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 1\n execute_action_guard\n end\n end\n end\n end",
"def make_basic_action_result\n # Gather the current Ammo Cost\n gather_ammo_cost = Ammo::Range_weapons_id[@active_battler.weapon_id]\n # Gather the Current Ammo\n gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]\n # Check if the Active Battler is attacking and if they are using a ranged weapon\n if @active_battler.current_action.basic == 0 and Ammo::Range_weapons_id.has_key?(@active_battler.weapon_id)\n # Check the Ammo Count\n if $game_party.item_number(gather_ammo) >= gather_ammo_cost\n # Sufficient Ammo, remove item\n $game_party.lose_item(gather_ammo,gather_ammo_cost)\n syn_scene_battle_range\n else\n # Insufficient Ammo\n @help_window.set_text(\"#{@active_battler.name} cannot attack due to insufficient Ammo\", 1)\n end\n # Call Default Code\n else\n syn_scene_battle_range\n end\n end",
"def get_completed_quests\n\n#check if the player has actually completed any quests\n#if he has not, tell him\n if self.quests.size == 0\n puts \"You have not completed any quests!!!\".red\n\n#otherwise, pull the completed quest objects and print the quest titles\n else\n puts \"Completed Quests:\".underline\n self.quests.each_with_index do |quest, i|\n puts \"#{i+1}: #{quest.title}\"\n end\n end\n end",
"def therapist_quest; end",
"def return_item\n items = self.see_purchases.map do |merchandise|\n {name: merchandise.name, merch_id: merchandise.id}\n end\n merch = TTY::Prompt.new.select(\"Here is a list of your purchases. What would you like to return?\",items)\n purchase = self.specific_purchase(merch)\n purchase.destroy \n puts \"your item has been refunded!\"\n restock = self.select_merchandise(merch)\n restock.update(inventory: restock.inventory + 1)\n end",
"def melee_weapon\n fetch('dnd.melee_weapons')\n end",
"def tally_goal(goal, reward)\n self.transaction do\n Mg::Choice.update_counters(self.id, :reward_count => 1, :reward => reward)\n end\n \n return self.reload\n end",
"def weaponsItems _args\n \"weaponsItems _args;\" \n end",
"def mechanic_quest; end",
"def get_available_weapons(difficulty)\n\n#if the difficulty of the quest is 1\n#only select weapons with attack power less than or equal to 3\n# and that the player has not yet obtained\n if difficulty == 1\n available_weapons = Weapon.all.where(\"attack_power <=3\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n#if the difficulty of the quest is 2\n#only select weapons with attack power greater than 3 and less than or equal to 6\n# and that the player has not yet obtained\n elsif difficulty == 2\n available_weapons = Weapon.all.where(\"attack_power >3 and attack_power <= 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n\n#if the difficulty of the quest is 3\n#only select weapons with attack power greater than 6\n# and that the player has not yet obtained\n else\n available_weapons = Weapon.all.where(\"attack_power > 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n end\n end",
"def reward\n -queue.sum.to_f if feasible?\n end",
"def redeem\n new_bottles = free_bottles_and_caps(@bottles, @caps)\n @bottles = new_bottles + leftover_bottles(@bottles)\n @caps = new_bottles + leftover_caps(@caps)\n @total_bottles += new_bottles\n redeem if redeemable?\nend",
"def allows_reward?\n true\n end",
"def completeQuest(quest,color=nil,story=false)\n return if !$PokemonGlobal\n $PokemonGlobal.quests.completeQuest(quest,color,story)\nend",
"def weapons _args\n \"weapons _args;\" \n end",
"def handgunWeapon _args\n \"handgunWeapon _args;\" \n end",
"def valid_skill\n @windows[Win_Help].move_to(2)\n @active_battler.current_action.set_skill(@spell.id)\n @targets = get_targets\n if @ATB_Active and \n GTBS::USE_WAIT_SKILLS and GTBS::ALLOW_SKILL_TARGET and \n GTBS::skill_wait(@spell.id)[0] > 0\n occ = occupied_by?(@cursor.x, @cursor.y)\n if occ and !occ.dead? \n type = Command_Confirm::Wait_Skill_Targeting\n end\n Sound.play_decision\n @cursor.active = false\n #Do immediat skill if type == nil\n @windows[Win_Confirm].ask(Command_Confirm::Skill, type)\n @windows[Win_Status].dmg_preview(2, @active_battler, @spell, @targets)\n \n elsif @targets.size >0 #unless targets 0 or less for some reason\n #make summons miss when cell is occupied\n if (GTBS::is_summon?(@spell.id, @active_battler.is_a?(Game_Actor))> 0 && occupied_by?(@cursor.x, @cursor.y)!= nil) or \n (@spell.for_opponent? && (@selected == @active_battler && !GTBS::ATTACK_ALLIES) &&\n !@active_battler.skill_range(@spell.id)[3] )\n Sound.play_buzzer\n else\n Sound.play_decision\n @cursor.active = false \n @windows[Win_Confirm].ask(Command_Confirm::Skill)\n @windows[Win_Status].dmg_preview(2, @active_battler, @spell, @targets)\n end\n \n elsif GTBS::is_summon?(@spell.id, @active_battler.is_a?(Game_Actor))>0 and $game_map.passable?(@cursor.x, @cursor.y, 0)\n Sound.play_decision\n @cursor.active = false \n @windows[Win_Confirm].ask(Command_Confirm::Skill)\n @windows[Win_Status].dmg_preview(2, @active_battler, @spell, @targets)\n \n elsif (!$game_system.actors_bodies? || GTBS::REVIVE_ANY_DEAD) and \n @spell.for_dead_friend? and occupied_by?(@cursor.x, @cursor.y) == nil\n open_revive_window\n \n else\n #Unauthorized validation\n Sound.play_buzzer\n end\n end",
"def draw_rewards\n y = @draw_y\n unless QuestData::VOCAB[:rewards].empty?\n draw_heading(:rewards, y)\n y += line_height\n end\n for i in [email protected] do draw_reward(i, y + i*line_height) end\n end",
"def calculate\n @calculated = true\n \n @weapon = Weapon.find(weapon_id)\n @armour = Armour.find(armour_id)\n \n # hp\n @base_hp = 20 + (level * 5) + (((base_end - 10) * level) / 2.5).round\n @dmg_taken = 0\n \n @intimidate = 0\n @discipline = 0\n @judgement = 0\n\n @can_train = true\n \n # load modifiers\n load_mods\n apply_mods\n \n # calculated values used in attack / dodge rolls\n @str_mod = (@str - 10) / 2\n @agi_mod = (@agi / 2).floor\n @int_mod = ((@int - 10) / 2).floor\n @x_mod = (@x / 2).floor\n\n \n @crit_range = 5 + @agi_mod + (@int_mod / 2)\n @str_dmg = (@str_mod + ((@str_mod * level) * 0.05)).ceil\n\n @dodge_percent = @agi_mod + @x_mod + (@int_mod / 2)\n @armour.is_light ? @dodge_percent += 5 : @dodge_percent -= 3\n @deflect_percent = (@str_mod / 2).floor + (@int_mod / 2)\n \n if @armour.is_heavy\n @deflect_percent += 7 # add 7% bonus for heavy armour\n else\n @dodge_percent += 5 # add 5% bonus for light armour\n @judgement += 1\n end\n \n # skill mods\n @intimidate += @str_mod + @int_mod\n @discipline += @str_mod + @int_mod\n @judgement += @int_mod\n \n @generated = 0\n @state = 1\n @intimidated = false\n @prepared = false\n end",
"def give_bonus player\n player.add_weapon(Vibrant_Weapon.new(@window, player))\n end",
"def draw_item_reward(y, item, amount = 1)\n w = contents_width\n w = QuestData::BASIC_DATA_WIDTH if QuestData::BASIC_DATA_WIDTH.between?(1, w)\n x = (contents_width - w) / 2\n draw_item_name(item, x, y, true, w - 40)\n if amount > 1\n change_color(text_color(QuestData::COLOURS[:reward_amount]))\n draw_text(x + w - 40, y, 40, line_height, sprintf(QuestData::VOCAB[:reward_amount], amount), 2)\n end\n end",
"def command_use_point\r\r\n if $game_actors[@actor.id].skill_tree[0] == 0 || confirm_skill_add\r\r\n Sound.play_buzzer\r\r\n @confirm.close\r\r\n @confirm.active = false\r\r\n else\r\r\n @skills_icons[@skill_selected].opacity = 255\r\r\n $game_actors[@actor.id].skill_tree[0] -= 1\r\r\n $game_actors[@actor.id].lose_jp(Actor[@actor.id][@skill_selected]['JP'])\r\r\n $game_actors[@actor.id].skill_mult[Actor[@actor.id][@skill_selected]['Skill_id']] += Actor[@actor.id][@skill_selected]['Multiply']\r\r\n $game_actors[@actor.id].skill_tree[Actor[@actor.id][@skill_selected]['Skill_id']] += 1\r\r\n $game_actors[@actor.id].learn_skill(Actor[@actor.id][@skill_selected]['Skill_id'])\r\r\n @info_window.refresh(@actor, @tree)\r\r\n Audio.se_play(\"Audio/SE/Skill3\",75,100)\r\r\n @confirm.close\r\r\n @confirm.active = false\r\r\n if $game_switches[19] # achievement available?\r\r\n #------------------------------------------------------------------------------- \r\r\n # Trophic: Markspony\r\r\n #-------------------------------------------------------------------------------\r\r\n earn_trophic = true\r\r\n for i in 546..561\r\r\n if !$game_actors[@actor.id].skill_learned?(i) && !$ACH_markspony\r\r\n earn_trophic = false\r\r\n break\r\r\n end\r\r\n end\r\r\n \r\r\n if earn_trophic && !$ACH_markspony\r\r\n $ACH_markspony = true\r\r\n GameJolt.award_trophy(\"53491\")\r\r\n p sprintf(\"Achievement unlock - markspony\")\r\r\n $game_system.earn_achievement(:markspony)\r\r\n end\r\r\n #------------------------------------------------------------------------------- \r\r\n # Trophic: Elementalist\r\r\n #------------------------------------------------------------------------------- \r\r\n earn_trophic = true\r\r\n for i in 563..582\r\r\n next if i == 567 || i == 571 || i == 577 || i == 581 \r\r\n if !$game_actors[@actor.id].skill_learned?(i) && !$ACH_elementalist\r\r\n earn_trophic = false\r\r\n break\r\r\n end\r\r\n end\r\r\n \r\r\n if earn_trophic && !$ACH_elementalist\r\r\n $ACH_elementalist = true\r\r\n GameJolt.award_trophy(\"53485\") \r\r\n p sprintf(\"Achievement unlock - elementalist\")\r\r\n $game_system.earn_achievement(:elementalist)\r\r\n end\r\r\n #---------------------------------------------------\r\r\n end\r\r\n end\r\r\n end",
"def quest(quest_id); $game_party.quests[quest_id]; end",
"def handle(weapon)\n weapon = weapon.to_sym if weapon\n output = \"\"\n return \"No monster here\\n\" unless @game.current_room_model.monster\n # Get the input for the user\n\n player = @game.player\n items = @game.player.items\n weapons = items[:weapons]\n # Omitted double ask for key line 740\n new_ferocity = @game.current_room_model.monster.ferocity\n\n if items.has_key? :suit\n output << \"Your armor increases your chance of success.\\n\"\n new_ferocity = 3 * (@game.current_room_model.monster.ferocity / 4).to_i\n end\n\n has_sword = weapons.include? :sword\n has_axe = weapons.include? :axe\n\n has_two_weapons = has_axe && has_sword\n if not has_two_weapons\n output << \"You must fight with bare hands.\\n\"\n new_ferocity = (new_ferocity + new_ferocity / 5).to_i\n end\n\n has_just_axe = has_axe && !has_sword\n if has_just_axe\n output << \"You has only an axe to fight.\\n\"\n new_ferocity = 4 * (new_ferocity / 5).to_i\n end\n\n has_just_sword = has_sword && !has_axe\n\n if has_just_sword\n output << \"You must fight with your sword.\\n\"\n new_ferocity = 3 * (new_ferocity / 4).to_i\n end\n\n #change to face 2\n #store first axe before sword\n unless weapons.empty?\n new_ferocity = 4 * (new_ferocity / 5).to_i if weapon == :axe\n new_ferocity = 3 * (new_ferocity / 4).to_i if weapon == :sword\n end\n\n #change to face 3 THE BATTLE\n # TODO loop do line 940\n if rand() > 0.5\n output << \"Attacks.\\n\"\n else\n output << \"You attack.\\n\"\n end\n\n if rand() > 0.5 && player.has_torch?\n output << \"Your Torch was knocked from your hand.\\n\"\n items.delete :torch\n end\n\n if rand() > 0.5 && items.has_key?(:axe)\n output << \"You drop your ace in the heat of battle\\n\"\n items.delete :axe\n new_ferocity = 5 * (new_ferocity / 4).to_i\n end\n\n if rand() > 0.5 && items.has_key?(:sword)\n output << \"Your Sword is knocked from your hand!!!\\n\"\n items.delete :sword\n new_ferocity = 4 * (new_ferocity / 3).to_i\n end\n\n if rand() > 0.5\n output << \"You manage to wound it\\n\"\n new_ferocity = (5 * new_ferocity / 6).to_i\n end\n\n if rand() > 0.95\n output << \"Aaaaargh!!\\n\"\n output << \"Rip! Tear! Rip!\\n\"\n end\n\n output << \"You Want to run but you stand your ground...\\n\" if rand() > 0.9\n\n output << '*&%%$#$% $%# !! @ #$$# #$@! #$ $#$' if rand() > 0.9\n\n output << \"Will this be a battle to the death?\\n\" if rand() > 0.7\n\n output << \"His eyes flash fearfully\\n\" if rand() > 0.7\n\n output << \"Blood drips from his claws\\n\" if rand() > 0.7\n\n output << \"You smell the sulphur on his breath\\n\" if rand() > 0.7\n\n output << \"He strikes wildly, madly......\\n\" if rand() > 0.7\n\n output << \"You have never fought and opponent like this!!\\n\" if rand() > 0.7\n\n if rand() > 0.5\n output << \"The monster wounds you!!!\\n\"\n player.strength -= 5\n end\n\n #if the condition of the loop do is false\n if rand() * 16 > new_ferocity\n # TODO implement the to_s from monster\n output << \"And you managed to kill the #{@game.current_room_model.monster.name}\\n\"\n player.monsters_killed += 1\n # TODO update game room status\n else\n output << \"The #{@game.current_room_model.monster.name} defeated you\\n\"\n player.strength /= 2\n end\n @game.state = ExploringState.new @game\n\n output << \"\\n\"\n output << @game.state.status\n\n output\n end",
"def quest; end",
"def weaponState _args\n \"weaponState _args;\" \n end",
"def load_abs_tool(item)\n return if @knockdown_data[0] > 0\n PearlKernel.load_item(item)\n \n return if self.is_a?(Game_Follower) and @targeted_character.nil?\n \n if !@targeting[0] and self.battler.is_a?(Game_Actor)\n if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)\n # apply target to skills items \n if PearlKernel.tool_target == \"true\" || item.scope == 7 ||\n item.scope == 9\n load_target_selection(item)\n return\n end\n else\n # apply target parsing the invoked skill to weapons and armors\n invoke = PearlKernel.tool_invoke\n if invoke != nil && invoke > 0 && invoke != 1 && invoke != 2\n invokeskill = $data_skills[invoke]\n if PearlKernel.tool_target == \"true\" || invokeskill.scope == 7 ||\n invokeskill.scope == 9\n load_target_selection(item)\n return\n end\n # apply target to normal weapon and armor without invoking\n else\n if PearlKernel.tool_target == \"true\"\n load_target_selection(item)\n return\n end\n end\n end\n end\n if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)\n battler.use_item(item) \n else\n if PearlKernel.tool_invoke != 0\n battler.use_item($data_skills[PearlKernel.tool_invoke])\n end\n end\n \n # if the tool has data continue\n if PearlKernel.has_data?\n consume_ammo_item(item) if battler.is_a?(Game_Actor) and\n PearlKernel.tool_itemcost != 0\n @anime_speed = PearlKernel.user_animespeed\n battler.apply_cooldown(item, PearlKernel.tool_cooldown)\n end\n create_projectile_object(item)\n create_anime_sprite_object(item)\n end",
"def getWeaponCargo _args\n \"getWeaponCargo _args;\" \n end",
"def advanced_actor_action(char)\n # initialize skill action\n dmg, heal, neutral = [], [], []\n # iterate through all actions\n $BlizzABS.util.get_actor_skills(char.battler).each {|id|\n # if skill can be used\n if char.skill_can_use?(id)\n # if damaging skill\n if $data_skills[id].power > 0\n # add to array of damaging skills\n dmg.push(id)\n # if healing skill\n elsif $data_skills[id].power < 0\n # add to array of healing skills\n heal.push(id)\n else\n # add to array of neutral skills\n neutral.push(id)\n end\n end}\n # decide a target\n decide_target(char, dmg, heal, neutral, true, true, false)\n end",
"def guild_rewards\r\n BnetApi::make_request('/wow/data/guild/rewards')\r\n end",
"def reward_params\n params.require(:reward).permit(:result_no, :generate_no, :e_no, :battle_income, :add_income, :attack, :support, :defense, :defeat, :selling, :sub_quest, :enemy_caution, :colosseum_win, :fight_money, :total_income, :ammunition_cost, :preparation_deduction, :preparation_cost, :union_cost, :prize, :union_interest, :parts_sell)\n end",
"def weaponCargo _args\n \"weaponCargo _args;\" \n end",
"def execute_action_skill\n # Call a custom battle method\n ty_execute_action_skill\n # Call the original battle method if still attacking\n if @active_battler.action.kind == 1\n ty_ammo_requirements_execute_skill\n end\n end",
"def chooseBestSkill(context, pur, weapon_type, prop)\n p \"choose best skill for #{pur}/#{weapon_type} by #{prop}\"\n # p \"skills #{context[:skills]}(size=#{context[:skills].size})}\"\n attacker_skills = context[:skills]\n \n best_skill = {\n :skill => nil\n }\n best_skill[prop] = 0\n reg2 = Regexp.new(\"#{pur}\", true)\n if (weapon_type and weapon_type.length >0)\n reg = Regexp.new(\"#{weapon_type}\", true)\n else\n reg = /./i\n end\n p \"==>1#{attacker_skills.inspect}\"\n for skill in attacker_skills\n if (!skill || skill.category=='premier')\n next\n end\n skillname = skill.query_data(\"skname\")\n p \"===>skill = #{skill}\"\n p \"===>skill name =#{skillname}\"\n #context[:thisskill] = skill\n# purpose = query_skill(skillname, \"for\", skill, context)\n\n purpose = skill.for # usage: attack parry ...\n type = skill.type # skill type: unarmed, fencing, daofa...\n \n # if skill is for attacking and has correct type with weapon\n if type=~ reg and purpose=~reg2 \n # ret = query_skill(skillname, prop, skill, context)\n # ret = skill.query(prop, context)\n ret = skill_power(skill, context[:user], pur)\n p \"===>#{prop} of #{skillname}: #{ret} \\n\"\n if (ret.to_i > best_skill[prop])\n best_skill[prop] = ret\n best_skill[:skill] = skill\n end\n end\n\n \n #p \"target:\"+@target_class+\", cmd:\"+@cmd+\", param:\"+@cparam\n end\n if ( best_skill[:skill] == nil)\n #if not found, add basic skill for this type of skill\n _skname = weapon_type\n if (pur == 'dodge')\n _skname = 'dodge'\n elsif (pur == 'parry')\n _skname = 'parry'\n end\n if _skname == nil or _skname==\"\"\n raise \"skill name is nil\"\n end\n # us = Userskill.new({\n # :uid => context[:user][:id],\n # :sid => context[:user][:sid],\n # :skid => 0,\n # :skname => _skname,\n # :skdname => \"basic #{weapon_type}\",\n # :level => 0,\n # :tp => 0,\n # :enabled => 1 \n # })\n # us.save!\n us = context[:user].set_skill(_skname, 0, 0)\n attacker_skills.push(us)\n best_skill[:skill] = us\n end\n p \"==>best skill of #{context[:user].name} for #{pur}, skill_type #{weapon_type}: #{best_skill}\"\n return best_skill\n end",
"def queryWeaponPool _args\n \"queryWeaponPool _args;\" \n end",
"def get_block_reward\n blocks = self.blocks_get_reward\n if blocks[\"success\"]\n return blocks[\"reward\"]\n else\n return nil\n end\n end",
"def quest_book\n GamePlay::QuestBookMenu.new.main\n Graphics.transition\n @wait_count = 2\n end",
"def change_reward_status(quest_id, value = true)\n quest(quest_id).reward_given = value\n end",
"def weaponsTurret _obj, _args\n \"_obj weaponsTurret _args;\" \n end",
"def equip(equip_type, id)\n case equip_type\n when 0 # Weapon\n if id == 0 or $game_party.weapon_number(id) > 0\n $game_party.gain_weapon(@weapon_id, 1)\n @weapon_id = id\n $game_party.lose_weapon(id, 1)\n end\n when 1 # Shield\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor1_id], $data_armors[id])\n $game_party.gain_armor(@armor1_id, 1)\n @armor1_id = id\n $game_party.lose_armor(id, 1)\n end\n when 2 # Head\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor2_id], $data_armors[id])\n $game_party.gain_armor(@armor2_id, 1)\n @armor2_id = id\n $game_party.lose_armor(id, 1)\n end\n when 3 # Body\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor3_id], $data_armors[id])\n $game_party.gain_armor(@armor3_id, 1)\n @armor3_id = id\n $game_party.lose_armor(id, 1)\n end\n when 4 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@armor4_id], $data_armors[id])\n $game_party.gain_armor(@armor4_id, 1)\n @armor4_id = id\n $game_party.lose_armor(id, 1)\n end\n when 5 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce1_id], $data_armors[id])\n $game_party.gain_armor(@pierce1_id, 1)\n @pierce1_id = id\n $game_party.lose_armor(id, 1)\n end\n when 6 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce2_id], $data_armors[id])\n $game_party.gain_armor(@pierce2_id, 1)\n @pierce2_id = id\n $game_party.lose_armor(id, 1)\n end\n when 7 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce3_id], $data_armors[id])\n $game_party.gain_armor(@pierce3_id, 1)\n @pierce3_id = id\n $game_party.lose_armor(id, 1)\n end\n when 8 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce4_id], $data_armors[id])\n $game_party.gain_armor(@pierce4_id, 1)\n @pierce4_id = id\n $game_party.lose_armor(id, 1)\n end \n when 9 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce5_id], $data_armors[id])\n $game_party.gain_armor(@pierce5_id, 1)\n @pierce5_id = id\n $game_party.lose_armor(id, 1)\n end\n when 10 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce6_id], $data_armors[id])\n $game_party.gain_armor(@pierce6_id, 1)\n @pierce6_id = id\n $game_party.lose_armor(id, 1)\n end\n when 11 # Accessory\n if id == 0 or $game_party.armor_number(id) > 0\n update_auto_state($data_armors[@pierce7_id], $data_armors[id])\n $game_party.gain_armor(@pierce7_id, 1)\n @pierce7_id = id\n $game_party.lose_armor(id, 1)\n end \n end\n $game_switches[100] = true\n end",
"def currentWeapon _args\n \"currentWeapon _args;\" \n end",
"def make_basic_action_result\n # If the current actor's weapon does not target all\n if @active_battler.current_action.basic != 128\n # Call the original method\n targetall_action\n else\n # Set animation ID\n @animation1_id = @active_battler.animation1_id\n @animation2_id = @active_battler.animation2_id\n # check restrictions and set targets\n @target_battlers = []\n # If attacking allies\n if @active_battler.restriction == 3\n # Attack all allies\n set_target_battlers(4)\n # If attacking enemies\n else\n # Attack all enemies\n set_target_battlers(2)\n end\n # Apply normal attack results\n for target in @target_battlers\n target.attack_effect(@active_battler)\n end\n end\n end",
"def reward_params\n params.require(:reward).permit(:title, :description, :price, :product_id, :user_id)\n end",
"def evaluate_item_with_target(target)\r\n target.result.clear\r\n target.make_damage_value(subject, item)\r\n if item.for_opponent?\r\n return target.result.hp_damage.to_f / [target.hp, 1].max\r\n else\r\n recovery = [-target.result.hp_damage, target.mhp - target.hp].min\r\n return recovery.to_f / target.mhp\r\n end\r\n end",
"def game_barrel_action\n if tool_canuse?(BAweaponId) and not @showing_barrel\n if $game_party.has_item?($data_items[BarrelItemCost]) \n $game_party.consume_item($data_items[BarrelItemCost])\n @gamebarrel.direction = @direction\n @gamebarrel.moveto(@x, @y)\n @gamebarrel.jump_passable?(1) ? @gamebarrel.start_jump(1) :\n @gamebarrel.jump(0, 0)\n @showing_barrel = true\n @tool_anime = 20\n RPG::SE.new(BarrelActionSe,80).play\n else\n Sound.play_buzzer\n end\n end\n end",
"def damage(item_damaged) #allow the item class to be use through the parameter\n until @current_time == @time || item_damaged.item_health == 0 || @tool_health == 0\n item_damaged.item_health -= 5\n @tool_health -= 10\n @current_time += 1\n end\n end",
"def process_tool_action(item)\n PearlKernel.load_item(item)\n return if !battler.tool_ready?(item)\n \n unless PearlKernel.has_data?\n if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)\n msgbox('Tool data missing') if $DEBUG\n return\n end\n if item.scope.between?(1, 6)\n msgbox('Tool data missing') if $DEBUG\n return\n elsif item.scope == 0\n return\n \n elsif !battler.usable?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return \n end\n end\n \n if PearlKernel.has_data? and not usable_test_passed?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return\n end\n \n @user_casting = [PearlKernel.tool_castime,item] if PearlKernel.has_data?\n if @user_casting[0] > 0\n @animation_id = 0\n @animation_id = PearlKernel.tool_castanimation\n else\n load_abs_tool(item)\n end\n end",
"def skillitem_process(ch, object)\n # determine whether skill or item for easier reference\n case object\n when RPG::Skill\n skill, d, time = true, Skills.range(object.id), Skills.trap(object.id)\n type, charge = Skills.type(object.id), Skills.charge(object.id)\n projectile_speed = Skills.projectile_speed(object.id)\n spriteset = BlizzABS::SPRProjSkill\n when RPG::Item\n skill, d, time = false, Items.range(object.id), Items.trap(object.id)\n type, charge = Items.type(object.id), Items.charge(object.id)\n projectile_speed = Items.projectile_speed(object.id)\n spriteset = BlizzABS::SPRProjItem\n end\n # fix the missing explosion animation error\n type[2] = 0 if type[1] != EXPLNone && type[2] == nil\n # if enemy\n if ch.is_a?(Map_Enemy) && charge[0] == CHARGETrigger\n # correct charge type\n charge[0] = CHARGEMove\n end\n # if not charging already and no selection data\n if charge[0] != CHARGENone && !ch.charging? &&\n $game_temp.select_data == nil\n # setup charging\n ch.setup_charge(object, charge)\n # not used yet\n return false\n end\n # if summoning\n if type[0] == SUMMON\n # nobody except actors can summon with caterpillar turned on\n return false unless ch.is_a?(Map_Actor) && $game_system.caterpillar\n # get summoning data\n summon = (skill ? Skills.summon(object.id) : Items.summon(object.id))\n # if summon ID or time is 0\n if summon[0] == SUMMONNone || summon[1] == 0 || summon[2] == 0\n # no summoning\n return false \n end\n # no summoning if already summoned\n return false if (@pets + @monsters).any? {|b| b.battler_id == summon[1]}\n # if any summon limit reached\n if summon[0] == SUMMONPet && @pets.size >= BlizzABS::Config::MAX_PETS ||\n summon[0] == SUMMONMonster &&\n @monsters.size >= BlizzABS::Config::MAX_MONSTERS ||\n @pets.size + @monsters.size >= BlizzABS::Config::MAX_SUMMONS\n # no summoning\n return false\n end\n # create new map actor\n new_battler = Map_Actor.new(summon[1])\n # if pet\n if summon[0] == SUMMONPet\n # summon pet\n summon_pet(new_battler, summon[2])\n # if monster\n elsif summon[0] == SUMMONMonster\n # summon monster\n summon_monster(new_battler, summon[2])\n else\n # something's not right here, no summoning\n return false\n end\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # move to correct position\n new_battler.moveto(ch.x / pix, ch.y / pix)\n # set correct battler\n new_battler.battler = $game_actors[summon[1]]\n # heal the battler completely\n new_battler.battler.recover_all\n # return to caterpillar first\n new_battler.cindex, new_battler.ai.state = nil, AI::Return\n # refresh display\n new_battler.refresh\n # set animation\n new_battler.animation_id = object.animation2_id\n # summon successful\n return true\n end\n # skill/item used (can be a common event call) if no target scope\n return true if object.scope == 0\n # if targeting self\n if object.scope == 7\n # if skill\n if skill\n # execute skill upon user\n ch.skill_effect(ch, ch.battler, object)\n # check special skill effects\n self.check_special_skills(ch, [ch], object)\n else\n # execute item upon user\n ch.item_effect(ch, object)\n end\n # clear damage displays\n ch.battler.damage, ch.battler.damage_pop = nil, false\n # skill/item used\n return true\n end\n # correct range\n d = 1 if d < 1\n # determine target alignment, dead flag and all flag\n enemy, dead, all = $BlizzABS.util.get_scope_data(object.scope)\n # doesn't target all and no death roulette initially\n target_all = false\n # if Tons is there and skill process\n if $tons_version != nil && $tons_version >= 6.02 && skill\n # if version is correct and Target 'em all! is being used for this skill\n if $game_system.TARGET_EM_ALL && FULL_TARGET_IDS.include?(object.id)\n # targets all and forces all flag\n target_all = all = true\n end\n end\n # temporary variable\n ai = ch.ai\n # determine whether actor or enemy for easier reference\n if ch.is_a?(Map_Actor)\n # decide target group\n group = (((ch == $game_player || ch.restriction != 3) == enemy) ?\n ai.negative : ai.positive)\n else\n # determine target group depending on confusion\n group = (((ch.restriction == 3) == enemy) ? ai.positive : ai.negative)\n end\n # selection only if player using selectable skill/item and not charging\n if ch == $game_player && $game_temp.select_data == nil &&\n (charge[0] == CHARGENone || charge[0] != CHARGENone &&\n ch.charged?) && (target_all || type[0] == HOMING ||\n type[0] == DIRECT || type[0] == BEAM && all)\n # temporary variable, selection skill/item\n handling = 0\n else\n # set handling for projectile skill/item or direct skill/item\n handling = ((type[0] == SHOOT || type[0] == HOMING ||\n type[0] == TRAP || type[0] == TIMED) ? 1 : 2)\n end\n # depending on handling\n case handling\n when 0 # selection\n # create circle shape data\n area = $BlizzABS.util.get_circle_area(ch, d)\n # create fullscreen rectangle\n screen = $BlizzABS.util.get_fullscreen_area\n # no use if scene not Scene_Map or spriteset doesn't exist\n return false if !$scene.is_a?(Scene_Map) || $scene.spriteset == nil\n # get all selectable map battlers\n available = $scene.spriteset.character_sprites.find_all {|sprite|\n sprite.character.is_a?(Map_Battler) &&\n !sprite.character.is_a?(Map_Remote) &&\n group.include?(sprite.character.ai.group) &&\n can_be_hit(sprite.character, dead, type, all, screen, area)}\n # no use if no selectable targets\n return false if available.size == 0\n # sort selectable targets by coordinates\n available.sort {|a, b| b.y > a.y ? 1 : b.y < a.y ? -1 : (b.x <=> a.x)}\n # setup select interuption\n $game_temp.select_data = [object, d * 32, type[0], available]\n # don't use skill/item yet\n return false\n when 1 # projectile\n # decide process branch depending on skill type\n case type[0]\n # set normal or break-through projectile data\n when SHOOT\n # if break-through\n if all\n # set break-through projectile skill or item\n projectype = (skill ? REMBreakSkill : REMBreakSkill)\n else\n # set normal projectile skill or item\n projectype = (skill ? REMNormalSkill : REMNormalItem)\n end\n # set range\n targets = [d]\n # homing skill/item\n when HOMING\n # get circle area\n area = $BlizzABS.util.get_circle_area(ch, d)\n # create fullscreen rectangle\n screen = $BlizzABS.util.get_fullscreen_area\n # get all targets that can be hit\n targets = ($game_map.battlers + $BlizzABS.battlers).find_all {|b|\n can_be_hit(b, dead, type, all, screen, area)}\n # if targetting everybody\n if target_all\n # reflection possible on everybody\n other = targets.clone\n else\n # reflection possible on non-target group\n other = targets.find_all {|b| !group.include?(b.ai.group)}\n # if predefined target exists\n if !all && ai.target != nil\n # set predefined target\n targets = [ai.target]\n else\n # set possible targets\n targets = targets.find_all {|b| group.include?(b.ai.group)}\n end\n end\n # set homing projectile type\n projectype = (skill ? REMInitSkill : REMInitItem)\n # homing skill/item\n when TRAP\n # targets for selection, other targets\n targets, other = [], []\n # set homing projectile type\n projectype = (skill ? REMTrapSkill : REMTrapItem)\n # homing skill/item\n when TIMED\n # targets for selection, other targets\n targets, other = [], []\n # set homing projectile type\n projectype = (skill ? REMTimedSkill : REMTimedItem)\n end\n when 2 # direct\n # if direct skill or shockwave skill\n if type[0] == DIRECT\n # get circle area\n area = $BlizzABS.util.get_circle_area(ch, d)\n # if beam skill (fullscreen skill that does not target all)\n elsif !all\n # get affection area rectangle\n area = $BlizzABS.util.get_front_area(ch, d)\n # initialize\n this = nil\n # if scene is Scene_Map and spriteset exists\n if $scene.is_a?(Scene_Map) && $scene.spriteset != nil\n # find the sprite of this character\n $scene.spriteset.character_sprites.each {|spr|\n if spr.character == ch\n this = spr\n break\n end}\n end\n # if sprite exists\n if this != nil\n # create sprite\n sprite = Sprite.new($scene.spriteset.viewport1)\n # try to\n begin\n # load the characterset file\n sprite.bitmap = RPG::Cache.character(object.icon_name, 0)\n # temporary variables\n w1, h = sprite.bitmap.width, sprite.bitmap.height\n # if failed\n rescue\n # get width and height\n w1, h = 24, d*32\n # create bitmap\n sprite.bitmap = Bitmap.new(w1, h)\n # get image from cache\n b = $BlizzABS.cache.image('beam1')\n # copy the beam image\n (0...h).each {|i|\n a = (i < h/2 ? i**2*2 : (h-i-1)**2*2)\n a = 255 if a > 255\n sprite.bitmap.blt(0, i, b, Rect.new(0, 0, b.width, b.height), a)}\n end\n w2 = case ch.direction\n when 6 then 16-w1/2\n else\n w1/2+16\n end\n # set sprite position, rotation and offsets depending on facing\n case ch.direction\n when 2\n sprite.angle, sprite.ox = 0, w1/2\n sprite.x, sprite.y, sprite.z = this.x, this.y, this.z+1\n when 4\n sprite.angle, sprite.ox, sprite.oy = 270, w2, w1/2+16\n sprite.x, sprite.y, sprite.z = this.x-w1-16, this.y, this.z-1\n when 6\n sprite.angle, sprite.ox, sprite.oy = 90, -w2, -w1/2+16\n sprite.x, sprite.y, sprite.z = this.x+16, this.y, this.z-1\n when 8\n sprite.angle, sprite.ox, sprite.oy = 180, w1/2, h+16\n sprite.x, sprite.y, sprite.z = this.x, this.y-h-32, this.z-32\n end\n # add sprite for handling\n $BlizzABS.cache.beams.push([sprite, 20])\n # set beam flag\n beam = true\n end\n end\n # create fullscreen rectangle\n screen = $BlizzABS.util.get_fullscreen_area\n # get all targets that can be hit\n targets = ($game_map.battlers + $BlizzABS.battlers).find_all {|b|\n can_be_hit(b, dead, type, all, screen, area)}\n # if targetting everybody\n if target_all\n # reflection possible on everybody\n other = targets.clone\n else\n # reflection possible on non-target group\n other = targets.find_all {|b| !group.include?(b.ai.group)}\n # if predefined target exists\n if !all && ai.target != nil\n # set predefined target\n targets = [ai.target]\n else\n # set possible targets\n targets = targets.find_all {|b| group.include?(b.ai.group)}\n end\n end\n end\n # if no selectable targets and not trap\n if targets.size == 0 && projectype != REMTrapSkill &&\n projectype != REMTrapItem && projectype != REMTimedSkill &&\n projectype != REMTimedItem\n # no use\n return (beam == true)\n end\n # if Full Reflection System is being used and not breaking reflection skill\n if $full_reflection_system != nil && $full_reflection_system >= 3.01 &&\n targets[0].is_a?(Map_Battler) && skill && !beam &&\n !BlizzCFG::BREAK_REFLECT.include?(object.id) &&\n projectype != REMTrapSkill && projectype != REMTrapItem &&\n projectype != REMTimedSkill && projectype != REMTimedItem\n # execute reflection effect in Blizz-ABS\n BlizzCFG.reflection_effect_blizzabs(ch, targets, other, object)\n end\n # get a random target if not targeting all and no beam or death roulette\n targets = [targets[rand(targets.size)]] if !all && !beam\n # if projectile data is available and projectile should be created\n if projectype != nil\n # temporary variable\n explode = (type[1] != EXPLNone ? type[1, 3] : nil)\n # if trap\n if projectype == REMTrapSkill || projectype == REMTrapItem\n # create trap\n proj = Map_Trap.new(spriteset + object.id.to_s, ch, object.id, d,\n time, projectype, group, dead, explode)\n # add trap to buffer\n $BlizzABS.cache.remotes.push(proj)\n # if timed trap\n elsif projectype == REMTimedSkill || projectype == REMTimedItem\n # create timed trap\n proj = Map_Timed.new(spriteset + object.id.to_s, ch, object.id, d,\n time, projectype, group, dead, explode)\n # add timed trap to buffer\n $BlizzABS.cache.remotes.push(proj)\n else\n # iterate through all targets\n targets.each {|target|\n # create projectile\n proj = Map_Projectile.new(spriteset + object.id.to_s, ch,\n object.id, target, projectile_speed, projectype, group, dead,\n explode)\n # add projectile to buffer\n $BlizzABS.cache.remotes.push(proj)}\n end\n # if skill\n elsif skill\n # execute skill effect upon all targets\n targets.each {|target| target.skill_effect(ch, ch.battler, object)}\n # check special skill effects\n self.check_special_skills(ch, targets, object)\n # clear damage displays upon all targets\n targets.each {|target|\n target.battler.damage, target.battler.damage_pop = nil, false}\n else\n # upon all targets\n targets.each {|target|\n # execute item effect\n target.item_effect(ch, object)\n # clear damage displays\n target.battler.damage, target.battler.damage_pop = nil, false}\n end\n # skill/item use successful\n return true\n end",
"def make_skill_sequence_action_result(battler)\n old_skill = $data_skills[battler.old_skill_used_id]\n battler.current_skill = battler.now_action\n unless battler.current_action.forcing or battler.multi_action_running\n unless battler.skill_can_use?(old_skill.id)\n $game_temp.forcing_battler = nil\n return\n end\n end\n unless battler.multi_action_running\n battler.consume_skill_cost(old_skill)\n end\n if old_skill.scope != battler.current_skill.scope\n battler.target_battlers = []\n set_targets(battler)\n end\n battler.multi_action_running = true\n @status_window.refresh if status_need_refresh\n battler.animation_1 = battler.now_action.animation1_id\n battler.animation_2 = battler.now_action.animation2_id\n @common_event_id = battler.current_skill.common_event_id\n for target in battler.target_battlers\n target.skill_effect(battler, battler.current_skill)\n end\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def execute_action\n # This is a VERY lazy way for using different enemy ammo counts.\n # When it's the enemies turn, add one to enemy_attack. This acts as a index\n # For emoving enemy ammo. It's an extremely simple and lazy way :x\n if @active_battler.is_a?(Game_Actor)\n @enemy_attack = -1\n else\n @enemy_attack += 1\n end\n ty_ammo_requirements_execute_action\n end",
"def default_reward\n\t\tself.rewards.create(:description => \"Thanks!\", :dollar_amount => 1)\n\tend",
"def setup_damage\n return if item_in_use.nil?\n item = copy(item_in_use) \n # Copy item. In case if you want to modify anything\n \n # ----- Evaluate skill ------- #\n if @acts[1].is_a?(String) # Change formula? No prob ~\n item.damage.formula = @acts[1]\n elsif @acts[1].is_a?(Integer) # Skill link? No prob ~\n item = $data_skills[@acts[1]]\n elsif @acts[1].is_a?(Float) # Rescale damage? No prob ~\n item.damage.formula = \"(#{item.damage.formula}) * #{@acts[1]}\"\n end\n \n # ------- Check target scope ------- #\n if area_flag && target_array\n # Damage to all targets ~\n target_array.uniq.each do |target|\n get_scene.tsbs_invoke_item(target, item, self)\n # Check animation guard\n if !item.ignore_anim_guard? && item.parallel_anim?\n target.anim_guard = target.anim_guard_id\n target.anim_guard_mirror = target.flip\n end\n end\n elsif target\n # Damage to single target\n get_scene.tsbs_invoke_item(target, item, self)\n # Check animation guard\n if !item.ignore_anim_guard? && item.parallel_anim?\n target.anim_guard = target.anim_guard_id\n target.anim_guard_mirror = target.flip\n end\n end\n end",
"def gain_item\n\t\titem = $data_items\n\t\t$game_party.gain_item(item[1], 1)\n\tend",
"def decide_target(char, dmg, heal, neutral, attack, defend, escape)\n # temporary variables\n x, y, ai = char.x, char.y, char.ai\n # get alignment setup\n negative, positive = ai.negative, ai.positive\n # invert setup if confused\n negative, positive = positive, negative if char.restriction == 3\n # initialize arrays\n allies, enemies = [char], []\n # if enemy\n if char.is_a?(Map_Enemy)\n # find all allies and all enemies in memory\n ai.memory.each_key {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n # if actor\n elsif char.is_a?(Map_Actor)\n # find all allies and all enemies in sight\n ai.sight.each {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n end\n # find all allies who need healing\n to_heal = allies.find_all {|b| b.valid? && b.battler.hp < b.battler.maxhp}\n # if decided to heal\n if (heal.size > 0 && to_heal.size > 0 && (ai.healer || rand(3) == 0) &&\n rand(5) == 0)\n # find all skills that heal all allies\n allheal = heal.find_all {|id|\n $data_skills[id].scope == 2 || $data_skills[id].scope == 4 ||\n $data_skills[id].scope == 6}\n # test again flag\n test_again = true\n # if more than 1 ally who needs healing exists and allheal skills exist\n if to_heal.size > 1 && allheal.size > 0\n # initialize data\n decided, now, new = nil, [], []\n # iterate through all all-healing skills\n allheal.each {|id|\n # fake Blizz-ABS action setup\n ai.act.set(Skills.range(id), ACTSkill, id, Skills.type(id)[0],\n ai.delay_time)\n # all allies who can be targeted by this skill\n new = to_heal.find_all {|b| $BlizzABS.can_execute?(char, b, ai.act)}\n # if not decided yet\n if decided == nil\n # decide this skill and those allies\n decided, now = id, new\n # 50% chance\n elsif rand(2) == 0\n # intialize damage counters\n dmg1 = dmg2 = 0\n # sum up all damage for last decided targets\n now.each {|b| dmg1 += b.battler.maxhp - b.battler.hp}\n # sum up all damage for new targets\n new.each {|b| dmg2 += b.battler.maxhp - b.battler.hp}\n # decide this skill if it contains battlers with more damaged HP\n decided, now = id, new if dmg2 > dmg1\n # if more battlers would be affected by this skill\n elsif new.size > now.size\n # decide this skill and those allies\n decided, now = id, new\n end}\n # if more than one battler can be healed\n if now.size > 1\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n # don't test for one battler\n test_again = false\n end\n end\n # if should test for one battler\n if test_again\n # find all skills that heal one ally\n oneheal = heal.find_all {|id|\n $data_skills[id].scope == 1 || $data_skills[id].scope == 3 ||\n $data_skills[id].scope == 5}\n # if any skill exists\n if oneheal.size > 0\n # decided action\n decided = oneheal[rand(oneheal.size)]\n # decided target\n ai.target = to_heal[rand(to_heal.size)]\n else\n # decided action\n decided = heal[rand(heal.size)]\n end\n # stop execution if no skill decided\n return false if decided == nil\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n end\n # confirm execution\n return true\n end\n # not decided to escape yet\n escaping = false\n # if able to run away\n if escape && rand(5) == 0\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler, ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 2\n # set this battler as escape reference\n ai.target = b\n # running away\n escaping = true\n # abort iteration\n break\n end\n end}\n # 20% chance\n elsif rand(5) == 0\n # initialize minimum range\n min = nil\n # iterate through all enemies\n enemies.each {|b|\n # if closer than anybody else\n if (b.is_a?(Map_Actor) && (min == nil ||\n Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y) < min))\n # set this battler as escape reference\n ai.target = b\n # set new minimum range\n min = Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y)\n # running away\n escaping = true\n # abort iteration\n break\n end}\n end\n end\n # if decided to escape\n if escaping\n # set AI state\n ai.state = Escape\n # set action data\n ai.act.set(ai.view_range - 1, ACTEscape, 0, 0, 80)\n # confirm execution\n return true\n end\n # not decided to defend yet\n defending = false\n # if able to defend\n if defend && rand(5) == 0\n # probability factor if higher if defensive and reset defend flag\n factor = rand(ai.defensive ? 10 : 30)\n # if decided to defend\n if char.battler.hp * 100 / char.battler.maxhp < factor\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler,\n ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 3\n # defending\n defending = true\n # abort iteration\n break\n end\n end}\n # 33% chance\n elsif enemies.size > 0 && rand(5) == 0\n # decided to defend\n defending = true\n end\n end\n end\n # if decided to defend\n if defending\n # set AI state\n ai.state = Defend\n # target the closest enemy\n ai.target = enemies.min {|a, b|\n Math.hypot(x-b.x, y-b.y) <=> Math.hypot(x-a.x, y-a.y)}\n # turn toward the target if target exists and not being force moved\n char.turn_toward(ai.target) if ai.target != nil && char.move_type != 3\n # use defend action\n char.use_defend\n # set action data\n ai.act.set(3, ACTDefend, 0, 0, rand(31) + 70)\n # confirm execution\n return true\n end\n # number of skills\n skill_number = dmg.size + heal.size + neutral.size\n # if able to attack and chosen to attack\n if attack && (skill_number == 0 || rand(skill_number) == 0)\n # if enemy\n if char.is_a?(Map_Enemy)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Enemies.range(char.battler_id), ACTAttack, 0,\n Enemies.type(char.battler_id), ai.delay_time)\n # if observing attribute and not confused\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if actor\n elsif char.is_a?(Map_Actor)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Weapons.range(char.battler.weapon_id), ACTAttack, 0,\n Weapons.type(char.battler.weapon_id), ai.delay_time)\n end\n # if no target exists\n if ai.target == nil || !ai.target.valid?\n # get any enemy\n ai.target = enemies[rand(enemies.size)]\n end\n # confirm execution\n return true\n end\n # decide a random skill action\n decided = (dmg + neutral)[rand(dmg.size + neutral.size)]\n # if action exists\n if decided != nil\n # if observing\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if no target was decided\n if ai.target == nil || !ai.target.valid?\n # if targeting enemies\n if $data_skills[decided].scope == 0 ||\n $data_skills[decided].scope == 1 ||\n $data_skills[decided].scope == 2\n # select a random enemy target\n ai.target = enemies[rand(enemies.size)]\n else\n # select a random ally target\n ai.target = allies[rand(allies.size)]\n end\n end\n end\n # stop execution if no target selected\n return false if ai.target == nil || !ai.target.valid?\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time)\n # confirm execution\n return true\n end",
"def prapor_quest; end",
"def set_reward\n @reward = Reward.find(params[:id])\n end",
"def set_reward\n @reward = Reward.find(params[:id])\n end",
"def set_reward\n @reward = Reward.find(params[:id])\n end",
"def currentWeaponTurret _obj, _args\n \"_obj currentWeaponTurret _args;\" \n end",
"def reward(opponent, groupsize)\n @experience = @experience + opponent.max_health / groupsize\n if @experience >= LEVEL_THRESHOLDS[@level]\n upgrade(@level)\n end\n end",
"def weaponLowered _args\n \"weaponLowered _args;\" \n end",
"def ranged_weapon\n fetch('dnd.ranged_weapons')\n end",
"def fence_quest; end",
"def search_weapon\n\t\t@weapon = rand(1..6)\n\t\tputs \"Tu as trouvé une arme de niveau #{@weapon}\"\n\t\tif @weapon <= @weapon_level # Si le niveau est inférieur ou égal au niveau de l'ancienne arme, on garde l'ancienne.\n\t\t\tputs \" M@*#$ l'arme trouvée est vraiment bidon, tu gardes l'ancienne\"\n\t\telse \n\t\t\tputs \"De la frappe frere !\\n\\n\"\n\t\t\t@weapon_level = @weapon # Si meilleure arme, on la prend\n\t\tend\n\tend",
"def battle\n # Your failures might strengthen the enemy\n rune_charges = 0\n if @artifact_rune == 0\n puts \"Rune of Dwayna provides Balthazar regeneration\"\n puts \"When he is about to die, he will use this artifact\"\n puts\n rune_charges = 3\n end\n\n puts \"Don't be afraid of fighting a God, #{@gladiator.name}\"\n puts \"As just a mere mortal, you brought him upon your feet!\"\n puts \"And after all you can gaze into his eyes without any trouble\"\n puts \"Still be careful and choose your weapon wisely.\"\n puts \"Don't forget, he draws his powers from Fire.\"\n puts \"When you are ready, enter any key to continue...\"\n gets\n # User character's base values\n gladiator_str = @gladiator.strength+10\n gladiator_heal = @gladiator.health*10\n\n puts \"Commander, your initial strength is #{gladiator_str}\"\n puts \"Commander, your initial health is #{gladiator_heal}\"\n puts \"Enchant your weapon with the sigil of your choice:\"\n\n puts \"1) Sigil of Water\"\n puts \"2) Sigil of Earth\"\n puts \"3) Sigil of Fire\"\n puts \"4) Sigil of Air\"\n puts \"5) No Sigil\"\n # Enemy base values\n enemy_str = 5\n enemy_heal = 150\n # Character may get a buff/nerf according to his choice\n sigil = gets.to_i\n\n if sigil == 1\n puts \"Sigil Of Water, very good choice against the God of Fire...\"\n gladiator_str += 10\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 2\n puts \"Sigil Of Earth, kind of a good choice against the God of Fire...\"\n gladiator_str += 5\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 3\n puts \"Sigil Of Fire, very bad choice against the God of Fire...\"\n gladiator_str -= 10\n puts \"Your strength has increased to #{gladiator_str}\"\n elsif sigil == 4\n puts \"Sigil Of Air, not a good choice against the God of Fire...\"\n gladiator_str -= 5\n puts \"Your strength has increased to #{gladiator_str}\"\n else\n puts \"You decided to use no sigil on your weapon.\"\n end\n\n puts \"When you are ready, enter any key to continue...\"\n gets\n\n puts \"The battle has begun!\"\n # Battle continues while enemy and gladiator are alive\n while enemy_heal > 0 && gladiator_heal > 0\n\n puts \"You attack Balthazar successfully\"\n enemy_heal -= gladiator_str\n puts \"Balthazar's health is #{enemy_heal}\"\n # In enemy possesses a special item, he can heal back several times.\n if enemy_heal <= 0 && rune_charges > 0\n puts \"Balthazar uses Rune of Dwayna to heal the killing blow\"\n enemy_heal += gladiator_str\n rune_charges -= 1\n end\n # Enemy always strikes last\n if enemy_heal > 0\n puts \"Balthazar strikes at you\"\n gladiator_heal -= enemy_str\n puts \"Your health is #{gladiator_heal}\"\n @gladiator.notify(\"harm\")\n puts\n end\n end\n # Outcome of final battle is designated here.\n # User has several retry changes before losing completely.\n if enemy_heal <= 0\n @gladiator.notify(\"win\")\n puts \"You have defeated Balthazar! Now the world is safe.\"\n puts \"Or is it?\"\n puts \"...\"\n\n elsif @retries > 0\n @gladiator.notify(\"lose\")\n puts \"Balthazar has beaten you... You'll return again.\"\n @retries -= 1\n battle\n else\n @gladiator.notify(\"lose\")\n puts \"You are dead... Game Over!\"\n end\n end",
"def award; end"
] | [
"0.71311235",
"0.6763951",
"0.67126644",
"0.64617056",
"0.63388056",
"0.6338314",
"0.63285893",
"0.6294439",
"0.6290409",
"0.62730455",
"0.61566705",
"0.6155623",
"0.60622466",
"0.605999",
"0.602159",
"0.598551",
"0.59470385",
"0.5893555",
"0.58841527",
"0.5860339",
"0.58595616",
"0.5857397",
"0.58257055",
"0.5821826",
"0.58075505",
"0.5801628",
"0.5801628",
"0.5801628",
"0.57667524",
"0.5763035",
"0.57536995",
"0.5750167",
"0.5744235",
"0.5735746",
"0.5733111",
"0.57295054",
"0.57199883",
"0.57132006",
"0.57055855",
"0.57013154",
"0.5696616",
"0.56889004",
"0.56814164",
"0.56755346",
"0.5656482",
"0.5645752",
"0.56427735",
"0.56381834",
"0.56256694",
"0.56247234",
"0.56210846",
"0.56194746",
"0.56102616",
"0.5606021",
"0.5600111",
"0.55888665",
"0.55779374",
"0.5564324",
"0.5547146",
"0.55462384",
"0.55461276",
"0.552823",
"0.55124074",
"0.5505213",
"0.5498245",
"0.5496578",
"0.54951805",
"0.5491415",
"0.54764885",
"0.5449197",
"0.5448699",
"0.54426366",
"0.54398",
"0.54369265",
"0.54339653",
"0.54286957",
"0.5406456",
"0.5405883",
"0.54006577",
"0.5386526",
"0.5386526",
"0.5386526",
"0.5386526",
"0.5381569",
"0.53805524",
"0.5379048",
"0.5372706",
"0.5354481",
"0.53535694",
"0.5350744",
"0.5350744",
"0.5350744",
"0.53294814",
"0.5328315",
"0.53259206",
"0.53226656",
"0.53199995",
"0.5319244",
"0.53179044",
"0.5316265"
] | 0.7366794 | 0 |
Methods for fighting other players obtain potential targets for a given player only select other characters with power less than or equal to player's power + 2 level this will return character objects | def recommended_targets
Character.all.select do |character|
character.power <= (self.power + 2) && character != self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_available_weapons(difficulty)\n\n#if the difficulty of the quest is 1\n#only select weapons with attack power less than or equal to 3\n# and that the player has not yet obtained\n if difficulty == 1\n available_weapons = Weapon.all.where(\"attack_power <=3\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n#if the difficulty of the quest is 2\n#only select weapons with attack power greater than 3 and less than or equal to 6\n# and that the player has not yet obtained\n elsif difficulty == 2\n available_weapons = Weapon.all.where(\"attack_power >3 and attack_power <= 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n\n\n#if the difficulty of the quest is 3\n#only select weapons with attack power greater than 6\n# and that the player has not yet obtained\n else\n available_weapons = Weapon.all.where(\"attack_power > 6\").select do |weapon|\n weapon.characters.include?(self) == false\n end\n end\n end",
"def make_attack_targets\n targets = []\n if battler.confusion?\n targets.push(friends_unit.random_target)\n elsif battler.berserker?\n targets.push(opponents_unit.random_target)\n else\n targets.push(opponents_unit.smooth_target(@target_index))\n end\n if battler.dual_attack # Chain attack\n targets += targets\n end\n return targets.compact\n end",
"def ygg_get_targets( l_x=0, l_y=0, target=\"ALL\", exclude_self = false )\n objects = $game_yggdrasil.battlers_xy( l_x, l_y ).inject([]) { |result, event|\n if event.targetable?( target )\n result.push( event )\n end unless (exclude_self && event == self)\n result\n }\n if $game_player.pos?( l_x, l_y ) and $game_player.targetable?( target )\n objects.push( $game_player )\n end unless (exclude_self && $game_player == self)\n return objects\n end",
"def targeted_battlers\n result = []\n for battler in SceneManager.scene.tactics_all\n next if battler.hidden?\n result.push battler if battler.positions & @target_positions != []\n end\n return result\n end",
"def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n victory = false\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n emp_phase(@attacker)\n emp_phase(@defender)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n turn_fleet.each do |fleet|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if fleet[1] > 0 && fleet[2] > 0 \n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target==-1)\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if fleet[3] == 2\n mult = DamageType.find(fleet[3]).shield_mult\n end\n damage = fleet[2] * mult\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult = 1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if (fleet[3] == 1)\n mult = DamageType.find(fleet[3]).shell_mult\n end \n if fleet[3] == 3 and !fleet[6]\n mult = DamageType.find(fleet[3]).station_mult\n end\n if fleet[3] == 4 and fleet[0] == @plattform_id\n mult = DamageType.find(fleet[3]).plattform_mult\n end \n # Bestimme welche Einheit getroffen wurde\n victim = target_fleet[target]\n # Schadensberechnung\n damage = fleet[2] * mult\n # Berechne neue HP\n hit_points = victim[-2]\n victim[-2] = hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim, target_user)\n end\n end \n end\n # Füge Runden-Bericht ein\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue = false\n if turn_user == @attacker\n victory = true \n end\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user == @attacker\n @attacker_shield = @fight_shield\n else\n @defender_shield = @fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet = turn_fleet\n tmp_user = turn_user\n turn_fleet = target_fleet\n turn_user = target_user\n target_fleet = tmp_fleet\n target_user = tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n attacker_fleet_ary = []\n defender_fleet_ary = []\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n attacker_fleet_ary = turn_fleet\n defender_fleet_ary = target_fleet\n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n\n attacker_fleet_ary = target_fleet\n defender_fleet_ary = turn_fleet\n end\n update_fighting_fleet(@attacker_fleet, attacker_fleet_ary)\n update_fighting_fleet(@defender_fleet, defender_fleet_ary)\n ary = [@attacker_fleet, @defender_fleet] \n return [@report, @spy_report]\n end",
"def attack(target)\n\n #check to see if there is any target\n if target == nil\n puts \"Invite some friends to play this awesome game.\".blue\n\n else\n #print fighting for the user\n\n puts Artii::Base.new.asciify \"Fight\"\n\n\n\n ###methods for determining probability of victory\n ###and damage to the opponent or current user#####\n\n #if the characters have the same attack power\n if self.power == target.power\n\n #if the player wins the battle\n if rand > 0.5\n\n #reduce the target's hp by 10\n target.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #see if the target is still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a greater attack power than that of the target\n elsif self.power > target.power\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand < (0.4 + ((self.power - target.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-5*(self.power - target.power))\n\n #print outcome of the battle\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a lower attack power than that of the target\n else\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand > (0.45 + ((target.power - self.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-2*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-3*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n end\n end\n end",
"def skill_power(skillname, player, usage)\n p \"==>calc #{player.name} skill power of #{skillname} for #{usage}:\"\n skill = player.query_skill(skillname)\n if (skill == nil)\n #logger.info(\"user #{player[:id]}-#{player.ext[:name]} doesn't have skill '#{skillname}'\")\n return 1\n end\n # p = skill.power(context)\n level = skill.data[:level]\n p \"=>level=#{level} apply_attack=#{player.tmp[:apply_attack]} apply_dodge=#{player.tmp[:apply_dodge]}\"\n \n if (usage == \"attack\" && player.tmp[:apply_attack] != nil)\n level += player.tmp[:apply_attack]\n end\n \n if (usage == \"dodge\" && player.tmp[:apply_dodge] != nil)\n # level += player.tmp[:apply_dodge]\n level = level * ( (100 + player.tmp[:apply_dodge]/10 ).to_f / 100 )\n end \n \n # if (usage == \"parry\" && player.tmp[:apply_defense] != nil)\n # level += player.tmp[:apply_dodge]\n # end \n jingli_bonus = 50 + player.tmp[:jingli]/ (player.tmp[:max_jl]+1) * 50\n if (jingli_bonus > 150)\n jingli_bonus = 150\n end\n \n total_exp = calc_total_exp(player.tmp[:level])\n p \"level=#{level} jingli_bonus=#{jingli_bonus}, total exp #{total_exp}\"\n if( level<1 ) \n return (total_exp/20.0 * (jingli_bonus/10) ).to_i\n end\n\n \n p =level**3/3 \n str = player.tmp[:str]\n dext = player.tmp[:dext]\n # p \"===>#{player.tmp.inspect}\"\n \n p \"==>p=#{p}, level=#{level} str=#{str} dext=#{dext} \"\n if (usage == \"attack\" || usage == \"parry\")\n p = (p + total_exp +1) / 30 * (( str+1)/10)\n else\n p = (p + total_exp +1) / 30 * (( dext+1)/10)\n end\n \n p = p.to_i\n p \"==>skill power=#{p}\"\n \n if p <= 1\n return 1\n else\n return p\n end\n end",
"def weapon_reward(available_weapons)\n\n #reward is 1 random choice from this array\n reward = available_weapons.sample\n\n #create to CharacterWeapon object to show that player obtains weaopn\n CharacterWeapon.new_character_weapon(self.id, reward.id)\n\n #print weapon details to player\n puts \"#{reward.name}\".bold.blue\n puts \"Weapon Power: #{reward.attack_power}\"\n puts\"#####################################\".blink\n\n #actually equip the weapon, if it will increase this player's attack power\n if reward.attack_power > self.power - 1 || self.power == 1\n #increase the player's attack power\n self.update(power: 1+reward.attack_power)\n end\n end",
"def util_targetselection_get_possible(launcher,skill)\n if launcher.position < 0\n arr = []\n util_targetselection_adjacent_pokemon(launcher).each do |target|\n arr << target if seviper_zangoose_detect(launcher, target)\n end\n return arr if arr.size > 0\n end\n case skill.target\n when :adjacent_pokemon # eo eo ex / ux ao ax\n return util_targetselection_adjacent_pokemon(launcher)\n when :adjacent_foe # eo eo ex / ux ax ax\n return util_targetselection_adjacent_foe(launcher)\n when :user_or_adjacent_ally # ex ex ex / uo ao ax\n return [launcher]+util_targetselection_adjacent_ally(launcher)\n when :adjacent_ally # ex ex ex / ux ao ax\n return util_targetselection_adjacent_ally(launcher)\n when :any_other_pokemon # ex ex ex / uo ax ax\n arr = ::BattleEngine.get_enemies!(launcher)\n arr += util_targetselection_adjacent_ally(launcher)\n return arr\n end\n return nil\n end",
"def tbs_make_attack_targets \n targets = []\n targets += subject.opponents + subject.friends\n targets &= subject.opponents if !GTBS::ATTACK_ALLIES\n targets &= $tbs_cursor.targeted_battlers \n targets = targets.select {|target| target.dead? == false}\n return targets.compact\n end",
"def battler_targets(pokemon, logic)\n case target\n # eo eo ex / ux ao ax || e! e! ex / ux a! ax\n when :adjacent_pokemon, :adjacent_all_pokemon\n return logic.adjacent_foes_of(pokemon).concat(logic.adjacent_allies_of(pokemon))\n # eo eo ex / ux ax ax || e! e! ex / ux ax ax\n when :adjacent_foe, :adjacent_all_foe\n return logic.adjacent_foes_of(pokemon)\n # e! e! e! / ux ax ax || e? e? e? / ux ax ax\n when :all_foe, :random_foe\n return logic.foes_of(pokemon)\n # e! e! e! / u! a! a!\n when :all_pokemon\n return logic.foes_of(pokemon).concat(logic.allies_of(pokemon)) << pokemon\n # ex ex ex / u! ax ax\n when :user\n return [pokemon]\n # ex ex ex / uo ao ax\n when :user_or_adjacent_ally\n return [pokemon].concat(logic.adjacent_allies_of(pokemon))\n # ex ex ex / ux ao ax\n when :adjacent_ally\n return logic.allies_of(pokemon)\n # ex ex ex / u! a! a!\n when :all_ally\n return [pokemon].concat(logic.allies_of(pokemon))\n # eo eo eo / ux ao ao\n when :any_other_pokemon\n return logic.foes_of(pokemon).concat(logic.allies_of(pokemon))\n end\n return [pokemon]\n end",
"def decide_target(char, dmg, heal, neutral, attack, defend, escape)\n # temporary variables\n x, y, ai = char.x, char.y, char.ai\n # get alignment setup\n negative, positive = ai.negative, ai.positive\n # invert setup if confused\n negative, positive = positive, negative if char.restriction == 3\n # initialize arrays\n allies, enemies = [char], []\n # if enemy\n if char.is_a?(Map_Enemy)\n # find all allies and all enemies in memory\n ai.memory.each_key {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n # if actor\n elsif char.is_a?(Map_Actor)\n # find all allies and all enemies in sight\n ai.sight.each {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n end\n # find all allies who need healing\n to_heal = allies.find_all {|b| b.valid? && b.battler.hp < b.battler.maxhp}\n # if decided to heal\n if (heal.size > 0 && to_heal.size > 0 && (ai.healer || rand(3) == 0) &&\n rand(5) == 0)\n # find all skills that heal all allies\n allheal = heal.find_all {|id|\n $data_skills[id].scope == 2 || $data_skills[id].scope == 4 ||\n $data_skills[id].scope == 6}\n # test again flag\n test_again = true\n # if more than 1 ally who needs healing exists and allheal skills exist\n if to_heal.size > 1 && allheal.size > 0\n # initialize data\n decided, now, new = nil, [], []\n # iterate through all all-healing skills\n allheal.each {|id|\n # fake Blizz-ABS action setup\n ai.act.set(Skills.range(id), ACTSkill, id, Skills.type(id)[0],\n ai.delay_time)\n # all allies who can be targeted by this skill\n new = to_heal.find_all {|b| $BlizzABS.can_execute?(char, b, ai.act)}\n # if not decided yet\n if decided == nil\n # decide this skill and those allies\n decided, now = id, new\n # 50% chance\n elsif rand(2) == 0\n # intialize damage counters\n dmg1 = dmg2 = 0\n # sum up all damage for last decided targets\n now.each {|b| dmg1 += b.battler.maxhp - b.battler.hp}\n # sum up all damage for new targets\n new.each {|b| dmg2 += b.battler.maxhp - b.battler.hp}\n # decide this skill if it contains battlers with more damaged HP\n decided, now = id, new if dmg2 > dmg1\n # if more battlers would be affected by this skill\n elsif new.size > now.size\n # decide this skill and those allies\n decided, now = id, new\n end}\n # if more than one battler can be healed\n if now.size > 1\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n # don't test for one battler\n test_again = false\n end\n end\n # if should test for one battler\n if test_again\n # find all skills that heal one ally\n oneheal = heal.find_all {|id|\n $data_skills[id].scope == 1 || $data_skills[id].scope == 3 ||\n $data_skills[id].scope == 5}\n # if any skill exists\n if oneheal.size > 0\n # decided action\n decided = oneheal[rand(oneheal.size)]\n # decided target\n ai.target = to_heal[rand(to_heal.size)]\n else\n # decided action\n decided = heal[rand(heal.size)]\n end\n # stop execution if no skill decided\n return false if decided == nil\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n end\n # confirm execution\n return true\n end\n # not decided to escape yet\n escaping = false\n # if able to run away\n if escape && rand(5) == 0\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler, ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 2\n # set this battler as escape reference\n ai.target = b\n # running away\n escaping = true\n # abort iteration\n break\n end\n end}\n # 20% chance\n elsif rand(5) == 0\n # initialize minimum range\n min = nil\n # iterate through all enemies\n enemies.each {|b|\n # if closer than anybody else\n if (b.is_a?(Map_Actor) && (min == nil ||\n Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y) < min))\n # set this battler as escape reference\n ai.target = b\n # set new minimum range\n min = Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y)\n # running away\n escaping = true\n # abort iteration\n break\n end}\n end\n end\n # if decided to escape\n if escaping\n # set AI state\n ai.state = Escape\n # set action data\n ai.act.set(ai.view_range - 1, ACTEscape, 0, 0, 80)\n # confirm execution\n return true\n end\n # not decided to defend yet\n defending = false\n # if able to defend\n if defend && rand(5) == 0\n # probability factor if higher if defensive and reset defend flag\n factor = rand(ai.defensive ? 10 : 30)\n # if decided to defend\n if char.battler.hp * 100 / char.battler.maxhp < factor\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler,\n ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 3\n # defending\n defending = true\n # abort iteration\n break\n end\n end}\n # 33% chance\n elsif enemies.size > 0 && rand(5) == 0\n # decided to defend\n defending = true\n end\n end\n end\n # if decided to defend\n if defending\n # set AI state\n ai.state = Defend\n # target the closest enemy\n ai.target = enemies.min {|a, b|\n Math.hypot(x-b.x, y-b.y) <=> Math.hypot(x-a.x, y-a.y)}\n # turn toward the target if target exists and not being force moved\n char.turn_toward(ai.target) if ai.target != nil && char.move_type != 3\n # use defend action\n char.use_defend\n # set action data\n ai.act.set(3, ACTDefend, 0, 0, rand(31) + 70)\n # confirm execution\n return true\n end\n # number of skills\n skill_number = dmg.size + heal.size + neutral.size\n # if able to attack and chosen to attack\n if attack && (skill_number == 0 || rand(skill_number) == 0)\n # if enemy\n if char.is_a?(Map_Enemy)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Enemies.range(char.battler_id), ACTAttack, 0,\n Enemies.type(char.battler_id), ai.delay_time)\n # if observing attribute and not confused\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if actor\n elsif char.is_a?(Map_Actor)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Weapons.range(char.battler.weapon_id), ACTAttack, 0,\n Weapons.type(char.battler.weapon_id), ai.delay_time)\n end\n # if no target exists\n if ai.target == nil || !ai.target.valid?\n # get any enemy\n ai.target = enemies[rand(enemies.size)]\n end\n # confirm execution\n return true\n end\n # decide a random skill action\n decided = (dmg + neutral)[rand(dmg.size + neutral.size)]\n # if action exists\n if decided != nil\n # if observing\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if no target was decided\n if ai.target == nil || !ai.target.valid?\n # if targeting enemies\n if $data_skills[decided].scope == 0 ||\n $data_skills[decided].scope == 1 ||\n $data_skills[decided].scope == 2\n # select a random enemy target\n ai.target = enemies[rand(enemies.size)]\n else\n # select a random ally target\n ai.target = allies[rand(allies.size)]\n end\n end\n end\n # stop execution if no target selected\n return false if ai.target == nil || !ai.target.valid?\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time)\n # confirm execution\n return true\n end",
"def create_test_character\n @level = 3\n @str = 10 # affects sword/unarmed attack, cbm, cbm_def\n @dex = 18 # affects ac, cbm_def\n @con = 14 # affects hp\n @mag = 15 # affects mag_resist, mag_dc\n @cha = 16 # affects crowd and magic\n\n @one_hand_prof = 2\n @dual_wield_prof = 2\n @two_hand_prof = 3\n @magic_prof = 2\n @unarmed_prof = 0\n\n calculate_initial_stats\n\n add_spell_to_known_spells(\"cure light wounds\", @full_spell_list[\"cure light wounds\"])\n add_spell_to_known_spells(\"magic missle\", @full_spell_list[\"magic missle\"])\n add_spell_to_known_spells(\"beguiler's grace\", @full_spell_list[\"beguiler's grace\"])\n add_spell_to_known_spells(\"shock weapon\", @full_spell_list[\"shock weapon\"])\n add_spell_to_known_spells(\"ray of sickening\", @full_spell_list[\"ray of sickening\"])\n add_spell_to_known_spells(\"ear-piercing scream\", @full_spell_list[\"ear-piercing scream\"])\n\n add_item(\"bronze sword\", @items.item_list[\"bronze sword\"])\n add_item(\"bronze dual swords\", @items.item_list[\"bronze dual swords\"])\n add_item(\"health potion\", @items.item_list[\"health potion\"])\n add_item(\"bronze shield\", @items.item_list[\"bronze shield\"])\n end",
"def advanced_enemy_action(char)\n # initialize basic action\n attack = defend = escape = false\n # initialize skill action\n dmg, heal, neutral = [], [], []\n # iterate through all actions\n char.battler.actions.each {|action|\n # conditions\n n = $game_temp.battle_turn\n a = action.condition_turn_a\n b = action.condition_turn_b\n # skip if conditions are not fulfilled\n next if b == 0 && n != a || b > 0 && (n < 1 || n < a || n % b != a % b)\n next if char.battler.hp * 100.0 / char.battler.maxhp > action.condition_hp\n next if $game_party.max_level < action.condition_level\n switch_id = action.condition_switch_id\n next if switch_id > 0 && !$game_switches[switch_id]\n # depending on which basic type of action\n case action.kind\n when 0 # basic action\n case action.basic\n when 0 then attack = true\n when 1 then defend = true\n when 2 then escape = true\n end\n when 1 # skill action\n # if skill can be used\n if char.skill_can_use?(action.skill_id)\n # if damaging skill\n if $data_skills[action.skill_id].power > 0\n # add to array of damaging skills\n dmg.push(action.skill_id)\n # if healing skill\n elsif $data_skills[action.skill_id].power < 0\n # add to array of healing skills\n heal.push(action.skill_id)\n else\n # add to array of neutral skills\n neutral.push(action.skill_id)\n end\n end\n end}\n # decide a target\n decide_target(char, dmg, heal, neutral, attack, defend, escape)\n end",
"def get_a_target(char, targets)\n # check trigger condition\n case @condition\n when TRGHP # HP condition\n # for each possible target\n targets.each {|b|\n # get comparator string\n comparator = Cache::TRGComparators[@comparator]\n # evaluate condition\n if eval(\"b.battler.hp * 100 / b.battler.maxhp #{comparator} @value\")\n # this target fulfills the condition\n return b\n end}\n when TRGSP # SP condition\n # for each possible target\n targets.each {|b|\n # get comparator string\n comparator = Cache::TRGComparators[@comparator]\n # evaluate condition\n if eval(\"b.battler.sp * 100 / b.battler.maxsp #{comparator} @value\")\n # this target fulfills the condition\n return b\n end}\n when TRGState # State condition\n # if no state condition\n if @value == 0\n # find a target that has no states\n targets.each {|b| return b if b.battler.states.size == 0}\n else\n # find a target with the condition state\n targets.each {|b| return b if b.battler.states.include?(@value)}\n end\n when TRGLocation # Location condition\n # temporary variable\n pix = $BlizzABS.pixel\n # sort all targets by relative distance ascending\n targets.sort! {|a, b|\n Math.hypot(char.x / pix - a.x / pix, char.y / pix - a.y / pix) <=>\n Math.hypot(char.x / pix - b.x / pix, char.y / pix - b.y / pix)}\n # return the requested battler\n return case @value\n when TRGClosest then targets[0]\n when TRGFarthest then targets[targets.size - 1]\n end\n end\n # this trigger has not been activated\n return nil\n end",
"def hero_ability(target)\n case\n when @hero_class == 'druid'\n @attack = 1\n @armour = amour + 1\n when @hero_class == 'hunter'\n target.health = target.health - 2\n when @hero_class == 'mage'\n target.health = target.health - 2\n when @hero_class == 'paladin'\n @battlefield.push(\"Silver Hand Recruit\")\n when @hero_class == 'priest'\n target.health = target.health + 2\n when @hero_class == 'rouge'\n @weapon = \"Dagger Mastery\"\n when @hero_class == 'shaman'\n totems = ['Healing Totem', 'Searinhg Totem', 'Stoneclaw Totem', 'Wrath of Air Totem']\n @battlefield.push(totems.sample)\n when @hero_class == 'warlock'\n darw_card(2)\n @health = @health - 2\n when @hero_class == 'warrior'\n @armour = @armour + 2\n end\n end",
"def _fight(p1, p2, context)\n msg = context[:msg]\n \n \n \n msg += line \"<div> 战斗开始!</div>\"\n \n # calculate temporary fight prop\n # p1.tmp[:apply_damage] = p1.query_weapon_damage\n # p1.tmp[:apply_dodge] = 0-p1.query_all_weight\n # p1.tmp[:apply_defense] = p1.query_armo_defense \n \n \n \n calc_apply_var(p1)\n p \"====>p1 load: #{p1.tmp[:apply_dodge]} damage:#{p1.tmp[:apply_damage]} defense:#{p1.tmp[:apply_defense] }\"\n calc_apply_var(p2)\n p \"====>p2 load: #{p2.tmp[:apply_dodge]} damage:#{p2.tmp[:apply_damage]} defense:#{p2.tmp[:apply_defense] }\"\n \n # calculate who attach first \n # TODO need improve\n if (p1.query_temp(\"dext\")+p1.tmp[:apply_dodge] > p1.query_temp(\"dext\")+p2.tmp[:apply_dodge])\n attacker = p1\n #attacker_gain = gain_p1\n defenser = p2\n # defenser_gain = gain_p2\n else\n attacker = p2\n #attacker_gain = gain_p2\n defenser = p1\n #defenser_gain = gain_p1\n end\n \n p \"attacker is #{attacker.name}\"\n msg += translate_msg(line(\"<div>$N抢先发动进攻!</div>\"), {:user=>attacker, :target=>defenser})\n \n \n # what weapon attacker is wielding\n hand_right_weapon = p1.query_wearing(\"handright\")\n hand_left_weapon = p1.query_wearing(\"handleft\")\n p1.tmp[:right_hand_weapon] = hand_right_weapon\n p1.tmp[:left_hand_weapon] = hand_left_weapon\n p \"=>righthand weapons #{hand_right_weapon}\"\n p \"=>lefthand weapons #{hand_left_weapon}\"\n # defaut is unarmed\n weapon_skill_type = 'unarmed'\n if (hand_right_weapon)\n weapon_skill_type = hand_right_weapon.skill_type\n p1.tmp[:main_weapon] = hand_right_weapon\n \n elsif hand_left_weapon\n weapon_skill_type = hand_left_weapon.skill_type\n p1.tmp[:main_weapon] = hand_left_weapon\n end\n \n=begin\n reg = /unarmed/i\n if (hand_right_weapon)\n weapon_type = hand_right_weapon.type\n reg = Regexp.new(\"#{weapon_type}\", true)\n end\n=end \n context_p1 = {\n :user => p1,\n :thisskill => nil,\n :skills=>p1.query_all_skills,\n :target => p2\n }\n # attacker choose the best dodge skill\n p1[:dodge_skill] = choosBestDodgeSkill(context_p1)\n # attacker choose the skill have best damage\n p1[:attack_skill] = choosBestAttackSkill(context_p1, weapon_skill_type)\n # attacker choose best defense skill\n p1[:defense_skill] = choosBestDefenseSkill(context_p1, weapon_skill_type)\n \n # choose perform for p1\n skill_types = []\n if p1.tmp[:left_hand_weapon]\n skill_types.push(p1.tmp[:left_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\")\n end\n if p1.tmp[:right_hand_weapon]\n skill_types.push(p1.tmp[:right_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\") if !skill_types.include?\"unarmed\"\n end\n p1.tmp[:perform] = chooseBestPerform(p1, skill_types)\n \n \n \n \n # choose skills for deffenser\n hand_right_weapon = p2.query_wearing(\"handright\")\n hand_left_weapon = p2.query_wearing(\"handleft\")\n p2.tmp[:right_hand_weapon] = hand_right_weapon\n p2.tmp[:left_hand_weapon] = hand_left_weapon\n p \"=>#{defenser.name} righthand weapons #{hand_right_weapon}\"\n p \"=>#{defenser.name} lefthand weapons #{hand_left_weapon}\"\n # defaut is unarmed\n weapon_skill_type = 'unarmed'\n if (hand_right_weapon)\n weapon_skill_type = hand_right_weapon.skill_type\n p2.tmp[:main_weapon] = hand_right_weapon\n elsif hand_left_weapon\n weapon_skill_type = hand_left_weapon.skill_type\n p2.tmp[:main_weapon] = hand_left_weapon\n end\n context_p2 = {\n :user => p2,\n :thisskill => nil,\n :skills=>p2.query_all_skills,\n :target => p1\n }\n # defenser choose the best dodge skill\n p2[:dodge_skill] = choosBestDodgeSkill(context_p2)\n # defenser choose the skill have best damage\n p2[:attack_skill] = choosBestAttackSkill(context_p2, weapon_skill_type)\n # defenser choose best defense skill\n p2[:defense_skill] = choosBestDefenseSkill(context_p2, weapon_skill_type) \n \n # choose perform for p2\n skill_types = []\n if p2.tmp[:left_hand_weapon]\n skill_types.push(p2.tmp[:left_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\")\n end\n if p2.tmp[:right_hand_weapon]\n skill_types.push(p2.tmp[:right_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\") if !skill_types.include?\"unarmed\"\n end\n p2.tmp[:perform] = chooseBestPerform(p2, skill_types)\n \n \n gain_p1 = {\n :exp =>0,\n # :hp =>0,\n # :stam =>0,\n :pot => 0,\n :level =>0,\n :skills =>{\n p1[:dodge_skill][:skill][:skname] =>\n {\n :skill => p1[:dodge_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p1[:dodge_skill][:skill].dname\n },\n p1[:attack_skill][:skill][:skname] =>\n {\n :skill => p1[:attack_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p1[:attack_skill][:skill].dname\n },\n p1[:defense_skill][:skill][:skname]=>\n {\n :skill => p1[:defense_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p1[:defense_skill][:skill].dname\n }\n }\n }\n gain_p2 = {\n :exp =>0,\n # :hp =>0,\n # :stam =>0,\n :pot => 0,\n :level =>0,\n :skills =>{\n p2[:dodge_skill][:skill][:skname] =>\n {\n :skill => p2[:dodge_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p2[:dodge_skill][:skill].dname\n },\n p2[:attack_skill][:skill][:skname] =>\n {\n :skill => p2[:attack_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p2[:attack_skill][:skill].dname\n },\n p2[:defense_skill][:skill][:skname]=>\n {\n :skill => p2[:defense_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p2[:defense_skill][:skill].dname\n }\n }\n }\n p \"==>gain.skill #{gain_p1.inspect}\"\n p \"==>gain.skill #{gain_p2.inspect}\"\n # context[:gain_p1] = gain_p1\n # context[:gain_p2] = gain_p2\n p1[:gain] = gain_p1\n p2[:gain] = gain_p2\n \n if (attacker == p1)\n attacker_gain = gain_p1\n defenser_gain = gain_p2\n else\n attacker_gain = gain_p2\n defenser_gain = gain_p1\n end\n \n p1.tmp[:willperform]=0\n p2.tmp[:willperform]=0\n\n \n srand(Time.now.tv_usec.to_i)\n i = 0\n style_c = \"user\"\n \n # show status\n msg += status_lines(attacker, defenser)\n \n winner = nil\n=begin\n while (i < 100 ) # max 100 turn\n if style_c == \"user\"\n style_c = \"enemy\"\n else\n style_c = \"user\"\n end\n \n # msg += \"<!--1--><div class=\\\"#{style_c}\\\">\\n#{__fight(attacker, defenser)}\\n</div>\\n\";\n msg += \"\\n<div class=\\\"#{style_c}\\\">\\n#{__fight(attacker, defenser)}</div>\\n\"\n \n \n i = i+1\n \n \n \n if (defenser.tmp[:hp] <=0 )\n msg += line \"<div>#{defenser.name}战斗不能</div>\"\n winner = attacker\n break;\n end\n \n if (defenser.tmp[:stam] <=0 && attacker.tmp[:stam]<=0)\n msg += line \"<div>双方都已经精疲力尽了!</div>\"\n break;\n end\n \n # swap\n t = defenser\n defenser = attacker\n attacker = t\n \n \n \n end #while\n=end \n f_context={\n :style=>style_c,\n :round=>0,\n # :winner=>nil\n }\n msg += __fight(attacker, defenser, f_context)\n i = f_context[:round]\n # winner = f_context[:winner]\n context[:round] = f_context[:round]\n \n if (p1.tmp[:hp] >= 0 and p2.tmp[:hp] >=0) || (p1.tmp[:hp] < 0 and p2.tmp[:hp] <0)\n winner = nil\n elsif p1.tmp[:hp] >=0 \n winner = p1\n else \n winner = p2\n end\n #\n # save to db # TODO should the enemy also save gain ?\n #\n if attacker[:isUser]\n copyExt(attacker)\n end\n if defenser[:isUser]\n copyExt(defenser)\n end\n if (attacker[:canGain])\n receive_gain(attacker, attacker[:gain])\n end\n if (defenser[:canGain])\n receive_gain(defenser, defenser[:gain])\n end\n\n win = 0\n msg += \"<!--1-->\\n<div class='fight_result'><div class='win'>\\n\"\n if !winner\n win = -1\n if attacker[:isUser]\n msg += \"你和#{defenser.name}战成平手!}\"\n elsif defenser[:isUser]\n msg += \"你和#{attacker.name}战成平手!\"\n else\n msg += \"#{attacker.name}和#{defenser.name}战成平手!\"\n end\n else\n if winner == p1\n win = 1\n else\n win = 0\n end\n if (winner[:isUser])\n msg += \"You(#{winner.name}) <span class='f_win'>Win</span> !\"\n elsif (defenser[:isUser])\n msg += \"You(#{defenser.name}) <span class='f_lose'>Lose</span> !\"\n else\n msg += \"#{winner.name} <span class='f_win'>Win</span> !\"\n end\n end\n p attacker.tmp\n msg += \"(in #{i} rounds)</div>\\n\"\n msg += \"</div><!--0-->\"\n if (context[:msg])\n context[:msg] += msg\n else\n context[:msg] = msg\n end\n p context[:msg]\n # return attacker[:isUser]\n # return attacker == p1\n return win\n end",
"def battle\n playerset($testing)\n fieldmonsters = []\n efieldmonsters = []\n @@monsterfield.each { |x| \n if x[:type] == \"monster\"\n fieldmonsters.push(x)\n end\n }\n if fieldmonsters.empty? == true\t\n puts \"There are no monsters to battle with\".red\n return\n end\n @@emonsterfield.each { |x| \t\t\t\n if x[:type] == \"monster\"\n efieldmonsters.push(x)\n end\n }\n if efieldmonsters.empty? == true\t\n puts \"There are no enemy monsters to battle\".red\n return\n end\n puts \"What monster do you choose?\"\n fieldmonsters.each {|x| puts x[:name]}\n response1 = gets.to_i\n response1 -= 1\n puts \"You have selected #{@@monsterfield[response1][:name]}\"\n puts \"What monster do you want to battle?\"\n efieldmonsters.each {|x| puts x[:name]}\n response2 = gets.to_i\n response2 -= 1\n answer = @@monsterfield[response1][:atk] - @@emonsterfield[response2][:atk]\n puts answer\n if answer < 0\n puts \"Your monster lost the battle\"\n $file.puts(\"#{@@name} loss a battle against #{@@ename}\")\n end\n if answer == 0\n puts \"Draw\"\n @@graveyard.push(@@monsterfield[response1])\n @@monsterfield.delete(@@monsterfield[response1])\n @@egraveyard.push(@@emonsterfield[response2])\n @@emonsterfield.delete(@@emonsterfield[response2])\n $file.puts(\"#{@@name} drew in a battle against #{@@ename}\")\n end\n if answer > 0\n puts \"Your monster won the battle\"\n $file.puts(\"#{@@name} won a battle against #{@@ename}\")\n decreaselp('enemy', answer)\n end\nend",
"def attack(troops)\n troops + self.level * troops\n end",
"def potential_tiles(entity, hex)\n return [] unless (tile_ability = abilities(entity))\n\n candidates = super\n candidates << @game.osterath_tile if hex.name == 'E8' && entity == @game.konzession_essen_osterath\n return candidates if candidates.empty? || tile_ability.owner != @game.seilzuganlage\n\n potentials = @game.all_potential_upgrades(hex.tile).map(&:name)\n candidates.select { |t| @game.upgrades_to?(hex.tile, t) && potentials.include?(t.name) }\n end",
"def attack(weapon)\n rand(10) + weapon.power\n end",
"def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n round_report = []\n round_report << \"Runde #{round+1}: \"\n round_report << \"#{turn_user.username} ist am Zug.\"\n if shield > 0\n round_report << \"Schild von #{target_user.username} ist aktiv.\"\n round_report << \"Schild hält noch #{shield} Schaden aus.\"\n round_report << \"Alle Truppen schießen auf den Schildt!\"\n else \n round_report << \"Schild von #{target_user.username} ist inaktiv.\"\n round_report << \"Angriffe werden nicht abgewehrt!\"\n round_report << \" \"\n end\n turn_fleet.each do |a|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if a[1] > 0 && a[2] > 0 \n round_report << \"Die Gruppe #{a[5]} trifft... \"\n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target == -2)\n round_report << \"nicht. Der Angriff ging daneben. \"\n round_report << \" \"\n round_report << \" \"\n elsif(target==-1)\n round_report << \"das Schild. Der Schaden beträgt: \"\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if a[3] == 2\n mult = 1.5\n end\n damage = a[2] * mult\n round_report << \"#{damage} \"\n round_report << \" \"\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult=1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if(a[3]==1)\n mult=1.5\n end \n # Bestimme welche Einheit getroffen wurde\n victim=target_fleet[target]\n # round_report << \"#{victim[5]}. Der Schaden beträgt: \"\n # Schadensberechnung\n damage=a[2]*mult\n round_report << \"#{damage} \"\n # Berechne neue HP\n hit_points=victim[-2]\n victim[-2]=hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim)\n round_report << \"#{victim[4]} Einheiten wurden zerstört. \"\n end\n end \n # Füge Runden-Bericht ein\n # @round_reports << round_report\n end\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue=false\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user==@attacker\n @attacker_shield=@fight_shield\n else\n @defender_shield=@fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet=turn_fleet\n tmp_user=turn_user\n turn_fleet=target_fleet\n turn_user=target_user\n target_fleet=tmp_fleet\n target_user=tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n @report << @round_reports\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n end\n end",
"def buyable_private_mines(entity)\n if entity == @hw\n @minors.select { |m| (!m.owner || @players.include?(m.owner)) && @minor_info[m][:vor_harzer] }\n else\n @minors.select { |m| !m.owner || @players.include?(m.owner) }\n end\n end",
"def powered_by\n random_and_sane [\n \"Diet Pepsi\",\n \"the funny voice he uses to talk to dogs\",\n \"the love of his life, <a href=\\\"http://thebluesunshine.com/\\\">Lizza</a>\",\n \"hoagies from <a href=\\\"https://foursquare.com/v/sarcones-deli/4a9b035ef964a520fc3320e3\\\">Sarcone's Deli</a>\",\n \"his sweet tooth for #{random_and_sane ['Nerds rope','Mike and Ikes','Peppermint Patties']}\",\n \"any and all potatoes\",\n \"rays of sunshine trickling through his backyard fig tree\"\n ]\n end",
"def get_difficulty\n if self.power < 3\n difficulty = 1\n elsif self.power >= 3 && self.power < 6\n difficulty = 2\n else\n difficulty = 3\n end\n end",
"def attack(user)\n # Variable to see how many damage instances will be\n damage_instances_count = 0\n\n # Search within weapons for damage bonus\n user.weapons.each do |weapon|\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'damage'\n damage_instances_count = bonus.multiplier\n end\n end\n end\n\n # For each damage bonus we will calculate the attack again\n damage_instances = (1..damage_instances_count).map do\n # Values from weapons\n weapon_attack_points = 0\n weapon_attack_modifiers = 0\n weapon_attack_recoil_modifier = 0\n\n weapon_defense_points = 0\n weapon_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.weapons.each do |weapon|\n weapon_attack_points += weapon.attack_points\n weapon_defense_points += weapon.defense_points\n\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n weapon_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'recoil'\n weapon_attack_recoil_modifier += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n weapon_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from rings\n rings_attack_points = 0\n rings_attack_modifiers = 0\n\n rings_defense_points = 0\n rings_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.rings.each do |ring|\n rings_attack_points += ring.attack_points\n rings_defense_points += ring.defense_points\n\n ring.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n rings_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n rings_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from helmets\n helmet_attack_points = user.helmet.attack_points\n helmet_attack_modifiers = 0\n\n helmet_defense_points = user.helmet.defense_points\n helmet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.helmet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n helmet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n helmet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from body armor\n body_armor_attack_points = user.body_armor.attack_points\n body_armor_attack_modifiers = 0\n\n body_armor_defense_points = user.body_armor.defense_points\n body_armor_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.body_armor.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n body_armor_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n body_armor_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from boots\n boots_attack_points = user.boots.attack_points\n boots_attack_modifiers = 0\n\n boots_defense_points = user.boots.defense_points\n boots_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.boots.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n boots_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n boots_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from gloves\n gloves_attack_points = user.gloves.attack_points\n gloves_attack_modifiers = 0\n\n gloves_defense_points = user.gloves.defense_points\n gloves_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.gloves.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n gloves_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n gloves_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from amulet\n amulet_attack_points = user.amulet.attack_points\n amulet_attack_modifiers = 0\n\n amulet_defense_points = user.amulet.defense_points\n amulet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.amulet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n amulet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n amulet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Making a sum of all the points from the itens\n attack_points_sum = weapon_attack_points + rings_attack_points + helmet_attack_points + body_armor_attack_points + boots_attack_points + gloves_attack_points + amulet_attack_points\n defense_points_sum = weapon_defense_points + rings_defense_points + helmet_defense_points + body_armor_defense_points + boots_defense_points + gloves_defense_points + amulet_defense_points\n\n # Making a sum of all the bonuses from the items\n attack_modifiers_sum = weapon_attack_modifiers + rings_attack_modifiers + helmet_attack_modifiers + body_armor_attack_modifiers + boots_attack_modifiers + gloves_attack_modifiers + amulet_attack_modifiers\n defense_modifiers_sum = weapon_defense_modifiers + rings_defense_modifiers + helmet_defense_modifiers + body_armor_defense_modifiers + boots_defense_modifiers + gloves_defense_modifiers + amulet_defense_modifiers\n\n # Calculating damage, defense and recoil\n attack_total = attack_points_sum * attack_modifiers_sum\n defense_total = defense_points_sum * defense_modifiers_sum\n recoil_total = (attack_total * weapon_attack_recoil_modifier * ((attack_total / (defense_total + (E ** -attack_total))) / 100)).floor\n\n # Creating a new DamageInstance\n DamageInstance.new(attack_total, recoil_total)\n end\n\n # Returning damage instances\n damage_instances\n end",
"def search_weapon\r\n lvl = rand(1..6)\r\n puts \"Tu as trouvé une arme de niveau #{lvl}\"\r\n if @weapon_level >= lvl\r\n puts \"M@*#$... elle n'est pas mieux que ton arme actuelle...\"\r\n else\r\n puts \"Youhou ! elle est meilleure que ton arme actuelle : tu la prends.\"\r\n @weapon_level = lvl\r\n end\r\n end",
"def make_obj_targets(obj)\n targets = []\n if obj.for_opponent?\n if obj.for_random?\n if obj.for_one? # One random enemy\n number_of_targets = 1\n elsif obj.for_two? # Two random enemies\n number_of_targets = 2\n else # Three random enemies\n number_of_targets = 3\n end\n number_of_targets.times do\n targets.push(opponents_unit.random_target)\n end\n elsif obj.dual? # One enemy, dual\n targets.push(opponents_unit.smooth_target(@target_index))\n targets += targets\n elsif obj.for_one? # One enemy\n targets.push(opponents_unit.smooth_target(@target_index))\n else # All enemies\n targets += opponents_unit.existing_members\n end\n elsif obj.for_user? # User\n targets.push(battler)\n elsif obj.for_dead_friend?\n if obj.for_one? # One ally (incapacitated)\n targets.push(friends_unit.smooth_dead_target(@target_index))\n else # All allies (incapacitated)\n targets += friends_unit.dead_members\n end\n elsif obj.for_friend?\n if obj.for_one? # One ally\n targets.push(friends_unit.smooth_target(@target_index))\n else # All allies\n targets += friends_unit.existing_members\n end\n end\n return targets.compact\n end",
"def battle\r\n\t\tcooldown = 0\r\n\t\twhile(!@battle_end) do\r\n\t\t\tcreate_turn_update_record(@turn)\r\n\t\t\t@champ_speeds.each do |x|\r\n\t\t\t\tcreate_hp_update_record\r\n\r\n\t\t\t\t# x is @team's champions\r\n\t\t\t\tif(x < 5)\r\n\t\t\t\t\tin_front = team_dead(@team)\r\n\t\t\t\t\tnum_alive_in_front = in_front[0...x].count(false)\r\n\t\t\t\t\trange = @team[x].range\r\n\t\t\t\t\tname = @team[x].name\r\n\t\t\t\t\tRails.logger.debug \"Alive in front on team for #{name}: #{num_alive_in_front} Range: #{range}}\"\r\n\r\n\t\t\t\t\tif range <= num_alive_in_front\r\n\t\t\t\t\t\tRails.logger.debug \"Nothing in range for #{name}\"\r\n\t\t\t\t\t\tcreate_nothing_in_range_record(x,range,num_alive_in_front)\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\topp_in_front = team_dead(@opp_team)\r\n\t\t\t\t\t\trange_left = range - num_alive_in_front\r\n\t\t\t\t\t\tRails.logger.debug \"Range: #{range} Range Left: #{range_left}\"\r\n\t\t\t\t\t\tnum_opp_alive = opp_in_front.count(false)\r\n\t\t\t\t\t\tRails.logger.debug \"Number of opponents alive: #{num_opp_alive}\"\r\n\t\t\t\t\t\tif range_left <= num_opp_alive\r\n\t\t\t\t\t\t\tnum_opp_alive = range_left\r\n\t\t\t\t\t\t\tRails.logger.debug \"Targets for randomming decreased from #{num_opp_alive} to the range: #{range_left}\"\r\n\t\t\t\t\t\tend\r\n\r\n\t\t\t\t\t\trandom_target = randomized_target(num_opp_alive)\r\n\t\t\t\t\t\tRails.logger.debug \"Random Target: #{random_target}\"\r\n\r\n\t\t\t\t\t\ttarget = -1\r\n\t\t\t\t\t\ttemp = -1\r\n\t\t\t\t\t\tfor y in 0..4\r\n\t\t\t\t\t\t\tif (!opp_in_front[y])\r\n\t\t\t\t\t\t\t\ttemp += 1\r\n\t\t\t\t\t\t\t\tRails.logger.debug \"#{@opp_team[y].name} is alive in front of #{name}\"\r\n\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\tif(temp == random_target)\r\n\t\t\t\t\t\t\t\ttarget = y\r\n\t\t\t\t\t\t\t\tRails.logger.debug \"temp: #{temp} y: #{y} random_target: #{random_target}\"\r\n\t\t\t\t\t\t\t\tbreak\r\n\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\t\tRails.logger.debug \"Thus the target is: #{@opp_team[target].name} at position: #{target}\"\r\n\r\n\t\t\t\t\t\tcreate_champion_turn_record(x,target + 5)\r\n\t\t\t\t\t\t# Ability power attack\r\n\t\t\t\t\t\tif(cooldown == 0)\r\n\r\n\t\t\t\t\t\t\t# Handle ability attack\r\n\t\t\t\t\t\t\tchamp_ap = @team[x].ap\r\n\t\t\t\t\t\t\tcreate_ability_power_record(x,champ_ap)\r\n\r\n\t\t\t\t\t\t\tchamp_mr = @opp_team[target].mr\r\n\t\t\t\t\t\t\tcreate_mr_record(champ_mr,target + 5)\r\n\r\n\t\t\t\t\t\t\tdamage = @opp_team[target].take_magic_damage(champ_ap)\r\n\t\t\t\t\t\t\tcreate_damage_record(x,damage,target + 5)\r\n\t\t\t\t\t\t\tcreate_just_dead_record(x,target + 5) if @opp_team[target].just_died?\r\n\t\t\t\t\t\telse\r\n\r\n\t\t\t\t\t\t\t# Handle physical attack\r\n\t\t\t\t\t\t\tchamp_ad = @team[x].ad\r\n\t\t\t\t\t\t\tcreate_attack_damage_record(x,champ_ad)\r\n\r\n\t\t\t\t\t\t\tchamp_ar = @opp_team[target].armor\r\n\t\t\t\t\t\t\tcreate_armor_record(champ_ar, target + 5)\r\n\r\n\t\t\t\t\t\t\tdamage = @opp_team[target].take_physical_damage(champ_ad)\r\n\t\t\t\t\t\t\tcreate_damage_record(x,damage,target + 5)\r\n\t\t\t\t\t\t\tcreate_just_dead_record(x,target + 5) if @opp_team[target].just_died?\r\n\t\t\t\t\t\tend\t\t\t\t\r\n\t\t\t\t\tend\r\n\r\n\t\t\t\t\t\r\n\r\n\t\t\t\telse # x > 5\r\n\t\t\t\t\t# x is @opp_team's champions\r\n\t\t\t\t\t\r\n\t\t\t\t\tin_front = team_dead(@opp_team)\r\n\t\t\t\t\tnum_alive_in_front = in_front[0...(x-5)].count(false)\r\n\t\t\t\t\trange = @opp_team[x-5].range\r\n\t\t\t\t\tname = @opp_team[x-5].name\r\n\t\t\t\t\tRails.logger.debug \"Alive in front for #{name}: #{num_alive_in_front} Range: #{range}\"\r\n\r\n\t\t\t\t\tif range <= num_alive_in_front\r\n\t\t\t\t\t\tRails.logger.debug \"Nothing in range for #{name}\"\r\n\t\t\t\t\t\tcreate_nothing_in_range_record(x,range,num_alive_in_front)\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\topp_in_front = team_dead(@team)\r\n\t\t\t\t\t\trange_left = @opp_team[x-5].range - num_alive_in_front\r\n\t\t\t\t\t\tRails.logger.debug \"Range: #{range} Range Left: #{range_left}\"\r\n\t\t\t\t\t\tnum_opp_alive = opp_in_front.count(false)\r\n\t\t\t\t\t\tRails.logger.debug \"Number team alive: #{num_opp_alive}\"\r\n\t\t\t\t\t\tif range_left <= num_opp_alive\r\n\t\t\t\t\t\t\tnum_opp_alive = range_left\r\n\t\t\t\t\t\t\tRails.logger.debug \"Targets for randomming decreased from #{num_opp_alive} to #{range_left}\"\r\n\t\t\t\t\t\tend\r\n\r\n\t\t\t\t\t\trandom_target = randomized_target(num_opp_alive)\r\n\t\t\t\t\t\tRails.logger.debug \"Random Target: #{random_target}\"\r\n\r\n\t\t\t\t\t\ttarget = -1\r\n\t\t\t\t\t\ttemp = -1\r\n\t\t\t\t\t\tfor y in 0..4\r\n\t\t\t\t\t\t\tif (!opp_in_front[y])\r\n\t\t\t\t\t\t\t\ttemp += 1\r\n\t\t\t\t\t\t\t\tRails.logger.debug \"#{@team[y].name} is alive in front of #{name}\"\r\n\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\tif(temp == random_target)\r\n\t\t\t\t\t\t\t\ttarget = y\r\n\t\t\t\t\t\t\t\tRails.logger.debug \"temp: #{temp} y: #{y} random_target: #{random_target}\"\r\n\t\t\t\t\t\t\t\tbreak\r\n\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\t\tRails.logger.debug \"Thus the target is: #{@team[target].name} at position: #{target}\"\r\n\r\n\r\n\t\t\t\t\t\tcreate_champion_turn_record(x,target)\r\n\r\n\t\t\t\t\t\tif(cooldown == 0)\r\n\r\n\t\t\t\t\t\t\tchamp_ap = @opp_team[x-5].ap\r\n\t\t\t\t\t\t\tcreate_ability_power_record(x,champ_ap)\r\n\r\n\t\t\t\t\t\t\tchamp_mr = @team[target].mr\r\n\t\t\t\t\t\t\tcreate_mr_record(champ_mr,target)\r\n\r\n\t\t\t\t\t\t\tdamage = @team[target].take_magic_damage(champ_ap)\r\n\t\t\t\t\t\t\tcreate_damage_record(x,damage,target)\r\n\t\t\t\t\t\t\tcreate_just_dead_record(x,target) if @team[target].just_died?\r\n\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tchamp_ad = @opp_team[x-5].ad\r\n\t\t\t\t\t\t\tcreate_attack_damage_record(x,champ_ad)\r\n\r\n\t\t\t\t\t\t\tchamp_ar = @team[target].armor\r\n\t\t\t\t\t\t\tcreate_armor_record(champ_ar, target)\r\n\r\n\t\t\t\t\t\t\tdamage = @team[target].take_physical_damage(champ_ad)\r\n\t\t\t\t\t\t\tcreate_damage_record(x,damage,target)\r\n\t\t\t\t\t\t\tcreate_just_dead_record(x,target) if @team[target].just_died?\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\r\n\r\n\t\t\t\tend\r\n\t\t\t\tbreak if create_battle_end_record\r\n\t\t\tend\r\n\t\t\t@turn = @turn + 1\r\n\t\t\tcooldown = cooldown + 1\r\n\t\t\tcooldown = 0 if cooldown == 3\r\n\t\t\tbreak if create_battle_end_record\r\n\t\tend\r\n\tend",
"def enemies(c)\n @characters.reject { |d| d.type == c.type || d == c || d.dead? }\n end",
"def fight\n # TODO: Add this back in, in a curses way\n #puts\n #puts \"========FIGHT========\"\n #puts \"#{@hero.name} Vs #{@monster.name}\"\n #puts\n\n # Populate an array with X number of levels Hero is and Y number of levels Monster is\n # This way whoever is a higher level has a better chance of attacking \n attack_arr = []\n @hero.level.to_i.times { attack_arr.push(\"Hero\") }\n @monster.level.to_i.times { attack_arr.push(\"Monster\") }\n\n # Loop until one character dies\n while @hero.cur_health > 0 && @monster.cur_health > 0\n case attack_arr.shuffle.first\n when \"Hero\" then @monster.cur_health -= @hero.strength\n when \"Monster\" then @hero.cur_health -= @monster.strength\n end\n end\n\n return (@hero.cur_health > @monster.cur_health)\n end",
"def isSkillUsable()\n if( @enemy != nil && @skill != nil )\n if(! @skill.isOverLimit ) \n if( @enemy.fire_magic >= @skill.fire_cost &&\n @enemy.water_magic >= @skill.water_cost &&\n @enemy.earth_magic >= @skill.earth_cost &&\n @enemy.wind_magic >= @skill.wind_cost )\n #@enemy.light_magic >= @skill.light_cost &&\n #@enemy.dark_magic >= @skill.dark_cost )\n \n self.tone.set(0, 30, 0)\n else\n self.tone.set(70, 0, 0)\n end\n else\n self.tone.set(0, 0, 70)\n end\n end\n end",
"def skl_p_gain(type, target, obj = nil, user = nil)\n result = 0\n case type\n # ---------------------------------------------------------------------- #\n when :attack # type and battler are valid\n result = 5\n result += rand(10)\n # ---------------------------------------------------------------------- #\n when :guard # type and battler are valid\n result = 2\n result += rand(10)\n # ---------------------------------------------------------------------- #\n when :skill # type and battler are valid\n result = (target.action.skill.skl_level+1) * 2 unless target.action.skill.nil?\n result += rand(10)\n # ---------------------------------------------------------------------- #\n when :item # type and battler are valid\n result = 10\n result += rand(10)\n # ---------------------------------------------------------------------- #\n when :use # type, battler, obj, user are all valid\n result = obj.skl_p + 15\n if SKILL_MODE == 1 and obj.is_a?(RPG::Skill) # // If skill mode is exp\n obj.skl_exp += result if obj.skl_skill? # // if skill is a valid skill level\n end\n # ---------------------------------------------------------------------- #\n end\n # ---------------------------------------------------------------------- #\n target.skl_p += result\n # ---------------------------------------------------------------------- #\n return result # Doesn't do anything really, but just for the sake of it\n end",
"def battlers\n return (@actors + @pets + @monsters)\n end",
"def get_winner_fight(pokemon1, pokemon2)\n current_hp_pokemon1 = pokemon1.base_stats[:hp].to_f\n current_hp_pokemon2 = pokemon2.base_stats[:hp].to_f\n while current_hp_pokemon1 >= 0 && current_hp_pokemon2 >= 0\n case first_turn(pokemon1, pokemon2)\n when 1\n current_hp_pokemon2 -= pokemon_attack(pokemon1, pokemon2)\n current_hp_pokemon1 -= pokemon_attack(pokemon2, pokemon1)\n when 2\n current_hp_pokemon1 -= pokemon_attack(pokemon2, pokemon1)\n current_hp_pokemon2 -= pokemon_attack(pokemon1, pokemon2)\n end\n end\n if current_hp_pokemon1 > current_hp_pokemon2\n pokemon1\n else\n pokemon2\n end\n end",
"def set_target_battlers(scope)\r\n # If battler performing action is enemy\r\n if @active_battler.is_a?(Game_Enemy)\r\n # Branch by effect scope\r\n case scope\r\n when 1 # single enemy\r\n index = @active_battler.current_action.target_index\r\n @target_battlers.push($game_party.smooth_target_actor(index))\r\n when 2 # all enemies\r\n for actor in $game_party.actors\r\n if actor.exist?\r\n @target_battlers.push(actor)\r\n end\r\n end\r\n when 3 # single ally\r\n index = @active_battler.current_action.target_index\r\n @target_battlers.push($game_troop.smooth_target_enemy(index))\r\n when 4 # all allies\r\n for enemy in $game_troop.enemies\r\n if enemy.exist?\r\n @target_battlers.push(enemy)\r\n end\r\n end\r\n when 5 # single ally (HP 0) \r\n index = @active_battler.current_action.target_index\r\n enemy = $game_troop.enemies[index]\r\n if enemy != nil and enemy.hp0?\r\n @target_battlers.push(enemy)\r\n end\r\n when 6 # all allies (HP 0) \r\n for enemy in $game_troop.enemies\r\n if enemy != nil and enemy.hp0?\r\n @target_battlers.push(enemy)\r\n end\r\n end\r\n when 7 # user\r\n @target_battlers.push(@active_battler)\r\n end\r\n end\r\n # If battler performing action is actor\r\n if @active_battler.is_a?(Game_Actor)\r\n # Branch by effect scope\r\n case scope\r\n when 1 # single enemy\r\n index = @active_battler.current_action.target_index\r\n @target_battlers.push($game_troop.smooth_target_enemy(index))\r\n when 2 # all enemies\r\n for enemy in $game_troop.enemies\r\n if enemy.exist?\r\n @target_battlers.push(enemy)\r\n end\r\n end\r\n when 3 # single ally\r\n index = @active_battler.current_action.target_index\r\n @target_battlers.push($game_party.smooth_target_actor(index))\r\n when 4 # all allies\r\n for actor in $game_party.actors\r\n if actor.exist?\r\n @target_battlers.push(actor)\r\n end\r\n end\r\n when 5 # single ally (HP 0) \r\n index = @active_battler.current_action.target_index\r\n actor = $game_party.actors[index]\r\n if actor != nil and actor.hp0?\r\n @target_battlers.push(actor)\r\n end\r\n when 6 # all allies (HP 0) \r\n for actor in $game_party.actors\r\n if actor != nil and actor.hp0?\r\n @target_battlers.push(actor)\r\n end\r\n end\r\n when 7 # user\r\n @target_battlers.push(@active_battler)\r\n end\r\n end\r\n end",
"def reduce_weapon_options\n # Here we're simple interested in eliminating weapons, so we care only\n # about combinations, not perumtations. This is more manageable.\n weapon_combinations = @current_level.weapon_combinations.to_a\n guesses_with_answer = []\n\n # Guess until we've narrowed it down to 10 weapons or fewer.\n while weapon_combinations.flatten.uniq.size > 10 do\n weapon_guess = weapon_combinations.sample\n resp = @client.solve_level(@current_level.levelNum, weapon_guess)\n weapon_combinations.select! do |possibility|\n # At the moment, we only care about which weapons are correctly used.\n Mastermind::Game.evaluate(weapon_guess, possibility).first == resp['response'].first\n end\n # Save guesses and full answer to process later.\n guesses_with_answer << [weapon_guess, resp['response']]\n end\n # Now that we've reduced the number of weapons, generate list of all\n # remaining possibilities.\n @remaining_possibilities = @current_level.possible_answers(weapon_combinations.flatten.uniq).to_a\n\n # Loop through prior guesses to eliminate any that can be.\n guesses_with_answer.each do |gwa|\n @remaining_possibilities.select! do |possibility|\n Mastermind::Game.evaluate(gwa[0], possibility) == gwa[1]\n end\n end\n @remaining_possibilities\n end",
"def characters\n Character.all.select{ |character| character.actor == self }\n end",
"def fight_scene\n\tjason = PowerRanger.new(\"Jason\", \"Red\")\n\ttommy = PowerRanger.new(\"tommy\", \"Green\")\n\tjon = Person.new(\"Jon\")\n\thoward = Person.new(\"Howard\")\n\tevilGuy_a = EvilNinja.new(\"Evil Guy 1\")\n\tevilGuy_b = EvilNinja.new(\"Evil Guy 2\")\n\n\tputs \"Two innocent bystanders are attacked by evil ninjas.\"\n\tjon.scream\n\thoward.scream\n\tjon.run\n\thoward.drink_coffee\n\thoward.run\n\n\tputs \"The Power Rangers arrive!\"\n\tjason.punch(evilGuy_a)\n\ttommy.punch(evilGuy_b)\n\tjason.rest(2)\n\ttommy.drink_coffee\n\n\tputs \"The Evil Ninjas fight back.\"\n\tevilGuy_a.punch(tommy)\n\tevilGuy_b.punch(tommy)\n\tevilGuy_a.cause_mayhem(jason)\n\n\tputs \"The Power Rangers try Megazord\"\n\tjason.use_megazord(evilGuy_a)\n\tevilGuy_a.punch(jason)\n\n\tputs \"Cmon Tommy!\"\n\ttommy.use_megazord(evilGuy_a)\n\ttommy.drink_coffee(10)\n\ttommy.use_megazord(evilGuy_b)\n\n\tputs \"Did the Power Rangers save the day?\"\n\n\tninja_array = [evilGuy_a, evilGuy_b]\n\twin = \"yes\"\n\n\tninja_array.each do |ninja|\n\t\t# p ninja.show_caffeine_level\n\t\tif ninja.caffeine_level > 0\n\t\t\twin = \"no\"\n\t\tend\n\tend\n\n\tif win == \"yes\"\n\t\tputs \"Yes!\"\n\telse\n\t\tputs \"No :(.\"\n\tend\n\nend",
"def team_fight(team1, team2, context)\n # # sort by level\n # sort_team(team1, \"level\", true)\n # sort_team(team2, \"level\", true)\n index_player_team1 = 0\n index_player_team2 = 0\n p \"team1 size #{team1.size}\"\n p \"team2.size #{team2.size}\"\n i =0 \n while index_player_team2 < team2.size && index_player_team1 < team1.size\n p \"===>team1 player index #{index_player_team1}\"\n p \"===>team2 player index #{index_player_team2}\"\n p1 = team1[index_player_team1]\n p2 = team2[index_player_team2]\n \n p1_hp = p1.tmp[:hp]\n p2_hp = p2.tmp[:hp]\n p1_st = p1.tmp[:stam]\n p2_st = p2.tmp[:stam]\n if !p1.tmp[:contrib]\n p1.tmp[:contrib] = {\n :score =>0,\n :win => 0\n }\n end\n \n if !p2.tmp[:contrib]\n p2.tmp[:contrib] = {\n :score =>0,\n :win => 0\n }\n end\n \n context[:msg] += \"<div class='baomu'>第#{i+1}阵 <span class='user'>#{p1.name}</span> VS <span class='user'>#{p2.name}</span></div>\"\n \n fight_context = {:msg=>\"\"}\n win = _fight(p1, p2, fight_context)\n \n context[:msg] += fight_context[:msg]\n \n p1_hp_delta = 0-(p1.tmp[:hp]-p1_hp)\n p2_hp_delta = 0-(p2.tmp[:hp]-p2_hp)\n p1_st_delta = 0-(p1.tmp[:stam] - p1_st)\n p2_st_delta = 0-(p2.tmp[:stam] - p2_st)\n \n if win == 1\n p1.tmp[:contrib][:score] += calc_zhanli(p2)\n p1.tmp[:contrib][:win] += 1\n if p1_hp_delta >0\n p2.tmp[:contrib][:score] += calc_zhanli(p1)*p1_hp_delta\n end\n \n context[:msg] += \"<div><span class='user'>#{p1.name}稍作休息,体力有所恢复...</span></div>\"\n p1.tmp[:hp] += p1_hp_delta/3\n p1.tmp[:stam] += p1_hp_delta/2\n index_player_team2 += 1\n context[:team1win] += 1\n elsif win == 0\n p2.tmp[:contrib][:score] += calc_zhanli(p1)\n p2.tmp[:contrib][:win] += 1\n if p2_hp_delta > 0\n p1.tmp[:contrib][:score] += calc_zhanli(p2)*p2_hp_delta\n end\n context[:msg] += \"<div><span class='user'>#{p2.name}稍作休息,体力有所恢复...</span></div>\"\n p2.tmp[:hp] += p2_hp_delta/3\n p2.tmp[:stam] += p2_hp_delta/2\n index_player_team1 += 1\n context[:team2win] += 1\n elsif win == -1 # duce\n p1.tmp[:contrib][:score] += calc_zhanli(p2)*p2_hp_delta\n # p1.tmp[:contrib][:win] += 1\n p2.tmp[:contrib][:score] += calc_zhanli(p1)*p1_hp_delta\n # p2.tmp[:contrib][:win] += 1\n index_player_team2 += 1\n index_player_team1 += 1\n end\n if context[:observer]\n context[:observer].notify(context)\n context[:msg]=\"\"\n end\n i += 1\n end\n \n if index_player_team2 > index_player_team1\n return 0\n elsif index_player_team2 < index_player_team1\n return 1\n elsif index_player_team2 == index_player_team1\n return -1\n end\n \n \n end",
"def possible_hero(king_loc, player, board)\r\n threat = offending_player(king_loc, player, board)[0]\r\n threat_loc = offending_player(king_loc, player, board)[1]\r\n attack_path = threat.calculate_path(threat_loc, king_loc)\r\n destroy_threat = []\r\n move_in_path = []\r\n board.each_with_index do |row, i|\r\n row.each_index do |j| \r\n piece = board[i][j]\r\n if !piece.nil? and piece.color == player and [i, j] != king_loc\r\n if piece.color == player\r\n destroy_threat << [i, j] if piece.valid_move([i,j], threat_loc, board)\r\n end\r\n attack_path.each do |block|\r\n if board[block[0]][block[1]].nil? \r\n move_in_path << [[i, j], block] if piece.valid_move([i,j], block, board)\r\n else\r\n move_in_path << [[i, j], block] if piece.valid_move([i,j], block, board) && board[block[0]][block[1]].color != player\r\n end\r\n end\r\n end \r\n end\r\n end \r\n possible_boards = []\r\n destroy_threat.each do |hero|\r\n possible_boards << temporary_board(hero, threat_loc)\r\n end\r\n move_in_path.each do |hero|\r\n possible_boards << temporary_board(hero[0], hero[1]) \r\n end\r\n checks = []\r\n possible_boards.each do |test_board|\r\n checks << in_check(player, test_board)\r\n end \r\n return true if checks.include? false\r\n return false\r\n end",
"def attack()\n return @level + rand(3) - rand(3)\n end",
"def choose_attack\n battle_commands.sample\n end",
"def search_weapon\n new_weapon = rand(1..6)\n puts \">>> Tu as trouvé une arme de niveau #{new_weapon}\"\n\n # Get a random value for the weapon. If the actual weapon has more power, keep the value\n # if it's lower it change the value to the best weapon value\n if new_weapon > @weapon_level\n puts \">>> Cette arme est plus puissante !\"\n @weapon_level = new_weapon\n else\n puts \">>> Cette arme est moins puissante !\"\n end\n end",
"def calculate_damage(source, target, move)\n\t\n\t#puts \"Calculating damage for #{move.name} against #{target.name}\"\n\t\n\t# Special static-damage moves that don't have normal damage calculation\n\treturn 40 if move.name == \"Dragon Rage\" # Always does 40 damage\n\t# Damage equal to the user's level\n\treturn 100 if (move.name == \"Night Shade\" || move.name == \"Seismic Toss\") # Damage equal to the user's level\n\treturn Random.rand(50..150) if move.name == \"Psywave\" # 50%-150% of the user's level\n\treturn 20 if move.name == \"Sonic Boom\" # Always does 20 damage\n\t\n\t# If the move doesn't have a base power, it will do 0 damage\n\tif move.power.nil?\n\t\treturn 0\n\tend\n\t\n\t# Critical hit check (crit increases)\n\tcritical_hit = move_crit?(source, move)\n\t\n\tif critical_hit\n\t\t#puts \"Critical hit!\"\n\tend\n\t\n\tattack = move.physical? ? source.attack * Pokemon::STAGE_MULTIPLIERS[source.attack_stage] : source.special_attack * Pokemon::STAGE_MULTIPLIERS[source.special_attack_stage]\n\tdefense = move.physical? ? target.defense * Pokemon::STAGE_MULTIPLIERS[source.defense_stage] : target.special_defense * Pokemon::STAGE_MULTIPLIERS[source.special_defense_stage]\n\t\n\t# level_calc = ((2 * pokemon_level) + 10) / 250.0\n\t# All pokemon are level 100, so the level_calc is always 0.84\n\tlevel_calc = 0.84\n\tstat_calc = attack.to_f / defense.to_f\n\tbase = (source.status_effect == \"s_burned\" && move.physical?) ? (move.power / 2.0) : (move.power || 0)\n\tif target.using_move && ((target.using_move.name == \"Dig\" && move.name == \"Earthquake\") || (target.using_move.name == \"Fly\" && (move.name == \"Gust\" || move.name == \"Thunder\")))\n\t\t#puts \"Target using DIG/FLY and source used EARTHQUAKE/GUST/THUNDER. Double base power applied\"\n\t\tbase = base * 2\n\tend\n\tdamage = (level_calc * stat_calc * base) + 2\n\t\n\t\n\tstab = ((source.type_1 == move.type_1) || (source.type_2 == move.type_1)) ? 1.5 : 1\n\ttype_1_effectiveness = type_1_effectiveness(source, target, move)\n\ttype_2_effectiveness = type_2_effectiveness(source, target, move)\n\ttype_effectiveness = type_1_effectiveness * (type_2_effectiveness || 1)\n\tcrit_multiplier = critical_hit ? 2 : 1\n\trandom = Random.rand(85..100) / 100.0\n\tmodifier = stab * type_effectiveness * crit_multiplier * random\n\t\n\ttotal_damage = damage * modifier\n\ttotal_damage_rounded = total_damage.round\n\t\n\t#puts \"Attack: #{attack}\"\n\t#puts \"Defense: #{defense}\"\n\t#puts \"Level calc: #{level_calc}\"\n\t#puts \"Stat calc: #{stat_calc}\"\n\t#puts \"Base: #{base}\"\n\t#puts \"Damage (before modifier): #{damage}\"\n\t#puts \"STAB: #{stab}\"\n\t#puts \"Type_1 effectiveness: #{type_1_effectiveness}\"\n\t#puts \"Type_2 effectiveness: #{type_2_effectiveness}\"\n\t#puts \"Crit multiplier: #{crit_multiplier}\"\n\t#puts \"Random % modifier: #{random}\"\n\t#puts \"Modifier: #{modifier}\"\n\t#puts \"Total damage: #{total_damage_rounded}\"\n\t\n\t#puts \"Hit for #{total_damage_rounded}\"\n\t\n\treturn total_damage_rounded\nend",
"def write_army!(is_win, target, player = nil, options = [])\n\t\treturn false if self.first.is_a?(Monster)\n\t\treturn false if options.blank?\n\n\t\twrite_xp = options.include?(:exp)\n\t\twrite_hp = options.include?(:hp)\n\n\t\talive_count = self.select{ |fighter| fighter.curr_hp > 0 }.size\n\n\t\teach_exp = 0\n\t\tplayer_exp = 0\n\n\t\tenemy_avg_level = 1\n\n\t\tif is_win && write_xp\n\t\t\ttotal_exp = 0\n\t\t\ttotal_level = 0\n\n\t\t\ttarget.army.each do |enemy|\n\t\t\t\ttotal_exp += enemy.xp.to_i\n\t\t\t\ttotal_level += enemy.level.to_i\n\t\t\tend\n\n\t\t\ttarget_count = target.army.size\n\t\t\ttarget_count = 1 if target_count <= 0\n\t\t\tenemy_avg_level = total_level / target_count\n\t\t\tenemy_avg_level = 1 if enemy_avg_level <= 0\n\n\t\t\teach_exp = total_exp / alive_count\n\t\t\tplayer_exp = Player.battle_exp[enemy_avg_level].to_i\n\t\tend\n\n\t\tresult = []\n\n\t\tresult = self.map do |fighter|\n\t\t\tnext if fighter.is_advisor\n\n\t\t\tnew_atts = {}\n\n\t\t\tlvl_dis = (fighter.level - enemy_avg_level).abs\n\t\t\teach_earn_xp = 0\n\n\t\t\tif lvl_dis <= 10\n\t\t\t\teach_earn_xp = (each_exp * lvl_dis * 0.1).to_i\n\t\t\telse\n\t\t\t\teach_earn_xp = (each_exp * 0.1).to_i\n\t\t\tend\n\n\t\t\tif each_earn_xp < 0\n\t\t\t\tnext\n\t\t\tend\n\n\t\t\tif write_xp && fighter.curr_hp > 0 && !fighter.is_advisor\n\t\t\t\tfighter.experience += each_earn_xp\n\t\t\t\tnew_atts[:experience] = fighter.experience\n\t\t\tend\n\n\t\t\tnew_atts[:current_hp] = fighter.curr_hp if write_hp && !fighter.is_advisor\n\n\t\t\tfighter.sets(new_atts) unless new_atts.blank?\n\n\t\t\tif write_xp && fighter.curr_hp > 0 && !fighter.is_advisor\n\t\t\t\t{\n\t\t\t\t\t:id => fighter.id,\n\t\t\t\t\t:exp_inc => each_earn_xp,\n\t\t\t\t\t:is_upgraded => fighter.experience >= fighter.next_level_exp\n\t\t\t\t}\n\t\t\tend\n\t\tend.compact\n\n\t\tif player && is_win && player_exp.to_i > 0\n\t\t\tplayer.earn_exp!(player_exp)\n\t\tend\n\n\t\tresult\n\tend",
"def set_target_battlers(scope)\n # If battler performing action is enemy\n if @active_battler.is_a?(Game_Enemy)\n # Branch by effect scope\n case scope\n when 1 # single enemy\n index = @active_battler.current_action.target_index\n @target_battlers.push($game_party.smooth_target_actor(index))\n when 2 # all enemies\n for actor in $game_party.actors\n if actor.exist?\n @target_battlers.push(actor)\n end\n end\n when 3 # single ally\n index = @active_battler.current_action.target_index\n @target_battlers.push($game_troop.smooth_target_enemy(index))\n when 4 # all allies\n for enemy in $game_troop.enemies\n if enemy.exist?\n @target_battlers.push(enemy)\n end\n end\n when 5 # single ally (HP 0) \n index = @active_battler.current_action.target_index\n enemy = $game_troop.enemies[index]\n if enemy != nil and enemy.hp0?\n @target_battlers.push(enemy)\n end\n when 6 # all allies (HP 0) \n for enemy in $game_troop.enemies\n if enemy != nil and enemy.hp0?\n @target_battlers.push(enemy)\n end\n end\n when 7 # user\n @target_battlers.push(@active_battler)\n end\n end\n # If battler performing action is actor\n if @active_battler.is_a?(Game_Actor)\n # Branch by effect scope\n case scope\n when 1 # single enemy\n index = @active_battler.current_action.target_index\n @target_battlers.push($game_troop.smooth_target_enemy(index))\n when 2 # all enemies\n for enemy in $game_troop.enemies\n if enemy.exist?\n @target_battlers.push(enemy)\n end\n end\n when 3 # single ally\n index = @active_battler.current_action.target_index\n @target_battlers.push($game_party.smooth_target_actor(index))\n when 4 # all allies\n for actor in $game_party.actors\n if actor.exist?\n @target_battlers.push(actor)\n end\n end\n when 5 # single ally (HP 0) \n index = @active_battler.current_action.target_index\n actor = $game_party.actors[index]\n if actor != nil and actor.hp0?\n @target_battlers.push(actor)\n end\n when 6 # all allies (HP 0) \n for actor in $game_party.actors\n if actor != nil and actor.hp0?\n @target_battlers.push(actor)\n end\n end\n when 7 # user\n @target_battlers.push(@active_battler)\n end\n end\n end",
"def advanced_actor_action(char)\n # initialize skill action\n dmg, heal, neutral = [], [], []\n # iterate through all actions\n $BlizzABS.util.get_actor_skills(char.battler).each {|id|\n # if skill can be used\n if char.skill_can_use?(id)\n # if damaging skill\n if $data_skills[id].power > 0\n # add to array of damaging skills\n dmg.push(id)\n # if healing skill\n elsif $data_skills[id].power < 0\n # add to array of healing skills\n heal.push(id)\n else\n # add to array of neutral skills\n neutral.push(id)\n end\n end}\n # decide a target\n decide_target(char, dmg, heal, neutral, true, true, false)\n end",
"def fight(user, enemies, player1, player2)\n while user.life_points >0 && (player1.life_points > 0 || player2.life_points >0)\n user.show_state\n puts \"\n Quelle action veux-tu effectuer ?\n\n a - chercher une meilleure arme\n s - chercher à se soigner \n \n attaquer un joueur en vue :\n\n 0 - Josiane a #{player1.life_points} points de vie\n 1 - José a #{player2.life_points} points de vie\"\n puts \"*******************************************************************\" \n choice = gets.chomp \n puts \"***********************************************************************\" \n \n if choice == \"a\" \n user.search_weapon\n elsif choice == \"s\"\n user.search_health_pack\n elsif choice == \"0\"\n user.attacks(player1)\n elsif choice == \"1\"\n user.attacks(player2)\n end\n\n puts \"***********************************************************************\" \n enemies.each do |x|\n break if x.life_points <= 0\n x.attacks(user)\n puts \"Les autres joueurs t'attaquent !\"\n end\n end \n if user.life_points > 0\n puts \"BRAVO ! TU AS GAGNE !\"\n else \n puts \"Loser ! Tu as perdu !\"\n end\nend",
"def enemies_attack\n total_bots_damage = 0\n @enemies.each do |bots_player|\n bots_damage = rand(1..6)\n @human_player.gets_damage(bots_damage)\n total_bots_damage += bots_damage\n end\n puts \"le(s) #{@enemies.length} inflige(nt) #{total_bots_damage} points de vie a #{@human_player.name}\"\n end",
"def attacks(player)\r\n puts \"#{@name} attaque le joueur #{player.name}\"\r\n player.gets_damage(compute_damage)\r\n end",
"def characters\n Character.all.select {|character| character.actor == self }\n end",
"def get_new_skills(level)\n self.skills.select do |skill|\n skill.min_level == level\n end\n end",
"def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true,canlose=false)\n if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0\n if $Trainer.pokemonCount>0\n Kernel.pbMessage(_INTL(\"SKIPPING BATTLE...\"))\n end\n pbSet(variable,1)\n $PokemonGlobal.nextBattleBGM = nil\n $PokemonGlobal.nextBattleME = nil\n $PokemonGlobal.nextBattleBack = nil\n return true\n end\n if species1.is_a?(String) || species1.is_a?(Symbol)\n species1 = getID(PBSpecies,species1)\n end\n if species2.is_a?(String) || species2.is_a?(Symbol)\n species2 = getID(PBSpecies,species2)\n end\n currentlevels = []\n for i in $Trainer.party\n currentlevels.push(i.level)\n end\n genwildpoke = pbGenerateWildPokemon(species1,level1)\n genwildpoke2 = pbGenerateWildPokemon(species2,level2)\n Events.onStartBattle.trigger(nil,genwildpoke)\n scene = pbNewBattleScene\n if $PokemonGlobal.partner\n othertrainer = PokeBattle_Trainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0])\n othertrainer.id = $PokemonGlobal.partner[2]\n othertrainer.party = $PokemonGlobal.partner[3]\n combinedParty = []\n for i in 0...$Trainer.party.length\n combinedParty[i] = $Trainer.party[i]\n end\n for i in 0...othertrainer.party.length\n combinedParty[6+i] = othertrainer.party[i]\n end\n battle = PokeBattle_Battle.new(scene,combinedParty,[genwildpoke,genwildpoke2],[$Trainer,othertrainer],nil)\n battle.fullparty1 = true\n else\n battle = PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke,genwildpoke2],$Trainer,nil)\n battle.fullparty1 = false\n end\n battle.internalbattle = true\n battle.doublebattle = battle.pbDoubleBattleAllowed?()\n battle.cantescape = !canescape\n pbPrepareBattle(battle)\n decision = 0\n pbBattleAnimation(pbGetWildBattleBGM(species1),2,[genwildpoke,genwildpoke2]) { \n pbSceneStandby {\n decision = battle.pbStartBattle(canlose)\n }\n pbAfterBattle(decision,canlose)\n }\n Input.update\n pbSet(variable,decision)\n return (decision!=2 && decision!=5)\nend",
"def whoWon(p1weapon, p2weapon)\n\n\t\tif (p1weapon === p2weapon) && (p1weapon != nil) && (p2weapon != nil)\n\t\t\t@winResult = 0\n\t\t\t#startGame\n\t\t\treturn @winResult\n\t\tend\t\n\n\t\tif (p1weapon === \"rock\" && p2weapon === \"scissors\") || (p1weapon === \"scissors\" && p2weapon === \"paper\") || (p1weapon === \"paper\" && p2weapon === \"rock\")\n\t\t\t@winResult = 1\n\t\t\taddScore\n\t\t\treturn @winResult\n\t\tend\n\n\t\tif (p2weapon === \"rock\" && p1weapon === \"scissors\") || (p2weapon === \"scissors\" && p1weapon === \"paper\") || (p2weapon === \"paper\" && p1weapon === \"rock\")\n\t\t\t@winResult = 2\n\t\t\taddScore\n\t\t\treturn @winResult\n\t\tend\n\tend",
"def attacks(attacked_player)\n # puts player1.name \n # print \"attacks\"\n # puts \"#{attacked_player}\"\n attacked_player.gets_damage(compute_damage)\n # puts \"He loses #{compute_damage} points\"\n end",
"def melee_weapon; end",
"def level2\n\t\tif @warrior.feel.enemy?\n\t\t\[email protected]!\n\t\telse\n\t\t\[email protected]!\n\t\tend\n\tend",
"def carried_weapons\n CharacterWeapon.where(:character_id => self.id, :carried => :true).order('equipped desc')\n end",
"def chooseBestSkill(context, pur, weapon_type, prop)\n p \"choose best skill for #{pur}/#{weapon_type} by #{prop}\"\n # p \"skills #{context[:skills]}(size=#{context[:skills].size})}\"\n attacker_skills = context[:skills]\n \n best_skill = {\n :skill => nil\n }\n best_skill[prop] = 0\n reg2 = Regexp.new(\"#{pur}\", true)\n if (weapon_type and weapon_type.length >0)\n reg = Regexp.new(\"#{weapon_type}\", true)\n else\n reg = /./i\n end\n p \"==>1#{attacker_skills.inspect}\"\n for skill in attacker_skills\n if (!skill || skill.category=='premier')\n next\n end\n skillname = skill.query_data(\"skname\")\n p \"===>skill = #{skill}\"\n p \"===>skill name =#{skillname}\"\n #context[:thisskill] = skill\n# purpose = query_skill(skillname, \"for\", skill, context)\n\n purpose = skill.for # usage: attack parry ...\n type = skill.type # skill type: unarmed, fencing, daofa...\n \n # if skill is for attacking and has correct type with weapon\n if type=~ reg and purpose=~reg2 \n # ret = query_skill(skillname, prop, skill, context)\n # ret = skill.query(prop, context)\n ret = skill_power(skill, context[:user], pur)\n p \"===>#{prop} of #{skillname}: #{ret} \\n\"\n if (ret.to_i > best_skill[prop])\n best_skill[prop] = ret\n best_skill[:skill] = skill\n end\n end\n\n \n #p \"target:\"+@target_class+\", cmd:\"+@cmd+\", param:\"+@cparam\n end\n if ( best_skill[:skill] == nil)\n #if not found, add basic skill for this type of skill\n _skname = weapon_type\n if (pur == 'dodge')\n _skname = 'dodge'\n elsif (pur == 'parry')\n _skname = 'parry'\n end\n if _skname == nil or _skname==\"\"\n raise \"skill name is nil\"\n end\n # us = Userskill.new({\n # :uid => context[:user][:id],\n # :sid => context[:user][:sid],\n # :skid => 0,\n # :skname => _skname,\n # :skdname => \"basic #{weapon_type}\",\n # :level => 0,\n # :tp => 0,\n # :enabled => 1 \n # })\n # us.save!\n us = context[:user].set_skill(_skname, 0, 0)\n attacker_skills.push(us)\n best_skill[:skill] = us\n end\n p \"==>best skill of #{context[:user].name} for #{pur}, skill_type #{weapon_type}: #{best_skill}\"\n return best_skill\n end",
"def choose_attack\n\t return @battle_commands[Random.rand(@battle_commands.length)]\n\tend",
"def player_win_condition_checkers\n (1..@player_count).map { |player| player_win_condition_checker(player) }\n end",
"def tbs_make_obj_targets(obj)\n #TODO: Need to clean this up a little. \n targets = []\n if obj.for_all?\n targets += $tbs_cursor.targeted_battlers\n elsif obj.for_opponent?\n if obj.for_random?\n number_of_targets = obj.scope-2 \n number_of_targets.times do\n all_targets = $tbs_cursor.targeted_battlers\n targets &= subject.opponents if !GTBS::ATTACK_ALLIES\n target = get_random_target(all_targets)\n #targets.push(all_targets[rand(all_targets.size)])\n targets << target\n end\n else\n if obj.for_one? # One enemy\n possible_opponents = $tbs_cursor.targeted_battlers\n if !GTBS::ATTACK_ALLIES\n possible_opponents &= subject.opponents\n end\n closest_opponent = possible_opponents.min do |a, b|\n $tbs_cursor.distance(a) <=> $tbs_cursor.distance(b) \n end\n targets.push(closest_opponent)\n else # All enemies \n targets += $tbs_cursor.targeted_battlers\n if !GTBS::ATTACK_ALLIES\n targets &= subject.opponents\n end\n end\n end\n elsif obj.for_user? # User\n targets.push(battler) if battler.positions & $tbs_cursor.target_positions != []\n elsif obj.for_dead_friend?\n if obj.for_one? # One ally (incapacitated)\n possible_friends = subject.dead_friends & $tbs_cursor.targeted_battlers\n closest_friend = possible_friends.min do |a, b|\n $tbs_cursor.distance(a) <=> $tbs_cursor.distance(b) \n end\n targets.push(closest_friend)\n else # All allies (incapacitated)\n targets += subject.dead_friends & $tbs_cursor.targeted_battlers\n end\n elsif obj.for_friend?\n if obj.for_one? # One ally\n possible_friends = $tbs_cursor.targeted_battlers\n if !GTBS::ATTACK_ALLIES\n possible_friends &= subject.friends\n end\n closest_friend = possible_friends.min do |a, b|\n $tbs_cursor.distance(a) <=> $tbs_cursor.distance(b) \n end\n targets.push(closest_friend)\n else # All allies \n targets += $tbs_cursor.targeted_battlers\n if !GTBS::ATTACK_ALLIES #exclude ENEMY targeted battlers\n targets &= subject.friends\n end\n end\n end\n if obj.is_a?(RPG::Skill) \n if GTBS::PREVENT_SKILL_FRIENDLY_DMG.include?(obj.id)\n targets &= subject.opponents\n end\n if GTBS::TARGET_FIENDLY_ONLY_SKILLS.include?(obj.id)\n targets &= subject.friends\n end\n end\n unless obj.for_dead_friend?\n targets = targets.select {|target| target.nil? == false && !target.dead?}\n end\n return targets.compact\n end",
"def battle(k)\n puts \"#{self.name} vs #{k.name}\"\n # Pick randomly which goes first\n while k.hp > 0 && self.hp >0\n kodomon_turn = rand(100) >= 50 ? self : k\n other = kodomon_turn === self ? k : self\n attack(kodomon_turn, other)\n if(other.hp > 0) # if other is still alive, it can attack\n attack(other, kodomon_turn)\n end\n end\n winner = self.hp > 0 ? self : k\n puts \"Winner: #{winner.name}\"\n return winner\n end",
"def select_word(dif_lvl)\n case dif_lvl\n when 1 # easy difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 0..1000).first\n when 2 # medium difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 1001..100000).first\n when 3 # hard difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 100001..200000).first\n when 4 # super hard difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 200001..400000).first\n when 5 # master difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 400001..Word.maximum(:difficulty)).first\n end\nend",
"def highest_attack_power_weapon\n weapon = self.weapons.sort_by do |weapon|\n weapon.attack_power\n end.last\n weapon\n end",
"def monster_attack\n #set up monster distance and next move\n distance_x = @mon_x - @cur_x\n distance_y = @mon_y - @cur_y\n sign_x = distance_x <=> 0\n sign_y = distance_y <=> 0\n new_x = @mon_x-(1*sign_x)\n new_y = @mon_y-(1*sign_y)\n next_square = @room[new_x][new_y]\n #move monster closer to hero unless blocked or next to hero\n if next_square == CHAR_FLOOR && (distance_x.abs > 1 || distance_y.abs > 1)\n @room[@mon_x][@mon_y] = CHAR_FLOOR\n draw_map(@mon_x, @mon_y)\n @mon_x, @mon_y = new_x, new_y\n @room[@mon_x][@mon_y] = @mon_type\n draw_map(@mon_x, @mon_y)\n end\n #hit hero if close enough and hero not on saftey square\n if (distance_x.abs <= 1 && distance_y.abs <= 1) && @room[@cur_x][@cur_y] != CHAR_SAFE\n hit = @mon_attack * 1.5\n #hit if not dodged\n skill = @stats[:luck]+@stats[:agility]\n clear_message_box\n if Random.rand(skill+(@mon_attack*3)) > skill\n @ui.place_text(MSG_DAMGAGE.ljust(20),1,2)\n damage = hit / (2+@defence)\n @stats[:strength] -= damage\n @stats[:vitality] -= damage/10\n #see if hit weapon\n if Random.rand(7) == @mon_attack #1 in 7 chance of loosing item\n item_found = false\n until item_found\n #get a random item, keep trying until found on hero\n object = ['2 HAND SWORD', 'BROADSWORD', 'SHORTSWORD', 'AXE', 'MACE', 'FLAIL', 'DAGGER', 'GAUNTLET',\n 'HEAVY ARMOUR', 'CHAIN ARMOUR'].rotate(Random.rand(10)+1).first\n item = @objects.find { |obj| obj[:name]==object }\n if item\n if object == 'HEAVY ARMOUR' || object == 'CHAIN ARMOUR'\n @defence -= item[:power]\n else\n @attack -= item[:power]\n end\n @ui.place_text(\"#{object}!!\".ljust(20), 1, 3)\n @objects.delete(item)\n item_found = true\n end\n end\n end\n else\n @ui.place_text(MSG_MMISS.ljust(20),1,2)\n end\n sleep 0.5 #slow everything down\n end\n end",
"def compute_damage\n rand(1..6) * @weapon_level\n end",
"def fight\n \n \n while @human.life_points >0 && (@player1.life_points > 0 || @player2.life_points >0)\n\n\n puts \"**********Menu**************\"\n puts \"a - find a better weapon\"\n puts \"s - find more points of life\" \n puts \"0 - attack player 1\"\n puts \"1 - attack player 2\"\n puts \"2 - receive attacks\"\n puts \"****************************\"\n puts \"Select an option:\"\n option = gets.chomp.to_s\n\n if option == \"a\"\n @human.search_weapon\n elsif option == \"s\"\n @human.search_health_pack\n elsif option == \"0\"\n @human.attacks(@player1)\n elsif option == \"1\"\n @human.attacks(@player2)\n elsif option == \"2\"\n puts \"You are under attack!\"\n @enemies.each { |i| i.life_points <= 0 ? break : i.attacks(@human)}\n @human.show_state\n else\n end\n end\n puts \"Game over\"\n puts \"You won\"\nend",
"def select_moves(source, target)\n \n source.moves = source.moves.reject {|m| m.category == \"god\" }\n \n # puts \"Selecting moves for #{source.name} vs #{target.name}\"\n \n selected_moves = Array.new\n \n # Select 2 STAB damaging moves as they will do the most damage\n same_type_damage_moves = source.moves.select { |m| ((source.type_1 == m.type_1 || source.type_2 == m.type_1) && m.power) }\n \n if same_type_damage_moves.any?\n \n same_type_damage_moves.each do |m|\n total_damage = 0\n 100.times do |i|\n total_damage = total_damage + calculate_damage(source, target, m)\n end\n m.average_damage = ((total_damage / 100.0) * (m.accuracy / 100.0)).round\n #puts \"#{source.name} used #{m.name} for an average of #{m.average_damage} damage\"\n end\n \n same_type_damage_moves.sort! { |x, y| x.average_damage <=> y.average_damage }\n same_type_damage_moves.reverse!\n \n # same_type_damage_moves.each do |m|\n # puts \"#{m.name} --> avg damage = #{m.average_damage}\"\n # end\n \n selected_moves.push(same_type_damage_moves[0]) unless same_type_damage_moves[0].nil?\n selected_moves.push(same_type_damage_moves[1]) unless same_type_damage_moves[1].nil?\n end\n \n # Select 1 stat change move: use the highest stage change value move because\n # it will be the most effective\n stat_change_moves = source.moves.select { |m| m.stage_change && m.stat_type != \"speed\" }\n \n if stat_change_moves.any?\n stat_change_moves.sort! { |x, y| x.stage_change <=> y.stage_change }\n stat_change_moves.reverse!\n end\n \n # stat_change_moves.each do |m|\n # puts \"#{m.name} --> #{m.stage_change}\"\n # end\n \n already_selected = selected_moves.include? stat_change_moves[0]\n selected_moves.push(stat_change_moves[0]) unless stat_change_moves[0].nil? || already_selected\n \n status_effect_moves = source.moves.select { |m| m.status_effect }\n \n if status_effect_moves.any?\n \n status_effect_moves.each do |m|\n true_status_effect_chance = (m.accuracy / 100.0) * (m.status_effect_chance / 100.0)\n m.true_status_effect_chance = true_status_effect_chance\n end\n status_effect_moves.sort! { |x, y| x.true_status_effect_chance <=> y.true_status_effect_chance }\n status_effect_moves.reverse!\n end\n \n # status_effect_moves.each do |m|\n # puts \"#{m.name} --> #{m.status_effect} || #{m.true_status_effect_chance}\"\n # end\n \n already_selected = selected_moves.include? status_effect_moves[0]\n selected_moves.push(status_effect_moves[0]) unless status_effect_moves[0].nil? || already_selected\n \n # puts \"SELECTED MOVES: #{selected_moves.length}\"\n \n while selected_moves.length < 4\n random_move = source.moves.sample\n selected_moves.push(random_move) unless selected_moves.include? random_move\n end\n \n # puts \"SELECTED MOVES AFTER RANDOM: #{selected_moves.length}\"\n \n # selected_moves.each do |m|\n # puts \"#{source.name} selected: #{m.name}\"\n # end\n \n return selected_moves\nend",
"def gaining_exp?\n return false if @exp_gained.empty?\n type, battler , targets = @exp_gained.shift \n #no exp for Enemy\n return false unless battler && battler.team == Battler_Actor && battler.actor?\n @windows[Win_Help].hide\n exp = battler.calculate_exp(targets)\n return false if exp == 0\n lev = {} \n if GTBS::EXP_ALL\n actors = friends_of(Battler_Actor).select {|mem| mem.is_a?(Game_Actor)}\n actors_gain_exp = GTBS::NEUTRAL_EXP ? actors : actors.select{|mem| !mem.neutral}\n for bat in actors_gain_exp\n if bat == battler\n bat_exp = exp\n else\n bat_exp = (exp * (GTBS::EXP_PERC_FOR_PARTY/100)).to_i\n end\n apply_gain_exp(bat, bat_exp, lev)\n end\n else# !GTBS::EXP_ALL\n apply_gain_exp(battler, exp, lev)\n end\n if lev.keys.size > 0\n @windows[Win_LevelUp] = Window_EXP_Earn.new(battler, lev)\n @windows[Win_LevelUp].visible = true\n @windows[Win_LevelUp].active = true\n #play levelup sound\n play_sound_levelup\n while @windows[Win_LevelUp] != nil\n update_basic\n update_exp_window\n end\n end\n wait(GTBS::EXP_WAIT_TIME)\n return true\n end",
"def compute_damage\n return rand(1..6) * @weapon_level\n end",
"def compute_damage\n return rand(1..6) * @weapon_level\n end",
"def open_private_mines\n @minors.select { |m| m.owner && @players.include?(m.owner) && mine_open?(m) }\n end",
"def generate_hero_power_level(hero)\n buffer\n line\n puts \"Your hero's power is being calculated...\"\n 3.times do\n puts \"...\"\n end\n power = rand(50..300)\n hero.power_lvl = power\n puts \"Your hero's power level is #{hero.power_lvl}\"\n puts \"Is this enough power? Press 1 if it is enough, press 2 to re-roll power level.\"\n line\n choice = gi_integer\n if choice == 1\n generate_hero_resistance(hero)\n elsif choice == 2\n generate_hero_power_level(hero)\n else line\n puts \"Your input was not recognized. Please begin this step again.\"\n line\n generate_hero_power_level(hero)\n end\n end",
"def not_losers\n players.reject { |p| p.hand.overkill? }\n end",
"def compute_damage\r\n return rand(1..6) * @weapon_level\r\n end",
"def get_target(map, loc)\n owned = nil\n owned_min = 1000\n GameMap::CARDINALS.each do |l|\n new_loc = map.find_location(loc, l)\n site = map.site(new_loc)\n if site.owner != $tag && site.strength < owned_min\n owned_min = site.strength\n owned = l\n end\n end\n owned\nend",
"def select_players_for_gryffindor(full_list_of_players, already_used_players)\nend",
"def choose_attack\n battle_commands[Random.rand(@battle_commands.length)]\n end",
"def best_target\n far_enough = competitors.select do |competitor|\n competitor.projected_position_at(current_tick_index).distance(self.sensors.position) >= RTanque::Bot::Turret::LENGTH\n end\n far_enough.sort_by do |competitor|\n competitor.projected_position_at(current_tick_index).distance(self.sensors.position) +\n (competitor.name == NAME ? 1000 : 0)\n end.first\n end",
"def update_exp_gain()\n if !@complete\n total_remaining = 0\n \n for i in 0 .. $game_party.members.size-1\n actor = $game_party.members[i]\n actor_exp = @actor_remaining_exp[i]\n \n if actor.dead? && !VICTORY_CONFIG::EXP_ON_DEATH\n actor_exp.remaining_exp = 0\n end\n \n total_remaining += actor_exp.remaining_exp\n \n if actor_exp.remaining_exp > 0\n last_level = actor.level\n last_skills = actor.skills\n \n if !@skipped\n \n if actor_exp.remaining_exp > actor_exp.tick_exp\n \n if actor_exp.tick_exp > actor.needed_exp && actor.needed_exp > 0\n \n exp_to_gain = actor.needed_exp\n \n else\n \n exp_to_gain = actor_exp.tick_exp\n \n end\n \n else\n \n exp_to_gain = actor_exp.remaining_exp\n \n end\n \n actor.gain_exp(exp_to_gain, false)\n actor_exp.remaining_exp -= exp_to_gain\n else\n actor.gain_exp(actor_exp.remaining_exp, false)\n actor_exp.remaining_exp = 0\n end\n \n @victory_char_info_windows[i].window_update(actor)\n \n if actor.level > last_level\n actor_exp.tick_exp = determine_tick(actor.next_exp, actor_exp.remaining_exp)\n \n @victory_level_up_windows[i].visible = true\n Sound.play_level_up_se\n wait(30)\n @victory_level_up_windows[i].visible = false\n end\n new_skills = actor.skills - last_skills\n for skill in new_skills\n @victory_new_skill_windows[i].window_update(skill)\n @victory_new_skill_windows[i].visible = true\n Sound.play_new_skill_se\n wait(30)\n @victory_new_skill_windows[i].visible = false\n end\n end\n end\n \n if total_remaining == 0\n @complete = true\n end\n end\n end",
"def random_target_enemy_hp0\n return random_target_enemy(true)\n end",
"def compute_damage\n rand(1..6) * @weapon_level\n end",
"def pokemon_combat(pokemon1, pokemon2)\n return win_by_default(pokemon1, pokemon2) if win_by_default(pokemon1, pokemon2)\n\n get_winner_fight(pokemon1, pokemon2)\n end",
"def whoWon(p1weapon, p2weapon)\n\n\tif p1weapon === p2weapon\n\t\twinnerResult = \"It's a tie!\"\n\t\tputs(winnerResult)\n\t\tputs \"The score is currently \" + $player1Score.to_s + \" to \" + $player2Score.to_s + \".\"\n\t\tstartGame\n\t\treturn winnerResult\n\tend\t\n\n\tif (p1weapon === \"rock\" && p2weapon === \"scissors\") || (p1weapon === \"scissors\" && p2weapon === \"paper\") || (p1weapon === \"paper\" && p2weapon === \"rock\")\n\t\twinnerResult = \"Player 1 wins!!!\"\n\t\tputs(winnerResult)\n\t\taddScore(winnerResult)\n\t\treturn winnerResult\n\tend\n\n\tif (p2weapon === \"rock\" && p1weapon === \"scissors\") || (p2weapon === \"scissors\" && p1weapon === \"paper\") || (p2weapon === \"paper\" && p1weapon === \"rock\")\n\t\twinnerResult = \"Player 2 wins!!!\"\n\t\tputs(winnerResult)\n\t\taddScore(winnerResult)\n\t\treturn winnerResult\n\tend\nend",
"def suggestedLevel\r\n minLevel = 1\r\n maxLevel = GameData::GrowthRate.max_level\r\n num = self.suggestedNumber\r\n for rule in @pokemonRules\r\n if rule.is_a?(MinimumLevelRestriction)\r\n minLevel = rule.level\r\n elsif rule.is_a?(MaximumLevelRestriction)\r\n maxLevel = rule.level\r\n end\r\n end\r\n totalLevel = maxLevel * num\r\n for rule in @subsetRules\r\n totalLevel = rule.level if rule.is_a?(TotalLevelRestriction)\r\n end\r\n return [maxLevel, minLevel].max if totalLevel >= maxLevel * num\r\n return [totalLevel / self.suggestedNumber, minLevel].max\r\n end",
"def perception(char, update_priority = BlizzABS::UPDFull)\n # temporary variables\n dir, x, y, ai, in_range = char.direction, char.x, char.y, char.ai, []\n # if enemy\n if char.is_a?(Map_Enemy)\n # if heavy update required\n if update_priority >= BlizzABS::UPDHeavy\n # find all battlers within perception range\n in_range = ($game_map.battlers + $BlizzABS.battlers - [char]).\n find_all {|b| b.valid? && !b.battler.dead? && ai.view_range * 128 >=\n Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y) &&\n !wall?(char, b.x, b.y)}\n # find all who are in sight\n ai.sight = in_range.find_all {|b| b.in_action > 0 ||\n can_see_char?(char, b.real_x, b.real_y) ||\n can_hear_char?(char, b.real_x, b.real_y)}\n # if full update required\n if update_priority == BlizzABS::UPDFull\n # memorize all unmemorized, seen battlers\n ai.add_to_memory(ai.sight - ai.memory.keys)\n end\n end\n # if medium update required\n if update_priority >= BlizzABS::UPDMedium\n # if observing attribute is active\n if ai.observe\n # valid and lost actors\n valid_actors, lost_actors = [], []\n # for each battler in sight\n ai.sight.each {|b|\n # if actor\n if b.is_a?(Map_Actor)\n # add the appropriate array\n (b.valid? ? valid_actors : lost_actors).push(b)\n end}\n # add all actors lost out of sight\n lost_actors |= (ai.memory.keys - ai.sight).find_all {|b|\n b.is_a?(Map_Actor)}\n # for each actor in sight\n valid_actors.each {|key|\n # get observation logs\n data = ai.observation[key.battler]\n # if no observation log exists\n if data == nil\n # create an observation log\n ai.observation[key.battler] = [Graphics.frame_count]\n # if interval not started yet\n elsif !data[data.size - 1].is_a?(Numeric)\n # start observation interval right now\n data.push(Graphics.frame_count)\n end}\n # for all actors that need to be forgotten\n lost_actors.each {|key|\n # get observation logs\n data = ai.observation[key.battler]\n # if logs exist, last log is a number and time has passed\n if data != nil && data[data.size-1].is_a?(Numeric) &&\n data[data.size-1] < Graphics.frame_count\n # convert number into inteval\n data.push(data.pop..Graphics.frame_count)\n end}\n end\n end\n # if actor\n elsif char.is_a?(Map_Actor)\n # in sight are all battlers in range\n ai.sight = ($game_map.battlers + $BlizzABS.battlers - [char]).\n find_all {|b| b.valid? && b.in_screen?}\n end\n # get alignment setup\n negative, positive = ai.negative, ai.positive\n # invert setup if confused\n negative, positive = positive, negative if char.restriction == 3\n # if a target exists\n if ai.target != nil\n # if force moving\n if char.move_type == 3\n # if delay counter expired\n if ai.act.ready?\n # execute action\n try_execute(char)\n # if nobody around\n if ai.memory.keys.size == 0 && ai.sight.size == 0\n # reset action\n char.reset_action\n # if about to move and target exists\n elsif char.force_move.size == 0 && ai.target != nil\n # get pixel movement rate and initialize flag\n pix, found = $BlizzABS.pixel, false\n # find the target in memory\n ai.memory.each_key {|key|\n # if this is the target\n if key == ai.target\n # if lost target completely\n if ai.memory[key].x / pix == char.x / pix &&\n ai.memory[key].y / pix == char.y / pix\n # reset action\n char.reset_action\n # abort method\n return\n end\n # found the target\n found = true\n break\n end}\n # reset action if not found in memory\n char.reset_action unless found\n end\n end\n else\n # face the target\n char.turn_toward(ai.target)\n # if running away\n if char.ai.act.escape?\n # move away from reference target\n char.move_away_random(ai.target, true, ai.act.range)\n # if delay counter expired\n elsif ai.act.ready?\n # execute action\n try_execute(char)\n # if nobody around\n if ai.memory.keys.size == 0 && ai.sight.size == 0\n # reset action\n char.reset_action\n # if about to move and target exists\n elsif char.force_move.size == 0 && ai.target != nil\n # if within sight\n if ai.sight.include?(ai.target)\n # request path to target\n request_path(char, ai.target)\n else\n # get pixel movement rate and initialize flag\n pix, found = $BlizzABS.pixel, false\n # find the target in memory\n ai.memory.each_key {|key|\n # if this is the target\n if key == ai.target\n # temporary variables\n x, y = ai.memory[key].x / pix, ai.memory[key].y / pix\n # if lost target completely\n if x == char.x / pix && y == char.y / pix\n # reset action\n char.reset_action\n # abort method\n return\n end\n # find path to last known coordinates\n request_path(char, x, y)\n found = true\n break\n end}\n # reset action if not found in memory\n char.reset_action unless found\n end\n end\n # if negative action and too close\n elsif negative.include?(ai.target.ai.group) &&\n Math.hypot(char.real_x-ai.target.real_x,\n char.real_y-ai.target.real_y) < 384\n # delete movement commands\n char.force_move = []\n # back off from reference target\n char.move_away_random(ai.target, false, ai.act.range)\n end\n # exit method\n return\n end\n end\n # if not actor\n unless char.is_a?(Map_Actor)\n # call for help\n call_for_help(char, in_range, negative, positive)\n end\n end",
"def mergeable_entities\n available_mines = if target_mines.empty?\n @game.mergeable_private_mines(buyer).select { |m| m.owner == owner }\n else\n @game.mergeable_private_mines(buyer) - [target_mines.first[:mine]]\n end\n\n if @game.turn == 1 && target_mines.empty?\n available_mines.select { |m| m == @game.mine_12 }\n elsif @game.corporation_info[buyer][:vor_harzer]\n available_mines.select { |pm| @game.minor_info[pm][:vor_harzer] }\n else\n available_mines\n end\n end",
"def check_special_skills(ch, targets, skill)\n # if Tons of Add-ons is being used\n if $tons_version != nil && $tons_version >= 6.4\n # if using absorbing skills\n if $game_system.ABSORB_HP_SP\n # set damage accumulation to 0\n damages = 0\n # if skill absorbs HP\n if SKILL_IDS_HP.include?(skill.id)\n # for each target\n targets.each {|target|\n # if damage was done\n if target.battler.damage.is_a?(Numeric)\n # accumulate damage\n damages += target.battler.damage\n end}\n # change battler HP\n ch.battler.hp += damages\n # request damage sprite\n $BlizzABS.util.request_damage_sprite(ch)\n # if skill absorbs SP\n elsif SKILL_IDS_SP.include?(skill.id)\n # for each target\n targets.each {|target|\n # if damage was done\n if target.battler.damage.is_a?(Numeric)\n # accumulate damage\n damages += target.battler.spdamage\n # remove damage\n target.battler.damage = nil\n # make SP damage text\n target.check_spdamage\n end}\n # change battler SP\n ch.battler.sp += damages\n # request damage sprite\n $BlizzABS.util.request_damage_sprite(ch)\n end\n end\n # if using Destructor Skill and battler should die\n if $game_system.DESTRUCTOR_SKILL && ch.battler.set_to_die\n # kill\n ch.battler.hp = 0\n end\n # if using Blus Magic Skills\n if $game_system.BLUE_MAGIC_SKILL && BLUE_MAGIC_IDS.include?(skill.id)\n # remove damage for all targets\n targets.each {|target| target.battler.damage = nil}\n # get a random target\n target = targets[rand(targets.size)]\n # try to learn\n if rand(100) < skill.hit\n # if enemy\n if target.battler.is_a?(Game_Enemy)\n # initialize array\n ids = []\n # get all skill IDs of the target\n target.battler.actions.each {|act|\n ids.push(act.skill_id) if act.kind == 1}\n # if actor\n elsif target.battler.is_a?(Game_Actor)\n # get all skill IDs of the target\n ids = target.battler.skills.clone\n end\n # if any ID exists\n if ids.size > 0\n # get skill\n newskill = $data_skills[ids[rand(ids.size)]]\n # if already knowing that skill\n if ch.battler.skills.include?(newskill.id)\n # make damage text\n target.battler.damage = \"#{newskill.name} known\"\n else\n # learn skill\n target.battler.learn_skill(newskill.id)\n # make damage text\n target.battler.damage = \"#{newskill.name} learned\"\n end\n else\n # no skills available\n target.battler.damage = 'None available'\n end\n else\n # not successful\n target.battler.damage = 'Miss'\n end\n end\n end\n end",
"def player_projectiles(player)\n\t\[email protected] { |projectile| projectile.player == player }\n\tend",
"def select_word(dif_lvl)\n case dif_lvl\n when 1 # easy difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 0..1000).first\n when 2 # medium difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 1001..100000).first\n when 3 # hard difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 100001..200000).first\n when 4 # expert difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 200001..400000).first\n when 5 # master difficulty\n word = Word.limit(1).order(\"RANDOM()\").where(difficulty: 400001..Word.maximum(:difficulty)).first\n end\nend",
"def ^( enemy )\n fight( enemy, 13)\n end",
"def skill_effect_power(user, skill)\r\n power = skill.power + user.atk * skill.atk_f / 100\r\n if power > 0\r\n power -= self.pdef * skill.pdef_f / 200\r\n power -= self.mdef * skill.mdef_f / 200\r\n power = [power, 0].max\r\n end\r\n return power\r\n end",
"def game_attack_formula( attacking_zones, support_attackers, defending_zone, support_defenders )\n\n # Get the user data.\n # ==================\n\n auser = User.find_by_id( attacking_zones[0].user_id )\n duser = User.find_by_id( defending_zone.user_id )\n\n # Gather the attacking strength\n # =============================\n\n modifier = ( attacking_zones.size() + 1 ) / 2 # Multiplier for amount you have the enemy surrounded.\n apower = ( ATTACK_POWER_SOLDIER * attacking_zones.size() * auser.total_soldiers / auser.total_zones )\n # Temporary calculation until we use soldier count per zone.\n\n #apower\t\t= 0\t\t\t\t# Temporarily commented out until we're using soldier count for each zone.\n #for z in attacking_zones\n #\tapower\t+= z.soldiers\n #end\n\n apower *= modifier\n\n for z in support_attackers\n if z.artillery == true\n apower += ATTACK_POWER_ARTILLERY\n end\n end\n\n # Gather the defending strength\n # =============================\n\n #dpower\t\t= ATTACK_POWER_SOLDIER * defending_zone.total_soldiers\t# Same reason.\n\n dpower = duser.total_soldiers / duser.total_zones\n if duser.bunker\n dpower *= BUNKER_DEFENSE_MULTIPLIER\n end\n\n for z in support_defenders\n if z.artillery == true\n dpower += ATTACK_POWER_ARTILLERY\n end\n end\n\n # Run some formula to figure out what happens.\n # ============================================\n\n srand()\n baseP = [50 - 4*dpower/20, 10 ].max\n prop = ( BaseP + apower / dpower ) / 10\n results = {}\n\n if rand() > prop then\n\n # A successful attack! Decide what happens!\n # We'll need to determine how many defending soldiers flee and how many attackers are lost.\n # =========================================================================================\n\n dSoldiers = duser.total_soldiers\n aSoldiers = auser.total_soldiers\n fleeCount = ( dSoldiers * ATTACK_MAX_UNIT_FLEE_PERCENT * rand() ).floor\n artilleryGet = rand() < ATTACK_ARTILLERY_HIJACK_PERCENT if defending_zone.artillery == true\n aLosses = [ aSoldiers-2, ( aSoldiers * ATTACK_MAX_UNIT_LOSS_PERCENT * rand() ).floor ].max # Make sure the user still has 2 soldiers left.\n\n # Set the Results.\n # ================\n\n results[:result] = true\n results[:dloss] = dSoldiers - fleeCount\n results[:dflee] = fleeCount\n results[:dartillery] = artilleryGet\n results[:aloss] = aLosses\n\n else\n\n # Defense stands strong! Decide what happens!\n # Basically we need to decide how many units the offense and defense will lose.\n # =============================================================================\n\n srand()\n aLPerc = rand() * ATTACK_MAX_UNIT_LOSS_PERCENT # Percent modifier that the attacker will lose from the attack: Basically 30% * rand(0 to 1)\n dLPerc = rand() * aLPerc # Percent modifier that the defender will lose from the attack: The one from before * rand(0 to 1)\n\n aLoss = [ ( auser.total_soldiers * aLPerc ).floor, auser.total_soldiers - 1 ].min # So make sure attacker will have at least one soldier left ( so they can occupy their own zone still. )\n dLoss = [ ( duser.total_soldiers * dLPerc ).floor, duser.total_soldiers - 1 ].min # So make sure duser will have at least one soldier left.\n\n # Set the results.\n # ================\n\n results[:dloss] = dLoss\n results[:aloss] = aLoss\n results[:result] = false\n\n end\n\n # Return the results\n # ==================\n\n return results\n\n end",
"def powerCase player_index\n\tp = player_index.sort_by{|val| val[0].power[1]}.reverse\n\ts = 0\n\ttemp = p[s][0]\n\tfor i in 0..player_index.length-2\n\t\tif(temp.power[1]==p[i+1][0].power[1])\n\t\t\tif(temp.power[2]<p[i+1][0].power[2] && temp.power[2]!=1)\n\t\t\t\twinner = p[i+1][1]\n\t\t\t\ttemp = p[i+1][0]\n\t\t\t\ts= i+1\n\t\t\telsif(temp.power[2]==p[i+1][0].power[2])\n\t\t\t\tif(temp.power[3]<p[i+1][0].power[3] && temp.power[3]!=1)\n\t\t\t\t\twinner = p[i+1][1]\n\t\t\t\t\ttemp = p[i+1][0]\n\t\t\t\t\ts = i+1\n\t\t\t\telsif(temp.power[3]==p[i+1][0].power[3])\n\t\t\t\t\twinner = 0\n\t\t\t\telse\n\t\t\t\t\twinner = p[s][1]\n\t\t\t\t\n\t\t\t\tend\n\t\t\telse\n\t\t\t\twinner = p[s][1]\n\t\t\tend\n\t\telsif(temp.power[1]<p[i+1][0].power[1] && temp.power[1]!=1)\n\t\t\twinner = p[i+1][1]\n\t\t\ttemp = p[i+1][0]\n\t\t\ts =i+1\n\t\telse\n\t\t\twinner = p[s][1]\n\t\tend\n\t\t\t\n\tend\n\tif(winner != 0)\n\t\tputs \"Player #{winner} wins\"\n\telse\n\t\tputs \"This is a draw.No Results\"\n\tend\nend",
"def enemies_attack\n @enemies.each do |mechant| #player contient Josiane et José\n if mechant.life_points > 0\n mechant.attacks(@human_player)\n end #end of if \n end #end of do\n end",
"def getChipsMatch\n @chips.each_index.select{|i| @chips[i] == @elevatorFloor}\n end",
"def filter_by(players, target, attribute)\n selected = []\n players.each do |player|\n if player[attribute] == target\n selected << player\n end\n end\n selected\nend",
"def fight\n return false if gladiators.size != 2\n\n # The names of each gladiator\n n1 = gladiators[0].name\n n2 = gladiators[1].name\n\n # Check for the special case that Maximus is around\n if n1 == \"Maximus\"\n remove(n2)\n return\n end\n\n if n2 == \"Maximus\"\n remove(n1)\n return\n end\n\n # If no Maximus, get weapons for each gladiator\n w1 = gladiators[0].weapon\n w2 = gladiators[1].weapon\n\n # If weapons are the same, remove both gladiators\n if w1 == w2\n remove(n1)\n remove(n2)\n else\n case w1\n when \"Spear\"\n # Spear loses to Trident but beats Club\n (w2 == \"Trident\") ? remove(n1) : remove(n2)\n when \"Trident\"\n # Trident loses to Club but beats Spear\n (w2 == \"Club\") ? remove(n1) : remove(n2)\n when \"Club\"\n # Club loses to Spear but beats Trident\n (w2 == \"Spear\") ? remove(n1) : remove(n2)\n end\n end\n end"
] | [
"0.6492809",
"0.59228694",
"0.57107985",
"0.55883014",
"0.55825436",
"0.5558533",
"0.55347407",
"0.5502413",
"0.54810715",
"0.5468582",
"0.5459844",
"0.5356746",
"0.5348944",
"0.5279519",
"0.52530515",
"0.52216107",
"0.5216078",
"0.52096",
"0.52093524",
"0.5207117",
"0.52007985",
"0.5184733",
"0.5176988",
"0.5171003",
"0.5143007",
"0.5132142",
"0.50901026",
"0.5069076",
"0.50611955",
"0.5056909",
"0.5048477",
"0.5045446",
"0.50447536",
"0.50442004",
"0.50375646",
"0.5031528",
"0.5027858",
"0.5027559",
"0.5027357",
"0.50267464",
"0.50246894",
"0.5023047",
"0.50152624",
"0.50123227",
"0.5006378",
"0.4991589",
"0.4989305",
"0.49856552",
"0.4982705",
"0.49727452",
"0.49703673",
"0.49610123",
"0.49590695",
"0.4952145",
"0.49496406",
"0.49471077",
"0.49451113",
"0.49414983",
"0.49337047",
"0.49324322",
"0.49269786",
"0.4924278",
"0.49238658",
"0.49209535",
"0.49200368",
"0.49145415",
"0.49141753",
"0.49127716",
"0.49114838",
"0.49102437",
"0.49079895",
"0.49061298",
"0.49061298",
"0.4904828",
"0.49037054",
"0.49004343",
"0.48983714",
"0.48952213",
"0.48933238",
"0.48912045",
"0.48841527",
"0.4883219",
"0.48782024",
"0.48740813",
"0.487286",
"0.48728418",
"0.48721522",
"0.48624638",
"0.48553738",
"0.48498866",
"0.48493183",
"0.48436195",
"0.48415464",
"0.48375076",
"0.48339942",
"0.4832014",
"0.48279253",
"0.4811046",
"0.4799882",
"0.47974157"
] | 0.74867165 | 0 |
print a list of the recommended targets to the player this will return a random sample of 5 of the potential targets for the given player | def print_recommended_targets
find_target_sample = self.recommended_targets.sample(5)
puts "Recommended Targets".bold.underline
puts "Your Attack Power: #{self.power}".italic.blue
find_target_sample.each_with_index do |target , i|
#display the target's name and relevant stats
puts "***********************".bold.red
puts "#{i+1}. #{target.name}".bold.blue.on_light_yellow
puts " ID: #{target.id}".bold
puts " Attack Power:#{target.power}"
puts " HP: #{target.hp}"
end
puts "***********************".bold.red
#return the target sample objects
find_target_sample
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def powered_by\n random_and_sane [\n \"Diet Pepsi\",\n \"the funny voice he uses to talk to dogs\",\n \"the love of his life, <a href=\\\"http://thebluesunshine.com/\\\">Lizza</a>\",\n \"hoagies from <a href=\\\"https://foursquare.com/v/sarcones-deli/4a9b035ef964a520fc3320e3\\\">Sarcone's Deli</a>\",\n \"his sweet tooth for #{random_and_sane ['Nerds rope','Mike and Ikes','Peppermint Patties']}\",\n \"any and all potatoes\",\n \"rays of sunshine trickling through his backyard fig tree\"\n ]\n end",
"def select_players_for_gryffindor(full_list_of_players, already_used_players)\n players = []\n while(players.size < 5) do\n player = full_list_of_players[rand(full_list_of_players.size)]\n if !players.include?(player)\n players << player\n end\n end\n players\nend",
"def util_targetselection_automatic(launcher, skill)\n case skill.target\n when :adjacent_pokemon # eo eo ex / ux ao ax\n arr = util_targetselection_adjacent_foe(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :adjacent_foe # eo eo ex / ux ax ax\n arr = util_targetselection_adjacent_foe(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :adjacent_all_foe # e! e! ex / ux ax ax\n return util_targetselection_adjacent_foe(launcher)\n when :all_foe # e! e! e! / ux ax ax\n return ::BattleEngine.get_enemies!(launcher)\n when :adjacent_all_pokemon # e! e! ex / ux a! ax\n return util_targetselection_adjacent_pokemon(launcher)\n when :all_pokemon # e! e! e! / u! a! a!\n return ::BattleEngine.get_enemies!(launcher) + ::BattleEngine.get_ally!(launcher)\n when :user # ex ex ex / u! ax ax\n return [launcher]\n when :user_or_adjacent_ally # ex ex ex / uo ao ax\n arr = [launcher]+util_targetselection_adjacent_ally(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :adjacent_ally # ex ex ex / ux ao ax\n arr = util_targetselection_adjacent_ally(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :all_ally # ex ex ex / u! a! a!\n return ::BattleEngine.get_ally!(launcher)\n when :any_other_pokemon # ex ex ex / uo ax ax\n arr = ::BattleEngine.get_enemies!(launcher)\n arr += util_targetselection_adjacent_ally(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :random_foe # e? e? e? / ux ax ax\n arr = ::BattleEngine.get_enemies!(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n end\n return [launcher]\n end",
"def pull_chance_cards\n chance_cards = ['go to jail', 'you won a beauty contest! collect $200', 'go to boardwalk', 'you shoplifted! pay $400']\n p 'collect chance card!'\n p chance_cards.sample\nend",
"def make_attack_targets\n targets = []\n if battler.confusion?\n targets.push(friends_unit.random_target)\n elsif battler.berserker?\n targets.push(opponents_unit.random_target)\n else\n targets.push(opponents_unit.smooth_target(@target_index))\n end\n if battler.dual_attack # Chain attack\n targets += targets\n end\n return targets.compact\n end",
"def decide_random_target_for_actor\n # Diverge with effect scope\n if for_one_friend_hp0?\n battler = $game_party.random_target_actor_hp0\n elsif for_one_friend?\n battler = $game_party.random_target_actor\n else\n battler = $game_troop.random_target_enemy\n end\n # If a target exists, get an index, and if a target doesn't exist,\n # clear the action\n if battler != nil\n @target_index = battler.index\n else\n clear\n end\n end",
"def select_players_for_slytherin(full_list_of_players, already_used_players)\n players = []\n while(players.size < 5) do\n player = full_list_of_players[rand(full_list_of_players.size)]\n if !already_used_players.include?(player) && !players.include?(player)\n players << player\n end\n end\n players\nend",
"def random_sample\nchance_cards = ['you win second prize in beauty contest','out of coffee','do not pass go']\n\np 'you have selected a card'\np chance_cards.sample\nend",
"def random_target_enemy_hp0\n return random_target_enemy(true)\n end",
"def select_player_random\n num_player = rand(@players.length)\n num_player\n end",
"def decide_random_target_for_enemy\n # Diverge with effect scope\n if for_one_friend_hp0?\n battler = $game_troop.random_target_enemy_hp0\n elsif for_one_friend?\n battler = $game_troop.random_target_enemy\n else\n battler = $game_party.random_target_actor\n end\n # If a target exists, get an index, and if a target doesn't exist,\n # clear the action\n if battler != nil\n @target_index = battler.index\n else\n clear\n end\n end",
"def random_winner(list)\n winner = list.sample # Randomly picks a winner from the array, and also works if there is only a single object in the array (Possibly have a method where the user can choose to re-vote between winning options?)\n system 'clear'\n puts \"And the winner is ... #{winner.name}!\"\nend",
"def pbCreateTargetTexts(idxBattler,target_data)\r\n texts = Array.new(@battle.battlers.length) do |i|\r\n next nil if [email protected][i]\r\n showName = false\r\n # NOTE: Targets listed here are ones with num_targets of 0, plus\r\n # RandomNearFoe which should look like it targets the user. All\r\n # other targets are handled by the \"else\" part.\r\n case target_data.id\r\n when :None, :User, :RandomNearFoe\r\n showName = (i==idxBattler)\r\n when :UserSide\r\n showName = [email protected]?(i,idxBattler)\r\n when :FoeSide\r\n showName = @battle.opposes?(i,idxBattler)\r\n when :BothSides\r\n showName = true\r\n else\r\n showName = @battle.pbMoveCanTarget?(i,idxBattler,target_data)\r\n end\r\n next nil if !showName\r\n next (@battle.battlers[i].fainted?) ? \"\" : @battle.battlers[i].name\r\n end\r\n return texts\r\n end",
"def random(tg,faulty,replacements,n)\n get_mappings(faulty,replacements).sample\nend",
"def get_sample\n reviews = Review.where(destination_id: self.id)\n sample = reviews[rand(reviews.length)]\n return sample\n end",
"def magiceightball\n\t\t answers = [\"outlook not so good\", \"cloudy, ask again later\", \"it is meant to be\", \"you may rely on it\"]\n\t\t @result = answers[Random.rand(4)]\n\tend",
"def sample(option, limit = 3)\n if option == :tracks\n names = shared(:tracks).map{ |item| item.name }\n names.shuffle\n names[0...limit]\n else\n names = top_shared(option, (limit + 2)).map { |item| item[0].name }\n names.shuffle[0...limit]\n end\n end",
"def sample(option, limit = 3)\n if option == :tracks\n names = shared(:tracks).map{ |item| item.name }\n names.shuffle\n names[0...limit]\n else\n names = top_shared(option, (limit + 2)).map { |item| item[0].name }\n names.shuffle[0...limit]\n end\n end",
"def recommend_new_songs\nselected =Song.all.select do |song|\n song.genre == self.favorite_genre\nend\nselected.sample(5)\n\n end",
"def random\n card_dealt = @possible_cards.sample\n end",
"def choose_attack\n battle_commands.sample\n end",
"def random_megazord\n megazords_arr = [\"Ninja Falcon Megazord\", \"Galaxy Megazord\", \"Thundersaurus Megazord\", \"Lightspeed Megazord\",\"DriveMax Megazord\", \"Wild Force Megazord\"]\n megazord = megazords_arr[rand(megazords_arr.length)]\nend",
"def treasure\n [\"ring\", \"necklace\", \"dagger\", \"amulet\", \"ruby\", \"sapphire\", \"piece of jade\", \"human skull\", \"tarask skull\"].sample\nend",
"def roulette(questions, user, n)\n probs = questions.map { |q| [1 - q.correct_ratio_user(user), 0.1].max }\n\n selected = []\n\n n.times do\n break if probs.empty?\n r, inc = rand * probs.max, 0\n questions.each_index do |i|\n if r < (inc += probs[i])\n selected << questions[i]\n # make selection not pick sample twice\n questions.delete_at i\n probs.delete_at i\n break\n end\n end\n end\n return selected\n end",
"def enemies_attack\n total_bots_damage = 0\n @enemies.each do |bots_player|\n bots_damage = rand(1..6)\n @human_player.gets_damage(bots_damage)\n total_bots_damage += bots_damage\n end\n puts \"le(s) #{@enemies.length} inflige(nt) #{total_bots_damage} points de vie a #{@human_player.name}\"\n end",
"def pick_actor\n ACTOR.sample\nend",
"def sniper_targets\n potential_sniper_targets.select do |planet|\n # Predict future accounting for all current fleets\n max_travel_time = @pw.fleets_underway_to(planet).map{|fleet| fleet.turns_remaining}.max || 0\n predictions = predict_future_population(planet, max_travel_time + 1)\n\n # Only go for planets that the enemy will eventually win\n next unless predictions.last.enemy?\n\n next if planet.enemy?\n if planet.mine?\n # Recapture\n elsif planet.enemy?\n # Don't go for planets that are getting reinforced. Don't fight the enemy head-on.\n next\n else # neutral\n # Snipe\n end\n true\n end\n end",
"def random_player \n\t\tsalida_aleatoria = rand(1..3)\n\t\tsalida_aleatoria\n\tend",
"def test_using_random_sample\n @filelist = nil\n sublist = sample_from( self.filelist ) \n results = test_using_sublist( sublist )\n output.puts \"Test Using Random Sample\".center(72)\n output.puts \"=\" * 72\n report_results( results )\n\n end",
"def pick(target)\n res = count = 0\n @N.each_with_index do |n, i|\n next unless n == target\n\n count += 1\n res = i if rand(1..10**9) % count == 0\n end\n res\n end",
"def four_four\n sample :drum_heavy_kick\n sleep 1\n sample :drum_snare_hard\n sleep 1\nend",
"def four_four\n sample :drum_heavy_kick\n sleep 1\n sample :drum_snare_hard\n sleep 1\nend",
"def determine_who_scored(team1, team2, scores)\n if rand(2) == 1\n scores[0] += 10\n player = team1[rand(team1.size)]\n puts \"#{player} from team 1 scored!\"\n else\n scores[1] += 10\n player = team2[rand(team2.size)]\n puts \"#{player} from team 2 scored!\"\n end\nend",
"def random_reward(reward_size)\n return self.rewards.random_of_size(reward_size)\n end",
"def rnd_permu(list)\n rnd_select(list, list.length)\nend",
"def random_mons_print(num)\n mons = Monster.all.sample(num)\n string_array = []\n mons.each{|monster|\n string_array << 'Name: '.green + \"#{monster.name.capitalize} \" + \"Type: \".green + \"#{monster.monster_type.capitalize} \" + \"Challenge Rating: \".green + \"#{monster.challenge_rating} \" + \"Alignment: \".green + \"#{monster.alignment.capitalize}\"\n }\n puts_with_delay(string_array, 0.3)\n end",
"def random_target_enemy(hp0 = false)\n # Initialize roulette\n roulette = []\n # Loop\n for enemy in @enemies\n # If it fits the conditions\n if (not hp0 and enemy.exist?) or (hp0 and enemy.hp0?)\n # Add an enemy to the roulette\n roulette.push(enemy)\n end\n end\n # If roulette size is 0\n if roulette.size == 0\n return nil\n end\n # Spin the roulette, choose an enemy\n return roulette[rand(roulette.size)]\n end",
"def generate_scenario(difficulty) \r\n Logger.debug \"Difficulty: #{difficulty}\"\r\n @killer = @npcs.sample\r\n @victim = @killer\r\n @victim = npcs.sample while @victim == @killer\r\n @victim.die\r\n @victim.map_id = MANSION_MAP_ID\r\n Logger.log \"Victim: #{@victim.name}\"\r\n Logger.debug \"Killer: #{@killer.name}\"\r\n \r\n non_victims = @npcs - [@victim]\r\n non_killers = non_victims - [@killer] \r\n non_killers.shuffle!\r\n \r\n num_signals = 3 + (2 * difficulty)\r\n evidence_counts = {}\r\n generate_signals_and_profiles(num_signals, non_victims, difficulty)\r\n \r\n Logger.debug \"Initial distribution: #{non_victims} v=#{non_victims.collect { |n| n.evidence_count }.variance}\"\r\n initial_sum = 0\r\n non_victims.map { |n| initial_sum += n.evidence_count }\r\n \r\n non_victims.each { |n| n.augment_profile }\r\n @victim.evidence_count = rand(2) # 0 or 1 signal, just \"for fun\"\r\n @victim.augment_profile\r\n \r\n # Everyone needs an alibi. Weak alibis are a signal.\r\n generate_killers_alibi(non_killers)\r\n generate_alibis(non_killers)\r\n murder_weapon_in_whose_house = nil\r\n # 50% chance to put the murder weapon in the house of an NPC\r\n if rand(50) <= 100\r\n # Pick a suitable NPC first\r\n suitable_npcs = non_victims.select { |n| n.evidence_count >= 2 }\r\n if !suitable_npcs.empty?\r\n npc = suitable_npcs.sample\r\n npc.evidence_count -= 2\r\n # Pick something on their map as the murder weapon\r\n @murder_weapon = @potential_murder_weapons.select { |weapon, map| map == npc.map_id }.keys.sample\r\n Logger.debug \"Murder weapon (#{npc.name}'s house): #{@murder_weapon}\"\r\n murder_weapon_in_whose_house = npc\r\n end\r\n end\r\n \r\n if murder_weapon_in_whose_house.nil?\r\n # goes in the mansion\r\n @murder_weapon = @potential_murder_weapons.select { |weapon, map| map == MANSION_MAP_ID }.keys.sample\r\n Logger.debug \"Murder weapon (mansion): #{@murder_weapon}\"\r\n end\r\n \r\n raise \"Something went terribly wrong with murder weapon selection\" if @murder_weapon.nil?\r\n @evidences = EvidenceGenerator::distribute_evidence(non_victims, @victim, @npc_maps, MANSION_MAP_ID, @notebook, @potential_murder_weapons.keys, @murder_weapon, murder_weapon_in_whose_house) \r\n EvidenceGenerator::complete_profiles_with_criminology(non_victims)\r\n \r\n Logger.debug '-' * 80\r\n Logger.debug \"Final distribution: #{non_victims}\" \r\n final_sum = 0\r\n non_victims.map { |n| final_sum += n.evidence_count }\r\n Logger.debug \"Signals consumed: #{initial_sum - final_sum}\"\r\n end",
"def recommended_targets\n Character.all.select do |character|\n character.power <= (self.power + 2) && character != self\n end\n end",
"def sel_rand(player, opponent)\n all = @corners + @edges + @center # all board positions\n taken = player + opponent # all occupied board positions\n position = (all - taken).sample # take a random open position\n end",
"def choose\n [:rock, :paper, :scissors, :spock, :lizard].sample\n end",
"def choose\n self.move = %w(spock lizard).sample\n end",
"def teach\n KNOWLEDGE.sample #returns random element from array\nend",
"def targets\n ['Barn 0 - 14', 'Ung 15 - 24', 'Voksen 25 - 65', 'Eldre 65 +']\n end",
"def robomoves\n ary_of_moves = [:right, :left, :up, :down] # defines method names for robots\n ary_of_moves.sample\nend",
"def random_reference\n # Draw a random number and compare it to probabilities.\n case Random.rand\n when 0..@p_lft then :lft # Indicate that activity with latest finish time should be chosen.\n when 0..(@p_lft + @p_random) then :random # Indicate that a random activity should be chosen.\n when 0..(@p_lft + @p_random + @p_inverse) then @solutions.sample.invert # Return inverted sample.\n else @solutions.sample # Return random sample from solution set.\n end\n end",
"def sample_agilities(fighter)\n sum = fighter.stats[:agility] + stats[:agility]\n Random.rand(sum) < stats[:agility]\n end",
"def randomize\n @links.sample\n end",
"def encourage\n r = rand(4)\n if r == 0\n puts \"Watch out world, here comes the next great multiplier!\\n\"\n elsif r == 1\n puts \"I haven't seen these kind of skills since ancient Egypt!\\n\"\n elsif r == 2\n puts \"You're so good you could take on Einstein!\\n\"\n else\n puts\"You're really tearing it up now!\\n\"\n end\nend",
"def random_fire_upon(player_board)\n @available_cells.shuffle!\n target_coord = @available_cells.pop\n player_board.cells[target_coord].fire_upon\n target_coord\n end",
"def select_naive(game)\n game.valid_moves.sample\nend",
"def random_skill\n rand(70..90)\nend",
"def roll_skills(ranks, preferred=[],[email protected], prefer=3000, orig_weight=3000, weight=50, new_skill=1) \r\n\t\tskills_with_ranks = skills.reject {|skill| skill.ranks <=0}\r\n\t\tranks = [ranks,1].max \r\n\t\tpoints = ranks\r\n\t\t\r\n\t\t#randomly pick a subset of skills to assign to (weigh them according to each param) remove from possibilities after picking\r\n\t\tpreferred.length>0 ? 0 : prefer=0\r\n\t\tskills_with_ranks.length>0 ? 0 : orig_weight=0\r\n\t\tskillnum = ([( ranks / (level==1? 4:1)),1].max )\r\n\t\t2.times { skillnum += 1 if rand(prefer+orig_weight+weight+new_skill) < (weight+prefer+new_skill)}\r\n\t\tsubset=Array.new\r\n\t\tclass_skills_dup = class_skills.uniq\r\n\t\tlist_dup = @@list.uniq\r\n\t\twhile subset.length < skillnum\r\n\t\t\ti=rand(weight+prefer+new_skill+orig_weight)+1\r\n\t\t\tcase i\r\n\t\t\t\twhen 0..orig_weight\r\n\t\t\t\t\tchoice =skills_with_ranks[rand(skills_with_ranks.length)].name\r\n\t\t\t\t\tskills_with_ranks.delete(choice)\r\n\t\t\t\t\torig_weight = 0 if skills_with_ranks.length <=0\r\n\t\t\t\twhen orig_weight..orig_weight+weight\r\n\t\t\t\t\tchoice =class_skills_dup[rand(class_skills_dup.length)]\r\n\t\t\t\t\tclass_skills_dup.delete(choice)\r\n\t\t\t\t\tweight = 0 if class_skills_dup.length <=0\r\n\t\t\t\twhen orig_weight+weight..orig_weight+weight+prefer\r\n\t\t\t\t\tchoice =preferred[rand(preferred.length)]\r\n\t\t\t\t\tpreferred.delete(choice)\r\n\t\t\t\t\tprefer = 0 if preferred.length <=0\r\n\t\t\t\telse\r\n\t\t\t\t\tif list_dup.length <= 0\r\n\t\t\t\t\t# if no more choices, break\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tchoice = list_dup[rand(list_dup.length)].name\r\n\t\t\t\t\t\tlist_dup.delete(choice)\r\n\t\t\t\t\tend\r\n\t\t\tend\r\n\t\t\tif !subset.include?(choice) && choice\r\n\t\t\t\tsubset.push(choice)\r\n\t\t\tend\r\n\t\tend\r\n\t\t#randomly assign the ranks between the subset of skills upto the max ranks. \r\n\t\toptions = subset.dup\r\n\t\twhile points > 0 do\r\n\t\t\tif options.length > 0\r\n\t\t\t\tskill = options[rand(options.length)]\r\n\t\t\telse\r\n\t\t\t\t#maxed all the options, pick from remaining non maxed skills\r\n\t\t\t\t#should rarely happen when skill points come from some place other than characterclass\r\n\t\t\t\t#puts \"----------error:Out of skills to pick in options --------------\" + points.to_s\r\n\t\t\t\ti = rand(weight + prefer + new_skill) + 1\r\n\t\t\t\tcase i\r\n\t\t\t\t when 0..weight\r\n\t\t\t\t\tchoice = class_skills_dup[rand(class_skills_dup.length)]\r\n\t\t\t\t\tclass_skills_dup.delete(choice)\r\n\t\t\t\t\tweight = 0 if class_skills_dup.length <=0\r\n\t\t\t\t when weight..weight + prefer\r\n\t\t\t\t\tchoice = prefered[rand(prefered.length)]\r\n\t\t\t\t\tpreferred.delete(choice)\r\n\t\t\t\t\tprefer = 0 if preferred.length <=0\r\n\t\t\t\t else \r\n\t\t\t\t\tlist_dup.compact!\r\n\t\t\t\t\tlist_dup.reject!{|v| skills.include?(v.name) ? skills[skills.index(v.name)].ranks >= level+3 : false} if list_dup.length >0\r\n\t\t\t\t\tif list_dup.length > 0\r\n\t\t\t\t\t\tchoice = list_dup[rand(list_dup.length)].name \r\n\t\t\t\t\t\tlist_dup.delete(choice)\r\n\t\t\t\t\telse\r\n\t\t\t\t\t #no more non-maxed skills... put remaining points in \"extra skills\" skill [note - cross-class]\r\n\t\t\t\t\t choice = \"Extra Skills\"\r\n\t\t\t\t\tend\r\n\t\t\t\tend\t\r\n\t\t\t\toptions.push(choice)\r\n\t\t\t\tskill = options[0]\r\n\t\t\tend\r\n\t\t\tFloat inc = !class_skills.include?(skill) ? 0.5 : 1\r\n\t\t\tif skills.include?(skill) \r\n\t\t\t\tif skills[skills.index(skill)].ranks.to_f + inc <= (level+3).to_f\r\n\t\t\t\t\tassign_ranks(skill,1)\r\n\t\t\t\t\tpoints-=1\r\n\t\t\t\telse\r\n\t\t\t\t\tif(skill == \"Extra Skills\")\r\n\t\t\t\t\t\tassign_ranks(skill,1)\r\n\t\t\t\t\t\tpoints-=1 \r\n\t\t\t\t\telse\r\n\t\t\t\t\t\toptions.delete(skill)\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\tif(skill.downcase == \"speak language\")\r\n\t\t\t\t\tif @character.languages.roll_lang(class_skills.include?(\"Speak Language\"))\r\n\t\t\t\t\t\t#assign skills to languages upto max number of languages.\r\n\t\t\t\t\t\tpoints-=1\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\toptions.delete(skill)\r\n\t\t\t\t\t\tlist_dup.delete(skill)\r\n\t\t\t\t\tend\r\n\t\t\t\telse\r\n\t\t\t\t\tassign_ranks(skill,1)\r\n\t\t\t\t\tpoints-=1\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend \r\n\tend",
"def computer_ai_1\n choices =['r', 'p', 's']\n choices.sample\n end",
"def dicks (n)\n n.times do\n puts \"#{BALLS}#{SHAFT * (rand(10)+1)}#{HEAD}\"\n end\nend",
"def generate\n (0..30).sort{ rand() } .take(@conf)\n end",
"def add_random_players\n\tplayer_number_array = [1,2,3,4,5,6,7,8,9,10,11].shuffle\n\tp player_number_array\n\tplayer_number_array.each do |each_number|\n\t\t\tfill_team_with_players(@team_name, Faker::Name.name, each_number)\n\t\tend\nend",
"def random_thank_you\n [\n \"Thanks for sharing. I'll post your secret anonymously soon. \" +\n \"You might want to unfollow me - I'll unfollow you, too.\",\n \"I'll post your message soon. For secrecy, you might want to unfollow me.\",\n \"Thank you! I'll post your secret soon.\"\n ].sample\n end",
"def pick_rps\n rpsArr.sample\n end",
"def gotAttack(damage)\r\n @@probsDeflects = Array['deflect', 'deflect', 'deflect', 'deflect', 'deflect',\r\n 'deflect', 'deflect', 'deflect', 'got hit', 'got hit' ]\r\n\r\n @@probs = @@probsDeflects[rand(0..9)]\r\n if @role.upcase == \"HERO\"\r\n if @@probs == 'deflect'\r\n puts \"#{@name} deflects the attack.\"\r\n @hitpoint += damage\r\n end\r\n end\r\n @hitpoint -= damage\r\n end",
"def spin_for(player, population)\n # new_population = population - [player]\n # temp = new_population.shuffle\n\n chosen_player = (population - [player]).shuffle.first\n \"Player #{player.name} got Player #{chosen_player.name} and it was true love. <3\"\n end",
"def guesses\n (three_guesses + [person]).shuffle\n end",
"def target_acquired(board)\n puts \"#{@name} has acquired a target.\\nPrepare for imminent destruction.\"\n if board.hits.length == 1\n board.pos_cross(board.hits[0]).sample\n else\n target_direction(board, board.hits.sort)\n end\n end",
"def select_player\n Player.new( [PLAYER_NAMES.try(:shuffle).try(:first), ('A'..'Z').try(:to_a).try(:sample).concat('.')].join(' ') )\n end",
"def help_players\n puts \"Greed is a dice game played among 2 or more players, using 5\"\n puts \"six-sided dice.\"\n pressToContinue\n end",
"def reward\n display_reward\n rewards = [\"some bandages\", \"a weapon\", \"a piece of armor\"]\n reward = rewards.sample\n case reward\n when \"some bandages\"\n hero.update(current_health: hero.max_health)\n puts \"Found #{reward}. Your health is restored.\"\n when \"a weapon\"\n weapon_power = rand(1..5)\n hero.update(power: hero.power + weapon_power)\n puts \"Found #{reward}. Power increased by #{weapon_power}.\"\n when \"a piece of armor\"\n armor_power = rand(1..10)\n hero.update(max_health: hero.max_health + armor_power)\n puts \"Found #{reward}. Max health increased by #{armor_power}.\"\n end\n sleep(3)\n end",
"def get_random_rating\n ratings = [\n ['Low Unsatisfactory', 2], \n ['High Unsatisfactory', 3], \n ['Low Satisfactory', 10], \n ['Mid Satisfactory', 15], \n ['High Satisfactory', 20], \n ['Low Advanced', 25], \n ['High Advanced', 25]\n ]\n wChooseUsingRand(@rand, ratings)\n end",
"def random_sleeping\n @reply_sleeping_text.sample\n end",
"def complain\n # random number from 1 to 4\n (rand(4) + 1).times do\n excl = rand(3)\n rnd = [rand(5) - 1, 0].max\n if rnd == 0\n print \"GET ME OFF\"\n elsif rnd < 3\n print \"HOT\"\n else\n print \"OW\"\n end\n excl.times { print \"!\" }\n print \" \"\n end\n puts\n end",
"def random_hugs\n huglist_sample = []\n 5.times { huglist_sample.push(Huglist.all.sample[:id]) }\n return huglist_sample.uniq\nend",
"def random_user\n\t\tUser.find([*1..40].sample)\n\tend",
"def grocery_item_guess(list)\n list.sample\nend",
"def choose_attack\n battle_commands[Random.rand(@battle_commands.length)]\n end",
"def random_alternatives(num_participants)\n if winner\n Array.new(num_participants, winner)\n else\n algorithm.choose_alternatives(self, num_participants)\n end\n end",
"def random(teams)\n adjacent(teams.shuffle)\n end",
"def random_move\n moves = (0..5).to_a\n sim_board = board_copy\n moves.reject!{|col| sim_board.col_full?(col)}\n moves.sample\n end",
"def get_random_user_list \n @users = user_list.sample(5).insert(rand(5), {name: \"ME\", bot: false})\n end",
"def cointoss\n\t\t\tnumber = rand(1..10)\n\t\t\t\treturn \"heads\" if number <= 5\n\t\t\t\treturn \"tails\" if number > 5\n\t\tend",
"def battler_targets(pokemon, logic)\n case target\n # eo eo ex / ux ao ax || e! e! ex / ux a! ax\n when :adjacent_pokemon, :adjacent_all_pokemon\n return logic.adjacent_foes_of(pokemon).concat(logic.adjacent_allies_of(pokemon))\n # eo eo ex / ux ax ax || e! e! ex / ux ax ax\n when :adjacent_foe, :adjacent_all_foe\n return logic.adjacent_foes_of(pokemon)\n # e! e! e! / ux ax ax || e? e? e? / ux ax ax\n when :all_foe, :random_foe\n return logic.foes_of(pokemon)\n # e! e! e! / u! a! a!\n when :all_pokemon\n return logic.foes_of(pokemon).concat(logic.allies_of(pokemon)) << pokemon\n # ex ex ex / u! ax ax\n when :user\n return [pokemon]\n # ex ex ex / uo ao ax\n when :user_or_adjacent_ally\n return [pokemon].concat(logic.adjacent_allies_of(pokemon))\n # ex ex ex / ux ao ax\n when :adjacent_ally\n return logic.allies_of(pokemon)\n # ex ex ex / u! a! a!\n when :all_ally\n return [pokemon].concat(logic.allies_of(pokemon))\n # eo eo eo / ux ao ao\n when :any_other_pokemon\n return logic.foes_of(pokemon).concat(logic.allies_of(pokemon))\n end\n return [pokemon]\n end",
"def choose_random_move(board, moves_list)\n \n possible_moves = []\n \n for i in moves_list\n if is_space_free(board, i)\n possible_moves.push(i)\n end\n end\n\n if possible_moves.length != 0\n return possible_moves.sample\n else\n return nil\n end \nend",
"def town_names amt=5, near_water=false\n starts = ['Bed', 'Brunn', 'Dun', 'Far', 'Glen', 'Tarn']\n middles = ['ding', 'fing', 'ly', 'ston']\n ends = ['borough', 'burg', 'ditch', 'hall', 'pool', 'ville', 'way', 'worth']\n waters = ['-on-sea', ' Falls']\n random_names = []\n i = 0\n while i < amt\n name = \"#{starts.sample}#{middles.sample}#{ends.sample}\"\n if near_water == 'near_water'\n name += waters.sample\n end\n random_names.push(name)\n i += 1\n end\n return random_names\nend",
"def kick\n rng.rand(value_range)\n end",
"def choose_item_and_on_whom(enemy)\n C[@inventory.random_item, [self, enemy].sample]\n end",
"def cuddle\n attempt = [0, 1]\n hug = attempt.sample\n end",
"def attack #basic attack for now\r\n attack_value = strength + rand(25..50)\r\n puts \"#{@name} SWINGS his Weapon for #{attack_value} Points of Damage!\"\r\n end",
"def rand_choice \n Random.rand(0...6)\n end",
"def choose_turn_order\r\n @players.shuffle!\r\n end",
"def pick\n @gommis_count = Gommi.count\n @gommis = Gommi.offset(rand(Gommi.count)).first\nend",
"def santa_machine(number)\r\n\t\r\n\texample_genders = [\"male\", \"female\", \"agender\", \"bigender\", \"gender fluid\", \"other\" ]\r\n\texample_ethnicities = [\"black\", \"white\", \"Japanese\", \"lizzard\", \"merpeople\" , \"plant\"]\r\n\tnumber.times do\r\n \t\tsanta = Santa.new(example_genders.sample, example_ethnicities.sample, rand(0..140))\r\n \t\tsanta.reindeer_shuffle\r\n \t\tsanta.about\r\n \t\tend\r\n\r\nend",
"def set_rand()\n rdm = Random.new()\n push_hp(rdm.rand(0.2..10.0))\n push_mp(rdm.rand(0.2..10.0))\n push_sp(rdm.rand(0.2..10.0))\n push_str(rdm.rand(0.2..5.0))\n push_vit(rdm.rand(0.2..5.0))\n push_int(rdm.rand(0.2..5.0))\n push_mnd(rdm.rand(0.2..5.0))\n push_dex(rdm.rand(0.2..5.0))\n push_agi(rdm.rand(0.2..5.0))\n push_luk(rdm.rand(0.2..5.0))\n end",
"def random_team()\n return @team_a if rand > 0.5\n @team_b\n end",
"def shufflers()\n a = shufflers1()\n a2 = shufflers2(a)\n l = shufflers3(a,a2[1])\n l2 = shufflers4(l)\n t = shufflers5(l2)\n t2 = shufflers6(t)\n write(t2) \nend",
"def random_weapon\n weapons = [\"sword\",\"bow and arrow\",\"laser gun\",\"Jungle Sword\",\"Lunar Cue\",\"Crimson Blaster\",\"Quake Hammer\",\"Drive Vortex\",\"Drive Defender\",\" Road Blaster\",\"Turbo Axe\",\"Rocket Blaster \"]\n weapon = weapons[rand(weapons.length)]\nend",
"def random_weighted(weighted)\n max = sum_of_weights(weighted)\n target = rand(1..max)\n \n weighted.each do |item, weight|\n return item if target <= weight\n target -= weight\n end\nend",
"def random_weighted(weighted)\n max = sum_of_weights(weighted)\n target = rand(1..max)\n \n weighted.each do |item, weight|\n return item if target <= weight\n target -= weight\n end\nend",
"def random_peg(*allowed_colors)\n allowed_colors[0][rand(0...allowed_colors[0].size)]\n end",
"def prox\n\t\trandom_weighted @jugadas\n\t\t\n\tend",
"def pick_suspect\n #random number and grab index from suspect array\n random_index = rand(0..Suspect.all.size)\n self.suspect = Suspect.all[random_index]\n end",
"def index\n @rand_user = User.all.sample\n unless @rand_user.id != current_user.id\n @rand_user = User.all.sample\n end\n @breaches = Breach.where(user_id: current_user.id)\n enemy_failed_breaches = Breach.where(target_id: current_user.id)\n @enemy_list = Array.new\n enemy_failed_breaches.each do |breach|\n @enemy_list.push(User.find(breach.user_id))\n end\n end",
"def g5_games(teams)\n games = Array.new\n teams.each do |team|\n 2.times do\n games << [team, G5_RATINGS.sample]\n end\n end\n\n games\nend"
] | [
"0.61591095",
"0.61492926",
"0.5988519",
"0.59762824",
"0.59223676",
"0.5917511",
"0.59096956",
"0.58983916",
"0.58554476",
"0.58409035",
"0.58405674",
"0.5810753",
"0.5773324",
"0.5758916",
"0.5749908",
"0.573031",
"0.56792575",
"0.56792575",
"0.5674176",
"0.5659517",
"0.56220055",
"0.5606274",
"0.5584936",
"0.5581409",
"0.5578465",
"0.55693316",
"0.5566508",
"0.5564565",
"0.5557181",
"0.55458516",
"0.55423623",
"0.55423623",
"0.55035096",
"0.5493519",
"0.5476415",
"0.5472309",
"0.54710937",
"0.54588133",
"0.5458494",
"0.54551554",
"0.54370296",
"0.54181224",
"0.5417818",
"0.54105484",
"0.54089904",
"0.5401742",
"0.53825444",
"0.5379904",
"0.53764737",
"0.53709155",
"0.537061",
"0.53615224",
"0.5357273",
"0.5355862",
"0.53526884",
"0.5345885",
"0.53450763",
"0.53229016",
"0.5322597",
"0.53202605",
"0.53201437",
"0.5319772",
"0.5319293",
"0.5316936",
"0.531258",
"0.53119844",
"0.53104985",
"0.53096914",
"0.53050274",
"0.52955574",
"0.52924424",
"0.52900064",
"0.5286288",
"0.52812606",
"0.5280708",
"0.5274962",
"0.52740264",
"0.5272469",
"0.5272234",
"0.5271774",
"0.5270951",
"0.52679294",
"0.5267292",
"0.5267029",
"0.5266964",
"0.52662325",
"0.5257462",
"0.5253355",
"0.52528095",
"0.5241148",
"0.5235467",
"0.5234298",
"0.5233936",
"0.5231625",
"0.5231625",
"0.52242213",
"0.52220184",
"0.5221699",
"0.52212703",
"0.52196014"
] | 0.80174303 | 0 |
method for player selecting a target | def select_target
target_list = print_recommended_targets
#check to see if there are any available targts
if target_list.size == 0
puts "There are no available targets!".bold.red
target = nil
#get input for available targets
else
puts "Select Your Target Number".bold.white.on_light_blue
input = gets.chomp
#check if the input is valid and prompt the user again
if input.to_i > 5 || input.to_i < 1
puts"Please input valid target number".red.bold
self.select_target
#select the target
else
target = target_list[input.to_i - 1]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_target\n @target or raise Vanagon::Error, '#select_target has not been implemented for your engine.'\n end",
"def target_choice\n launcher, skill, target_bank, target_position = @visual.show_target_choice\n if launcher\n # The player made a choice we store the action and check if he can make other choices\n @player_actions << { type: :attack, launcher: launcher, skill: skill, target_bank: target_bank, target_position: target_position }\n log_debug(\"Action : #{@player_actions.last}\") if debug? # To prevent useless overhead outside debug\n @next_update = can_player_make_another_action_choice? ? :player_action_choice : :trigger_all_AI\n else\n # If the player canceled we return to the player action\n @next_update = :player_action_choice\n end\n ensure\n @skip_frame = true\n end",
"def tbs_target_selection\n @tb_event.flash_soft_tb = false if @tb_event\n select_tb_unit($game_player.x, $game_player.y)\n @showing_temp_hls = false\n end",
"def selectPlayer _args\n \"selectPlayer _args;\" \n end",
"def determine_target\n used = false\n if @skill.for_all?\n for target in $game_party.members\n target.skill_effect(@actor, @skill)\n used = true unless target.skipped\n end\n elsif @skill.for_user?\n target = $game_party.members[@target_window.index]\n target.skill_effect(@actor, @skill)\n used = true unless target.skipped\n else\n $game_party.last_target_index = @target_window.index\n target = $game_party.members[@target_window.index]\n target.skill_effect(@actor, @skill)\n used = true unless target.skipped\n end\n if used\n use_skill_nontarget\n else\n Sound.play_buzzer\n end\n end",
"def determine_target\n used = false\n if @skill.for_all?\n for target in $game_party.members\n target.skill_effect(@actor, @skill)\n used = true unless target.skipped\n end\n elsif @skill.for_user?\n target = $game_party.members[@target_window.index]\n target.skill_effect(@actor, @skill)\n used = true unless target.skipped\n else\n $game_party.last_target_index = @target_window.index\n target = $game_party.members[@target_window.index]\n target.skill_effect(@actor, @skill)\n used = true unless target.skipped\n end\n if used\n use_skill_nontarget\n else\n Sound.play_buzzer\n end\n end",
"def util_targetselection_automatic(launcher, skill)\n case skill.target\n when :adjacent_pokemon # eo eo ex / ux ao ax\n arr = util_targetselection_adjacent_foe(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :adjacent_foe # eo eo ex / ux ax ax\n arr = util_targetselection_adjacent_foe(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :adjacent_all_foe # e! e! ex / ux ax ax\n return util_targetselection_adjacent_foe(launcher)\n when :all_foe # e! e! e! / ux ax ax\n return ::BattleEngine.get_enemies!(launcher)\n when :adjacent_all_pokemon # e! e! ex / ux a! ax\n return util_targetselection_adjacent_pokemon(launcher)\n when :all_pokemon # e! e! e! / u! a! a!\n return ::BattleEngine.get_enemies!(launcher) + ::BattleEngine.get_ally!(launcher)\n when :user # ex ex ex / u! ax ax\n return [launcher]\n when :user_or_adjacent_ally # ex ex ex / uo ao ax\n arr = [launcher]+util_targetselection_adjacent_ally(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :adjacent_ally # ex ex ex / ux ao ax\n arr = util_targetselection_adjacent_ally(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :all_ally # ex ex ex / u! a! a!\n return ::BattleEngine.get_ally!(launcher)\n when :any_other_pokemon # ex ex ex / uo ax ax\n arr = ::BattleEngine.get_enemies!(launcher)\n arr += util_targetselection_adjacent_ally(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n when :random_foe # e? e? e? / ux ax ax\n arr = ::BattleEngine.get_enemies!(launcher)\n return [arr[rand(arr.size)]] if arr.size > 0\n end\n return [launcher]\n end",
"def target( **query )\n query[:visible_to] = self\n Game.instance.target(**query)\n end",
"def pbChooseTarget(index,targettype)\n curwindow=pbFirstTarget(index,targettype)\n if curwindow==-1\n raise RuntimeError.new(\"No targets somehow...\")\n end\n [email protected] ? 4 : 2\n for i in 0...numwindows\n @pkmnwindows[i].highlighted=(i==curwindow)\n end\n pbRefresh\n loop do\n Graphics.update\n Input.update\n pbFrameUpdate(nil)\n if Input.trigger?(Input::DOWN)\n newwindow=pbNextTarget(curwindow,index)\n if newwindow>=0\n curwindow=newwindow\n for i in 0...numwindows\n @pkmnwindows[i].highlighted=(i==curwindow)\n end\n end\n end\n if Input.trigger?(Input::UP)\n newwindow=pbPrevTarget(curwindow,index)\n if newwindow>=0\n curwindow=newwindow\n for i in 0...numwindows\n @pkmnwindows[i].highlighted=(i==curwindow)\n end\n end\n end\n if Input.trigger?(Input::B)\n for i in 0...numwindows\n @pkmnwindows[i].highlighted=false\n @pkmnwindows[i].update\n end\n return -1\n end\n if Input.trigger?(Input::C)\n for i in 0...numwindows\n @pkmnwindows[i].highlighted=false\n @pkmnwindows[i].update\n end\n return curwindow\n end\n end\n end",
"def select_player_choice (player)\n puts \"\\n#{player.name}, it's your turn.\\n\\nHere are your options:\\n\"\n @acceptable_choices.each { |e| puts e}\n player.select_choice(self)\n end",
"def target!\n @target\n end",
"def set_target\n @target = Target.find(params[:id]||params[:target_id])\n end",
"def determine_mix_target\n if $imported[\"YEA-BattleCommandList\"]\n determine_mix_target_yea_bcl\n elsif $imported[\"YEA-BattleEngine\"]\n determine_mix_target_yea_abe\n else # default battle system\n @item = @mix_window.mix_result\n BattleManager.actor.input.set_item(@item.id)\n \n if [email protected]_selection?\n set_actor_mix_items # mix\n next_command\n elsif @item.for_opponent?\n select_enemy_selection\n else\n select_actor_selection\n end # if\n end # if\n end",
"def target=(value)\n @target = value\n end",
"def on_target_ok\n BattleManager.actor.input.set = [@target_window.target]\n @target_window.hide\n @skill_window.hide\n @item_window.hide\n next_command\n end",
"def set_target\n @target = Target.find(params[:id])\n end",
"def set_target\n @target = Target.find(params[:id])\n end",
"def tbs_unit_selection\n map, p = $game_map, $game_player\n x,y = p.x, p.y\n \n if Input.trigger?(TM::Defaults::ShowAtt) #&& !TM.selecting_target?\n on_click\n set_tb_event(x,y)\n return if TM.selecting? # command window is up\n next_atk_hls(x,y) \n # Press Z to show route then Z again to move the unit\n elsif Input.trigger?(TM::Defaults::ShowMove) \n on_click\n return tb_enter_trade unless @selecting_tb_trade.nil?\n return if TM.selecting? # command window is up\n return tbs_target_selection if TM.selecting_target?\n return move_unit_tb(x,y) if @move_pos_selecting && can_move?\n return next_menu_ok_tb if @showing_temp_hls # @showing_temp_hls = false\n pok = produce_units if !TM.selecting_target?\n return SceneManager.call(SceneTBMainMenu) if show_mm_ok_tb?(x,y, pok)\n @menu_ok_tb = false\n elsif Input.trigger?(TM::Defaults::SelectAtk)\n on_click\n set_tb_event(x,y)\n return if TM.selecting? # command window is up\n next_atk_hls(x,y, true) \n elsif Input.trigger?(:B) \n on_click\n on_cancel_select if !@showing_status\n return if !@tb_event.nil? && @tb_event.move_route_forcing\n return @selecting_tb_trade = nil if @selecting_tb_trade \n if TM.selecting_target? || @move_pos_selecting || @showing_temp_hls\n end_select\n elsif @showing_status\n @showing_status = false\n @status_window_tb.hide\n @tb_command_window.activate\n else\n turn_off_flash_tbe\n @tb_event = nil\n check_unit_to_show\n SceneManager.call(SceneTBMainMenu) if !TM.selecting? && @tb_event.nil?\n end\n end_click\n end\n end",
"def set_target\n @target = Target.find(params[:id])\n end",
"def set_target\n @target = Target.find(params[:id])\n end",
"def skill_choice\n if @visual.show_skill_choice(@player_actions.size)\n # The player choosed a move\n @next_update = :target_choice\n else\n # The player canceled\n @next_update = :player_action_choice\n end\n ensure\n @skip_frame = true\n end",
"def selectWeaponTurret _obj, _args\n \"_obj selectWeaponTurret _args;\" \n end",
"def _active_target\n @target\n end",
"def target=(target)\n @target = target\n end",
"def select_position\n @players = @game.players\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def play(opponent)\n opponent.choose\n end",
"def decide_random_target_for_actor\n # Diverge with effect scope\n if for_one_friend_hp0?\n battler = $game_party.random_target_actor_hp0\n elsif for_one_friend?\n battler = $game_party.random_target_actor\n else\n battler = $game_troop.random_target_enemy\n end\n # If a target exists, get an index, and if a target doesn't exist,\n # clear the action\n if battler != nil\n @target_index = battler.index\n else\n clear\n end\n end",
"def select_tb_unit(x,y)\n tm = TactBattleManager\n return tm.set_selecting_target(false) if !(@hl_att_points||={})[Vertex.new(x,y)]\n tbu = @tb_event.tb_unit\n is_skill = @tb_item.is_a?(RPG::Skill)\n b = @tb_event.tb_unit.battler\n tl = tbu.tb_actions[:targets]\n type = nil\n if is_skill && @tb_item.id == b.basic_atk_tb\n lmt = tbu.tb_actions[:atk]\n return end_select if !tbu.atk_ok? # lmt >= tbu.atk_action_lmt || tl >= tbu.target_tb_lmt\n type = :atk\n elsif is_skill\n lmt = tbu.tb_actions[:skill]\n return end_select if !tbu.skill_ok? # lmt >= tbu.skill_action_lmt || tl>=tbu.target_tb_lmt\n type = :skill\n else\n lmt = tbu.tb_actions[:item]; \n return end_select if !tbu.item_ok? # lmt >= tbu.item_action_lmt || tl>=tbu.target_tb_lmt\n type = :item\n end\n \n map = $game_map \n res, use = false, false\n dir = @tb_event.dir_to_sym_era\n \n if @tb_item.tb_aoe\n use = Era::AI.apply_aoe_item(x,y,@tb_item, @tb_event.id, dir)\n else\n use = Era::AI.apply_item(x,y,@tb_item, @tb_event.id, dir)\n end\n \n if use\n @tb_event.tb_unit.use_item(@tb_item)\n tbu.used_action(type,1)\n tbu.lose_item(@tb_item, 1)\n end\n reset_aoe_follows\n # @spriteset.remove_group(DISPLAY_TB) # @spriteset.dispose_highlights_tb # for now remove all highlights\n remove_show_hls\n end_select\n end",
"def decide_random_target_for_enemy\n # Diverge with effect scope\n if for_one_friend_hp0?\n battler = $game_troop.random_target_enemy_hp0\n elsif for_one_friend?\n battler = $game_troop.random_target_enemy\n else\n battler = $game_party.random_target_actor\n end\n # If a target exists, get an index, and if a target doesn't exist,\n # clear the action\n if battler != nil\n @target_index = battler.index\n else\n clear\n end\n end",
"def seleccion\n case @selection\n when 1\n push_game_state(EnterName.new(callback: method(:enter_name)))\n when 2\n if @token_difficulty.zero?\n @difficulty_message.text = \"Dificultad: #{@difficulty[1]}\"\n @token_difficulty = 1\n @select_sound = 0\n elsif @token_difficulty == 1\n @difficulty_message.text = \"Dificultad: #{@difficulty[2]}\"\n @token_difficulty = 2\n @select_sound = 1\n @sound_tracks_list[@select_sound].play if @music_playing\n else\n @difficulty_message.text = \"Dificultad: #{@difficulty[0]}\"\n @token_difficulty = 0\n @select_sound = 0\n @sound_tracks_list[@select_sound].play if @music_playing\n end\n when 3\n if @music_playing\n @music_message.text = 'Musica: OFF'\n @music_playing = false\n @sound_tracks_list[@select_sound].pause\n else\n @music_message.text = 'Musica: ON'\n @music_playing = true\n @sound_tracks_list[@select_sound].play\n end\n when 4\n push_game_state(Acerca)\n when 5\n exit\n end\n\n end",
"def determine_mix_target_yea_abe\n @item = @mix_window.mix_result\n $game_temp.battle_aid = @item\n BattleManager.actor.input.set_item(@item.id)\n if @item.for_opponent?\n select_enemy_selection\n elsif @item.for_friend?\n select_actor_selection\n else\n set_actor_mix_items # mix\n next_command\n $game_temp.battle_aid = nil\n end\n end",
"def attack_ui(entity, action, options = {})\n selected_targets = []\n\n target = @prompt.select(\"#{entity.name} targets\") do |menu|\n battle.valid_targets_for(entity, action, target_types: options[:target_types], range: options[:range]).each do |target|\n menu.choice target.name, target\n end\n menu.choice 'Manual'\n menu.choice 'Back', nil\n end\n\n return nil if target == 'Back'\n\n if target == 'Manual'\n targets = target_ui(validation: lambda { |selected|\n selected_entities = map.thing_at(*selected)\n\n return false if selected_entities.empty?\n\n selected_entities.detect do |selected_entity|\n battle.valid_targets_for(entity, action, target_types: options[:target_types], range: options[:range], include_objects: true).include?(selected_entity)\n end\n })\n\n if targets.size > (options[:num_select].presence || 1)\n loop do\n target = @prompt.select('multiple targets at location(s) please select specific targets') do |menu|\n targets.each do |t|\n menu.choice t.name.to_s, t\n end\n end\n selected_targets << target\n break unless selected_targets.size < options[:num_select]\n end\n else\n selected_targets = targets\n end\n\n return nil if target.nil?\n else\n selected_targets << target\n end\n\n selected_targets.flatten\n end",
"def target; end",
"def target; end",
"def target(*args)\n if args.blank?\n const_defined?(:Target) ? const_get(:Target) : (@target || name[0..-5].classify.constantize)\n else\n self.target = args.first\n end\n end",
"def target\n @target\n end",
"def target\n @target\n end",
"def selectWeapon _obj, _args\n \"_obj selectWeapon _args;\" \n end",
"def command_attack\n BattleManager.actor.input.set_attack\n select_target_selection\n end",
"def get_target\n @target\n end",
"def load_target\r\n @target = params[:target]\r\n end",
"def load_target\r\n @target = params[:target]\r\n end",
"def target_acquired(board)\n puts \"#{@name} has acquired a target.\\nPrepare for imminent destruction.\"\n if board.hits.length == 1\n board.pos_cross(board.hits[0]).sample\n else\n target_direction(board, board.hits.sort)\n end\n end",
"def on_skill_ok\n @skill = @skill_window.item\n BattleManager.actor.input.set_skill(@skill.id)\n action = BattleManager.actor.input\n BattleManager.actor.last_skill.object = @skill\n if @skill.target_type[0] == :one then select_target_selection\n else\n case @skill.target_type[0]\n when :all\n BattleManager.actor.input.set = SES::TargetManager.make_targets(action)\n when :rand\n targets, set = [], SES::TargetManager.make_targets(action)\n (@skill.target_type[1][0] + rand(@skill.target_type[1][1])).times do\n targets << set[rand(set.size)]\n end\n BattleManager.actor.input.set = set\n end\n @skill_window.hide\n next_command\n end\n end",
"def update_target\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Erase target window\r\n @skill_window.active = true\r\n @target_window.visible = false\r\n @target_window.active = false\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # If unable to use because SP ran out\r\n unless @actor.skill_can_use?(@skill.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # If target is all\r\n if @target_window.index == -1\r\n # Apply skill use effects to entire party\r\n used = false\r\n for i in $game_party.actors\r\n used |= i.skill_effect(@actor, @skill)\r\n end\r\n end\r\n # If target is user\r\n if @target_window.index <= -2\r\n # Apply skill use effects to target actor\r\n target = $game_party.actors[@target_window.index + 10]\r\n used = target.skill_effect(@actor, @skill)\r\n end\r\n # If single target\r\n if @target_window.index >= 0\r\n # Apply skill use effects to target actor\r\n target = $game_party.actors[@target_window.index]\r\n used = target.skill_effect(@actor, @skill)\r\n end\r\n # If skill was used\r\n if used\r\n # Play skill use SE\r\n $game_system.se_play(@skill.menu_se)\r\n # Use up SP\r\n @actor.sp -= @skill.sp_cost\r\n # Remake each window content\r\n @status_window.refresh\r\n @skill_window.refresh\r\n @target_window.refresh\r\n # If entire party is dead\r\n if $game_party.all_dead?\r\n # Switch to game over screen\r\n $scene = Scene_Gameover.new\r\n return\r\n end\r\n # If command event ID is valid\r\n if @skill.common_event_id > 0\r\n # Command event call reservation\r\n $game_temp.common_event_id = @skill.common_event_id\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end\r\n # If skill wasn't used\r\n unless used\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n end\r\n return\r\n end\r\n end",
"def selectNoPlayer \n \"selectNoPlayer\" \n end",
"def set_user_target\n @user_target = UserTarget.find(params[:id])\n end",
"def update_phase3_actor_select\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # End actor selection\r\n end_actor_select\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.target_index = @actor_arrow.index\r\n # End actor selection\r\n end_actor_select\r\n # If skill window is showing\r\n if @skill_window != nil\r\n # End skill selection\r\n end_skill_select\r\n end\r\n # If item window is showing\r\n if @item_window != nil\r\n # End item selection\r\n end_item_select\r\n end\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end\r\n end",
"def test_selection\n @player = @battle.user_select(1)\n assert_instance_of(Karl, @player)\n\n @rand_player = @battle.user_select(4)\n assert_instance_of([Karl, Guspatcho, LemonyWinks], @rand_player)\n end",
"def update_phase3_enemy_select\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # End enemy selection\r\n end_enemy_select\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Set action\r\n @active_battler.current_action.target_index = @enemy_arrow.index\r\n # End enemy selection\r\n end_enemy_select\r\n # If skill window is showing\r\n if @skill_window != nil\r\n # End skill selection\r\n end_skill_select\r\n end\r\n # If item window is showing\r\n if @item_window != nil\r\n # End item selection\r\n end_item_select\r\n end\r\n # Go to command input for next actor\r\n phase3_next_actor\r\n end\r\n end",
"def determine_mix_target_yea_bcl\n @item = @mix_window.mix_result\n BattleManager.actor.input.set_item(@item.id)\n\n status_redraw_target(BattleManager.actor)\n if $imported[\"YEA-BattleEngine\"]\n $game_temp.battle_aid = @item\n if @item.for_opponent?\n select_enemy_selection\n elsif @item.for_friend?\n select_actor_selection\n else\n set_actor_mix_items # mix\n next_command\n $game_temp.battle_aid = nil\n end\n else\n if [email protected]_selection?\n set_actor_mix_items # mix\n next_command\n elsif @item.for_opponent?\n select_enemy_selection\n else\n select_actor_selection\n end\n end\n end",
"def select_last\n select($game_party.target_actor.index || 0)\n end",
"def choose_winner; end",
"def target=(target)\n @target = target\n @ori_target = target\n end",
"def select_piece(left,top)\n clicked_box = get_clicked_box(left,top)\n # select the piece if the piece exists and is a human player piece\n @selected_piece = clicked_box if @board.exists?(clicked_box) && @board.piece(clicked_box).color == HUMAN_PLAYER\n highlight(@selected_piece)\nend",
"def select_target_from(pooler) # rubocop:disable Metrics/AbcSize\n request_object = build_request_object\n\n VanagonLogger.info \"Requesting VMs with job_id: #{@saved_job_id}. Will poll for up to an hour.\"\n #the initial request is always replied with \"come back again\"\n response = Vanagon::Utilities.http_request_generic(\n \"#{pooler}/request\",\n 'POST',\n request_object.to_json,\n { 'X-AUTH-TOKEN' => @token }\n )\n\n unless response.code == \"202\"\n VanagonLogger.info \"failed to request ABS with code #{response.code}\"\n if valid_json?(response.body)\n response_json = JSON.parse(response.body)\n VanagonLogger.info \"reason: #{response_json['reason']}\"\n end\n return ''\n end\n response_body = check_queue(pooler, request_object)\n\n return '' unless response_body[\"ok\"]\n @target = response_body[build_host_name]['hostname']\n Vanagon::Driver.logger.info \"Reserving #{@target} (#{build_host_name}) [#{@token ? 'token used' : 'no token used'}]\"\n return pooler\n end",
"def player_select\n puts \"Select X or O\"\n choice = gets.chomp.upcase\n if choice == \"X\" || choice == \"O\"\n @player_choice = choice\n puts \"Player chose #{@player_choice}\"\n sleep 1\n computer_choice\n else\n puts \"Invalid selection, try again.\"\n player_select\n end\n end",
"def selected; end",
"def target=(target)\n self.each{|e| e.target=target}\n end",
"def target=(new_value)\n @target = new_value unless const_defined?(:Target)\n end",
"def selectLeader _obj, _args\n \"_obj selectLeader _args;\" \n end",
"def set_target(id)\n @target = Target.find(id)\n end",
"def set_target\n access_key = '16e5c472cbad4e592e977029af54b1500b551362'\n secret_key = '932998f43862357f0da1a3e9b0340f5b38c55eb1'\n connection = Vws::Api.new(access_key, secret_key)\n width = 32\n active_flag = true\n application_metadata = nil\n puts @target.image.inspect\n puts vuforia_return = \"ok\"\n # vuforia_return = connection.add_target(target_name, \"http://api.playarshop.com\" + @target.image.url, width, active_flag, application_metadata)\n vuforia_return = connection.add_target(target_name, \"./public/logo.png\", width, active_flag, application_metadata)\n puts vuforia_return.inspect\n @target = Target.find(params[:id])\n end",
"def is? target\n\t\treturn target.downcase.to_sym == :player\n\tend",
"def set_target\n @user = current_user\n render \"target\"\n end",
"def target(target_name, server = nil)\n targets(server).find { |name, _| name == target_name }.last\n end",
"def target\n return @target\n end",
"def update_phase3_enemy_select\n pkmn = @actors[@actor_actions.size]\n skill = pkmn.skills_set[@atk_index]\n if skill.id == 174 and !pkmn.type_ghost? #> Malédiction\n return [pkmn]\n end\n #>Choix automatique en 1v1\n if $game_temp.vs_type == 1 or (@enemy_party.pokemon_alive==1 and $pokemon_party.pokemon_alive==1) or skill.is_no_choice_skill?\n return util_targetselection_automatic(pkmn, skill)\n #>Choix 2v2\n elsif $game_temp.vs_type == 2\n data = update_phase3_pokemon_select_2v2(pkmn, skill)\n return -1 if data == -1\n if data < 2\n return [@enemies[data]]\n end\n return [@actors[data-2]]\n else\n return -1\n end\n\n end",
"def switch_choice\n pokemon_to_send = @visual.show_pokemon_choice\n if pokemon_to_send\n pokemon_to_switch = @logic.battler(0, @player_actions.size)\n # The player made a choice we store the action and we check if he can make other choices\n @player_actions << { type: :switch, who: pokemon_to_switch, with: pokemon_to_send }\n pokemon_to_send.switching = true\n pokemon_to_switch.switching = true\n log_debug(\"Action : #{@player_actions.last}\") if debug? # To prevent useless overhead outside debug\n @next_update = can_player_make_another_action_choice? ? :player_action_choice : :trigger_all_AI\n else\n # If the player canceled we return to the player action\n @next_update = :player_action_choice\n end\n end",
"def choose\n \n end",
"def select_playeros\n user = current_user\n if !!user.contest_travelite\n redirect_to contests_travelite_path\n else\n ContestTravelite.create(:user_id => current_user.id, :selection => 'playero')\n redirect_to contests_travelite_step2_path\n end\n end",
"def target\n targets && targets.length == 1 && targets[0] || nil\n end",
"def select\n select_passive_target NFC::Device::IM_ISO14443A_106\n end",
"def update_phase3_enemy_select\n # Update enemy arrow\n @enemy_arrow.update\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # End enemy selection\n end_enemy_select\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.target_index = @enemy_arrow.index\n # End enemy selection\n end_enemy_select\n # If skill window is showing\n if @skill_window != nil\n # End skill selection\n end_skill_select\n end\n # If item window is showing\n if @item_window != nil\n # End item selection\n end_item_select\n end\n # Go to command input for next actor\n phase3_next_actor\n end\n end",
"def target\n if self.respond_to?(:auto_targeted_index)\n if auto_target?\n auto_idx = auto_targeted_index\n if auto_idx.present?\n datastore['TARGET'] = auto_idx\n else\n # If our inserted Automatic Target was selected but we failed to\n # find a suitable target, we just grab the original first target.\n datastore['TARGET'] = 1\n end\n end\n end\n\n target_idx = target_index\n return (target_idx) ? targets[target_idx.to_i] : nil\n end",
"def select_player_profile\n push_game_state(ProfileSelect)\n end",
"def target=(target)\n @target = target\n loaded!\n end",
"def target=(target)\n @target = target\n loaded!\n end",
"def update_target\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # If unable to use because items ran out\n unless $game_party.item_can_use?(@item.id)\n # Remake item window contents\n @item_window.refresh\n end\n # Erase target window\n @item_window.active = true\n @target_window.visible = false\n @target_window.active = false\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # If items are used up\n if $game_party.item_number(@item.id) == 0\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n return\n end\n # If target is all\n if @target_window.index == -1\n # Apply item effects to entire party\n used = false\n for i in $game_party.actors\n used |= i.item_effect(@item)\n end\n end\n # If single target\n if @target_window.index >= 0\n # Apply item use effects to target actor\n target = $game_party.actors[@target_window.index]\n used = target.item_effect(@item)\n end\n # If an item was used\n if used\n # Play item use SE\n $game_system.se_play(@item.menu_se)\n # If consumable\n if @item.consumable\n # Decrease used items by 1\n $game_party.lose_item(@item.id, 1)\n # Redraw item window item\n @item_window.draw_item(@item_window.index)\n end\n # Remake target window contents\n @target_window.refresh\n # If all party members are dead\n if $game_party.all_dead?\n # Switch to game over screen\n $scene = Scene_Gameover.new\n return\n end\n # If common event ID is valid\n if @item.common_event_id > 0\n # Common event call reservation\n $game_temp.common_event_id = @item.common_event_id\n # Switch to map screen\n $scene = Scene_Map.new\n return\n end\n end\n # If item wasn't used\n unless used\n # Play buzzer SE\n $game_system.se_play($data_system.buzzer_se)\n end\n return\n end\n end",
"def update_phase3_actor_select\n # Update actor arrow\n @actor_arrow.update\n # If B button was pressed\n if Input.trigger?(Input::B)\n # Play cancel SE\n $game_system.se_play($data_system.cancel_se)\n # End actor selection\n end_actor_select\n return\n end\n # If C button was pressed\n if Input.trigger?(Input::C)\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Set action\n @active_battler.current_action.target_index = @actor_arrow.index\n # End actor selection\n end_actor_select\n # If skill window is showing\n if @skill_window != nil\n # End skill selection\n end_skill_select\n end\n # If item window is showing\n if @item_window != nil\n # End item selection\n end_item_select\n end\n # Go to command input for next actor\n phase3_next_actor\n end\n end",
"def setup_move_to_target\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n xpos = target.x + (flip ? -@acts[1] : @acts[1])\n ypos = target.y + @acts[2]\n goto(xpos, ypos, @acts[3], @acts[4], @acts[5] || 0)\n end",
"def abs_target\n opponents_unit.abs_target(item.number_of_targets)\n end",
"def target\n self['target']\n end",
"def update_target\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # If unable to use because items ran out\r\n unless $game_party.item_can_use?(@item.id)\r\n # Remake item window contents\r\n @item_window.refresh\r\n end\r\n # Erase target window\r\n @item_window.active = true\r\n @target_window.visible = false\r\n @target_window.active = false\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # If items are used up\r\n if $game_party.item_number(@item.id) == 0\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # If target is all\r\n if @target_window.index == -1\r\n # Apply item effects to entire party\r\n used = false\r\n for i in $game_party.actors\r\n used |= i.item_effect(@item)\r\n end\r\n end\r\n # If single target\r\n if @target_window.index >= 0\r\n # Apply item use effects to target actor\r\n target = $game_party.actors[@target_window.index]\r\n used = target.item_effect(@item)\r\n end\r\n # If an item was used\r\n if used\r\n # Play item use SE\r\n $game_system.se_play(@item.menu_se)\r\n # If consumable\r\n if @item.consumable\r\n # Decrease used items by 1\r\n $game_party.lose_item(@item.id, 1)\r\n # Redraw item window item\r\n @item_window.draw_item(@item_window.index)\r\n end\r\n # Remake target window contents\r\n @target_window.refresh\r\n # If all party members are dead\r\n if $game_party.all_dead?\r\n # Switch to game over screen\r\n $scene = Scene_Gameover.new\r\n return\r\n end\r\n # If common event ID is valid\r\n if @item.common_event_id > 0\r\n # Common event call reservation\r\n $game_temp.common_event_id = @item.common_event_id\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end\r\n # If item wasn't used\r\n unless used\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n end\r\n return\r\n end\r\n end",
"def update_target\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # If unable to use because items ran out\r\n unless $game_party.item_can_use?(@item.id)\r\n # Remake item window contents\r\n @item_window.refresh\r\n end\r\n # Erase target window\r\n @item_window.active = true\r\n @target_window.visible = false\r\n @target_window.active = false\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # If items are used up\r\n if $game_party.item_number(@item.id) == 0\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # If target is all\r\n if @target_window.index == -1\r\n # Apply item effects to entire party\r\n used = false\r\n for i in $game_party.actors\r\n used |= i.item_effect(@item)\r\n end\r\n end\r\n # If single target\r\n if @target_window.index >= 0\r\n # Apply item use effects to target actor\r\n target = $game_party.actors[@target_window.index]\r\n used = target.item_effect(@item)\r\n end\r\n # If an item was used\r\n if used\r\n # Play item use SE\r\n $game_system.se_play(@item.menu_se)\r\n # If consumable\r\n if @item.consumable\r\n # Decrease used items by 1\r\n $game_party.lose_item(@item.id, 1)\r\n # Redraw item window item\r\n @item_window.draw_item(@item_window.index)\r\n end\r\n # Remake target window contents\r\n @target_window.refresh\r\n # If all party members are dead\r\n if $game_party.all_dead?\r\n # Switch to game over screen\r\n $scene = Scene_Gameover.new\r\n return\r\n end\r\n # If common event ID is valid\r\n if @item.common_event_id > 0\r\n # Common event call reservation\r\n $game_temp.common_event_id = @item.common_event_id\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end\r\n # If item wasn't used\r\n unless used\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n end\r\n return\r\n end\r\n end",
"def selected?; end",
"def selected?; end",
"def camSetTarget _obj, _args\n \"_obj camSetTarget _args;\" \n end",
"def action_target_center\n @target_x = $scene.spriteset.battleback_width / 2\n @target_y = $scene.spriteset.battleback_height / 2\n end",
"def choose_player\n case @name\n when 'R2D2' then rtwodtwo\n when 'Hal' then hal\n when 'Chappie' then chappie\n end\n end",
"def update_selected \n #no select when exiting\n if @battle_exiting\n @selected = nil\n \n #fast update if @cursor didn't change position\n elsif @selected.nil? or not @selected.at_xy_coord(@cursor.x, @cursor.y) \n @selected = nil\n battler = $game_map.occupied_by?(@cursor.x, @cursor.y)\n if battler != nil\n #for battler in tactics_all\n # next if battler.nil? \n # if battler.at_xy_coord(@cursor.x, @cursor.y)\n @selected = battler\n @windows[Win_Status].update(battler)\n #Modified to be hard coded to top right checking. \n mx = Graphics.width - @windows[Win_Status].width\n mw = Graphics.width\n my = 0\n mv = @windows[Win_Status].height\n if @spriteset.cursor.x.between?(mx, mw) && @spriteset.cursor.y.between?(my,mv)\n @windows[Win_Status].move_to(3); #lower right\n else\n @windows[Win_Status].move_to(9); #upper right // Default\n end\n return\n # end\n end \n end\n end"
] | [
"0.77905816",
"0.7041471",
"0.6987912",
"0.66176575",
"0.65036726",
"0.65036726",
"0.6498322",
"0.6466121",
"0.6454266",
"0.6448202",
"0.64133596",
"0.6408906",
"0.63759273",
"0.6330023",
"0.6318779",
"0.6271247",
"0.6271247",
"0.62537056",
"0.6233939",
"0.6233939",
"0.6200543",
"0.6194849",
"0.6186553",
"0.61527854",
"0.61155576",
"0.61028177",
"0.61028177",
"0.61028177",
"0.61028177",
"0.61028177",
"0.61028177",
"0.61028177",
"0.61028177",
"0.61028177",
"0.6095669",
"0.60880214",
"0.6063512",
"0.6055051",
"0.60530585",
"0.6042716",
"0.602293",
"0.59706336",
"0.59706336",
"0.5960895",
"0.59524745",
"0.5951568",
"0.59293854",
"0.5927048",
"0.5924875",
"0.5921844",
"0.5921844",
"0.59076864",
"0.5905467",
"0.58817905",
"0.5877089",
"0.58663654",
"0.5865976",
"0.5865348",
"0.5847275",
"0.58352536",
"0.5832219",
"0.5816945",
"0.58146584",
"0.5763413",
"0.5751677",
"0.57226783",
"0.5722214",
"0.572121",
"0.5719309",
"0.57185906",
"0.5717846",
"0.571021",
"0.5698381",
"0.56809133",
"0.5669948",
"0.566741",
"0.5667254",
"0.5650276",
"0.56437373",
"0.5640753",
"0.56094384",
"0.55956894",
"0.55873156",
"0.5583032",
"0.55806893",
"0.5571215",
"0.5571215",
"0.5569728",
"0.55675095",
"0.55660933",
"0.5565454",
"0.556113",
"0.5558365",
"0.5558365",
"0.55430144",
"0.55430144",
"0.5540402",
"0.5539229",
"0.5530949",
"0.55204004"
] | 0.6689106 | 3 |
method for the actual combat | def attack(target)
#check to see if there is any target
if target == nil
puts "Invite some friends to play this awesome game.".blue
else
#print fighting for the user
puts Artii::Base.new.asciify "Fight"
###methods for determining probability of victory
###and damage to the opponent or current user#####
#if the characters have the same attack power
if self.power == target.power
#if the player wins the battle
if rand > 0.5
#reduce the target's hp by 10
target.update_hp(-10)
#display outcome of the battle to the player
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
puts "#{self.name} Has Defeated #{target.name}".green.on_light_blue.bold
puts "#{self.name} HP: #{self.hp}"
#see if the target is still alive
if target.hp > 0
puts "#{target.name} HP: #{target.hp}"
end
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
#if the player loses the battle
#reduce the player's hp
else
self.update_hp(-10)
#display outcome of the battle to the player
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
puts "#{self.name} Has Lost Battle to #{target.name}".black.on_light_red
puts "#{self.name} HP: #{self.hp}"
puts "#{target.name} HP: #{target.hp}"
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
end
#if the player has a greater attack power than that of the target
elsif self.power > target.power
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
#if the player wins the battle
#calculation based on distance between the attack powers
#of the player and target
if rand < (0.4 + ((self.power - target.power).to_f/4))
#reduce hp of the target
target.update_hp(-5*(self.power - target.power))
#print outcome of the battle
puts "#{self.name} Has Defeated #{target.name}".green.on_light_blue.bold
puts "#{self.name} HP: #{self.hp}"
#check if target still alive
if target.hp > 0
puts "#{target.name} HP: #{target.hp}"
end
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
#if the player loses the battle
#reduce the player's hp
else
self.update_hp(-10)
#display outcome of the battle to the player
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
puts "#{self.name} Has Lost Battle to #{target.name}".black.on_light_red
puts "#{self.name} HP: #{self.hp}"
puts "#{target.name} HP: #{target.hp}"
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
end
#if the player has a lower attack power than that of the target
else
#if the player wins the battle
#calculation based on distance between the attack powers
#of the player and target
if rand > (0.45 + ((target.power - self.power).to_f/4))
#reduce hp of the target
target.update_hp(-2*(-self.power + target.power))
#display outcome of the battle to the player
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
puts "#{self.name} Has Defeated #{target.name}".green.on_light_blue.bold
puts "#{self.name} HP: #{self.hp}"
#check if target still alive
if target.hp > 0
puts "#{target.name} HP: #{target.hp}"
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
end
#if the player loses the battle
#reduce the player's hp
else
self.update_hp(-3*(-self.power + target.power))
#display outcome of the battle to the player
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
puts "#{self.name} Has Lost Battle to #{target.name}".black.on_light_red
puts "#{self.name} HP: #{self.hp}"
puts "#{target.name} HP: #{target.hp}"
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combat\n if state == GameState::BEFORECOMBAT or state == GameState::INIT\n combatResult = combatGo(@currentSpaceStation, @currentEnemy)\n else\n combatResult = CombatResult::NOCOMBAT\n end\n combatResult\n end",
"def combat\n\t\tif @battleManager.actionUnitsEmpty\n\t\t\tsetMenu\n\t\telse\n\t\t\tunitChange = [email protected]\n\t\t\tif unitChange\n\t\t\t\t@phase = @battleManager.checkChanges\n\t\t\t\tputs @phase\n\t\t\tend\n\t\tend\n\tend",
"def combat() # : CombatResult\n result = @currentPlayer.combat(@currentMonster)\n \n if(result == CombatResult::LOSEANDCONVERT)\n cultistCard = CardDealer.instance.nextCultist()\n cultistPlayer = CultistPlayer.new(@currentPlayer, cultistCard)\n @currentPlayer = cultistPlayer\n @player[@currentPlayerIndex] = cultistPlayer \n end\n \n CardDealer.instance.giveMonsterBack(@currentMonster)\n result\n end",
"def combat?; false; end",
"def combat(m)\n \n if(getCombatLevel >= getOponentLevel(m))\n applyPrize(m)\n \n if(@level >= @@MAXLEVEL)\n combat_result=CombatResult::WINGAME\n else\n combat_result=CombatResult::WIN\n end\n \n else\n applyBadConsequence(m)\n if(shouldConvert)\n combat_result=CombatResult::LOSEANDCONVERT\n else\n combat_result=CombatResult::LOSE\n end\n \n end\n \n return combat_result\n end",
"def combatir(entrenadores_combate) # entrenadores_combate = [entrenador1, entrenador2]\n pok_ini_entrenador1 = entrenadores_combate[0].pokemon_actual\n pok_ini_entrenador2 = entrenadores_combate[1].pokemon_actual\n\n #arreglo de pokemones combatiendo\n pok_combatientes = [pok_ini_entrenador1, pok_ini_entrenador2]\n\n # Este if revisa quien partirá atacando\n if pok_ini_entrenador1.vel > pok_ini_entrenador2.vel\n turnos = [0, 1].cycle #cycle sirve para crear un arreglo que se repite n cantidad de veces (en este caso es infinito) \n elsif pok_ini_entrenador1.vel < pok_ini_entrenador2.vel\n turnos = [1, 0].cycle\n else\n if entrenador1.id < entrenador2.id\n turnos = [0, 1].cycle\n else\n turnos = [1, 0].cycle\n end\n end\n\n # este while revisa si aun quedan pokemones con vida en cualquiera de los dos equipos\n while pok_combatientes[0] != nil && pok_combatientes[1] != nil\n ataca = turnos.next #al hacer next este valor a a variar entre 0 y 1 cada vez que se ejecuta next\n # posicion del defensor de este turno en el arreglo de pokemones combatiendo\n defensor = turnos.next\n\n pok_combatientes[defensor].recibir_daño(pok_combatientes[ataca].atq)\n #Logica de cuando un pokemon muere\n if pok_combatientes[defensor].vida <= 0\n pok_combatientes[defensor] = entrenadores_combate[defensor].pokemon_actual\n #sumar puntos por derrotar a un pokemon\n entrenadores_combate[ataca].ganar_puntos 1\n \n end\n\n #Si no hago esto, en la proxima iteracion el pokemon atacante no cambiara porque\n #ejecute next 2 veces en el mismo turno\n turnos.next\n end\n #finaliza el combate\n\n # Obtiene un arreglo con los ids de los pokemones sobrevivientes\n # uso filter para retornar un arreglo con los pokemones que quedaron vivos\n # uso map para retornar un arreglo con los ids de los pokemones filtrados\n pokemones_vivos = (entrenadores_combate[ataca].pokemones.filter { |p| p.vida > 0 }).map { |p| p.id }\n \n #sumar puntos por ganar\n entrenadores_combate[ataca].ganar_puntos 3\n \n # creo la instancia del combate con los datos obtenidos y se lo agrego al atributo @combates\n @combates << Combate.new(entrenadores_combate[0].id,\n entrenadores_combate[1].id,\n entrenadores_combate[ataca].id,\n pokemones_vivos)\n\n # Reinicio el estado de los pokemones\n entrenadores_combate.each do |e|\n e.curar_pokemones\n end\n end",
"def combat(monster)\n # If player's level is greater than monster's level\n # the player wins.\n # Otherwise a dice is rolled. If the dice return 5 or 6\n # the player can scape. Else the player loses the combat.\n if getCombatLevel > getOponentLevel(monster)\n applyPrize(monster.prize)\n combatResult = @level < 10? CombatResult::WIN : CombatResult::WINANDWINGAME\n else\n randomNumber = Dice.instance.nextNumber\n if randomNumber >= 5\n combatResult = CombatResult::LOSEANDESCAPE\n elsif monster.badCons.kills\n die\n combatResult = CombatResult::LOSEANDDIE\n else\n applyBadConsequence(monster.badCons)\n if shouldConvert\n combatResult = CombatResult::LOSEANDCONVERT\n else\n combatResult = CombatResult::LOSE\n end\n end\n end\n # Discard the necklace if it is a visible treasure\n discardNecklaceIfVisible\n # Return the combat result\n combatResult\n end",
"def combat_mode\n\t$in_combat = true\n\t######\n while $boss_alive do\n \tputs \"Fight me, coward!\"\n \tputs \"#{$boss_hp} <-- their health\"\n \tputs \"What do you do?\\n1: attack\\n2: call it a name\\n3: listen to it talk\\n4: leave\"\n \t@combat = (gets).to_i\n\n \tif @combat == 1\n \t\tputs \"You strike the boss.\"\n \t\t$boss_hp -= 7\n \t\tputs $boss_hp\n \telsif @combat == 2\n \t\tputs \"You call them a really nasty name.\"\n \t\t$boss_hp\n \telsif @combat == 3\n \t\tputs \"'Y-you mean it?'\\nThey seem to be beaming with joy.\"\n \t\t$boss_hp += 3\n \telsif @combat == 4\n \tputs \"You leave in the middle of their taunt.\\n'H-How dare you!'\\nThey seem upset.\\nLeave anyway?\\n1: Yes\\n2: No\"\n \t\tleave = (gets).to_i\n\n \t\t\tif leave == 1\n \t\t\t\tputs \"You walk away from the boss, their heart breaks and they die.\"\n \t\t\t\t$boss_hp -= 40\n \t\t\t\tputs \"You win\"\n $boss_alive = false\n win_fight\n \t\t\telsif leave == 2\n \t\t\t\tputs \"You decide to stay.\"\n \t\t\telse\n \t\t\t\tputs \"You walk away anyway.\"\n \t\t\t\t$in_combat = false\n $boss_hp -= 40\n win_fight\n $boss_alive = false\n $in_boss = false\n \t\t\tend\n# default + player damage option\n \t\telse\n \t\t\tputs \"You get bored\\nThe boss hits you.\"\n \t\t\t$player_hp -= 1\n \t\t\tputs $player_hp\n# checks if player is still alive (you can't die)\n if $player_hp <= 0\n puts \"They actually can't hurt you\\n you were just being nice.\"\n $player_hp = 20\n else\n# defaults back to game\n end\n# end of 2nd layer if/else\n end\n end\n end",
"def hero_ability(target)\n case\n when @hero_class == 'druid'\n @attack = 1\n @armour = amour + 1\n when @hero_class == 'hunter'\n target.health = target.health - 2\n when @hero_class == 'mage'\n target.health = target.health - 2\n when @hero_class == 'paladin'\n @battlefield.push(\"Silver Hand Recruit\")\n when @hero_class == 'priest'\n target.health = target.health + 2\n when @hero_class == 'rouge'\n @weapon = \"Dagger Mastery\"\n when @hero_class == 'shaman'\n totems = ['Healing Totem', 'Searinhg Totem', 'Stoneclaw Totem', 'Wrath of Air Totem']\n @battlefield.push(totems.sample)\n when @hero_class == 'warlock'\n darw_card(2)\n @health = @health - 2\n when @hero_class == 'warrior'\n @armour = @armour + 2\n end\n end",
"def combatGo(station, enemy)\n character = @dice.firstShot\n if character == GameCharacter::ENEMYSTARSHIP\n result = station.receiveShot enemy.fire\n if result == ShotResult::RESIST\n result = enemy.receiveShot station.fire\n enemyWins = (result == ShotResult::RESIST)\n else\n enemyWins = true\n end\n else\n result = enemy.receiveShot station.fire\n enemyWins = (result == ShotResult::RESIST)\n end\n if enemyWins\n moves = @dice.spaceStationMoves(station.getSpeed)\n if not moves\n station.setPendingDamage(enemy.damage)\n combatResult = CombatResult::ENEMYWINS\n else\n station.move\n combatResult = CombatResult::STATIONESCAPES\n end\n else\n @transform = station.setLoot(enemy.loot)\n if @transform == Transformation::GETEFFICIENT\n makeStationEfficient\n combatResult = CombatResult::STATIONWINSANDCONVERTS\n elsif @transform == Transformation::SPACECITY and not @haveSpaceCity\n createSpaceCity\n combatResult = CombatResult::STATIONWINSANDCONVERTS\n else\n @transform = Transformation::NOTRANSFORM\n combatResult = CombatResult::STATIONWINS\n end \n end\n @gameState.next(@turns, @spaceStations.size)\n combatResult\n end",
"def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n victory = false\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n emp_phase(@attacker)\n emp_phase(@defender)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n turn_fleet.each do |fleet|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if fleet[1] > 0 && fleet[2] > 0 \n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target==-1)\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if fleet[3] == 2\n mult = DamageType.find(fleet[3]).shield_mult\n end\n damage = fleet[2] * mult\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult = 1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if (fleet[3] == 1)\n mult = DamageType.find(fleet[3]).shell_mult\n end \n if fleet[3] == 3 and !fleet[6]\n mult = DamageType.find(fleet[3]).station_mult\n end\n if fleet[3] == 4 and fleet[0] == @plattform_id\n mult = DamageType.find(fleet[3]).plattform_mult\n end \n # Bestimme welche Einheit getroffen wurde\n victim = target_fleet[target]\n # Schadensberechnung\n damage = fleet[2] * mult\n # Berechne neue HP\n hit_points = victim[-2]\n victim[-2] = hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim, target_user)\n end\n end \n end\n # Füge Runden-Bericht ein\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue = false\n if turn_user == @attacker\n victory = true \n end\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user == @attacker\n @attacker_shield = @fight_shield\n else\n @defender_shield = @fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet = turn_fleet\n tmp_user = turn_user\n turn_fleet = target_fleet\n turn_user = target_user\n target_fleet = tmp_fleet\n target_user = tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n attacker_fleet_ary = []\n defender_fleet_ary = []\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n attacker_fleet_ary = turn_fleet\n defender_fleet_ary = target_fleet\n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n\n attacker_fleet_ary = target_fleet\n defender_fleet_ary = turn_fleet\n end\n update_fighting_fleet(@attacker_fleet, attacker_fleet_ary)\n update_fighting_fleet(@defender_fleet, defender_fleet_ary)\n ary = [@attacker_fleet, @defender_fleet] \n return [@report, @spy_report]\n end",
"def fight\n # TODO: Add this back in, in a curses way\n #puts\n #puts \"========FIGHT========\"\n #puts \"#{@hero.name} Vs #{@monster.name}\"\n #puts\n\n # Populate an array with X number of levels Hero is and Y number of levels Monster is\n # This way whoever is a higher level has a better chance of attacking \n attack_arr = []\n @hero.level.to_i.times { attack_arr.push(\"Hero\") }\n @monster.level.to_i.times { attack_arr.push(\"Monster\") }\n\n # Loop until one character dies\n while @hero.cur_health > 0 && @monster.cur_health > 0\n case attack_arr.shuffle.first\n when \"Hero\" then @monster.cur_health -= @hero.strength\n when \"Monster\" then @hero.cur_health -= @monster.strength\n end\n end\n\n return (@hero.cur_health > @monster.cur_health)\n end",
"def handle\r\n self.names.each do |name|\r\n Battle.with_a_combatant(name, client, enactor) do |combat, combatant|\r\n Battle.leave_combat(combat, combatant)\r\n end\r\n end\r\n end",
"def monsterfight(user, monster, mAtk, enemy)\n\n#make a loop with a boolean value. The loop will keep running unless somebody's health goes to zero or \n#the user runs away\n\n\tenemy['name'] = monster.sample\n\tcombat = true\n\n\tif enemy['name'] == 'Mutated Octopus'\n\t\tenemy['hp'] = 7\n\t\tenemy['atkSpd'] = 6\n\t\tenemy['armor'] = 1\n\n\telsif enemy['name'] == 'Sabertooth Goldfish'\n\t\tenemy['hp'] = 6\n\t\tenemy['atkSpd'] = 5\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Lady Gaga'\n\t\tenemy['hp'] = 8\n\t\tenemy['atkSpd'] = 8\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Hannah Montana'\n\t\tenemy['hp'] = 10\n\t\tenemy['atkSpd'] = 10\n\t\tenemy['armor'] = 1\n\tend\n\n\tputs ''\n\n# choosing the random attack of the monster. no need to push into a hash\n\tdef monsterAttack(user, mAtk, enemy)\n\t\trandAttack = mAtk.sample\n\n\t\tif randAttack == 'Slap'\n\t\t\tmonsterDmg = 1\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Bite'\n\t\t\tmonsterDmg = 2\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Eyepoke'\n\t\t\tmonsterDmg = 3\n\t\t\tuser['health'] -= 1\n\t\tend\n\n\t\tputs \"You get hit by #{enemy['name']} for #{monsterDmg}. Your health is now #{user['health']}\"\n\t\t\n\tend\n\n\tdef heroAttack(user, enemy)\n\n\t\theroAttack = user['weapon']\n\n\t\tif heroAttack == 'Sword'\n\t\t\thitDmg = rand(2...5)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Spear'\n\t\t\thitDmg = rand(1...6)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Axe'\n\t\t\thitDmg = rand(3...4)\n\t\t\tenemy['hp'] -= hitDmg\n\t\tend\n\t\t\n\t\tputs \"You hit the #{enemy['name']} for #{hitDmg}. Their health is now #{enemy['hp']}\"\n\tend\n\n\tputs \"A wild #{enemy['name']} has appeared. Do you choose to fight or run? (enter 'fight' or 'run')\"\n\n\tchoice = gets.chomp.downcase\n\n\twhile (user['health'] > 0 && enemy['hp'] > 0 && combat == true)\n\n\t\tif choice == 'fight'\n\t\t\tputs 'Alright lets do this!'\n\t\t\tmonsterAttack(user, mAtk, enemy)\n\t\t\theroAttack(user, enemy)\n\n\t\telsif choice == 'run'\n\t\t\tputs 'You attempt to escape'\n\n\t\telsif choice != 'fight' || choice != 'run' \n\t\t\tputs 'Please enter \"fight\" or \"run\"'\n\t\t\tchoice = gets.chomp.downcase\n\t\tend\n\n\t\tif enemy['hp'] > 0 && user['health']\n\t\t\tputs \"Continue fighting? (fight or run)\"\n\t\t\tchoice = gets.chomp.downcase\n\n\t\telsif enemy['hp'] <= 0\n\t\t\tputs \"You have killed #{enemy['name']}\"\n\t\t\tcombat == false\n\n\t\telsif user['health'] <= 0\n\t\t\tputs \"You have died\"\n\t\t\tcombat == false\n\t\tend\n\tend\n\nend",
"def decide_target(char, dmg, heal, neutral, attack, defend, escape)\n # temporary variables\n x, y, ai = char.x, char.y, char.ai\n # get alignment setup\n negative, positive = ai.negative, ai.positive\n # invert setup if confused\n negative, positive = positive, negative if char.restriction == 3\n # initialize arrays\n allies, enemies = [char], []\n # if enemy\n if char.is_a?(Map_Enemy)\n # find all allies and all enemies in memory\n ai.memory.each_key {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n # if actor\n elsif char.is_a?(Map_Actor)\n # find all allies and all enemies in sight\n ai.sight.each {|b|\n allies.push(b) if positive.include?(b.ai.group)\n enemies.push(b) if negative.include?(b.ai.group)}\n end\n # find all allies who need healing\n to_heal = allies.find_all {|b| b.valid? && b.battler.hp < b.battler.maxhp}\n # if decided to heal\n if (heal.size > 0 && to_heal.size > 0 && (ai.healer || rand(3) == 0) &&\n rand(5) == 0)\n # find all skills that heal all allies\n allheal = heal.find_all {|id|\n $data_skills[id].scope == 2 || $data_skills[id].scope == 4 ||\n $data_skills[id].scope == 6}\n # test again flag\n test_again = true\n # if more than 1 ally who needs healing exists and allheal skills exist\n if to_heal.size > 1 && allheal.size > 0\n # initialize data\n decided, now, new = nil, [], []\n # iterate through all all-healing skills\n allheal.each {|id|\n # fake Blizz-ABS action setup\n ai.act.set(Skills.range(id), ACTSkill, id, Skills.type(id)[0],\n ai.delay_time)\n # all allies who can be targeted by this skill\n new = to_heal.find_all {|b| $BlizzABS.can_execute?(char, b, ai.act)}\n # if not decided yet\n if decided == nil\n # decide this skill and those allies\n decided, now = id, new\n # 50% chance\n elsif rand(2) == 0\n # intialize damage counters\n dmg1 = dmg2 = 0\n # sum up all damage for last decided targets\n now.each {|b| dmg1 += b.battler.maxhp - b.battler.hp}\n # sum up all damage for new targets\n new.each {|b| dmg2 += b.battler.maxhp - b.battler.hp}\n # decide this skill if it contains battlers with more damaged HP\n decided, now = id, new if dmg2 > dmg1\n # if more battlers would be affected by this skill\n elsif new.size > now.size\n # decide this skill and those allies\n decided, now = id, new\n end}\n # if more than one battler can be healed\n if now.size > 1\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n # don't test for one battler\n test_again = false\n end\n end\n # if should test for one battler\n if test_again\n # find all skills that heal one ally\n oneheal = heal.find_all {|id|\n $data_skills[id].scope == 1 || $data_skills[id].scope == 3 ||\n $data_skills[id].scope == 5}\n # if any skill exists\n if oneheal.size > 0\n # decided action\n decided = oneheal[rand(oneheal.size)]\n # decided target\n ai.target = to_heal[rand(to_heal.size)]\n else\n # decided action\n decided = heal[rand(heal.size)]\n end\n # stop execution if no skill decided\n return false if decided == nil\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time / 2)\n end\n # confirm execution\n return true\n end\n # not decided to escape yet\n escaping = false\n # if able to run away\n if escape && rand(5) == 0\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler, ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 2\n # set this battler as escape reference\n ai.target = b\n # running away\n escaping = true\n # abort iteration\n break\n end\n end}\n # 20% chance\n elsif rand(5) == 0\n # initialize minimum range\n min = nil\n # iterate through all enemies\n enemies.each {|b|\n # if closer than anybody else\n if (b.is_a?(Map_Actor) && (min == nil ||\n Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y) < min))\n # set this battler as escape reference\n ai.target = b\n # set new minimum range\n min = Math.hypot(b.real_x-char.real_x, b.real_y-char.real_y)\n # running away\n escaping = true\n # abort iteration\n break\n end}\n end\n end\n # if decided to escape\n if escaping\n # set AI state\n ai.state = Escape\n # set action data\n ai.act.set(ai.view_range - 1, ACTEscape, 0, 0, 80)\n # confirm execution\n return true\n end\n # not decided to defend yet\n defending = false\n # if able to defend\n if defend && rand(5) == 0\n # probability factor if higher if defensive and reset defend flag\n factor = rand(ai.defensive ? 10 : 30)\n # if decided to defend\n if char.battler.hp * 100 / char.battler.maxhp < factor\n # if observation attribute is active\n if ai.observe && char.restriction != 3\n # iterate through all enemies\n enemies.each {|b|\n # if actor\n if b.is_a?(Map_Actor) && ai.observation[b.battler] != nil\n # get damage per second rate\n dps = get_observation(b.battler,\n ai.observation[b.battler].clone)\n # 20% chance or damage per second-distance rate high enough\n if rand(5) == 0 || dps * 128 / Math.hypot(b.real_x-\n char.real_x, b.real_y-char.real_y) > char.battler.hp / 3\n # defending\n defending = true\n # abort iteration\n break\n end\n end}\n # 33% chance\n elsif enemies.size > 0 && rand(5) == 0\n # decided to defend\n defending = true\n end\n end\n end\n # if decided to defend\n if defending\n # set AI state\n ai.state = Defend\n # target the closest enemy\n ai.target = enemies.min {|a, b|\n Math.hypot(x-b.x, y-b.y) <=> Math.hypot(x-a.x, y-a.y)}\n # turn toward the target if target exists and not being force moved\n char.turn_toward(ai.target) if ai.target != nil && char.move_type != 3\n # use defend action\n char.use_defend\n # set action data\n ai.act.set(3, ACTDefend, 0, 0, rand(31) + 70)\n # confirm execution\n return true\n end\n # number of skills\n skill_number = dmg.size + heal.size + neutral.size\n # if able to attack and chosen to attack\n if attack && (skill_number == 0 || rand(skill_number) == 0)\n # if enemy\n if char.is_a?(Map_Enemy)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Enemies.range(char.battler_id), ACTAttack, 0,\n Enemies.type(char.battler_id), ai.delay_time)\n # if observing attribute and not confused\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if actor\n elsif char.is_a?(Map_Actor)\n # set AI state\n ai.state = Ready\n # setup Blizz-ABS action\n ai.act.set(Weapons.range(char.battler.weapon_id), ACTAttack, 0,\n Weapons.type(char.battler.weapon_id), ai.delay_time)\n end\n # if no target exists\n if ai.target == nil || !ai.target.valid?\n # get any enemy\n ai.target = enemies[rand(enemies.size)]\n end\n # confirm execution\n return true\n end\n # decide a random skill action\n decided = (dmg + neutral)[rand(dmg.size + neutral.size)]\n # if action exists\n if decided != nil\n # if observing\n if ai.observe && char.restriction != 3\n # decide a target based upon observation experience\n observation_target(char, ai, enemies)\n end\n # if no target was decided\n if ai.target == nil || !ai.target.valid?\n # if targeting enemies\n if $data_skills[decided].scope == 0 ||\n $data_skills[decided].scope == 1 ||\n $data_skills[decided].scope == 2\n # select a random enemy target\n ai.target = enemies[rand(enemies.size)]\n else\n # select a random ally target\n ai.target = allies[rand(allies.size)]\n end\n end\n end\n # stop execution if no target selected\n return false if ai.target == nil || !ai.target.valid?\n # setup Blizz-ABS action\n ai.act.set(Skills.range(decided), ACTSkill, decided,\n Skills.type(decided)[0], ai.delay_time)\n # confirm execution\n return true\n end",
"def activate\n Game::STATSTRACKER.last_unit_activated = self\n\n if Game::STATSTRACKER.last_unit_activated.nationality == \"fr\"\n Game::STATSTRACKER.phasing_player = Game::FRENCH\n else\n Game::STATSTRACKER.phasing_player = Game::ALLIED\n end\n\n roll = Die.new.roll\n\n CRT.result(@name_symbol, roll).each do |action|\n # Handle morale loss results.\n if action[-1] == 'M'\n if action[-2] == 'F'\n Game::FRENCH.morale_loss(action[-3].to_i)\n else\n Game::ALLIED.morale_loss(action[-3].to_i)\n end\n # Handle casualty results.\n elsif action[-1] == 'C'\n if action[-2] == 'F'\n if @nationality == 'fr'\n casualty(action[0].to_i)\n else\n puts 'casualty on enemy'\n end\n else\n if @nationality == 'ac'\n puts 'casualty on self'\n else\n puts 'Casualty on enemy'\n end\n end\n end\n end\n end",
"def attack()\r\n @warrior.attack!\r\n end",
"def attack()\r\n @warrior.attack!\r\n end",
"def getCombatLevel\n combatLevel = @level\n @visibleTreasures.each { |treasure| combatLevel += treasure.getBonus}\n combatLevel\n end",
"def combat_2ennemi(user_nameP, barret, ennemi1, ennemi2)\n puts ' _________ ________ _____ __________ ________________ '\n puts ' \\_ ___ \\ \\_____ \\ / \\\\______ \\ / _ \\__ ___/ '\n puts ' / \\ \\/ / | \\ / \\ / \\| | _/ / /_\\ \\| | '\n puts ' \\ \\____/ | \\/ Y \\ | \\/ | \\ | '\n puts ' \\______ /\\_______ /\\____|__ /______ /\\____|__ /____| '\n puts ' \\/ \\/ \\/ \\/ \\/ '\n numero_tour = 0\n\n\n while ennemi1.personnage_alive && ennemi2.personnage_alive\n if ennemi1.personnage_hp <= 0\n puts \"\"\n puts \"--------------------------------\"\n puts \"Le #{ennemi1.name} est mort !\"\n puts \"--------------------------------\"\n puts \"\"\n end\n if ennemi2.personnage_hp <= 0\n puts \"\"\n puts \"--------------------------------\"\n puts \"Le #{ennemi2.name} est mort !\"\n puts \"--------------------------------\"\n puts \"\"\n end\n if ennemi1.personnage_hp <= 0 && ennemi2.personnage_hp <= 0\n puts \"\"\n puts \"--------------------------------\"\n puts \"Les ennemis sont morts !\"\n puts \"--------------------------------\"\n total_xp = ennemi1.xp + ennemi2.xp\n puts \"Vous gagnez #{total_xp} points d'XP !\"\n ennemi1.personnage_alive = false\n ennemi2.personnage_alive = false\n\n if ennemi1.loot == '1po'\n $mon_inventaire.addpotion\n puts \"--------------------------------\"\n puts \"1x Potion ajoutée à votre inventaire.\"\n puts \"--------------------------------\"\n\n elsif ennemi1.loot == '1gre'\n $mon_inventaire.addgrenade\n puts \"--------------------------------\"\n puts \"1x Grenade ajoutée à votre inventaire.\"\n puts \"--------------------------------\"\n\n elsif ennemi1.loot == '1po1gre'\n $mon_inventaire.addpotion\n $mon_inventaire.addgrenade\n puts \"--------------------------------\"\n puts \"1x Potion ajoutée à votre inventaire.\"\n puts \"1x Grenade ajoutée à votre inventaire.\"\n puts \"--------------------------------\"\n\n elsif ennemi2.loot == '1po'\n puts \"--------------------------------\"\n puts \"1x Potion ajoutée à votre inventaire.\"\n puts \"--------------------------------\"\n $mon_inventaire.addpotion\n\n elsif ennemi2.loot == '1gre'\n puts \"--------------------------------\"\n puts \"1x Grenade ajoutée à votre inventaire.\"\n puts \"--------------------------------\"\n $mon_inventaire.addgrenade\n end\n\n puts \"\"\n elsif ennemi1.personnage_hp > 0 || ennemi2.personnage_hp > 0\n\n numero_tour += 1\n puts \"----------------------------------\"\n puts \"Tour n°#{numero_tour}\"\n puts \"Ennemis : #{ennemi1.name} ET #{ennemi2.name}\"\n puts \"TIRENT A DISTANCE\"\n if ennemi1.personnage_hp > 0\n puts \"POINTS DE VIE : #{ennemi1.name} #{ennemi1.personnage_hp} HP\"\n end\n if ennemi1.personnage_hp <= 0\n puts \"#{ennemi1.name} : mort.\"\n end\n if ennemi2.personnage_hp > 0\n puts \"POINTS DE VIE : #{ennemi2.name} #{ennemi2.personnage_hp} HP\"\n end\n if ennemi2.personnage_hp <= 0\n puts \"#{ennemi2.name} : mort.\"\n end\n puts \"\"\n puts \"Que faites-vous ?\"\n puts \"1. Attaquer\"\n puts \"2. Défendre\"\n puts \"3. Utiliser un objet\"\n user_choice_4 = $stdin.gets.chomp\n if user_choice_4 == \"1\"\n puts \"Qui attaquer ?\"\n if ennemi1.personnage_hp > 0\n puts \"1. #{ennemi1.name}\"\n end\n if ennemi2.personnage_hp > 0\n puts \"2. #{ennemi2.name}\"\n end\n print \"> \"\n user_choice_4_fight = $stdin.gets.chomp\n if user_choice_4_fight == \"1\" && ennemi1.personnage_hp > 0\n puts \"\"\n puts \"BIM !\"\n puts \"Vous attaquez le #{ennemi1.name}.\"\n puts \"Le #{ennemi1.name} réduit les dégats de #{ennemi1.personnage_defense}.\"\n degats_totaux = user_nameP.personnage_attaque - ennemi1.personnage_defense\n puts \"Le #{ennemi1.name} subit #{(user_nameP.personnage_attaque - ennemi1.personnage_defense)} points de dégats !\"\n\n #On fait attaquer Barret\n\n puts \"Barret attaque le #{ennemi1.name}.\"\n puts \"Le #{ennemi1.name} réduit les dégats de #{ennemi1.personnage_defense}.\"\n degats_barret_1 = barret.personnage_attaque - ennemi1.personnage_defense\n puts \"Le #{ennemi1.name} subit #{(barret.personnage_attaque - ennemi1.personnage_defense)} points de dégats !\"\n\n if ennemi1.personnage_hp > 0\n\n ennemi1.personnage_hp -= degats_totaux\n puts \"\"\n puts \"Le #{ennemi1.name} vous attaque !\"\n puts \"Vous réduisez ses dégats de #{user_nameP.personnage_defense} !\"\n degats_encaisses = ennemi1.personnage_attaque - user_nameP.personnage_defense\n puts \"Vous perdez #{degats_encaisses} points de vie !\"\n user_nameP.personnage_hp -= degats_encaisses\n puts \"Il vous reste #{user_nameP.personnage_hp} points de vie.\"\n\n puts \"Le #{ennemi2.name} attaque Barret !\"\n degats_barret_encaiss = ennemi2.personnage_attaque - barret.personnage_defense\n puts \"Barret perd #{degats_barret_encaiss} points de vie !\"\n barret.personnage_hp -= degats_barret_encaiss\n puts \"Barret a #{barret.personnage_hp} points de vie.\"\n\n if ennemi1.personnage_hp > 0 || ennemi2.personnage_hp > 0\n puts \"Que faites-vous ?\"\n end\n elsif ennemi1.personnage_hp <= 0 || ennemi2.personnage_hp <= 0\n puts \"\"\n puts \"Le #{ennemi1.name} est mort !\"\n ennemi1.personnage_alive = false\n end\n elsif user_choice_4_fight == \"2\" && ennemi2.personnage_hp > 0\n puts \"\"\n puts \"BIM !\"\n puts \"Vous attaquez le #{ennemi2.name}.\"\n puts \"Le #{ennemi2.name} réduit les dégats de #{ennemi2.personnage_defense}.\"\n degats_totaux = user_nameP.personnage_attaque - ennemi2.personnage_defense\n puts \"Le #{ennemi2.name} subit #{(user_nameP.personnage_attaque - ennemi2.personnage_defense)} points de dégats !\"\n if ennemi2.personnage_hp > 0\n\n ennemi2.personnage_hp -= degats_totaux\n puts \"\"\n puts \"Le #{ennemi2.name} vous attaque !\"\n puts \"Vous réduisez ses dégats de #{user_nameP.personnage_defense} !\"\n degats_encaisses = ennemi2.personnage_attaque - user_nameP.personnage_defense\n puts \"Vous perdez #{degats_encaisses} points de vie !\"\n user_nameP.personnage_hp -= degats_encaisses\n puts \"Il vous reste #{user_nameP.personnage_hp} points de vie.\"\n\n puts \"Le #{ennemi2.name} attaque Barret !\"\n degats_barret_encaiss = ennemi2.personnage_attaque - barret.personnage_defense\n puts \"Barret perd #{degats_barret_encaiss} points de vie !\"\n barret.personnage_hp -= degats_barret_encaiss\n puts \"Barret a #{barret.personnage_hp} points de vie.\"\n\n if ennemi1.personnage_hp > 0 || ennemi2.personnage_hp > 0\n puts \"Que faites-vous ?\"\n end\n elsif ennemi1.personnage_hp <= 0 || ennemi2.personnage_hp <= 0\n puts \"\"\n puts \"Le #{ennemi2.name} est mort !\"\n ennemi2.personnage_alive = false\n end\n end\n elsif user_choice_4 == \"2\"\n puts \"Vous gagnez de la défense !\"\n puts \"Barret gagne de la défense !\"\n user_nameP.personnage_defense += 3\n barret.personnage_defense += 3\n puts \"\"\n puts \"Le #{ennemi1.name} vous attaque !\"\n puts \"Vous réduisez ses dégats de #{user_nameP.personnage_defense} !\"\n degats_encaisses = ennemi1.personnage_attaque - user_nameP.personnage_defense\n puts \"Vous perdez #{degats_encaisses} points de vie !\"\n user_nameP.personnage_hp -= degats_encaisses\n puts \"Le #{ennemi1.name} attaque Barret !\"\n degats_barret_encaiss = ennemi2.personnage_attaque - barret.personnage_defense\n puts \"Barret perd #{degats_barret_encaiss} points de vie !\"\n barret.personnage_hp -= degats_barret_encaiss\n puts \"Barret a #{barret.personnage_hp} points de vie.\"\n\n elsif user_choice_4 ==\"3\"\n if $mon_inventaire.show_potion > 0 || $mon_inventaire.show_grenade > 0\n puts \"Potions : #{$mon_inventaire.show_potion}\"\n puts \"Grenades : #{$mon_inventaire.show_grenade}\"\n puts \"Que voulez-vous utiliser ?\"\n if $mon_inventaire.show_potion > 0\n puts \"1. Une potion.\"\n puts \"2. Rien finalement.\"\n combat2_potion_simple = $stdin.gets.chomp\n\n if combat2_potion_simple == \"1\"\n puts \"Sur qui la lancer ?\"\n puts \"1. Sur vous-même.\"\n puts \"2. Sur Barret.\"\n user_potion_fight = $stdin.gets.chomp\n\n if user_potion_fight == \"1\"\n puts \"Vous regagnez #{50 - user_nameP.personnage_hp} points de vie.\"\n user_nameP.personnage_hp = 50\n $mon_inventaire.removpotion\n elsif user_potion_fight ==\"2\"\n puts \"Barret regagne #{60 - barret.personnage_hp} points de vie.\"\n barret.personnage_hp = 60\n $mon_inventaire.removpotion\n else\n \"Merci d'indiquer un bon chiffre.\"\n end\n puts \"Le #{ennemi1.name} vous attaque !\"\n puts \"Vous réduisez ses dégats de #{user_nameP.personnage_defense} !\"\n degats_encaisses = ennemi1.personnage_attaque - user_nameP.personnage_defense\n puts \"Vous perdez #{degats_encaisses} points de vie !\"\n user_nameP.personnage_hp -= degats_encaisses\n puts \"Que faites-vous ?\"\n elsif combat2_potion_simple == \"2\"\n numero_tour -= 1\n else\n puts \"Merci d'indiquer un nombre pertinent.\"\n numero_tour -=1\n end\n\n elsif $mon_inventaire.show_grenade > 0\n puts \"1. Une grenade !\"\n puts \"2. Rien finalement.\"\n combat2_grenade_simple = $stdin.gets.chomp\n if combat2_grenade_simple == \"1\"\n \"Le #{ennemi1.name} subit 30 points de dégats.\"\n garde1.personnage_hp -= 30\n $mon_inventaire.removgrenade\n elsif combat2_grenade_simple == \"2\"\n numero_tour -= 1\n else\n numero_tour -= 1\n end\n else\n puts \"1. Une potion.\"\n puts \"2. Une grenade !\"\n puts \"3. Rien finalement.\"\n combat2_grenade_ou_potion = $stdin.gets.chomp\n if combat2_grenade_ou_potion == \"1\"\n puts \"Sur qui la lancer ?\"\n puts \"1. Sur #{user_name}.\"\n puts \"2. Sur Barret.\"\n user_potion_fight1 = $stdin.gets.chomp\n\n if user_potion_fight1 == \"1\"\n puts \"Vous regagnez #{50 - user_nameP.personnage_hp} points de vie.\"\n user_nameP.personnage_hp = 50\n $mon_inventaire.removpotion\n elsif user_potion_fight1 ==\"2\"\n puts \"Barret regagne #{60 - barret.personnage_hp} points de vie.\"\n barret.personnage_hp = 60\n $mon_inventaire.removpotion\n else\n \"Merci d'indiquer un bon chiffre.\"\n end\n puts \"Le #{ennemi1.name} vous attaque !\"\n puts \"Vous réduisez ses dégats de #{user_nameP.personnage_defense} !\"\n degats_encaisses = ennemi1.personnage_attaque - user_nameP.personnage_defense\n puts \"Vous perdez #{degats_encaisses} points de vie !\"\n user_nameP.personnage_hp -= degats_encaisses\n puts \" Que faites-vous ?\"\n elsif combat2_grenade_ou_potion == \"2\"\n \"Le #{ennemi1.name} subit 30 points de dégats.\"\n garde1.personnage_hp -= 30\n $mon_inventaire.removgrenade\n elsif combat2_grenade_ou_potion == \"3\"\n numero_tour -= 1\n else\n numero_tour -= 1\n end\n\n\n end\n else\n puts \"Vous n'avez pas d'objet !\"\n numero_tour -= 1\n end\n\n elsif user_choice_4 ==\"i\" || user_choice_4 ==\"I\" && $mon_inventaire.show_potion > 0 || $mon_inventaire.show_grenade > 0\n puts \"\"\n puts '|' + '-'*20 + '|'\n puts \"|INVENTAIRE |\"\n puts '|' + '-'*20 + '|'\n puts \"|Potions : #{$mon_inventaire.show_potion} |\"\n puts \"|Grenades : #{$mon_inventaire.show_grenade} |\"\n puts '|' + '-'*20+ '|'\n numero_tour -= 1\n elsif user_choice_4 ==\"i\" || user_choice_4 ==\"I\"\n puts \"Vous n'avez pas d'objets dans votre inventaire pour l'instant.\"\n numero_tour -= 1\n else\n puts \"\"\n puts \"Je n'ai pas compris. Que faites-vous ?\"\n puts \"\"\n numero_tour -= 1\n end\n end\n end\n\n def afficher_inventaire\n#à compléter\n\n end\nend",
"def game_combat\n \n while @player1.life_point > 0 && @player2.life_point > 0\n\n puts \"\\n\\n C'est au tour de #{@name1} d'attaquer !!\\n\"\n @player1.attacks(@player2)\n puts \"\\n\\n Voici l'etat de nos joueurs\"\n puts \"#{@player1.show_stats}\"\n puts \"#{@player2.show_stats}\"\n break if @player1.life_point <= 0 || @player2.life_point <= 0\n puts \"\\n\\n C'est au tour de #{@name2} d'attaquer !!\\n\"\n @player2.attacks(@player1)\n puts \"\\n\\n Voici l'etat de nos joueurs\"\n puts \"#{@player1.show_stats}\"\n puts \"#{@player2.show_stats}\"\n end\n\n \n if @player1.life_point <= 0\n puts \"\\n\\n GAME OVER !!!\\n\\n Victoire écrasante de #{@name2} !!!!\\n Il a pulvérisé #{@name1}\"\n else\n puts \"\\n\\n GAME OVER !!!\\n\\n Victoire écrasante de #{@name1} !!!!\\n Il a EXPLOSE #{@name2}\"\n \n end\n puts \"\\n\\n Press Enter pour sortir\"\n gets.chomp\nend",
"def enemy; end",
"def control_combatant\n\t\t\t@playercombatant = @combatants.sample\n\t\t\tputs \"\\nFor this game of Eschaton, you've been designated to be represent #{@playercombatant.nation}. (press Enter)\\n \"\n\t\t\[email protected] '*'\n\t\t\[email protected]_player = true\n\t\tend",
"def dmg( d_type, dmg, ap, srpe_att, char_att )\n d = dmg\n\n # surprise attacks do more damage\n if srpe_att\n d = d * 1.5\n end\n\n # when you see it coming, there is a chance that you get to evade part of the damage\n if !srpe_att && (rand(100) + 1 < @c_evade)\n d = d / 1.25; # consider redesigning this feature, the original value was way to strong, temp reducing the divider\n end\n\n # modify damage based on your resistances to the different types\n case d_type\n when :standard\n d -= @c_class == 'Knight' ? 10 : 0 # Warriors get a special resistance to standard damage\n when :magic\n d -= @c_class == 'Wizard' ? 10 : 1 # Magi get a special resistance to magic damage\n when :earth\n d -= 1\n when :fire\n d -= 1\n when :water\n d -= 1\n when :wind\n d -= 1\n when :shadow\n d -= @c_class == 'Shinobi' ? 10 : 1 # Rogue get a special resistance to shadow damage\n when :ice\n d -= 1\n when :lightning\n d -= 1\n when :dark\n d -= 1\n when :light\n d -= 1\n when :psionic\n d -= 1\n else\n d -= 0\n end\n\n # modify damage based on armor worn\n if @armor == 'Leather'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (2 - ap)\n end\n elsif @armor == 'Chain mail'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (6 - ap)\n end\n elsif @armor == 'Full Plate'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (12 - ap)\n end\n end\n\n # make sure we don't give them hp when they block it\n if d < 0\n d = 0;\n end\n\n # apply the damage\n @c_hp = @c_hp - d\n\n # display results\n if d == 0\n puts 'You suffered no damage from the attack, way to go!'\n elsif @c_hp <= 0\n @c_lvl -= 1\n puts \"You #{ @c_name } have perished. You respawn back at town square but have suffered loss in level. You are now level #{ @c_lvl }\"\n else\n puts \"You have suffered #{ d } wounds and now have #{ @c_hp } health left\"\n end\n\n # NOTE: this is becoming to painful, removing until we figure out\n # how to handle all the different combos for the counter attack\n # if @c_hp > 0 && !srpe_att && (rand(100) + 1 < @c_counter)\n # if @c_class == 'Knight' && @weapon == 'Short Sword'\n # char_att.dmg(:physical, rand(10) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Longsword'\n # char_att.dmg(:physical, rand(20) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Battle Axe'\n # char_att.dmg(:physical, rand(11) + 10, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Fireball'\n # char_att.dmg(:fire, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Ice Spikes'\n # char_att.dmg(:ice, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Crushing Grasp'\n # char_att.dmg(:magic, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Tanto'\n # char_att.dmg(:magic, rand(6) + 6, 6, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Ninjato'\n # char_att.dmg(:magic, rand(12) + 6, 3, false)\n # end\n # end\n end",
"def base_atk\n return $data_enemies[@enemy_id].atk\n end",
"def award; end",
"def melee_weapon; end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def battle\n # Your failures might strengthen the enemy\n rune_charges = 0\n if @artifact_rune == 0\n puts \"Rune of Dwayna provides Balthazar regeneration\"\n puts \"When he is about to die, he will use this artifact\"\n puts\n rune_charges = 3\n end\n\n puts \"Don't be afraid of fighting a God, #{@gladiator.name}\"\n puts \"As just a mere mortal, you brought him upon your feet!\"\n puts \"And after all you can gaze into his eyes without any trouble\"\n puts \"Still be careful and choose your weapon wisely.\"\n puts \"Don't forget, he draws his powers from Fire.\"\n puts \"When you are ready, enter any key to continue...\"\n gets\n # User character's base values\n gladiator_str = @gladiator.strength+10\n gladiator_heal = @gladiator.health*10\n\n puts \"Commander, your initial strength is #{gladiator_str}\"\n puts \"Commander, your initial health is #{gladiator_heal}\"\n puts \"Enchant your weapon with the sigil of your choice:\"\n\n puts \"1) Sigil of Water\"\n puts \"2) Sigil of Earth\"\n puts \"3) Sigil of Fire\"\n puts \"4) Sigil of Air\"\n puts \"5) No Sigil\"\n # Enemy base values\n enemy_str = 5\n enemy_heal = 150\n # Character may get a buff/nerf according to his choice\n sigil = gets.to_i\n\n if sigil == 1\n puts \"Sigil Of Water, very good choice against the God of Fire...\"\n gladiator_str += 10\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 2\n puts \"Sigil Of Earth, kind of a good choice against the God of Fire...\"\n gladiator_str += 5\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 3\n puts \"Sigil Of Fire, very bad choice against the God of Fire...\"\n gladiator_str -= 10\n puts \"Your strength has increased to #{gladiator_str}\"\n elsif sigil == 4\n puts \"Sigil Of Air, not a good choice against the God of Fire...\"\n gladiator_str -= 5\n puts \"Your strength has increased to #{gladiator_str}\"\n else\n puts \"You decided to use no sigil on your weapon.\"\n end\n\n puts \"When you are ready, enter any key to continue...\"\n gets\n\n puts \"The battle has begun!\"\n # Battle continues while enemy and gladiator are alive\n while enemy_heal > 0 && gladiator_heal > 0\n\n puts \"You attack Balthazar successfully\"\n enemy_heal -= gladiator_str\n puts \"Balthazar's health is #{enemy_heal}\"\n # In enemy possesses a special item, he can heal back several times.\n if enemy_heal <= 0 && rune_charges > 0\n puts \"Balthazar uses Rune of Dwayna to heal the killing blow\"\n enemy_heal += gladiator_str\n rune_charges -= 1\n end\n # Enemy always strikes last\n if enemy_heal > 0\n puts \"Balthazar strikes at you\"\n gladiator_heal -= enemy_str\n puts \"Your health is #{gladiator_heal}\"\n @gladiator.notify(\"harm\")\n puts\n end\n end\n # Outcome of final battle is designated here.\n # User has several retry changes before losing completely.\n if enemy_heal <= 0\n @gladiator.notify(\"win\")\n puts \"You have defeated Balthazar! Now the world is safe.\"\n puts \"Or is it?\"\n puts \"...\"\n\n elsif @retries > 0\n @gladiator.notify(\"lose\")\n puts \"Balthazar has beaten you... You'll return again.\"\n @retries -= 1\n battle\n else\n @gladiator.notify(\"lose\")\n puts \"You are dead... Game Over!\"\n end\n end",
"def attack_process(ch)\n # temporary variable\n ai = ch.ai\n # determine whether actor or enemy for easier reference\n if ch.is_a?(Map_Actor)\n # decide target group\n group = ((ch != $game_player && ch.restriction == 3)) ?\n ai.positive : ai.negative\n # determine range\n d = Weapons.range(ch.battler.weapon_id)\n d = 1 if d < 1\n # determine type\n type = Weapons.type(ch.battler.weapon_id)\n # determine charge\n charge = Weapons.charge(ch.battler.weapon_id)\n # determine projectile speed\n projectile_speed = Weapons.projectile_speed(ch.battler.weapon_id)\n else\n # determine target group depending on confusion\n group = (ch.restriction == 3 ? ai.positive : ai.negative)\n # determine range\n d = Enemies.range(ch.battler_id)\n d = 1 if d < 1\n # determine type\n type = Enemies.type(ch.battler_id)\n # determine charge\n charge = Enemies.charge(ch.battler_id)\n # determine charge\n charge[0] = BlizzABS::CHARGEMove if charge[0] == BlizzABS::CHARGETrigger\n # determine projectile speed\n projectile_speed = Weapons.projectile_speed(ch.battler_id)\n end\n # if item shooting type\n if type == BOW_ARROW\n # temporary variable\n ids = Weapons.consume(ch.battler.weapon_id)\n # if no more items\n if !ids.include?(ch.battler.item) ||\n $game_party.item_number(ch.battler.item) == 0\n # can't use\n return false\n end\n end\n # if not charging already\n if charge[0] != CHARGENone && !ch.charging?\n # setup charging\n ch.setup_charge(ch, charge)\n # not used yet\n return false\n end\n # create affection area depending on attack type\n case type\n when SWORD, SPEAR, FLAIL # sword attack\n # get attack affection area\n area = $BlizzABS.util.get_attack_area(ch, d, type)\n when BOOMERANG # returning projectile attack\n # decide spriteset\n spriteset = ch.is_a?(Map_Actor) ?\n BlizzABS::SPRProjWeapon + ch.battler.weapon_id.to_s :\n BlizzABS::SPRProjEnemy + ch.battler_id.to_s\n # create returning projectile\n proj = Map_Projectile.new(spriteset, ch, 0, d, projectile_speed,\n REMReturning, group)\n when BOW # projectile attack\n # decide spriteset\n spriteset = ch.is_a?(Map_Actor) ?\n BlizzABS::SPRProjWeapon + ch.battler.weapon_id.to_s :\n BlizzABS::SPRProjEnemy + ch.battler_id.to_s\n # create returning projectile\n proj = Map_Projectile.new(spriteset, ch, 0, d, projectile_speed,\n REMNormal, group)\n when BOW_ARROW # item consuming projectile\n # remove one item from inventory\n $game_party.lose_item(ch.battler.item, 1)\n # temporary variable\n item = $data_items[ch.battler.item]\n # get item explosion data\n explode = Items.type(item.id)\n # if explosion exists\n if explode[1] != EXPLNone\n # fix the missing explosion animation error\n explode[2] = 0 if explode[2] == nil\n # create projectile from exploding item with weapon attack effect\n proj = Map_Projectile.new(BlizzABS::SPRProjItem + item.id.to_s, ch,\n item.id, d, projectile_speed, REMShotItem, group, false,\n explode[1, 3])\n else\n # create projectile from item with weapon attack effect\n proj = Map_Projectile.new(BlizzABS::SPRProjItem + item.id.to_s, ch,\n item.id, d, projectile_speed, REMShotItem, group)\n end\n when SHURIKEN # self consuming weapon\n # temporary variable\n weapon = $data_weapons[ch.battler.weapon_id]\n # unequip last weapon if no more weapons in inventory\n ch.battler.equip(0, 0) if $game_party.weapon_number(weapon.id) == 0\n # remove one weapon from inventory\n $game_party.lose_weapon(weapon.id, 1)\n # self shooting weapon, create projectile from weapon\n proj = Map_Projectile.new(BlizzABS::SPRProjWeapon + weapon.id.to_s, ch,\n weapon.id, d, projectile_speed, REMShotWeapon, group)\n end\n # if projectile fired\n if proj != nil\n # add projectile to buffer\n $BlizzABS.cache.remotes.push(proj)\n # used\n return true\n end\n # iterate through all battlers\n ($game_map.battlers + $BlizzABS.battlers).each {|battler|\n # if target can be hit considering all conditions\n if battler.battler != nil && group.include?(battler.ai.group) &&\n !battler.battler.dead? && @util.intersection(area,\n Rect.new(battler.real_x / 4, battler.real_y / 4, 32, 32))\n # execute attack\n battler.attack_effect(ch, ch.battler)\n # clear damage displays\n battler.battler.damage, battler.battler.damage_pop = nil, false\n end}\n # enemies were attacked\n return true\n end",
"def taking_damage_action\n if @warrior.feel(:backward).empty? && @health < 10\n @warrior.walk!(:backward)\n elsif @warrior.feel.empty?\n @warrior.walk!\n elsif @warrior.feel.enemy?\n @warrior.attack!\n end\n end",
"def pbMoveBaseDamage(move,user,target,skill)\r\n baseDmg = move.baseDamage\r\n baseDmg = 60 if baseDmg==1\r\n return baseDmg if skill<PBTrainerAI.mediumSkill\r\n # Covers all function codes which have their own def pbBaseDamage\r\n case move.function\r\n when \"010\" # Stomp\r\n baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]\r\n # Sonic Boom, Dragon Rage, Super Fang, Night Shade, Endeavor\r\n when \"06A\", \"06B\", \"06C\", \"06D\", \"06E\"\r\n baseDmg = move.pbFixedDamage(user,target)\r\n when \"06F\" # Psywave\r\n baseDmg = user.level\r\n when \"070\" # OHKO\r\n baseDmg = 200\r\n when \"071\", \"072\", \"073\" # Counter, Mirror Coat, Metal Burst\r\n baseDmg = 60\r\n when \"075\", \"076\", \"0D0\", \"12D\" # Surf, Earthquake, Whirlpool, Shadow Storm\r\n baseDmg = move.pbModifyDamage(baseDmg,user,target)\r\n # Gust, Twister, Venoshock, Smelling Salts, Wake-Up Slap, Facade, Hex, Brine,\r\n # Retaliate, Weather Ball, Return, Frustration, Eruption, Crush Grip,\r\n # Stored Power, Punishment, Hidden Power, Fury Cutter, Echoed Voice,\r\n # Trump Card, Flail, Electro Ball, Low Kick, Fling, Spit Up\r\n when \"077\", \"078\", \"07B\", \"07C\", \"07D\", \"07E\", \"07F\", \"080\", \"085\", \"087\",\r\n \"089\", \"08A\", \"08B\", \"08C\", \"08E\", \"08F\", \"090\", \"091\", \"092\", \"097\",\r\n \"098\", \"099\", \"09A\", \"0F7\", \"113\"\r\n baseDmg = move.pbBaseDamage(baseDmg,user,target)\r\n when \"086\" # Acrobatics\r\n baseDmg *= 2 if !user.item || user.hasActiveItem?(:FLYINGGEM)\r\n when \"08D\" # Gyro Ball\r\n targetSpeed = pbRoughStat(target,:SPEED,skill)\r\n userSpeed = pbRoughStat(user,:SPEED,skill)\r\n baseDmg = [[(25*targetSpeed/userSpeed).floor,150].min,1].max\r\n when \"094\" # Present\r\n baseDmg = 50\r\n when \"095\" # Magnitude\r\n baseDmg = 71\r\n baseDmg *= 2 if target.inTwoTurnAttack?(\"0CA\") # Dig\r\n when \"096\" # Natural Gift\r\n baseDmg = move.pbNaturalGiftBaseDamage(user.item_id)\r\n when \"09B\" # Heavy Slam\r\n baseDmg = move.pbBaseDamage(baseDmg,user,target)\r\n baseDmg *= 2 if Settings::MECHANICS_GENERATION >= 7 && skill>=PBTrainerAI.mediumSkill &&\r\n target.effects[PBEffects::Minimize]\r\n when \"0A0\", \"0BD\", \"0BE\" # Frost Breath, Double Kick, Twineedle\r\n baseDmg *= 2\r\n when \"0BF\" # Triple Kick\r\n baseDmg *= 6 # Hits do x1, x2, x3 baseDmg in turn, for x6 in total\r\n when \"0C0\" # Fury Attack\r\n if user.hasActiveAbility?(:SKILLLINK)\r\n baseDmg *= 5\r\n else\r\n baseDmg = (baseDmg * 31 / 10).floor # Average damage dealt\r\n end\r\n when \"0C1\" # Beat Up\r\n mult = 0\r\n @battle.eachInTeamFromBattlerIndex(user.index) do |pkmn,_i|\r\n mult += 1 if pkmn && pkmn.able? && pkmn.status == :NONE\r\n end\r\n baseDmg *= mult\r\n when \"0C4\" # Solar Beam\r\n baseDmg = move.pbBaseDamageMultiplier(baseDmg,user,target)\r\n when \"0D3\" # Rollout\r\n baseDmg *= 2 if user.effects[PBEffects::DefenseCurl]\r\n when \"0D4\" # Bide\r\n baseDmg = 40\r\n when \"0E1\" # Final Gambit\r\n baseDmg = user.hp\r\n when \"144\" # Flying Press\r\n if GameData::Type.exists?(:FLYING)\r\n if skill>=PBTrainerAI.highSkill\r\n targetTypes = target.pbTypes(true)\r\n mult = Effectiveness.calculate(:FLYING,\r\n targetTypes[0],targetTypes[1],targetTypes[2])\r\n baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round\r\n else\r\n mult = Effectiveness.calculate(:FLYING,\r\n target.type1,target.type2,target.effects[PBEffects::Type3])\r\n baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round\r\n end\r\n end\r\n baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]\r\n when \"166\" # Stomping Tantrum\r\n baseDmg *= 2 if user.lastRoundMoveFailed\r\n when \"175\" # Double Iron Bash\r\n baseDmg *= 2\r\n baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]\r\n end\r\n return baseDmg\r\n end",
"def perform_damage_effect\n end",
"def perform_damage_effect\n end",
"def do_action\n if self.affects == \"world\" then\n player_tile = self.character.tile\n\n # an aoe effect is represented as a list of objects,\n # each one representing the effect on one tile\n ITEM_PROPERTIES[self.item_type][\"aoe\"].each do |aoe|\n dx = aoe[\"xCoordPlus\"]\n dy = aoe[\"yCoordPlus\"]\n tile_becomes = aoe[\"tileBecomes\"]\n Tile.tile_at(player_tile.x + dx, player_tile.y + dy).become tile_becomes\n end\n\n elsif self.affects == \"player\" then\n\n dx = self.moves_player_x\n dy = self.moves_player_y\n\n # Move me to the place this item takes me\n if (dx != 0 or dy != 0) then\n target_tile = Tile.tile_at(self.character.tile.x + dx,\n self.character.tile.y + dy)\n if target_tile\n self.character.tile = target_tile\n end\n end\n\n self.character.heal(self.health_effect)\n self.character.charge(self.battery_effect)\n end\n\n if self.consumable then\n self.character.item = nil\n self.destroy\n end\n\n end",
"def attack_effect(attacker)\n # Clear critical flag\n self.critical = false\n # First hit detection\n hit_result = (rand(100) < attacker.hit)\n # If hit occurs\n if hit_result == true\n # Calculate basic damage\n atk = [attacker.atk - self.pdef / 2, 0].max\n self.damage = atk * (20 + attacker.str) / 20\n # Element correction\n self.damage *= elements_correct(attacker.element_set)\n self.damage /= 100\n # If damage value is strictly positive\n if self.damage > 0\n # Critical correction\n if rand(100) < 4 * attacker.dex / self.agi\n self.damage *= 2\n self.critical = true\n end\n # Guard correction\n if self.guarding?\n self.damage /= 2\n end\n end\n # Dispersion\n if self.damage.abs > 0\n amp = [self.damage.abs * 15 / 100, 1].max\n self.damage += rand(amp+1) + rand(amp+1) - amp\n end\n # Second hit detection\n eva = 8 * self.agi / attacker.dex + self.eva\n hit = self.damage < 0 ? 100 : 100 - eva\n hit = self.cant_evade? ? 100 : hit\n hit_result = (rand(100) < hit)\n end\n # If hit occurs\n if hit_result == true\n # State Removed by Shock\n remove_states_shock\n # Substract damage from HP\n self.hp -= self.damage\n # State change\n @state_changed = false\n states_plus(attacker.plus_state_set)\n states_minus(attacker.minus_state_set)\n # When missing\n else\n # Set damage to \"Miss\"\n self.damage = \"Miss\"\n # Clear critical flag\n self.critical = false\n end\n # End Method\n return true\n end",
"def setCombat\n\t\t@phase = \"combat\"\n\t\[email protected]\n\t\[email protected]\n\t\[email protected](0, 0, 11, 3)\n\t\tBATTLE_BACKGROUND.blit(@screen, [188, 106], nil)\n\t\t@menuStack = []\n\tend",
"def _fight(p1, p2, context)\n msg = context[:msg]\n \n \n \n msg += line \"<div> 战斗开始!</div>\"\n \n # calculate temporary fight prop\n # p1.tmp[:apply_damage] = p1.query_weapon_damage\n # p1.tmp[:apply_dodge] = 0-p1.query_all_weight\n # p1.tmp[:apply_defense] = p1.query_armo_defense \n \n \n \n calc_apply_var(p1)\n p \"====>p1 load: #{p1.tmp[:apply_dodge]} damage:#{p1.tmp[:apply_damage]} defense:#{p1.tmp[:apply_defense] }\"\n calc_apply_var(p2)\n p \"====>p2 load: #{p2.tmp[:apply_dodge]} damage:#{p2.tmp[:apply_damage]} defense:#{p2.tmp[:apply_defense] }\"\n \n # calculate who attach first \n # TODO need improve\n if (p1.query_temp(\"dext\")+p1.tmp[:apply_dodge] > p1.query_temp(\"dext\")+p2.tmp[:apply_dodge])\n attacker = p1\n #attacker_gain = gain_p1\n defenser = p2\n # defenser_gain = gain_p2\n else\n attacker = p2\n #attacker_gain = gain_p2\n defenser = p1\n #defenser_gain = gain_p1\n end\n \n p \"attacker is #{attacker.name}\"\n msg += translate_msg(line(\"<div>$N抢先发动进攻!</div>\"), {:user=>attacker, :target=>defenser})\n \n \n # what weapon attacker is wielding\n hand_right_weapon = p1.query_wearing(\"handright\")\n hand_left_weapon = p1.query_wearing(\"handleft\")\n p1.tmp[:right_hand_weapon] = hand_right_weapon\n p1.tmp[:left_hand_weapon] = hand_left_weapon\n p \"=>righthand weapons #{hand_right_weapon}\"\n p \"=>lefthand weapons #{hand_left_weapon}\"\n # defaut is unarmed\n weapon_skill_type = 'unarmed'\n if (hand_right_weapon)\n weapon_skill_type = hand_right_weapon.skill_type\n p1.tmp[:main_weapon] = hand_right_weapon\n \n elsif hand_left_weapon\n weapon_skill_type = hand_left_weapon.skill_type\n p1.tmp[:main_weapon] = hand_left_weapon\n end\n \n=begin\n reg = /unarmed/i\n if (hand_right_weapon)\n weapon_type = hand_right_weapon.type\n reg = Regexp.new(\"#{weapon_type}\", true)\n end\n=end \n context_p1 = {\n :user => p1,\n :thisskill => nil,\n :skills=>p1.query_all_skills,\n :target => p2\n }\n # attacker choose the best dodge skill\n p1[:dodge_skill] = choosBestDodgeSkill(context_p1)\n # attacker choose the skill have best damage\n p1[:attack_skill] = choosBestAttackSkill(context_p1, weapon_skill_type)\n # attacker choose best defense skill\n p1[:defense_skill] = choosBestDefenseSkill(context_p1, weapon_skill_type)\n \n # choose perform for p1\n skill_types = []\n if p1.tmp[:left_hand_weapon]\n skill_types.push(p1.tmp[:left_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\")\n end\n if p1.tmp[:right_hand_weapon]\n skill_types.push(p1.tmp[:right_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\") if !skill_types.include?\"unarmed\"\n end\n p1.tmp[:perform] = chooseBestPerform(p1, skill_types)\n \n \n \n \n # choose skills for deffenser\n hand_right_weapon = p2.query_wearing(\"handright\")\n hand_left_weapon = p2.query_wearing(\"handleft\")\n p2.tmp[:right_hand_weapon] = hand_right_weapon\n p2.tmp[:left_hand_weapon] = hand_left_weapon\n p \"=>#{defenser.name} righthand weapons #{hand_right_weapon}\"\n p \"=>#{defenser.name} lefthand weapons #{hand_left_weapon}\"\n # defaut is unarmed\n weapon_skill_type = 'unarmed'\n if (hand_right_weapon)\n weapon_skill_type = hand_right_weapon.skill_type\n p2.tmp[:main_weapon] = hand_right_weapon\n elsif hand_left_weapon\n weapon_skill_type = hand_left_weapon.skill_type\n p2.tmp[:main_weapon] = hand_left_weapon\n end\n context_p2 = {\n :user => p2,\n :thisskill => nil,\n :skills=>p2.query_all_skills,\n :target => p1\n }\n # defenser choose the best dodge skill\n p2[:dodge_skill] = choosBestDodgeSkill(context_p2)\n # defenser choose the skill have best damage\n p2[:attack_skill] = choosBestAttackSkill(context_p2, weapon_skill_type)\n # defenser choose best defense skill\n p2[:defense_skill] = choosBestDefenseSkill(context_p2, weapon_skill_type) \n \n # choose perform for p2\n skill_types = []\n if p2.tmp[:left_hand_weapon]\n skill_types.push(p2.tmp[:left_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\")\n end\n if p2.tmp[:right_hand_weapon]\n skill_types.push(p2.tmp[:right_hand_weapon].skill_type)\n else\n skill_types.push(\"unarmed\") if !skill_types.include?\"unarmed\"\n end\n p2.tmp[:perform] = chooseBestPerform(p2, skill_types)\n \n \n gain_p1 = {\n :exp =>0,\n # :hp =>0,\n # :stam =>0,\n :pot => 0,\n :level =>0,\n :skills =>{\n p1[:dodge_skill][:skill][:skname] =>\n {\n :skill => p1[:dodge_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p1[:dodge_skill][:skill].dname\n },\n p1[:attack_skill][:skill][:skname] =>\n {\n :skill => p1[:attack_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p1[:attack_skill][:skill].dname\n },\n p1[:defense_skill][:skill][:skname]=>\n {\n :skill => p1[:defense_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p1[:defense_skill][:skill].dname\n }\n }\n }\n gain_p2 = {\n :exp =>0,\n # :hp =>0,\n # :stam =>0,\n :pot => 0,\n :level =>0,\n :skills =>{\n p2[:dodge_skill][:skill][:skname] =>\n {\n :skill => p2[:dodge_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p2[:dodge_skill][:skill].dname\n },\n p2[:attack_skill][:skill][:skname] =>\n {\n :skill => p2[:attack_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p2[:attack_skill][:skill].dname\n },\n p2[:defense_skill][:skill][:skname]=>\n {\n :skill => p2[:defense_skill][:skill][:skname],\n :point => 0,\n :level => 0,\n :dname =>p2[:defense_skill][:skill].dname\n }\n }\n }\n p \"==>gain.skill #{gain_p1.inspect}\"\n p \"==>gain.skill #{gain_p2.inspect}\"\n # context[:gain_p1] = gain_p1\n # context[:gain_p2] = gain_p2\n p1[:gain] = gain_p1\n p2[:gain] = gain_p2\n \n if (attacker == p1)\n attacker_gain = gain_p1\n defenser_gain = gain_p2\n else\n attacker_gain = gain_p2\n defenser_gain = gain_p1\n end\n \n p1.tmp[:willperform]=0\n p2.tmp[:willperform]=0\n\n \n srand(Time.now.tv_usec.to_i)\n i = 0\n style_c = \"user\"\n \n # show status\n msg += status_lines(attacker, defenser)\n \n winner = nil\n=begin\n while (i < 100 ) # max 100 turn\n if style_c == \"user\"\n style_c = \"enemy\"\n else\n style_c = \"user\"\n end\n \n # msg += \"<!--1--><div class=\\\"#{style_c}\\\">\\n#{__fight(attacker, defenser)}\\n</div>\\n\";\n msg += \"\\n<div class=\\\"#{style_c}\\\">\\n#{__fight(attacker, defenser)}</div>\\n\"\n \n \n i = i+1\n \n \n \n if (defenser.tmp[:hp] <=0 )\n msg += line \"<div>#{defenser.name}战斗不能</div>\"\n winner = attacker\n break;\n end\n \n if (defenser.tmp[:stam] <=0 && attacker.tmp[:stam]<=0)\n msg += line \"<div>双方都已经精疲力尽了!</div>\"\n break;\n end\n \n # swap\n t = defenser\n defenser = attacker\n attacker = t\n \n \n \n end #while\n=end \n f_context={\n :style=>style_c,\n :round=>0,\n # :winner=>nil\n }\n msg += __fight(attacker, defenser, f_context)\n i = f_context[:round]\n # winner = f_context[:winner]\n context[:round] = f_context[:round]\n \n if (p1.tmp[:hp] >= 0 and p2.tmp[:hp] >=0) || (p1.tmp[:hp] < 0 and p2.tmp[:hp] <0)\n winner = nil\n elsif p1.tmp[:hp] >=0 \n winner = p1\n else \n winner = p2\n end\n #\n # save to db # TODO should the enemy also save gain ?\n #\n if attacker[:isUser]\n copyExt(attacker)\n end\n if defenser[:isUser]\n copyExt(defenser)\n end\n if (attacker[:canGain])\n receive_gain(attacker, attacker[:gain])\n end\n if (defenser[:canGain])\n receive_gain(defenser, defenser[:gain])\n end\n\n win = 0\n msg += \"<!--1-->\\n<div class='fight_result'><div class='win'>\\n\"\n if !winner\n win = -1\n if attacker[:isUser]\n msg += \"你和#{defenser.name}战成平手!}\"\n elsif defenser[:isUser]\n msg += \"你和#{attacker.name}战成平手!\"\n else\n msg += \"#{attacker.name}和#{defenser.name}战成平手!\"\n end\n else\n if winner == p1\n win = 1\n else\n win = 0\n end\n if (winner[:isUser])\n msg += \"You(#{winner.name}) <span class='f_win'>Win</span> !\"\n elsif (defenser[:isUser])\n msg += \"You(#{defenser.name}) <span class='f_lose'>Lose</span> !\"\n else\n msg += \"#{winner.name} <span class='f_win'>Win</span> !\"\n end\n end\n p attacker.tmp\n msg += \"(in #{i} rounds)</div>\\n\"\n msg += \"</div><!--0-->\"\n if (context[:msg])\n context[:msg] += msg\n else\n context[:msg] = msg\n end\n p context[:msg]\n # return attacker[:isUser]\n # return attacker == p1\n return win\n end",
"def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n round_report = []\n round_report << \"Runde #{round+1}: \"\n round_report << \"#{turn_user.username} ist am Zug.\"\n if shield > 0\n round_report << \"Schild von #{target_user.username} ist aktiv.\"\n round_report << \"Schild hält noch #{shield} Schaden aus.\"\n round_report << \"Alle Truppen schießen auf den Schildt!\"\n else \n round_report << \"Schild von #{target_user.username} ist inaktiv.\"\n round_report << \"Angriffe werden nicht abgewehrt!\"\n round_report << \" \"\n end\n turn_fleet.each do |a|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if a[1] > 0 && a[2] > 0 \n round_report << \"Die Gruppe #{a[5]} trifft... \"\n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target == -2)\n round_report << \"nicht. Der Angriff ging daneben. \"\n round_report << \" \"\n round_report << \" \"\n elsif(target==-1)\n round_report << \"das Schild. Der Schaden beträgt: \"\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if a[3] == 2\n mult = 1.5\n end\n damage = a[2] * mult\n round_report << \"#{damage} \"\n round_report << \" \"\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult=1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if(a[3]==1)\n mult=1.5\n end \n # Bestimme welche Einheit getroffen wurde\n victim=target_fleet[target]\n # round_report << \"#{victim[5]}. Der Schaden beträgt: \"\n # Schadensberechnung\n damage=a[2]*mult\n round_report << \"#{damage} \"\n # Berechne neue HP\n hit_points=victim[-2]\n victim[-2]=hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim)\n round_report << \"#{victim[4]} Einheiten wurden zerstört. \"\n end\n end \n # Füge Runden-Bericht ein\n # @round_reports << round_report\n end\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue=false\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user==@attacker\n @attacker_shield=@fight_shield\n else\n @defender_shield=@fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet=turn_fleet\n tmp_user=turn_user\n turn_fleet=target_fleet\n turn_user=target_user\n target_fleet=tmp_fleet\n target_user=tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n @report << @round_reports\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n end\n end",
"def fight(enemy, weapon)\n if life <= 0\n puts \"[#{self.class} is too dead!]\"\n return\n end\n\n #Attack the opponent\n your_hit = rand(strength+weapon)\n puts \"[you hit with #{your_hit} points of damage!]\"\n enemy.hit(your_hit)\n\n #Retaliation\n p enemy\n if enemy.life >0\n enemy_hit = rand(enemy.strength + enemy.weapon)\n puts \"[your enemy hit with #{enemy_hit} points of damage!]\"\n self.hit(enemy_hit)\n end\n end",
"def attacks(attacked_player)\n # puts player1.name \n # print \"attacks\"\n # puts \"#{attacked_player}\"\n attacked_player.gets_damage(compute_damage)\n # puts \"He loses #{compute_damage} points\"\n end",
"def execute_action\n # This is a VERY lazy way for using different enemy ammo counts.\n # When it's the enemies turn, add one to enemy_attack. This acts as a index\n # For emoving enemy ammo. It's an extremely simple and lazy way :x\n if @active_battler.is_a?(Game_Actor)\n @enemy_attack = -1\n else\n @enemy_attack += 1\n end\n ty_ammo_requirements_execute_action\n end",
"def attacks(player)\n\t\tputs \"#{@name} attaque #{player.name} !\"\n\t\tdamage = compute_damage\n player.gets_damage(damage)\n \n\t\tif player.life_points > 0\n\t\tputs \"#{@name} lui inflige #{damage} points de dommage.\\n\\n\"\n\t\telse \n\t\t\tputs \"Oups, #{player.name} c'est fait décapité...\\n\\n\"\n end\n\n end",
"def gotAttack(damage)\r\n @@probsDeflects = Array['deflect', 'deflect', 'deflect', 'deflect', 'deflect',\r\n 'deflect', 'deflect', 'deflect', 'got hit', 'got hit' ]\r\n\r\n @@probs = @@probsDeflects[rand(0..9)]\r\n if @role.upcase == \"HERO\"\r\n if @@probs == 'deflect'\r\n puts \"#{@name} deflects the attack.\"\r\n @hitpoint += damage\r\n end\r\n end\r\n @hitpoint -= damage\r\n end",
"def win_fight\n if $boss_hp <= 0\n puts \"You win!\"\n $in_combat = false\n $in_boss = false\n $dead_boss = true #add a unique dialogue somewhere if this is true\n $in_forest = true\n end\nend",
"def pbRoughDamage(move,user,target,skill,baseDmg)\r\n # Fixed damage moves\r\n return baseDmg if move.is_a?(PokeBattle_FixedDamageMove)\r\n # Get the move's type\r\n type = pbRoughType(move,user,skill)\r\n ##### Calculate user's attack stat #####\r\n atk = pbRoughStat(user,:ATTACK,skill)\r\n if move.function==\"121\" # Foul Play\r\n atk = pbRoughStat(target,:ATTACK,skill)\r\n elsif move.specialMove?(type)\r\n if move.function==\"121\" # Foul Play\r\n atk = pbRoughStat(target,:SPECIAL_ATTACK,skill)\r\n else\r\n atk = pbRoughStat(user,:SPECIAL_ATTACK,skill)\r\n end\r\n end\r\n ##### Calculate target's defense stat #####\r\n defense = pbRoughStat(target,:DEFENSE,skill)\r\n if move.specialMove?(type) && move.function!=\"122\" # Psyshock\r\n defense = pbRoughStat(target,:SPECIAL_DEFENSE,skill)\r\n end\r\n ##### Calculate all multiplier effects #####\r\n multipliers = {\r\n :base_damage_multiplier => 1.0,\r\n :attack_multiplier => 1.0,\r\n :defense_multiplier => 1.0,\r\n :final_damage_multiplier => 1.0\r\n }\r\n # Ability effects that alter damage\r\n moldBreaker = false\r\n if skill>=PBTrainerAI.highSkill && target.hasMoldBreaker?\r\n moldBreaker = true\r\n end\r\n if skill>=PBTrainerAI.mediumSkill && user.abilityActive?\r\n # NOTE: These abilities aren't suitable for checking at the start of the\r\n # round.\r\n abilityBlacklist = [:ANALYTIC,:SNIPER,:TINTEDLENS,:AERILATE,:PIXILATE,:REFRIGERATE]\r\n canCheck = true\r\n abilityBlacklist.each do |m|\r\n next if move.id != m\r\n canCheck = false\r\n break\r\n end\r\n if canCheck\r\n BattleHandlers.triggerDamageCalcUserAbility(user.ability,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n if skill>=PBTrainerAI.mediumSkill && !moldBreaker\r\n user.eachAlly do |b|\r\n next if !b.abilityActive?\r\n BattleHandlers.triggerDamageCalcUserAllyAbility(b.ability,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n if skill>=PBTrainerAI.bestSkill && !moldBreaker && target.abilityActive?\r\n # NOTE: These abilities aren't suitable for checking at the start of the\r\n # round.\r\n abilityBlacklist = [:FILTER,:SOLIDROCK]\r\n canCheck = true\r\n abilityBlacklist.each do |m|\r\n next if move.id != m\r\n canCheck = false\r\n break\r\n end\r\n if canCheck\r\n BattleHandlers.triggerDamageCalcTargetAbility(target.ability,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n if skill>=PBTrainerAI.bestSkill && !moldBreaker\r\n target.eachAlly do |b|\r\n next if !b.abilityActive?\r\n BattleHandlers.triggerDamageCalcTargetAllyAbility(b.ability,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n # Item effects that alter damage\r\n # NOTE: Type-boosting gems aren't suitable for checking at the start of the\r\n # round.\r\n if skill>=PBTrainerAI.mediumSkill && user.itemActive?\r\n # NOTE: These items aren't suitable for checking at the start of the\r\n # round.\r\n itemBlacklist = [:EXPERTBELT,:LIFEORB]\r\n if !itemBlacklist.include?(user.item_id)\r\n BattleHandlers.triggerDamageCalcUserItem(user.item,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n if skill>=PBTrainerAI.bestSkill && target.itemActive?\r\n # NOTE: Type-weakening berries aren't suitable for checking at the start\r\n # of the round.\r\n if target.item && !target.item.is_berry?\r\n BattleHandlers.triggerDamageCalcTargetItem(target.item,\r\n user,target,move,multipliers,baseDmg,type)\r\n end\r\n end\r\n # Global abilities\r\n if skill>=PBTrainerAI.mediumSkill\r\n if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||\r\n (@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)\r\n if @battle.pbCheckGlobalAbility(:AURABREAK)\r\n multipliers[:base_damage_multiplier] *= 2 / 3.0\r\n else\r\n multipliers[:base_damage_multiplier] *= 4 / 3.0\r\n end\r\n end\r\n end\r\n # Parental Bond\r\n if skill>=PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND)\r\n multipliers[:base_damage_multiplier] *= 1.25\r\n end\r\n # Me First\r\n # TODO\r\n # Helping Hand - n/a\r\n # Charge\r\n if skill>=PBTrainerAI.mediumSkill\r\n if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC\r\n multipliers[:base_damage_multiplier] *= 2\r\n end\r\n end\r\n # Mud Sport and Water Sport\r\n if skill>=PBTrainerAI.mediumSkill\r\n if type == :ELECTRIC\r\n @battle.eachBattler do |b|\r\n next if !b.effects[PBEffects::MudSport]\r\n multipliers[:base_damage_multiplier] /= 3\r\n break\r\n end\r\n if @battle.field.effects[PBEffects::MudSportField]>0\r\n multipliers[:base_damage_multiplier] /= 3\r\n end\r\n end\r\n if type == :FIRE\r\n @battle.eachBattler do |b|\r\n next if !b.effects[PBEffects::WaterSport]\r\n multipliers[:base_damage_multiplier] /= 3\r\n break\r\n end\r\n if @battle.field.effects[PBEffects::WaterSportField]>0\r\n multipliers[:base_damage_multiplier] /= 3\r\n end\r\n end\r\n end\r\n # Terrain moves\r\n if skill>=PBTrainerAI.mediumSkill\r\n case @battle.field.terrain\r\n when :Electric\r\n multipliers[:base_damage_multiplier] *= 1.5 if type == :ELECTRIC && user.affectedByTerrain?\r\n when :Grassy\r\n multipliers[:base_damage_multiplier] *= 1.5 if type == :GRASS && user.affectedByTerrain?\r\n when :Psychic\r\n multipliers[:base_damage_multiplier] *= 1.5 if type == :PSYCHIC && user.affectedByTerrain?\r\n when :Misty\r\n multipliers[:base_damage_multiplier] /= 2 if type == :DRAGON && target.affectedByTerrain?\r\n end\r\n end\r\n # Badge multipliers\r\n if skill>=PBTrainerAI.highSkill\r\n if @battle.internalBattle\r\n # Don't need to check the Atk/Sp Atk-boosting badges because the AI\r\n # won't control the player's Pokémon.\r\n if target.pbOwnedByPlayer?\r\n if move.physicalMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_DEFENSE\r\n multipliers[:defense_multiplier] *= 1.1\r\n elsif move.specialMove?(type) && @battle.pbPlayer.badge_count >= Settings::NUM_BADGES_BOOST_SPDEF\r\n multipliers[:defense_multiplier] *= 1.1\r\n end\r\n end\r\n end\r\n end\r\n # Multi-targeting attacks\r\n if skill>=PBTrainerAI.highSkill\r\n if pbTargetsMultiple?(move,user)\r\n multipliers[:final_damage_multiplier] *= 0.75\r\n end\r\n end\r\n # Weather\r\n if skill>=PBTrainerAI.mediumSkill\r\n case @battle.pbWeather\r\n when :Sun, :HarshSun\r\n if type == :FIRE\r\n multipliers[:final_damage_multiplier] *= 1.5\r\n elsif type == :WATER\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n when :Rain, :HeavyRain\r\n if type == :FIRE\r\n multipliers[:final_damage_multiplier] /= 2\r\n elsif type == :WATER\r\n multipliers[:final_damage_multiplier] *= 1.5\r\n end\r\n when :Sandstorm\r\n if target.pbHasType?(:ROCK) && move.specialMove?(type) && move.function != \"122\" # Psyshock\r\n multipliers[:defense_multiplier] *= 1.5\r\n end\r\n end\r\n end\r\n # Critical hits - n/a\r\n # Random variance - n/a\r\n # STAB\r\n if skill>=PBTrainerAI.mediumSkill\r\n if type && user.pbHasType?(type)\r\n if user.hasActiveAbility?(:ADAPTABILITY)\r\n multipliers[:final_damage_multiplier] *= 2\r\n else\r\n multipliers[:final_damage_multiplier] *= 1.5\r\n end\r\n end\r\n end\r\n # Type effectiveness\r\n if skill>=PBTrainerAI.mediumSkill\r\n typemod = pbCalcTypeMod(type,user,target)\r\n multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE\r\n end\r\n # Burn\r\n if skill>=PBTrainerAI.highSkill\r\n if user.status == :BURN && move.physicalMove?(type) &&\r\n !user.hasActiveAbility?(:GUTS) &&\r\n !(Settings::MECHANICS_GENERATION >= 6 && move.function == \"07E\") # Facade\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n end\r\n # Aurora Veil, Reflect, Light Screen\r\n if skill>=PBTrainerAI.highSkill\r\n if !move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR)\r\n if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0\r\n if @battle.pbSideBattlerCount(target) > 1\r\n multipliers[:final_damage_multiplier] *= 2 / 3.0\r\n else\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n elsif target.pbOwnSide.effects[PBEffects::Reflect] > 0 && move.physicalMove?(type)\r\n if @battle.pbSideBattlerCount(target) > 1\r\n multipliers[:final_damage_multiplier] *= 2 / 3.0\r\n else\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n elsif target.pbOwnSide.effects[PBEffects::LightScreen] > 0 && move.specialMove?(type)\r\n if @battle.pbSideBattlerCount(target) > 1\r\n multipliers[:final_damage_multiplier] *= 2 / 3.0\r\n else\r\n multipliers[:final_damage_multiplier] /= 2\r\n end\r\n end\r\n end\r\n end\r\n # Minimize\r\n if skill>=PBTrainerAI.highSkill\r\n if target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2)\r\n multipliers[:final_damage_multiplier] *= 2\r\n end\r\n end\r\n # Move-specific base damage modifiers\r\n # TODO\r\n # Move-specific final damage modifiers\r\n # TODO\r\n ##### Main damage calculation #####\r\n baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max\r\n atk = [(atk * multipliers[:attack_multiplier]).round, 1].max\r\n defense = [(defense * multipliers[:defense_multiplier]).round, 1].max\r\n damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2\r\n damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max\r\n # \"AI-specific calculations below\"\r\n # Increased critical hit rates\r\n if skill>=PBTrainerAI.mediumSkill\r\n c = 0\r\n # Ability effects that alter critical hit rate\r\n if c>=0 && user.abilityActive?\r\n c = BattleHandlers.triggerCriticalCalcUserAbility(user.ability,user,target,c)\r\n end\r\n if skill>=PBTrainerAI.bestSkill\r\n if c>=0 && !moldBreaker && target.abilityActive?\r\n c = BattleHandlers.triggerCriticalCalcTargetAbility(target.ability,user,target,c)\r\n end\r\n end\r\n # Item effects that alter critical hit rate\r\n if c>=0 && user.itemActive?\r\n c = BattleHandlers.triggerCriticalCalcUserItem(user.item,user,target,c)\r\n end\r\n if skill>=PBTrainerAI.bestSkill\r\n if c>=0 && target.itemActive?\r\n c = BattleHandlers.triggerCriticalCalcTargetItem(target.item,user,target,c)\r\n end\r\n end\r\n # Other efffects\r\n c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant]>0\r\n if c>=0\r\n c += 1 if move.highCriticalRate?\r\n c += user.effects[PBEffects::FocusEnergy]\r\n c += 1 if user.inHyperMode? && move.type == :SHADOW\r\n end\r\n if c>=0\r\n c = 4 if c>4\r\n damage += damage*0.1*c\r\n end\r\n end\r\n return damage.floor\r\n end",
"def strategy\n\n attacks_in_last_24_hours = Action.where([\"type_id = ? OR type_id = ?\", Action::TYPE_ATTACK_USER, Action::TYPE_ATTACK_USER_DDOS]).where(target_id: id, target_type: \"User\", completed: true).where(\"completed_at >= ?\", DateTime.now-24.hours).count\n\n # how often was the player succesfully attacked in the last 24 hours?\n if successful_attacks_in_last_24_hours > 0 && !counterattack_successful?\n agressiveness = (successful_attacks_in_last_24_hours.to_f/attacks_in_last_24_hours.to_f*100).to_i\n else\n agressiveness = 50\n end\n\n # how many other players can be attacked by this player?\n other_players = User.where([\"id != ?\", id])\n attack_opportunities = 0\n stronger_opportunities = 0\n weaker_opportunities = 0\n total_opportunities = other_players.count*2\n other_players.each do |player|\n [:hack, :ddos].each do |type|\n attack_opportunities += 1 if can_attack?(player, type)\n weaker_opportunities += 1 if to_strong_for(player, type)\n stronger_opportunities += 1 if to_weak_for(player, type)\n end\n end\n\n # assume that own defense is too low if defense is less than 33% of all attributes and more than 25% of other players are stronger\n if (hacking_ratio+defense_ratio+botnet_ratio) > 0 && \n ((defense_ratio.to_f/(hacking_ratio.to_f+defense_ratio.to_f+botnet_ratio.to_f)*100).round(0) < 33) &&\n (stronger_opportunities.to_f/total_opportunities.to_f*100).round(0) > 25\n defensiveness = 100\n else\n defensiveness = 50\n end\n\n # determine strategy according to relation between agressiveness and defensiveness\n if agressiveness > defensiveness\nRails.logger.info(\"---> AI: my strategy is agressive\")\n :agressive\n elsif agressiveness < defensiveness\nRails.logger.info(\"---> AI: my strategy is defensive\")\n :defensive\n else\nRails.logger.info(\"---> AI: my strategy is moderate\")\n :moderate\n end\n end",
"def pokemon_combat(pokemon1, pokemon2)\n return win_by_default(pokemon1, pokemon2) if win_by_default(pokemon1, pokemon2)\n\n get_winner_fight(pokemon1, pokemon2)\n end",
"def enemies_attack\n @enemies.each do |mechant| #player contient Josiane et José\n if mechant.life_points > 0\n mechant.attacks(@human_player)\n end #end of if \n end #end of do\n end",
"def skill_effect(user, skill)\n # Clear critical flag\n self.critical = false\n # If skill scope is for ally with 1 or more HP, and your own HP = 0,\n # or skill scope is for ally with 0, and your own HP = 1 or more\n if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or\n ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)\n # End Method\n return false\n end\n # Clear effective flag\n effective = false\n # Set effective flag if common ID is effective\n effective |= skill.common_event_id > 0\n # First hit detection\n hit = skill.hit\n if skill.atk_f > 0\n hit *= user.hit / 100\n end\n hit_result = (rand(100) < hit)\n # Set effective flag if skill is uncertain\n effective |= hit < 100\n # Si Golpeas\n if hit_result == true\n if Wep::Atribute_mod_skills[skill.id] != nil\n # Extract and calculate effect\n # Calculate power\n ef = Wep::Atribute_mod_skills[skill.id][0] + user.atk * skill.atk_f / 100\n ef -= self.pdef * skill.pdef_f / 200\n ef -= self.mdef * skill.mdef_f / 200\n # Calculate rate\n ra = 20\n ra += (user.str * skill.str_f / 100)\n ra += (user.dex * skill.dex_f / 100)\n ra += (user.agi * skill.agi_f / 100)\n ra += (user.int * skill.int_f / 100)\n # Calculate total effect\n total_ef = ef * ra / 20\n # Apply dispersion\n if skill.variance > 0\n amp = [total_ef * skill.variance / 100, 1].max\n total_ef += rand(amp+1) + rand(amp+1) - amp\n end\n \n # Apply if exist\n case Wep::Atribute_mod_skills[skill.id][1]\n \n when 'maxhp':\n self.atr_mod_list.maxhp += total_ef\n when 'maxsp':\n self.atr_mod_list.maxsp += total_ef\n \n when 'str':\n self.atr_mod_list.str += total_ef\n when 'dex':\n self.atr_mod_list.dex += total_ef\n when 'int':\n self.atr_mod_list.int += total_ef\n when 'agi':\n self.atr_mod_list.agi += total_ef\n \n when 'atk':\n self.atr_mod_list.atk += total_ef\n when 'pdef':\n self.atr_mod_list.pdef += total_ef\n when 'mdef':\n self.atr_mod_list.mdef += total_ef\n when 'eva':\n self.atr_mod_list.eva += total_ef\n end\n end\n \n # Calculate power\n power = skill.power + user.atk * skill.atk_f / 100\n if power > 0\n power -= self.pdef * skill.pdef_f / 200\n power -= self.mdef * skill.mdef_f / 200\n power = [power, 0].max\n end\n # Calculate rate\n rate = 20\n rate += (user.str * skill.str_f / 100)\n rate += (user.dex * skill.dex_f / 100)\n rate += (user.agi * skill.agi_f / 100)\n rate += (user.int * skill.int_f / 100)\n # Calculate basic damage\n self.damage = power * rate / 20\n # Element correction\n self.damage *= elements_correct(skill.element_set)\n self.damage /= 100\n # If damage value is strictly positive\n if self.damage > 0\n # Guard correction\n if self.guarding?\n self.damage /= 2\n end\n end\n # Dispersion\n if skill.variance > 0 and self.damage.abs > 0\n amp = [self.damage.abs * skill.variance / 100, 1].max\n self.damage += rand(amp+1) + rand(amp+1) - amp\n end\n # Second hit detection\n eva = 8 * self.agi / user.dex + self.eva\n hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100\n hit = self.cant_evade? ? 100 : hit\n hit_result = (rand(100) < hit)\n # Set effective flag if skill is uncertain\n effective |= hit < 100\n end\n # If hit occurs\n if hit_result == true\n # If physical attack has power other than 0\n if skill.power != 0 and skill.atk_f > 0\n # State Removed by Shock\n remove_states_shock\n # Set to effective flag\n effective = true\n end\n # Substract damage from HP\n last_hp = self.hp\n self.hp -= self.damage\n effective |= self.hp != last_hp\n # State change\n @state_changed = false\n if Wep::Skill_state_rates[skill.id] != nil\n state_add = []\n state_remove = []\n # Loop over state rates and check the posibiltys. Create a state list.\n for state_rate in Wep::Skill_state_rates[skill.id]\n if rand(100) < state_rate[1]\n state_add.push(state_rate[0])\n for s in state_rate[2]\n state_remove.push(s)\n end\n end\n end\n states_plus(state_add)\n states_minus(state_remove)\n #effective |= states_plus(state_add)\n #effective |= states_minus(state_remove)\n else\n states_plus(skill.plus_state_set)\n states_minus(skill.minus_state_set)\n #effective |= states_plus(skill.plus_state_set)\n #effective |= states_minus(skill.minus_state_set)\n end\n # If power is 0\n if skill.power == 0\n # No damage\n self.damage = \"\"\n # If state does not change\n unless @state_changed\n # Miss\n self.damage = \"Miss\"\n end\n end\n else\n # Miss\n self.damage = \"Miss\"\n end\n unless $game_temp.in_battle\n self.damage = nil\n end\n return effective\n end",
"def attack #basic attack for now\r\n attack_value = strength + rand(25..50)\r\n puts \"#{@name} SWINGS his Weapon for #{attack_value} Points of Damage!\"\r\n end",
"def data_battler\n enemy\n end",
"def battle\n playerset($testing)\n fieldmonsters = []\n efieldmonsters = []\n @@monsterfield.each { |x| \n if x[:type] == \"monster\"\n fieldmonsters.push(x)\n end\n }\n if fieldmonsters.empty? == true\t\n puts \"There are no monsters to battle with\".red\n return\n end\n @@emonsterfield.each { |x| \t\t\t\n if x[:type] == \"monster\"\n efieldmonsters.push(x)\n end\n }\n if efieldmonsters.empty? == true\t\n puts \"There are no enemy monsters to battle\".red\n return\n end\n puts \"What monster do you choose?\"\n fieldmonsters.each {|x| puts x[:name]}\n response1 = gets.to_i\n response1 -= 1\n puts \"You have selected #{@@monsterfield[response1][:name]}\"\n puts \"What monster do you want to battle?\"\n efieldmonsters.each {|x| puts x[:name]}\n response2 = gets.to_i\n response2 -= 1\n answer = @@monsterfield[response1][:atk] - @@emonsterfield[response2][:atk]\n puts answer\n if answer < 0\n puts \"Your monster lost the battle\"\n $file.puts(\"#{@@name} loss a battle against #{@@ename}\")\n end\n if answer == 0\n puts \"Draw\"\n @@graveyard.push(@@monsterfield[response1])\n @@monsterfield.delete(@@monsterfield[response1])\n @@egraveyard.push(@@emonsterfield[response2])\n @@emonsterfield.delete(@@emonsterfield[response2])\n $file.puts(\"#{@@name} drew in a battle against #{@@ename}\")\n end\n if answer > 0\n puts \"Your monster won the battle\"\n $file.puts(\"#{@@name} won a battle against #{@@ename}\")\n decreaselp('enemy', answer)\n end\nend",
"def allocateTraits\r\n\r\n\tif $class == \"1\" #Soldier\r\n\t\t$lvl=1\t#character level\r\n\t\t$str=8\t#Strength\r\n\t\t$dex=8\t#dexterity\r\n\t\t$con=8\t#constitution\r\n\t\t$int=8\t#intelligence\r\n\t\t$wis=8\t#wisdom\r\n\t\t$cha=8\t#charisma\t\r\n\t\t$maxVit=10 #vitality\r\n\t\t$vit=10\r\n\t\t$atk=$lvl #base attack\r\n\t\t$defenseBonus=0 \r\n\t\t\r\n\r\n\telsif $class == 2 #Scout\r\n\t\t$lvl=1\t\r\n\t\t$str=8\r\n\t\t$dex=8\r\n\t\t$con=8\r\n\t\t$int=8\r\n\t\t$wis=8\r\n\t\t$cha=8\r\n\t\t$maxVit=8\r\n\t\t$vit=8\r\n\t\t$atk=($lvl*0.75) #base attack\r\n\t\t$defenseBonus=2\r\n\r\n\telsif $class == 3 #Scoundrel\r\n\t\t$str=8\r\n\t\t$dex=8\r\n\t\t$con=8\r\n\t\t$int=8\r\n\t\t$wis=8\r\n\t\t$cha=8\r\n\t\t$maxVit=6\r\n\t\t$vit=6\r\n\t\t$atk=($lvl*0.75) #base attack\r\n\t\t$defenseBonus=4\r\n\t\t\r\n\telse\r\n\t\t$vit = 6\r\n\t\t$maxVit = 6\r\n\t\r\n\r\n\tend\r\n\r\nend",
"def fight(enemy, weapon)\n if life <= 0\n puts \"[#{self.class} is too dead to fight!]\"\n return\n end\n\n # Attack the opponent\n your_hit = rand(strength + weapon)\n puts \"[You hit with #{your_hit} points of damage!]\"\n enemy.hit(your_hit)\n\n # Retaliation\n p enemy\n if enemy.life > 0\n enemy_hit = rand(enemy.strength + enemy.weapon)\n puts \"[Your enemy hit with #{enemy_hit} points of damage!]\"\n hit(enemy_hit)\n end\n end",
"def enemies_attack\n total_bots_damage = 0\n @enemies.each do |bots_player|\n bots_damage = rand(1..6)\n @human_player.gets_damage(bots_damage)\n total_bots_damage += bots_damage\n end\n puts \"le(s) #{@enemies.length} inflige(nt) #{total_bots_damage} points de vie a #{@human_player.name}\"\n end",
"def take_action(warrior)\n\tif @attack_type == \"melee\"\n\t\tif warrior.feel.empty?\t\t\t# nothing directly in front of warrior\n\t\t\tif warrior.health == MAX_HEALTH || @health > warrior.health\n\t\t\t\tif @health > warrior.health && warrior.health < @@fight_threshhold\t# warrior is hurt, being attacked, and needs to get out of danger to heal\n\t\t\t\t\twarrior.walk!(:backward)\n\t\t\t\telse\t\t\t\t\t#warrior is healthy enough to take on enemy\n\t\t\t\t\twarrior.walk!\t\t\n\t\t\t\tend\n\t\t\telse\t\t\t\t\t\t#warrior needs to heal\n\t\t\t\twarrior.rest!\n\t\t\tend\n\t\telse\t\t\t\t\t\t\t# warrior is next to something\n\t\t\tif warrior.feel.captive?\t# warrior is next to captive, free him\n\t\t\t\twarrior.rescue!\n\t\t\telse\t\t\t\t\t\t# warrior is next to enemy, attack him\n\t\t\t\twarrior.attack!\n\t\t\tend\n\t\tend\n\telse\t# action is to attack an enemy at range(wizard or archer)\n\t\twarrior.shoot!\n\tend\n end",
"def battle\n\n puts \"You have reached the dragon's domain! You will fight him here.\"\n puts \"Mordremoth's biggest weakness if that he is made of plants.\"\n # User character's base values\n gladiator_str = @gladiator.strength+10\n gladiator_heal = @gladiator.health*10\n\n puts \"Commander, your initial strength is #{gladiator_str}\"\n puts \"Commander, your initial health is #{gladiator_heal}\"\n puts \"Enchant your weapon with the sigil of your choice:\"\n\n puts \"1) Sigil of Water\"\n puts \"2) Sigil of Earth\"\n puts \"3) Sigil of Fire\"\n puts \"4) Sigil of Air\"\n puts \"5) No Sigil\"\n # Enemy base values\n enemy_str = 5\n enemy_heal = 150\n # Character may get a buff/nerf according to his choice\n sigil = gets.to_i\n\n if sigil == 1\n puts \"Sigil Of Water, very bad choice against a plant enemy...\"\n gladiator_str -= 10\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 2\n puts \"Sigil Of Earth, not a good choice against a plant enemy...\"\n gladiator_str -= 5\n puts \"Your strength has decreased to #{gladiator_str}\"\n elsif sigil == 3\n puts \"Sigil Of Fire, very good choice against a plant enemy...\"\n gladiator_str += 10\n puts \"Your strength has increased to #{gladiator_str}\"\n elsif sigil == 4\n puts \"Sigil Of Air, kind of good choice against a plant enemy...\"\n gladiator_str += 5\n puts \"Your strength has increased to #{gladiator_str}\"\n else\n puts \"You decided to use no sigil on your weapon.\"\n end\n\n puts \"When you are ready, enter any key to continue...\"\n gets\n\n puts \"The battle has begun!\"\n # Battle continues while enemy and gladiator are alive\n while enemy_heal > 0 && gladiator_heal > 0\n\n puts \"You attack Mordremoth successfully\"\n enemy_heal -= gladiator_str\n puts \"Mordremoth's health is #{enemy_heal}\"\n # Enemy always strikes last\n if enemy_heal> 0\n puts \"Mordremoth strikes at you\"\n gladiator_heal -= enemy_str\n puts \"Your health is #{gladiator_heal}\"\n @gladiator.notify(\"harm\")\n puts\n end\n end\n # Outcome of final battle is designated here.\n # User has several retry changes before losing completely.\n if enemy_heal <= 0\n @gladiator.notify(\"win\")\n puts\n puts \"You have defeated Mordremoth! Now the world is safe.\"\n puts \"Or is it? Find out in the next episode: Path Of Fire!\"\n\n elsif @retries > 0\n @gladiator.notify(\"lose\")\n puts \"Mordremoth has beaten you... You'll return again.\"\n @retries -= 1\n battle\n else\n @gladiator.notify(\"lose\")\n puts \"You are dead... Game Over!\"\n end\n end",
"def getCombatLevel\n super + @myCultistCard.getSpecialValue\n end",
"def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}\"\n \tdamage = compute_damage\n \tputs \"Il lui inflige #{damage} points de dommage\"\n \tplayer.gets_damage(damage)\n end",
"def attack(user)\n # Variable to see how many damage instances will be\n damage_instances_count = 0\n\n # Search within weapons for damage bonus\n user.weapons.each do |weapon|\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'damage'\n damage_instances_count = bonus.multiplier\n end\n end\n end\n\n # For each damage bonus we will calculate the attack again\n damage_instances = (1..damage_instances_count).map do\n # Values from weapons\n weapon_attack_points = 0\n weapon_attack_modifiers = 0\n weapon_attack_recoil_modifier = 0\n\n weapon_defense_points = 0\n weapon_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.weapons.each do |weapon|\n weapon_attack_points += weapon.attack_points\n weapon_defense_points += weapon.defense_points\n\n weapon.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n weapon_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'recoil'\n weapon_attack_recoil_modifier += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n weapon_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from rings\n rings_attack_points = 0\n rings_attack_modifiers = 0\n\n rings_defense_points = 0\n rings_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.rings.each do |ring|\n rings_attack_points += ring.attack_points\n rings_defense_points += ring.defense_points\n\n ring.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n rings_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n rings_defense_modifiers += bonus.multiplier\n end\n end\n end\n\n # Values from helmets\n helmet_attack_points = user.helmet.attack_points\n helmet_attack_modifiers = 0\n\n helmet_defense_points = user.helmet.defense_points\n helmet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.helmet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n helmet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n helmet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from body armor\n body_armor_attack_points = user.body_armor.attack_points\n body_armor_attack_modifiers = 0\n\n body_armor_defense_points = user.body_armor.defense_points\n body_armor_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.body_armor.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n body_armor_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n body_armor_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from boots\n boots_attack_points = user.boots.attack_points\n boots_attack_modifiers = 0\n\n boots_defense_points = user.boots.defense_points\n boots_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.boots.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n boots_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n boots_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from gloves\n gloves_attack_points = user.gloves.attack_points\n gloves_attack_modifiers = 0\n\n gloves_defense_points = user.gloves.defense_points\n gloves_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.gloves.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n gloves_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n gloves_defense_modifiers += bonus.multiplier\n end\n end\n\n # Values from amulet\n amulet_attack_points = user.amulet.attack_points\n amulet_attack_modifiers = 0\n\n amulet_defense_points = user.amulet.defense_points\n amulet_defense_modifiers = 0\n\n # Finding bonuses and adding to the list\n user.amulet.bonuses.each do |bonus|\n if bonus.bonus_type == 'attack'\n amulet_attack_modifiers += bonus.multiplier\n elsif bonus.bonus_type == 'defense'\n amulet_defense_modifiers += bonus.multiplier\n end\n end\n\n # Making a sum of all the points from the itens\n attack_points_sum = weapon_attack_points + rings_attack_points + helmet_attack_points + body_armor_attack_points + boots_attack_points + gloves_attack_points + amulet_attack_points\n defense_points_sum = weapon_defense_points + rings_defense_points + helmet_defense_points + body_armor_defense_points + boots_defense_points + gloves_defense_points + amulet_defense_points\n\n # Making a sum of all the bonuses from the items\n attack_modifiers_sum = weapon_attack_modifiers + rings_attack_modifiers + helmet_attack_modifiers + body_armor_attack_modifiers + boots_attack_modifiers + gloves_attack_modifiers + amulet_attack_modifiers\n defense_modifiers_sum = weapon_defense_modifiers + rings_defense_modifiers + helmet_defense_modifiers + body_armor_defense_modifiers + boots_defense_modifiers + gloves_defense_modifiers + amulet_defense_modifiers\n\n # Calculating damage, defense and recoil\n attack_total = attack_points_sum * attack_modifiers_sum\n defense_total = defense_points_sum * defense_modifiers_sum\n recoil_total = (attack_total * weapon_attack_recoil_modifier * ((attack_total / (defense_total + (E ** -attack_total))) / 100)).floor\n\n # Creating a new DamageInstance\n DamageInstance.new(attack_total, recoil_total)\n end\n\n # Returning damage instances\n damage_instances\n end",
"def display_commencement \n slow_puts(\"The battle begins! #{@combatants[0].name} vs. #{@combatants[1].name}\")\n end",
"def attacks(enemy)\n puts \"#{@name} attaque #{enemy.name}\"\n damage = compute_damage\n puts \"il lui inflige #{damage} points de dommages\"\n enemy.gets_damage(damage)\n end",
"def attack_effect_base_damage(attacker)\r\n atk = [attacker.atk - self.pdef / 2, 0].max\r\n self.damage = atk * (20 + attacker.str) / 20\r\n end",
"def hit\n self.damage = damage + 1\n check_boat\n end",
"def caste_based_details(caste)\n case caste\n when \"Slave, Labor\"\n\n @@endurance += d(10)\n @@strength += d(10)\n @@intelligence = [@@intelligence - d(10), 1].max\n @@perception = [@@perception - d(6), 1].max\n @@outfittingcode = \"Escaped Prisoner\"\n puts \"+d10 to Endurance and Strength; -d10 to Intelligence, -d6 to Perception.\"\n bounty_chance(32,(20 + (d(6) + d(6) + d(6))))\n\n\n when \"Slave, Kitchen\"\n\n @@endurance = [@@endurance - d(6), 1].max\n @@strength = [@@strength - d(6), 1].max\n @@intelligence += d(6)\n @@willpower = [@@willpower - d(12), 1].max\n @@outfittingcode = \"Escaped Prisoner\"\n bounty_chance(27,(20 + (d(6) + d(6) + d(6))))\n\n when \"Slave, Servant\"\n\n @@endurance = [@@endurance - d(6), 1].max\n @@strength = [@@strength - d(6), 1].max\n @@intelligence += d(6)\n @@perception += d(6)\n @@willpower = [@@willpower - d(6), 1].max\n @@outfittingcode = \"Escaped Prisoner\"\n @@misc_skill_rolls += 1\n bounty_chance(76,(100 + (d(6) + d(6) + d(6))))\n @@literacy = \"Literate\"\n\n when \"Slave, Whore\"\n\n @@endurance = [@@endurance - d(6), 1].max\n @@strength = [@@strength - d(6), 1].max\n @@intelligence = [@@intelligence - d(6), 1].max\n @@willpower = [@@willpower - d(6), 1].max\n @@appearance += d(6)\n @@outfittingcode = \"Escaped Prisoner\"\n @@skills << \"Erotic Arts\"\n bounty_chance(82,(100 + (d(4) * 25)))\n\n when \"Slave, Court\"\n\n @@endurance = [@@endurance - d(6), 1].max\n @@strength = [@@strength - d(6), 1].max\n @@intelligence = [@@intelligence - d(6), 1].max\n @@perception += d(6)\n @@willpower = [@@willpower - d(6), 1].max\n @@appearance += d(6)\n @@outfittingcode = \"Escaped Prisoner\"\n @@misc_skill_rolls += d(3)\n bounty_chance(87,(100 + (d(4) * 25)))\n @@literacy = \"Literate\" # assumption\n @@number_of_languages += d(4)\n @@character_notes << \"Has a fairly accurate knowledge of the political and geographic layout of the region.\"\n\n\n when \"Slave, Gladiator\"\n\n @@endurance += (d(10) + d(10))\n @@strength += (d(10) + d(10))\n @@agility += d(8)\n @@accuracy += d(8)\n @@intelligence = [@@intelligence - d(10), 1].max\n @@perception += d(8)\n @@willpower = [@@willpower - d(4), 1].max\n @@appearance = [@@appearance - (d(8) + d(8)), 1].max\n @@outfittingcode = \"Escaped Prisoner\"\n d(3).times do\n @@skills << \"Brawling\"\n end\n @@warrior_skill_rolls += (4+(rand(1..4)))\n bounty_chance(94,(200 + (d(100) + d(100))))\n literacy_chance(2,0)\n\n\n when \"Fisher\"\n\n @@endurance += d(6)\n @@strength += d(6)\n @@perception += d(8)\n @@outfittingcode = \"Poor\"\n d(3).times do\n @@skills << \"Spear Weapons\"\n end\n @@misc_skill_rolls += 1\n @@equipment << \"collapsible wooden fishing rod with reel\";\"30m of fshing line\";\"fishing hooks and lures\";\n \"small fshing net\";\"fishing spear/harpoon\"\n literacy_chance(6,0)\n\n when \"Hunter\"\n\n @@endurance += d(8)\n @@strength += d(8)\n @@agility += d(6)\n @@accuracy += d(6)\n @@perception += d(8)\n @@outfittingcode = \"Poor\"\n d(3).times do\n @@skills << \"Weapons Expert: Bow\"\n end\n @@skills << \"Wilderness Survival\"\n @@misc_skill_rolls += 1\n @@character_notes << \"Accustomed to being outdoors, knows most animals by their tracks, and can start a fre with mere sticks, knows how to conceal the fre at night, make simple shelters, snares and deadfall traps.\"\n\n when \"Miner\"\n\n @@endurance += d(10)\n @@strength += (d(10) + (rand(1..10)))\n @@appearance = [@@appearance - d(6), 1].max\n @@outfittingcode = \"Poor\"\n d(3).times do\n @@skills << \"Weapons Expert: Pickaxe\"\n end\n @@misc_skill_rolls += 1\n @@equipment << \"shovel\"; \"pickaxe\"; \"#{d(20) + d(20) + d(20)} m rope\"; \"lantern and oil\"\n literacy_chance(5,0)\n\n when \"Logger\"\n\n @@endurance += d(8)\n @@strength += d(8)\n @@agility += d(6)\n @@perception += d(6)\n @@appearance = [@@appearance - d(3), 1].max\n @@outfittingcode = \"Poor\"\n d(3).times do\n @@skills << \"Weapons Expert: Axe\"\n end\n @@misc_skill_rolls += 1\n @@equipment << \"hatchet\"; \"logger's double-headed axe (battle axe)\"\n @@character_notes << \"+3 initiative in encounters with carnivorous mutant plants\"\n literacy_chance(6,0)\n\n when \"Farmer\"\n\n @@endurance += d(6)\n @@strength += d(6)\n @@perception += d(6)\n @@outfittingcode = 'Poor'\n d(3).times do\n @@skills << \"Weapons Expert: Pitchfork\"\n end\n @@misc_skill_rolls += 1\n @@character_notes << \"Can throw pitchfork 2x typical range\"\n literacy_chance(4,32)\n\n when \"Nomad\"\n\n @@agility += d(10)\n @@perception += d(6)\n @@outfittingcode = \"Poor\"\n d(3).times do\n @@skills << \"Rider\"\n end\n @@skills << \"Navigate by Stars\"\n @@misc_skill_rolls += d(3)\n literacy_chance(13,18)\n\n when \"Trader\"\n def trader_background(roll)\n case roll\n when 1..34\n \"self-employed traveling peddler\"\n else\n \"merchant's apprentice\"\n end\n end\n def trader_debt(roll)\n case roll\n when 1..23\n @@debts << \"Owes #{(d(1000) + d(1000) + d(1000))} to the merchant's guild of the largest regional free town.\"\n end\n end\n @@intelligence += (d(10) + (d(10)))\n @@perception += d(10)\n @@outfittingcode = \"Well Equipped\"\n @@skills << \"Barter\"\n @@misc_skill_rolls += (1 + d(3))\n @@character_notes << \"Was a #{trader_background(d(100))} before becoming an excavator.\"\n @@number_of_languages += d(4)\n @@literacy = \"Literate\"\n @@do_math = \"Can do math\"\n @@money += (d(100) + d(100))\n trader_debt(d(100))\n\n when \"Craftsperson\"\n def craft_specialty(roll) # Hub Rules p. 14\n case roll\n when 1\n \"glass and plastic jeweler\"\n when 2\n \"potter\"\n when 3\n \"leatherworker\"\n when 4\n \"fletcher/arrow crafter\"\n when 5\n \"beer and wine brewer\"\n when 6\n \"paper maker\"\n when 7..8\n \"cook at an inn\"\n when 9\n \"visual art (maps, signs, insignia, wanted posters, etc.)\"\n when 10\n \"smithy assistant\"\n when 11\n \"weaver\"\n when 12\n \"butcher's assistant\"\n when 13\n \"glass blower\"\n when 14\n \"tattoo artist\"\n when 15..19\n \"carpenter's assistant\"\n when 20\n \"stone mason's assistant\"\n end\n end\n if @@intelligence >= 35\n @@literacy = \"Literate\"\n end\n @@character_notes << \"Before becoming an excavator, worked as a #{craft_specialty(d(20))}\"\n\n when \"Student\"\n\n @@endurance = [@@endurance - d(6), 1].max\n @@strength = [@@strength - d(6), 1].max\n @@intelligence += (d(10) + d(10) + d(10))\n @@appearance += d(6)\n @@outfittingcode = \"Modest\"\n @@educated_skill_rolls += (d(6) + d(6) + 2)\n @@misc_skill_rolls += d(2)\n @@number_of_languages += d(4)\n @@literacy = \"Literate\"\n @@do_math = \"Can do math\"\n\n when \"Scribe\"\n def scribe_past(roll)\n case roll\n when 1..66\n \"local government\"\n else\n \"powerful merchant\"\n end\n end\n bounty_chance(22,(250 + (d(100) + d(100))))\n if @@bounty_offered == \"Yes\"\n @@bounty_offered = \"Yes (death)\"\n @@character_notes << \"Certain secrets crossed this scribe's desk, resulting in a hefty bounty...\"\n end\n @@endurance = [@@endurance - d(6), 1].max\n @@strength = [@@strength - d(6), 1].max\n @@perception += d(6)\n @@outfittingcode = \"Modest\"\n @@educated_skill_rolls += d(3)\n @@misc_skill_rolls += 1\n @@literacy = \"Literate\"\n @@do_math = \"Advanced math\"\n @@character_notes << \"Scribe worked for a #{scribe_past(d(100))} and has a clear knowledge of regional settlements and political climate.\"\n @@number_of_languages += (d(3) + 1)\n\n when \"Technician\"\n\n @@agility += d(3)\n @@accuracy += d(3)\n @@intelligence += (d(8) + rand(1..8))\n @@outfittingcode = \"Well Equipped\"\n @@tech_skill_rolls += (d(6) + rand(1..6))\n @@educated_skill_rolls += rand(1..2)\n @@misc_skill_rolls += d(3)\n bounty_chance(28,(200 + (d(100) + d(100))))\n\n when \"Street Urchin\"\n def urchin_past(roll)\n case roll\n when 1..26\n \"runaway\"\n else\n \"orphan\"\n end\n end\n def urchin_outlaw(roll)\n case roll\n when 1..6\n @@character_notes << \"Wanted by the law: if arrested in hometown, faces #{(d(6) + d(6))}-year prison sentence\"\n end\n end\n def urchin_debt(roll)\n case roll\n when 1..12\n @@debts << \"Owes #{(d(100) + d(100) + d(100))} to former gang in home town, who'll beat and rob the character if s/he returns.\"\n end\n end\n @@character_notes << \"Character was a/an #{urchin_past(d(100))} before becoming an excavator.\"\n @@endurance = [@@endurance - d(6), 1].max\n @@strength = [@@strength - d(3), 1].max\n @@agility += d(10)\n @@accuracy += d(6)\n @@appearance = [@@appearance - d(6), 1].max\n @@outfittingcode = \"Impoverished\"\n #skills: brawling d3; criminal d3+1; 1 misc roll\n @@criminal_skill_rolls += d(3)\n @@misc_skill_rolls += 1\n d(3).times do\n @@skills << \"Brawling\"\n end\n urchin_debt(d(100))\n\n when \"Street Thug\"\n\n @@endurance += (d(6) + d(6))\n @@strength += (d(6) + + d(6))\n @@intelligence = [@@intelligence - d(6), 1].max\n @@appearance = [@@appearance - d(6), 1].max\n @@outfittingcode = \"Poor\"\n #skills: brawling d4; criminal 2; warrior 2; 1 roll on misc table\n d(4).times do\n @@skills << \"Brawling\"\n end\n @@criminal_skill_rolls += 2\n @@warrior_skill_rolls += 2\n @@misc_skill_rolls += 1\n literacy_chance(14,19)\n bounty_chance(15,\"Death\")\n\n when \"Raider\"\n def has_horse(roll)\n case roll\n when 1..36\n @@equipment << \"Saddle horse\"\n end\n end\n @@endurance += d(10)\n @@strength += d(10)\n @@outfittingcode = \"Poor\"\n #skills: rider d3; criminal 2; warrior 2; 1 roll on misc table\n d(3).times do\n @@skills << \"Riding\"\n end\n @@criminal_skill_rolls += 2\n @@warrior_skill_rolls += 2\n @@misc_skill_rolls += 1\n has_horse(d(100))\n literacy_chance(16,21)\n @@character_notes << \"9% chance per encounter with any raiders character is recognized, and raiders will (d6: 1-3. try and sell him as a slave/ 4,5. forcibly enlist him and his companions / 6. kill him.)\"\n\n when \"Pirate\"\n\n @@endurance += d(10)\n @@strength += d(10)\n @@outfittingcode = \"Poor\"\n #skills: navigate by stars 1; criminal 2; warrior 2; 1 roll on misc table\n @@skills << \"Navigate by Stars\"\n @@criminal_skill_rolls += 2\n @@warrior_skill_rolls += 2\n @@misc_skill_rolls += 1\n literacy_chance(9,12)\n @@character_notes << \"In any encounters with pirates, character is 46% likely to be recognized by a crew member. If so, she will be deemed a traitor to her caste and either stripped and sold as a slave, after a good flogging (01-79% chance), or (80-00%) drawn and quartered on the spot.\"\n\n when \"Thief\"\n\n @@endurance = [@@endurance - d(3), 1].max\n @@strength = [@@strength - d(3), 1].max\n @@agility += d(12)\n @@accuracy += d(8)\n @@outfittingcode = \"Impoverished\"\n #skills: brawling 1; criminal d3+4; 1 roll on misc table\n @@skills << \"Brawling\"\n @@criminal_skill_rolls += (d(3) + 4)\n @@misc_skill_rolls += 1\n literacy_chance(17,24)\n # @@equipment << \"lock pick set\", \"30m of rope\", \"a dark cloak\", \"soft boots for quiet walking\"\n bounty_chance(57,(d(100) + d(100) + d(100) + d(100)))\n if @@bounty_value > 0\n @@character_notes << \"In hometown, 78% likely character is recognized and 2d6 raiders are sent to cripple and rob her, plus any associates she might travel with.\"\n end\n\n when \"Assassin\"\n\n @@endurance += d(6)\n @@strength += (d(6) + (rand(1..6)))\n @@agility += d(10)\n @@accuracy += d(10)\n @@perception += d(10)\n @@outfittingcode = \"Fully Armed\"\n #skills: martial arts d4; knife throwing d3; criminal d3; warrior d6; 1 roll on misc table\n d(4).times do\n @@skills << \"Martial Arts\"\n end\n d(3).times do\n @@skills << \"Knife Throwing\"\n end\n @@criminal_skill_rolls += d(3)\n @@warrior_skill_rolls += d(6)\n @@misc_skill_rolls += 1\n\n @@equipment << \"black cloak and ninja style outfit (in addition to regular streeth clothes)\"\n def assassin_poison(roll)\n case roll\n when 1..7\n @@equipment << \"100ml of type C death poison (10ml needed to coat a blade and potentially poison anybody who is punctured)\"\n end\n end\n assassin_poison(d(10))\n @@character_notes << \"In each encounter with bounty hunters, 41% chance character wanted dead.\"\n @@character_notes << \"While entering any town while not in disguise, 13% chance per day that the assassin’s brotherhood have located him and will send d6+2 members after him that night.\"\n\n when \"Draftee\"\n def draftee_history(roll)\n case roll\n when 1..87\n \"Drafted for home town militia\"\n else\n \"Drafted while visiting a neighboring town\"\n end\n end\n @@endurance += d(3)\n @@strength += d(3)\n @@outfittingcode = \"Modest\"\n #skills: warrior 1; misc d2\n @@warrior_skill_rolls += 1\n @@misc_skill_rolls += d(2)\n literacy_chance(28,33)\n @@character_notes << \"73% chance upon returning to town where drafted, she'll be recognized and arrested. d6: 1-3. hang her from the nearest tree/ 4,5. sell her as a slave/ 6. put her in jail for 2d6 months before drafting her back into the army, but chain her at night.\"\n\n when \"Militia Soldier\"\n\n @@endurance += d(6)\n @@strength += d(6)\n @@outfittingcode = \"Modest\"\n #skills: warrior d3; misc d2\n @@warrior_skill_rolls += d(3)\n @@misc_skill_rolls += d(2)\n literacy_chance(32,39)\n\n when \"Watchman\"\n\n @@endurance += d(6)\n @@strength += d(10)\n @@perception += d(10)\n @@outfittingcode = \"Well Equipped\"\n #skills: brawling d3; warrior d3; misc d2\n d(3).times do\n @@skills << \"Brawling\"\n end\n @@warrior_skill_rolls += d(3)\n @@misc_skill_rolls += d(2)\n @@character_notes << \"not well liked in his home town, and if he returns, there is a 17% chance that a mob of 2d8 raiders will somehow try to corner him and his associates, and beat them soundly, if not kill them.\"\n literacy_chance(22,31)\n\n when \"Infantryman\"\n def infantry_history(roll)\n case roll\n when 1..68\n @@character_notes << \"Deserter. 47% chance per encounter with city's/nation's army, character recognized and jailed 2d6 years.\"\n @@enemies << \"City/nation army character previously served with.\"\n when 69..89\n @@character_notes << \"Retiree from the army. 47% chance per encounter with city's/nation's army, character recognized, saluted, and assisted.\"\n when 90..100\n @@character_notes << \"AWOL - was sole survivor of an operation and never returned to active duty. 47% chance per encounter with city's/nation's army, character recognized and reassigned to a new unit.\"\n end\n end\n infantry_history(d(100))\n @@endurance += d(12)\n @@strength += d(12)\n @@outfittingcode = \"Well Equipped\"\n #skills: warrior d6; misc d2\n @@warrior_skill_rolls += d(6)\n @@misc_skill_rolls += d(2)\n literacy_chance(15,22)\n\n when \"Cavalry\"\n def cavalry_history(roll)\n case roll\n when 1..68\n @@character_notes << \"Deserter. 47% chance per encounter with city's/nation's army, character recognized and jailed 2d6 years.\"\n when 69..89\n @@character_notes << \"Retiree. 47% chance per encounter with city's/nation's army, character recognized, saluted, and assisted.\"\n when 90..100\n @@character_notes << \"AWOL - was sole survivor of an operation and never returned to active duty. 47% chance per encounter with city's/nation's army, character recognized and reassigned to a new unit.\"\n end\n end\n cavalry_history(d(100))\n @@endurance += d(10)\n @@strength += d(12)\n @@agility += d(3)\n @@outfittingcode = \"Well Equipped\"\n #skills: riding d6; warrior d4; misc d2\n d(6).times do\n @@skills << \"Riding\"\n end\n @@warrior_skill_rolls += d(4)\n @@misc_skill_rolls += d(2)\n literacy_chance(15,22)\n\n when \"Mercenary\"\n def mercenary_bonus_skills(roll1,roll2,roll3,roll4,roll5,roll6)\n case roll1\n when 1..36\n d(3).times do\n @@skills << \"Gambling\"\n end\n end\n case roll2\n when 1..14\n @@skills << \"Negotiation\"\n end\n case roll3\n when 1..32\n d(3).times do\n @@skills << \"Lying\"\n end\n end\n case roll4\n when 1..29\n d(3).times do\n @@skills << \"Riding\"\n end\n end\n case roll5\n when 1..32\n @@criminal_skill_rolls += d(3)\n end\n case roll6\n when 1..43\n @@equipment << \"Riding horse\"\n end\n end\n def mercenary_history(roll)\n case roll\n when 1..87\n @@character_notes << \"Left mercenary employment on good terms.\"\n when 88..100\n @@character_notes << \"14% likely per every meeting with mercenaries in that region that he will run into his own squad, who will be angry that he left and rob and sell him into slavery, along with any companions.\"\n end\n end\n mercenary_bonus_skills(d(100),d(100),d(100),d(100),d(100),d(100))\n mercenary_history(d(100))\n @@endurance += d(10)\n @@strength += d(10)\n @@agility += d(6)\n @@accuracy += d(6)\n @@outfittingcode = \"Well Equipped\"\n #skills: brawling d3; warrior d6; misc d4\n d(3).times do\n @@skills << \"Brawling\"\n end\n @@warrior_skill_rolls += d(6)\n @@misc_skill_rolls += d(4)\n literacy_chance(18,27)\n\n when \"Elite Soldier\"\n def elite_soldier_history(roll)\n case roll\n when 1..38\n @@character_notes << \"Retired from military service.\"\n else\n case bounty_roll(roll)\n when 1..73\n @@bounty_offered = (200 + d(100) + d(100))\n @@enemies << \"Squad of #{d(6) + d(6) + d(6)} from former military company hunting this character.\"\n end\n bounty_roll(d(100))\n end\n end\n elite_soldier_history(d(100))\n @@endurance += (d(8) + (rand(1..8)))\n @@strength += (d(8) + (rand(1..8)))\n @@agility += d(8)\n @@accuracy += d(8)\n @@willpower += d(8)\n @@outfittingcode = \"Well Equipped\"\n #skills: brawling d4; warrior d6+4; misc d4\n d(4).times do\n @@skills << \"Brawling\"\n end\n @@warrior_skill_rolls += (4 + d(6))\n @@misc_skill_rolls += d(4)\n literacy_chance(34,41)\n\n else puts \"Hmm... looks like caste-based attributes and skills assignment screwed up. Debug mofo!\"\n\n end\n\nend",
"def fight\n display_hero_attack(attack_resolver(hero, monster))\n if monster.current_health > 0\n display_monster_attack(attack_resolver(monster, hero))\n else\n hero_win\n end\n end",
"def perform_melee_attack!\n # First the regular attack\n @attack = AttackAtomicStep.new( @attacking_unit, @defending_unit, :melee, :attack )\n attack_hits = @attack.roll_attack\n\n puts @attack.to_s if @verbose\n\n if @attack.attack_type == :cac\n # If attack was cac then we perform the retail\n @retaliation = AttackAtomicStep.new(@defending_unit, @attacking_unit, :melee, :retaliation )\n retail_hits = @retaliation.roll_attack\n\n puts @retaliation.to_s if @verbose\n\n # Hits must be assigned after the fight.\n @hits_history.retailing_unit = HitsAssignment.new(\n @attacking_gang, @attacking_unit, verbose: @verbose ).assign_hits!( retail_hits )\n end\n\n # And the attacking hits\n @hits_history.attacking_unit = HitsAssignment.new(\n @defending_gang, @defending_unit, verbose: @verbose ).assign_hits!( attack_hits )\n end",
"def fight( enemy, weapon )\n if life <= 0\n puts \"[#{ self.class } is too dead to fight!]\"\n return\n end\n \n # Attack the opponent\n your_hit = rand( strength + weapon )\n puts \"[You hit with #{ your_hit } points of damage!]\"\n enemy.hit( your_hit )\n\n # Retaliation\n puts \"[#{ enemy.class } has #{enemy.life} life remaining!!]\"\n if enemy.life > 0\n enemy_hit = rand( enemy.strength + enemy.weapon )\n puts \"[Your enemy hit with #{ enemy_hit } points of damage!]\"\n self.hit( enemy_hit )\n end\n end",
"def creature; end",
"def creature; end",
"def creature; end",
"def creature; end",
"def attack_effect_damage\r\n self.hp -= self.damage\r\n end",
"def take_damage amt, name, sym, message\n @hp -= amt\n @last_hit_by = name\n @kill_type = sym\n hear_line message\n # check if you died?\n end",
"def action\n if taking_damage?\n taking_damage_action\n elsif @warrior.feel.stairs? #&& ground_covered?\n @warrior.walk!\n elsif @warrior.feel.empty? && @warrior.health < MAX_HEALTH\n @warrior.rest!\n elsif @warrior.feel.enemy?\n @warrior.attack!\n elsif @warrior.feel.captive?\n @warrior.rescue!\n elsif @warrior.feel.empty?\n @warrior.walk!\n elsif @warrior.feel.wall?\n @warrior.pivot!(:backward)\n end\n end",
"def attacks(player)\r\n puts \"#{@name} attaque le joueur #{player.name}\"\r\n player.gets_damage(compute_damage)\r\n end",
"def being_attacked\n\tif @enemy_health > 0\n\t\t@enemy_power -= rand(-3..3)\n\t\tputs \"The #{@enemy} attacks again, doing #{@enemy_power - @defense} damage.\"\n\t\t@health -= (@enemy_power - @defense)\n\t\tfight\n\telse\n\t\tputs \"You beat the #{@enemy}!\"\n\t\tputs \"\"\n\t\tputs \"+#{@enemy_power + rand(9) + (@luck * @luck_points)} pointless points!\"\n\t\t@pointless_points += (@enemy_power + rand(9) + (@luck * @luck_points))\n\t\tcontroller\n\tend\nend",
"def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}.\"\n # On récupère le nombre de points de dommage correspondant au lancer de dé via la méthode compute_damage\n damage_points = compute_damage\n puts \"Il lui inflige #{damage_points} points de dommage.\"\n # Ces points de dommage sont infligés à player. Si player n'a plus de points de vie, le programme affiche qu'il est mort.\n player.get_damage(damage_points)\n end",
"def attack(player)\n player.receive_damage\n end",
"def award\n\tend",
"def decide_action(char)\n # temporary variables\n dir, x, y, ai = char.direction, char.x, char.y, char.ai\n pix = $BlizzABS.pixel\n # get alignment setup\n negative, positive = ai.negative, ai.positive\n # invert setup if confused\n negative, positive = positive, negative if char.restriction == 3\n # get all enemies in sight\n in_sight_e = ai.sight.find_all {|b| negative.include?(b.ai.group)}\n # if no enemies are available\n if in_sight_e.size == 0\n # initialize\n in_sight_a, in_range = [], ai.memory.keys\n # get all allies and enemies in range\n in_range.each {|b|\n in_sight_a.push(b) if positive.include?(b.ai.group)\n in_sight_e.push(b) if negative.include?(b.ai.group)}\n # if still no enemies are available\n if in_sight_e.size == 0\n # initialize again\n in_sight_a = []\n # get all allies and enemies from memory\n ai.memory.each_key {|b|\n in_sight_a.push(b) if positive.include?(b.ai.group)\n in_sight_e.push(b) if negative.include?(b.ai.group)}\n end\n else\n # get all allies in sight\n in_sight_a = ai.sight.find_all {|b| positive.include?(b.ai.group)}\n end\n # exit if no enemies are in sight\n return if in_sight_e.size == 0\n # if actor\n if char.is_a?(Map_Actor)\n # exit if \"no enemies\" are in sight\n return if in_sight_e.size == 0\n # get radius reach of player\n rad = $BlizzABS.util.get_player_radius\n # find all enemies within radius according to aggressiveness\n in_radius = in_sight_e.find_all {|e|\n Math.hypot(char.x / pix - e.x / pix, char.y / pix - e.y / pix) <=\n rad * char.ai.aggressive / 15}\n # check next trigger if action can't be executed\n return if in_radius.size == 0\n # add self as ally\n in_sight_a.push(char)\n # if confused or no trigger action was set up\n if char.restriction == 3 ||\n !trigger_actor_action(char, in_sight_a, in_sight_e)\n # set up advanced action based on Blizz-ABS AI\n advanced_actor_action(char)\n end\n # if enemy\n elsif char.is_a?(Map_Enemy)\n # if action attribute is not active\n if !ai.actions\n # decide normal action\n char.battler.make_action\n # temporary variable\n act = char.battler.current_action\n # set up the action in Blizz-ABS as normal action\n normal_action(char, in_sight_a, in_sight_e, (act.kind == 0),\n act.basic, rand(31) + 70, 80, act.skill_id)\n else\n # set up advanced action based on Blizz-ABS AI\n advanced_enemy_action(char)\n end\n end\n # if target doesn't exist or forced moving\n if ai.target == nil || !ai.target.valid?\n # reset action\n char.reset_action\n # if not being force moved\n elsif char.is_a?(Map_Enemy) && char.move_type != 3\n # set path request state\n ai.state = Request\n # turn toward the target not to lose it out of sight\n char.turn_toward(ai.target)\n # request a path\n request_path(char, ai.target)\n end\n end",
"def after_battle_effect\n case $game_process\n when 0\n framed_narration('After having a quick break in the tent, you felt refreshed.(HP restored)')\n @player[:hp] = 45\n when 1\n framed_narration('You had a BBQ around the campfire and felt energised to move on. (HP restored)')\n @player[:hp] = 45\n when 2\n framed_narration('Donkey Kong fainted, and the illusion of the Jungle was expelled.')\n next_line\n framed_narration('Congrats! you have completed the game!')\n next_line\n framed_narration('Thanks for playing! See you in the future!')\n next_line\n framed_narration('-- Mark Huang')\n exit\n end\n end",
"def attacks(player)\n puts \"#{@name} attaque #{player.name}\"\n damage = compute_damage\n puts \" il lui inflige #{damage} points dommages\"\n player.gets_damage(damage)\n end",
"def attack() stat(:attack) end",
"def attack_effect_dispersion\r\n if self.damage.abs > 0\r\n amp = [self.damage.abs * 15 / 100, 1].max\r\n self.damage += rand(amp+1) + rand(amp+1) - amp\r\n end\r\n end",
"def fight\n @state.fight(self)\n end",
"def attack(opponent)\n\t\tmoveNumber = Random.new.rand(1..3)\n\t\tif(moveNumber == 1)\n\t\t\tp @name + \" kicks \"+ opponent.name #+\" loses 3 HP\"\n\t\t\topponent.HP-=3\n\t\t\tp opponent.name + \" loses 3 HP. His new HP is\"\n\t\t\tp opponent.HP\n\t\telsif(moveNumber == 2)\n\t\t\tp @name + \" scrachs \"+opponent.name #+\" loses 2 HP\"\t\n\t\t\tp opponent.name + \" loses 2 HP. His new HP is\"\n\t\t\topponent.HP-=2\n\t\t\tp opponent.HP\n\t\telsif(moveNumber == 3)\n\t\t\tp @name + \" bites \"+opponent.name #+\" loses 1 HP\"\n\t\t\tp opponent.name + \" loses 1 HP. His new HP is\"\n\t\t\topponent.HP-=1\n\t\t\tp opponent.HP\n\t\tend\n\tend",
"def affichage_player\n\n\n end",
"def attacks(victim)\n #AFFICHE LE JOUEUR ATTAQUANT SA VICTIME\n puts \"le joueur #{self.names} attaque le joueur #{victim.names}\"\n\n #DAMAGE_COMPUTED PREND LA VALEUR DU NOMBRE OBTENU ALEATOIREMENT\n damage_computed = compute_damage\n\n #AFFICHE LE NOMBRE DE DOMMAGES INFLIGES\n puts \"il lui inflige #{damage_computed} points de dommages\"\n\n #VICTIM RECOIS LES DOMMAGES\n victim.gets_damage(damage_computed)\n end",
"def give_bonus player\n player.add_1_life\n end",
"def get_actions ()\n\n #acciones del personaje que esta jugando\n player_character.base_card.base_actions.each do |action|\n actions.create!(base_action_id: action.id)\n end\n\n #acciones por distritos morados\n\n purple_districts = districts_on_game.where(\"colour = 'purple' AND name not in ('lighthouse', 'bell_tower')\")\n purple_districts.each do |district|\n district.base_card.base_actions.each do |action|\n actions.create!(base_action_id: action.id)\n end\n end\n\n\n character = player_character.base_card.name\n\n case character\n when 'merchant'\n current_coins = coins\n update_attribute(:coins, current_coins + 1)\n when 'architect'\n card_list = party.cards.districts.where(\"player_id is NULL\").order('position').limit(2)\n card_list.each do |card|\n Card.update(card.id, :state => 'ONHAND', :player_id => id)\n end\n end\n\n\n\n end",
"def handle\r\n action_klass = Battle.find_action_klass(self.combat_command)\r\n if (!action_klass)\r\n client.emit_failure t(battle.unknown_command)\r\n return\r\n end\r\n\r\n self.names.each do |name|\r\n\r\n Battle.with_a_combatant(name, client, enactor) do |combat, combatant|\r\n if (combatant.is_subdued? && self.combat_command != \"escape\")\r\n client.emit_failure t('battle.must_escape_first')\r\n next\r\n end\r\n Battle.set_action(client, enactor, combat, combatant, action_klass, self.action_args)\r\n end\r\n end\r\n end",
"def pbAfterBattle(decision,canlose)\n for i in $Trainer.party\n (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil)\n end\n if $PokemonGlobal.partner\n pbHealAll\n for i in $PokemonGlobal.partner[3]\n i.heal\n (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil)\n end\n end\n if decision==2 || decision==5 # if loss or draw\n if canlose\n for i in $Trainer.party; i.heal; end\n for i in 0...10\n Graphics.update\n end\n end\n end\n Events.onEndBattle.trigger(nil,decision,canlose)\nend",
"def enemies_attack\r\n puts \"Les ennemies vous attaquent\"\r\n @enemies.each{|player| player.attacks(@human_player)}\r\n end",
"def use_potion\n character = Character.find(params[:character_id])\n enemy = Game.determine_enemy(params[:enemy_class], params[:enemy_id])\n\n # if the battle is still going on and it's against an \"enemy\" type, it loads back into the battle \n if Game.continue_battle?(enemy, character) && enemy.class.name == \"Enemy\"\n response = character.use_potion\n character.update_health(enemy)\n flash[:notice] = response\n redirect_to user_game_path(current_user,character.game, :enemy_type => \"enemy\")\n\n # if the battle is still going on and it's against an \"boss\" type, it loads back into the battle \n elsif Game.continue_battle?(enemy, character) && enemy.class.name == \"Boss\"\n response = character.use_potion\n character.update_health(enemy)\n flash[:notice] = response\n redirect_to user_game_path(current_user,character.game, :enemy_type => \"boss\")\n \n else\n # if the player is killed during a heal attempt, they load back into the character screen\n flash[:notice] = \"You were defeated, and returned to the character page\"\n character.revive\n redirect_to user_character_path(current_user, character)\n end\n end",
"def advanced_enemy_action(char)\n # initialize basic action\n attack = defend = escape = false\n # initialize skill action\n dmg, heal, neutral = [], [], []\n # iterate through all actions\n char.battler.actions.each {|action|\n # conditions\n n = $game_temp.battle_turn\n a = action.condition_turn_a\n b = action.condition_turn_b\n # skip if conditions are not fulfilled\n next if b == 0 && n != a || b > 0 && (n < 1 || n < a || n % b != a % b)\n next if char.battler.hp * 100.0 / char.battler.maxhp > action.condition_hp\n next if $game_party.max_level < action.condition_level\n switch_id = action.condition_switch_id\n next if switch_id > 0 && !$game_switches[switch_id]\n # depending on which basic type of action\n case action.kind\n when 0 # basic action\n case action.basic\n when 0 then attack = true\n when 1 then defend = true\n when 2 then escape = true\n end\n when 1 # skill action\n # if skill can be used\n if char.skill_can_use?(action.skill_id)\n # if damaging skill\n if $data_skills[action.skill_id].power > 0\n # add to array of damaging skills\n dmg.push(action.skill_id)\n # if healing skill\n elsif $data_skills[action.skill_id].power < 0\n # add to array of healing skills\n heal.push(action.skill_id)\n else\n # add to array of neutral skills\n neutral.push(action.skill_id)\n end\n end\n end}\n # decide a target\n decide_target(char, dmg, heal, neutral, attack, defend, escape)\n end"
] | [
"0.74400353",
"0.7438527",
"0.73380214",
"0.7261905",
"0.707193",
"0.6778616",
"0.6581202",
"0.6542766",
"0.65268683",
"0.6475391",
"0.64686334",
"0.6422843",
"0.6419648",
"0.64079475",
"0.640092",
"0.6381136",
"0.6378247",
"0.6378247",
"0.63596094",
"0.63396055",
"0.6331795",
"0.6328809",
"0.630845",
"0.6304847",
"0.62865007",
"0.6277761",
"0.62658954",
"0.6252292",
"0.6252292",
"0.6252292",
"0.6252292",
"0.6242105",
"0.624158",
"0.62387145",
"0.6223537",
"0.6202354",
"0.6202354",
"0.6198403",
"0.6154048",
"0.61440605",
"0.612615",
"0.6116727",
"0.6113284",
"0.6109652",
"0.60950536",
"0.609486",
"0.6086322",
"0.60738367",
"0.6066946",
"0.60607064",
"0.6050856",
"0.6041961",
"0.60396206",
"0.60286963",
"0.60088366",
"0.5995332",
"0.5994826",
"0.5990866",
"0.5983631",
"0.59834415",
"0.59827864",
"0.59813875",
"0.5978928",
"0.59704477",
"0.59692574",
"0.5968354",
"0.59669113",
"0.59625787",
"0.5958587",
"0.59569186",
"0.59555244",
"0.5954712",
"0.59525084",
"0.59525084",
"0.59525084",
"0.59525084",
"0.5950806",
"0.59492016",
"0.5947109",
"0.59469545",
"0.5944785",
"0.59397364",
"0.5935607",
"0.5931725",
"0.5930825",
"0.5930539",
"0.5929156",
"0.59265053",
"0.5920807",
"0.5918232",
"0.59180355",
"0.5915195",
"0.5912203",
"0.5894368",
"0.5893286",
"0.5892365",
"0.58916414",
"0.58907706",
"0.5885487",
"0.58817166"
] | 0.65983874 | 6 |
method for updating a character object's hp | def update_hp(change)
self.update(hp:self.hp + change)
#check to see if the character is dead
if self.hp <= 0
#display to the user that the character is dead
puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$".blink
puts "#{self.name} IS DEAD !!!!!!!!!!!".bold.red.on_black
#destroy the object from the database
self.destroy
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hp=(hp)\n @hp = hp\n end",
"def updateHpBar\n return if self.disposed?\n # updates the current state of the HP bar\n zone = 0\n zone = 1 if self.hp <= @battler.totalhp*0.50\n zone = 2 if self.hp <= @battler.totalhp*0.25\n @sprites[\"hp\"].bitmap.blt(0,0,@colors,Rect.new(zone*2,0,2,6))\n hpbar = @battler.totalhp == 0 ? 0 : (self.hp*@hpBarWidth/@battler.totalhp.to_f)\n @sprites[\"hp\"].zoom_x = hpbar\n # updates the HP text\n str = \"#{self.hp}/#{@battler.totalhp}\"\n @sprites[\"textHP\"].bitmap.clear\n textpos = [[str,@sprites[\"textHP\"].bitmap.width,0,1,Color.white,Color.new(0,0,0,125)]]\n pbDrawTextPositions(@sprites[\"textHP\"].bitmap,textpos) if @showhp\n end",
"def heal_entity(entity, new_hp)\n entity.set_stats(hp: new_hp)\n end",
"def alter_hp(new_hp, db)\n # binding.pry\n db.execute(\"UPDATE pokemon SET hp = ? WHERE id = ?\", new_hp, self.id)\n end",
"def refresh_hp\n if @actor.hide_info?\n @hp = nil\n @maxhp = nil\n else\n @hp = @actor.hp\n @maxhp = @actor.mhp\n end\n @hp_bar.refresh(@hp, @maxhp)\n end",
"def alter_hp(new_hp, db)\n self.hp = new_hp\n sql = <<-SQL\n UPDATE pokemon \n SET hp = ?\n WHERE id = ?\n SQL\n db.execute(sql, new_hp, @id)\n end",
"def summons_change_hp(hp)\n set_summons\n for summon in @summons\n $game_actors[summon.id].hp += hp unless summon.dead?\n end\n end",
"def punch(player_name)\n\t # we change the life (hp) of our adversary, and we can because of the hp accessor ! \n\t player_name.hp = player_name.hp - 10\n\n\tend",
"def damaged\n @hp = @hp - 1\n end",
"def heal(h)\n if @health+h > @max_health\n @health = @max_health\n else\n @health += h\n end\n end",
"def alter_hp(hp,db)\n #db.execute(\"ALTER TABLE pokemon ADD COLUMN hp INTEGER DEFAULT 60 END;\") unless db.execute(\"SELECT hp FROM pokemon\")==nil\n db.execute(\"UPDATE pokemon SET hp=? WHERE id=?;\",hp,self.id)\n #id=db.execute(\"SELECT id FROM pokemon WHERE name='Pikachu'\")[0][0]\n #if @name='Pikachu' {@hp=hp}\n #puts Pokemon.find(1, @db).name\n #puts self.hp\n\n end",
"def heal!\n @health_remaining = @max_health\n end",
"def alter_hp(new_hp, db)\n #self is an instance (individual pokemon) of the Pokemon class\n #self.id is id number\n #need to find the right pokemon, then UPDATE hp column\n update = db.prepare(\"UPDATE pokemon SET hp = ? WHERE id = ?\")\n update.execute(new_hp, self.id)\n end",
"def draw_actor_hp(actor, x, y, width = 144, fake = false)\n self.contents.font.size = Scan_Window_Font_Size\n self.contents.font.color = system_color\n self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)\n self.contents.font.color = actor.hp == 0 ? knockout_color :\n actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color\n hp_x = x + width - 108\n hp = fake ? '????' : actor.hp.to_s\n self.contents.draw_text(hp_x, y, 48, 32, hp, 2)\n self.contents.font.color = normal_color\n self.contents.draw_text(hp_x + 48, y, 12, 32, '/', 1)\n self.contents.font.bold = true\n maxhp = fake ? '????' : actor.maxhp.to_s\n self.contents.draw_text(hp_x + 60, y, 48, 32, maxhp)\n self.contents.font.bold = false\n end",
"def heal\n 2.times { super } # or self.helth = [self.helth + 2, MAX_HEALTH].min\n 'Ready for Battle!'\n end",
"def reduce_HP\n @points -= 10\n end",
"def eat_humans\n @health += 20\n self\n end",
"def kick(player_name)\n\t\n\t player_name.hp = player_name.hp - 20\n\n\t end",
"def heal(amount)\n self.health += amount\n self.save!\n end",
"def update\n\n #Print player current life and life total to formatted string\n @life_text.text = sprintf(\"%03d/%03d\", @player.health, 100)\n\n #Print rubies gathered and rubies total to formatted string\n @score_text.text = sprintf(\"%03d/%03d\", @player.rubies_gathered, @rubies_total)\n\n #Victory! Stop timers\n if @player.state == :won then\n stop_timers()\n end\n\n #Print time limit and kill player if time has run out\n if @time_limit <= 0 && @player.state != :dead\n stop_timers()\n @player.take_damage(100)\n else\n #Print time remaining\n @time_text.text = sprintf(\"%02d:%02d\", @time_limit/60, @time_limit - (@time_limit/60)*60)\n end\n\n end",
"def update\n bosses_update\n update_boss_hp_bar\n end",
"def hp_text\n \"#@hp / #{self.max_hp}\"\n end",
"def enemy_change_hp(id, operation, operand_type, operand, allow_kill)\n # creating an interpreter\n interpreter = Interpreter.new\n # get value from data\n value = interpreter.operate_value(operation, operand_type, operand)\n # for all target enemies\n get_enemies(id).each {|enemy|\n # if actually existing enemy\n if enemy.battler != nil\n # if not allowed to kill and change would kill\n if !allow_kill && enemy.battler.hp <= -value\n # set to 1 HP\n enemy.battler.hp = 1\n else\n # change HP\n enemy.battler.hp += value\n end\n end}\n end",
"def heal_hp(count)\n @objectives.push([\n Objective::HealHp,\n {:key => Objective::HealHp::KEY, :count => count}\n ])\n end",
"def heal(_amount)\n\t\t@current_hp += _amount\n\t\t@current_hp = @hit_points if @current_hp > @hit_points\n\tend",
"def change_hp(value, enable_death)\r\n if !enable_death && @hp + value <= 0\r\n self.hp = 1\r\n else\r\n self.hp += value\r\n end\r\n end",
"def reset_hp\n @pokemon.each do |pokemon|\n pokemon.hp = pokemon.max_hp\n end\n end",
"def current_hp\n\t\t@current_hp + temp_hp\n\tend",
"def pbHPChanged(pkmn,oldhp,anim=false)\n hpchange=pkmn.hp-oldhp\n if hpchange<0\n hpchange=-hpchange\n PBDebug.log(\"[HP change] #{pkmn.pbThis} lost #{hpchange} HP (#{oldhp}=>#{pkmn.hp})\")\n else\n PBDebug.log(\"[HP change] #{pkmn.pbThis} gained #{hpchange} HP (#{oldhp}=>#{pkmn.hp})\")\n end\n pbRefresh\n end",
"def pbHPChanged(pkmn,oldhp,anim=false)\n hpchange=pkmn.hp-oldhp\n if hpchange<0\n hpchange=-hpchange\n PBDebug.log(\"[HP change] #{pkmn.pbThis} lost #{hpchange} HP (#{oldhp}=>#{pkmn.hp})\")\n else\n PBDebug.log(\"[HP change] #{pkmn.pbThis} gained #{hpchange} HP (#{oldhp}=>#{pkmn.hp})\")\n end\n pbRefresh\n end",
"def hp_rate\r\n @hp.to_f / mhp\r\n end",
"def guts_hp_recovery\n if actor?\n self.hp += (mhp * (self.actor.guts_hp_recovery_rate * 0.01)).to_i\n else\n self.hp += (mhp * (self.enemy.guts_hp_recovery_rate * 0.01)).to_i\n end\n end",
"def heal\n\t\tif self.weapon == true\n\t\t\tself.hitpoints += (self.faith + self.weapon.mending)\n\t\t\thealth_overflow_check\n\t\t\tself.save!\n\t\telse\n\t\t\tself.hitpoints += self.faith\n\t\t\thealth_overflow_check\n\t\t\tself.save!\n\t\tend\n\tend",
"def draw_actor_hp_hud(actor, x, y, w = 148)\n # calculate fill rate\n rate = (actor.maxhp > 0 ? actor.hp.to_f / actor.maxhp : 0)\n # create color depending on fill rate\n if rate > 0.6\n color1 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192) \n elsif rate > 0.2 && rate <= 0.6\n color1 = Color.new(240, 600 * (rate-0.2), 0, 192) \n elsif rate <= 0.2\n color1 = Color.new(240, 0, 0, 192)\n end\n # background color\n color2 = Color.new(0, 80, 0, 192)\n # draw bar\n self.contents.gradient_bar_simple(x + 32, y, w - 48, color1, color2, rate)\n # fix y coordinate\n y -= 9\n self.contents.font.color = system_color\n # draw HP word\n self.contents.draw_text_full(x, y, 32, 32, $data_system.words.hp)\n # set offset\n hp_x = x + w - 122\n # set colors and draw values\n self.contents.font.color = actor.hp == 0 ? knockout_color :\n actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color\n self.contents.draw_text_full(hp_x, y, 48, 32, actor.hp.to_s, 2)\n self.contents.font.color = normal_color\n self.contents.draw_text_full(hp_x + 48, y, 12, 32, '/', 1)\n self.contents.draw_text_full(hp_x + 60, y, 48, 32, actor.maxhp.to_s)\n self.contents.font.color.alpha = 255\n end",
"def attk_char(character)\n damage = self.attack_power\n if damage > 0\n character.update(hp: character.hp - damage)\n puts @@pastel.magenta(\"-----------------------------------------------------------------\".center(145))\n puts @@pastel.magenta(\"#{self.name} dealt #{damage} damage to #{character.name}!\".center(145))\n puts @@pastel.magenta(\"#{character.name} has #{character.hp} HP left!\".center(145))\n puts @@pastel.magenta(\"-----------------------------------------------------------------\".center(145))\n sleep(1)\n end\n end",
"def hp\n h / 360.0\n end",
"def draw_actor_hp(actor, x, y, width = 120)\n if actor.hide_info?\n draw_actor_hp_gauge(actor, x, y, width)\n self.contents.font.color = system_color\n self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)\n self.contents.font.color = hp_color(actor)\n last_font_size = self.contents.font.size\n xr = x + width\n if width < 120\n self.contents.draw_text(xr - 44, y, 44, WLH, \"???\", 2)\n else \n self.contents.draw_text(xr - 99, y, 44, WLH, \"???\", 2)\n self.contents.font.color = normal_color\n self.contents.draw_text(xr - 55, y, 11, WLH, \"/\", 2)\n self.contents.draw_text(xr - 44, y, 44, WLH, \"???\", 2) \n end\n else\n super\n end\n end",
"def initialize hp, *params\n super params\n @hp = hp.abs\n @hp = @hp > MAX_HITPOINT ? MAX_HITPOINT : @hp \n end",
"def update_player_stats(pname, pclass, locale, exp, level, gold, hp, max_hp, damage, armor, silver,sp, max_sp)\n\t\t\tupdate_locale(pname, locale)\n\t\t\tupdate_exp(pname, exp)\n\t\t\tupdate_level(pname, level)\n\t\t\tupdate_gold(pname, gold)\n\t\t\tupdate_hp(pname, hp)\n\t\t\tupdate_max_hp(pname, max_hp)\n\t\t\tupdate_damage(pname, damage)\n\t\t\tupdate_armor(pname,armor)\n\t\t\tupdate_silver(pname,silver)\n\t\t\tupdate_sp(pname,sp)\n\t\t\tupdate_max_sp(pname,max_sp)\n\t\tend",
"def yuusya_attack(hero_attack) #引き数の部分はhero.attackと同義。勇者の攻撃力を用いている\n self.hp -= hero_attack\n end",
"def gain_temp_hp(_amount)\n\t\t@temp_hp = _amount\n\tend",
"def hero_win\n puts \"#{monster.name} defeated! You gain #{monster.experience} experience.\"\n hero.update(experience: hero.experience + monster.experience)\n reward\n end",
"def give_hr\n monster_attackers.each do |attacker|\n if attacker.damage_done > 50 + attacker.player.hr && attacker.player.hr < 100\n attacker.player.update(hr: attacker.player.hr + 1)\n end\n end\n end",
"def getHealth()\n return @hp\n end",
"def getHealth()\n return @hp\n end",
"def make_damage(hero, damage)\n hero.hp_pool -= damage\n end",
"def update_boss_hp_bar\n return unless @boss_hp_bar\n @boss_hp_bar.update\n end",
"def attack(hero, villain)\n hero.update(hp: (hero.hp - (villain.power_lvl - hero.resistance)))\n villain.update(hp: (villain.hp - (hero.power_lvl - villain.resistance)))\n sleep(1)\n end",
"def heal\n @mana -= 5\n if @mana < 5\n puts \"You don't have the mana\"\n @health += 0\n else\n @health += 10\n end\n end",
"def health=(v) self['Health'] = v end",
"def heal(health_points)\n @health += (health_points * 1.2).to_i\n end",
"def update\n super\n update_bitmap # Update HP Graphic\n update_screen # Update the position the graphic should be displayed\n end",
"def current_hp\n puts \"P1: #{@player1.hp}/3 vs P2: #{@player2.hp}/3\"\n end",
"def pbHPChanged(battler, oldhp, anim = false)\n # set up variables\n databox = @sprites[\"dataBox_#{battler.index}\"]\n @briefmessage = false\n hpchange = battler.hp - oldhp\n # show common animation for health change\n if anim && @battle.battlescene\n if battler.hp > oldhp\n pbCommonAnimation(\"HealthUp\", battler, nil)\n elsif battler.hp < oldhp\n pbCommonAnimation(\"HealthDown\", battler, nil)\n end\n end\n databox.animateHP(oldhp, battler.hp)\n while databox.animatingHP\n databox.update\n self.wait(1, true)\n end\n # try set low HP BGM music\n setBGMLowHP(false)\n setBGMLowHP(true)\n # displays opposing trainer message if Pokemon falls to low HP\n handled = pbTrainerBattleSpeech(playerBattler?(battler) ? \"damage\" : \"damageOpp\") if hpchange.abs/battler.totalhp.to_f >= 0.6 && hpchange < 0\n handled = pbTrainerBattleSpeech(playerBattler?(battler) ? \"resist\" : \"resistOpp\") if hpchange.abs/battler.totalhp.to_f <= 0.1 && hpchange < 0 && !handled\n handled = pbTrainerBattleSpeech(playerBattler?(battler) ? \"lowHP\" : \"lowHPOpp\") if battler.hp > 0 && (battler.hp < battler.totalhp*0.3) && !handled\n handled = pbTrainerBattleSpeech(playerBattler?(battler) ? \"halfHP\" : \"halfHPOpp\") if battler.hp > 0 && (battler.hp < battler.totalhp*0.5) && !handled\n # reset vector if necessary\n @vector.reset if battler.hp <= 0\n end",
"def generate_hero_hp(hero)\n buffer\n line\n puts \"Your hero's hp is being calculated...\"\n buffer\n hp = rand(500..1000)\n hero.hp = hp\n puts \"Your hero's health point are #{hero.hp}\"\n puts \"Is this enough health? Press 1 if it is enough, press 2 to re-roll power level.\"\n line\n choice = gi_integer\n if choice == 1\n generate_hero_gender(hero)\n elsif choice == 2\n generate_hero_hp(hero)\n else line\n puts \"Your input was not recognized. Please begin this step again.\"\n line\n generate_hero_hp(hero)\n end\n end",
"def attack(target)\n\n #check to see if there is any target\n if target == nil\n puts \"Invite some friends to play this awesome game.\".blue\n\n else\n #print fighting for the user\n\n puts Artii::Base.new.asciify \"Fight\"\n\n\n\n ###methods for determining probability of victory\n ###and damage to the opponent or current user#####\n\n #if the characters have the same attack power\n if self.power == target.power\n\n #if the player wins the battle\n if rand > 0.5\n\n #reduce the target's hp by 10\n target.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #see if the target is still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a greater attack power than that of the target\n elsif self.power > target.power\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand < (0.4 + ((self.power - target.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-5*(self.power - target.power))\n\n #print outcome of the battle\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n end\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-10)\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player has a lower attack power than that of the target\n else\n\n #if the player wins the battle\n #calculation based on distance between the attack powers\n #of the player and target\n if rand > (0.45 + ((target.power - self.power).to_f/4))\n\n #reduce hp of the target\n target.update_hp(-2*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Defeated #{target.name}\".green.on_light_blue.bold\n puts \"#{self.name} HP: #{self.hp}\"\n\n #check if target still alive\n if target.hp > 0\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n\n #if the player loses the battle\n #reduce the player's hp\n else\n self.update_hp(-3*(-self.power + target.power))\n\n #display outcome of the battle to the player\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n puts \"#{self.name} Has Lost Battle to #{target.name}\".black.on_light_red\n puts \"#{self.name} HP: #{self.hp}\"\n puts \"#{target.name} HP: #{target.hp}\"\n puts \"$$$$$$$$$$$$$$$$$$$$$$$$$$$\".blink\n end\n end\n end\n end",
"def attack_town\n @health += 50\n self\n end",
"def alter_stats(entity, equipping)\n \n # Alter the stats as appropriate.\n if equipping\n entity.attack += @stat_change[:attack] if @stat_change[:attack]\n entity.defense += @stat_change[:defense] if @stat_change[:defense]\n entity.agility += @stat_change[:agility] if @stat_change[:agility]\n else\n entity.attack -= @stat_change[:attack] if @stat_change[:attack]\n entity.defense -= @stat_change[:defense] if @stat_change[:defense]\n entity.agility -= @stat_change[:agility] if @stat_change[:agility]\n end\n \n end",
"def health\n return @@playable_char_health\n end",
"def hit(damage)\n @hp -= damage\n end",
"def update_weapon_stats\n weapons = fetch_weapons(@career)\n weapons = weapons.sort {|a,b| b[1] <=> a[1]}\n 5.times do |i|\n self[\"weapon#{i+1}_name\"] = weapons[i][0][0] rescue \"Not Enough Data\"\n self[\"weapon#{i+1}_url\"] = weapons[i][0][1] rescue \"http://www.bungie.net/images/halo3stats/weapons/unknown.gif\"\n self[\"weapon#{i+1}_num\"] = weapons[i][1] rescue 0\n end\n end",
"def attack_effect_damage\r\n self.hp -= self.damage\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def heal()\r\n @warrior.rest!\r\n end",
"def damage(ap)\n @health_points -= ap\n end",
"def attacks (player)\n damage = compute_damage\n\n puts \">>> Le joueur #{self.name} attaque le joueur #{player.name}\"\n\n puts \">>> Il lui inflige #{damage} points de dommages\"\n\n # Give damages to the \"player\" in argument\n player.gets_damage(damage)\n end",
"def update!(**args)\n @strength = args[:strength] if args.key?(:strength)\n @tune = args[:tune] if args.key?(:tune)\n end",
"def add_hp(x=0.0)\n @hp += x if x > 0\n end",
"def damage(attack_power)\n @health_points -= attack_power\n end",
"def update(character=nil)\n if distance(character.x,character.y,@x,@y+200)<125\n if character.coins>=@cost_coin &&\n character.rubies>=@cost_ruby &&\n character.emeralds>=@cost_emer &&\n character.sapphires>=@cost_sapp\n if @time>5\n character.buy(@type,@cost_coin,@cost_ruby,@cost_emer,@cost_sapp)\n @window.set_monetary(@cost_coin,@cost_ruby,@cost_emer,@cost_sapp)\n @pur_time = 100\n @pur_text = [\"THANK YOU!\"]\n @name_text = \"\"\n @bought = true\n end\n else\n if @time>5\n @pur_time = 150\n @pur_text = []\n #VALIDATE text display\n if character.coins<@cost_coin\n if @cost_coin-character.coins==1\n @pur_text.push(\"#{@cost_coin-character.coins} more COIN\")\n else\n @pur_text.push(\"#{@cost_coin-character.coins} more COINS\")\n end\n end\n if character.rubies<@cost_ruby\n if @cost_ruby-character.rubies==1\n @pur_text.push(\"#{@cost_ruby-character.rubies} more RUBY\")\n else\n @pur_text.push(\"#{@cost_ruby-character.rubies} more RUBIES\")\n end\n end\n if character.emeralds<@cost_emer\n if @cost_emer-character.emeralds==1\n @pur_text.push(\"#{@cost_emer-character.emeralds} more EMERALD\")\n else\n @pur_text.push(\"#{@cost_emer-character.emeralds} more EMERALDS\")\n end\n end\n if character.sapphires<@cost_sapp\n if @cost_sapp-character.sapphires==1\n @pur_text.push(\"#{@cost_sapp-character.sapphires} more SAPPHIRE\")\n else\n @pur_text.push(\"#{@cost_sapp-character.sapphires} more SAPPHIRES\")\n end\n end\n if character.fully_healed? && @type==\"health_item\"\n @pur_text.push(\"Your health is fine anyway, stupid.\")\n end\n if character.tinman==true && @type==\"tinman_item\"\n @pur_text.push(\"You're already Tin Man! Sheesh!\")\n end\n if character.zorro_bat==true && @type==\"zorro_item\"\n @pur_text.push(\"C'mon! You don't really need this.\")\n end\n end\n end\n end\n end",
"def health=(new_health)\n @health = new_health\n end",
"def hp!(n)\n @health_remaining += n\n if @health_remaining > @max_health\n @health_remaining = @max_health\n elsif @health_remaining <= 0\n die!\n @game_state.die!\n end\n end",
"def health\n return @@playable_char_health\n end",
"def repair_hp(count)\n @objectives.push([\n Objective::RepairHp,\n {:key => Objective::RepairHp::KEY, :count => count}\n ])\n end",
"def takeHit(x)\n @hp = @hp - x\n return @hp\n end",
"def takeHit(x)\n @hp = @hp - x\n return @hp\n end",
"def takeDamage (dmg)\n\t\t@currentHealth -= dmg\n\tend",
"def take_damage amt, name, sym, message\n @hp -= amt\n @last_hit_by = name\n @kill_type = sym\n hear_line message\n # check if you died?\n end",
"def window_update(actor)\n if actor != nil\n @cCharName.text = actor.name\n @ucCharLvl.cValue.text = actor.level\n \n @ucHpStat.cValue.text = sprintf(MENU_CONFIG::GAUGE_PATTERN, actor.hp, actor.maxhp)\n @ucHpStatGauge.value = actor.hp\n @ucHpStatGauge.max_value = actor.maxhp\n \n if actor.hp == 0\n @ucHpStat.cValue.font.color = Color.knockout_color\n elsif actor.hp < actor.maxhp / 4\n @ucHpStat.cValue.font.color = Color.crisis_color\n else\n @ucHpStat.cValue.font.color = Color.normal_color\n end\n \n @ucMpStat.cValue.text = sprintf(MENU_CONFIG::GAUGE_PATTERN, actor.mp, actor.maxmp)\n @cMpStatGauge.value = actor.mp\n @cMpStatGauge.max_value = actor.maxmp\n \n if actor.mp < actor.maxmp / 4\n @ucMpStat.cValue.font.color = Color.crisis_color\n else\n @ucMpStat.cValue.font.color = Color.normal_color\n end\n \n end\n refresh()\n end",
"def window_update(actor)\n if actor != nil\n @cCharName.text = actor.name\n @ucCharLvl.cValue.text = actor.level\n \n @ucHpStat.cValue.text = sprintf(MENU_CONFIG::GAUGE_PATTERN, actor.hp, actor.maxhp)\n @ucHpStatGauge.value = actor.hp\n @ucHpStatGauge.max_value = actor.maxhp\n \n if actor.hp == 0\n @ucHpStat.cValue.font.color = Color.knockout_color\n elsif actor.hp < actor.maxhp / 4\n @ucHpStat.cValue.font.color = Color.crisis_color\n else\n @ucHpStat.cValue.font.color = Color.normal_color\n end\n \n @ucMpStat.cValue.text = sprintf(MENU_CONFIG::GAUGE_PATTERN, actor.mp, actor.maxmp)\n @cMpStatGauge.value = actor.mp\n @cMpStatGauge.max_value = actor.maxmp\n \n if actor.mp < actor.maxmp / 4\n @ucMpStat.cValue.font.color = Color.crisis_color\n else\n @ucMpStat.cValue.font.color = Color.normal_color\n end\n \n end\n refresh()\n end",
"def hp_decriment(opponent)\n\t\thp_will_change!\n\t\tputs \"damage taken!\"\n\t\t# self.hp -= 1 \n\t\tself.hp -= (1 + opponent.attack/self.defense)\n\t\tif self.hp <=0 \n\t\t\tputs \"Fatality!\"\n\t\t\tself.lives_decriment()\n\t\tend\n\t\tself.save!\n\tend",
"def advance_player!(player)\n @hash[player] += @die.roll * 2\n @hash[player] = @length if @hash[player] > (length)\n end",
"def hit(opponent)\n opponent.health -= self.power\n end",
"def stats\n\t\[email protected]([[@hero.name], [\"HP\", \"MP\"], [@hero.current_hp.to_s, @hero.current_mp.to_s]])\n\t\[email protected]\n\tend",
"def attacks(player)\n dice = compute_damage\n puts \"#{@name} attaque #{player.name} : Il lui inflige #{dice} points de dommages\"\n player.life_points = player.life_points - dice\n end",
"def fly\n @health -= 10\n self\n end",
"def add_hp(x=0.0)\n @hp += x if x > 0.0\n end",
"def make_hp_regeneration\n @superman.hp_pool += @superman.hp_regen\n @batman.hp_pool += @batman.hp_regen\n end",
"def update_reputation\n self.warband.reputation += achievement.reputation\n self.warband.save!\n end",
"def receive_damage\n @hit_points-= 10\n end",
"def health=(new_value)\n change_amount = health - new_value\n event_name = ((new_value > health) ? :healed : :hit)\n changed(true)\n @health = new_value\n notify_observers(self, event_name, [self.display_name, \"was\", event_name, \"for\", change_amount].join(\" \"))\n end",
"def takeDamage (damage)\n\t\t@health = @health - damage\n\tend",
"def update_bitmap\n # Check if hiding HP from enemy view is true\n if @unit.army.officer.hide_hp and [email protected]\n self.bitmap = RPG::Cache.picture(\"hp_hide\")\n else # Display normal HP value\n # If unit has damage on it\n if @unit.unit_hp < 10\n self.bitmap = RPG::Cache.picture(\"hp_\" + @unit.unit_hp.to_s)\n # Otherwise, draw no flag\n else\n self.bitmap = nil\n end\n end\n end",
"def set_graphic(character_name, character_hue, battler_name, battler_hue)\r\n @character_name = character_name\r\n @character_hue = character_hue\r\n @battler_name = battler_name\r\n @battler_hue = battler_hue\r\n end",
"def attack #basic attack for now\r\n attack_value = strength + rand(25..50)\r\n puts \"#{@name} SWINGS his Weapon for #{attack_value} Points of Damage!\"\r\n end",
"def set_graphic(character_name, character_hue, battler_name, battler_hue)\n @character_name = character_name\n @character_hue = character_hue\n @battler_name = battler_name\n @battler_hue = battler_hue\n end",
"def restore_pokemon_hp\n\n end",
"def hit\n @health -= 1\n end"
] | [
"0.7233305",
"0.72171783",
"0.7141941",
"0.68779904",
"0.68349004",
"0.6806555",
"0.6759613",
"0.66288334",
"0.6586484",
"0.64738137",
"0.6460168",
"0.645487",
"0.6424386",
"0.6378438",
"0.6336327",
"0.6302253",
"0.6299974",
"0.6298051",
"0.62900376",
"0.6264237",
"0.6261312",
"0.6246456",
"0.6233153",
"0.62170714",
"0.6205981",
"0.620387",
"0.61795926",
"0.6169632",
"0.6156982",
"0.6156982",
"0.6153734",
"0.61391866",
"0.61307895",
"0.6107621",
"0.6086267",
"0.6075013",
"0.60280985",
"0.6018296",
"0.59988415",
"0.5989412",
"0.59882057",
"0.59876204",
"0.59782434",
"0.59779423",
"0.59779423",
"0.596333",
"0.59406793",
"0.5925285",
"0.589671",
"0.5887799",
"0.5868114",
"0.5842004",
"0.58249223",
"0.5820769",
"0.5792913",
"0.5788515",
"0.5779669",
"0.5778589",
"0.57709026",
"0.57533365",
"0.5747032",
"0.5730066",
"0.5715329",
"0.5715329",
"0.5715329",
"0.5715329",
"0.5695874",
"0.5694911",
"0.5679801",
"0.56704426",
"0.5662007",
"0.56528586",
"0.5632893",
"0.56302315",
"0.5619021",
"0.5614159",
"0.56134415",
"0.56134415",
"0.560494",
"0.5598065",
"0.55844104",
"0.55844104",
"0.558224",
"0.55716884",
"0.55713344",
"0.55687714",
"0.55654126",
"0.55549943",
"0.55288666",
"0.55218804",
"0.5520219",
"0.551291",
"0.55127996",
"0.55086535",
"0.5506174",
"0.550248",
"0.55015576",
"0.54886377",
"0.5488451",
"0.5486166"
] | 0.7799209 | 0 |
method for displaying the stats of a given player | def show_stats
puts "*********************************"
#check to see if the player has any weapons
#display stats
if self.weapons.size == 0
puts "Current Health:".red + " #{self.hp}".bold
puts "Current Power:".blue + " #{self.power}".bold
#display
else
puts "Current Health:".red + " #{self.hp}".bold
puts "Current Power:".blue + " #{self.power}".bold
puts "Equipped Weapon:".green + " #{self.highest_attack_power_weapon.name}".bold
end
puts "*********************************"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_player_stats\n @output.puts '- Players -'.center(WIDTH)\n seperator = \"\\t\"\n stat_width = WIDTH - 5\n stats = String.new\n bot_stats = String.new\n\n stats << \"Player: #{@player.name}\".ljust(WIDTH/2)\n stats << seperator\n stats << \"Chips: #{@player.chips}\"\n @output.puts stats.center(stat_width)\n\n if @bots.empty?\n @output.puts 'No AI opponents.'.center(WIDTH)\n else\n @bots.each do |bot|\n bot_stats = \"AI: #{bot.name}\".ljust(WIDTH/2)\n bot_stats << seperator\n bot_stats << \"Chips: #{bot.chips}\"\n @output.puts bot_stats.center(stat_width)\n end\n end\n end",
"def displayPlayer()\n puts \"*** Player Info ***\"\n puts \"Name: #{@name}\"\n puts\n end",
"def show_players\r\n puts \"Tu as #{human_player.life_points}\"\r\n puts \"il reste #{@enemies.length} bots, courage!!\"\r\n end",
"def show_player(name)\n if player = Player.find_by_name(name)\n puts \"____________________________________________________________________\"\n puts \"#{player.player} Age:#{player.age} Position:#{player.position}\"\n puts \"Team:#{player.team}\"\n puts \"Games Played: #{player.games_played}\"\n puts \"Goals: #{player.goals}\"\n puts \"Assists: #{player.assists}\"\n puts \"Points: #{player.points}\"\n puts \"Shooting Percentage: #{player.shooting_percentage}\"\n puts \"Plus Minus: #{player.plus_minus}\"\n puts \"Penalty Minutes: #{player.penalty_minutes}\"\n puts \"Average TOI: #{player.toi_avg}\"\n puts \"Blocks: #{player.blocks}\"\n puts \"Hits: #{player.hits}\"\n puts \"Faceoff Percentage: #{player.faceoff_percentage}\"\n puts \"____________________________________________________________________\"\n else\n raise_player_error\n end\n end",
"def player_info\n if @health <= 0\n puts \"#{@name} has 0 health remaining!\"\n puts \"\"\n else \n puts \"#{@name} has #{@health} health remaining.\"\n puts \"\"\n \n end\n\n end",
"def player_stats (player_name)\n lookup_by_player(player_name);\nend",
"def player_stats(playerName)\n players[playerName]\nend",
"def display_info\n \n puts \"\\nPlayer Name: #{self.name}\"\n puts \"Current Rank: #{self.rank}\"\n puts \"Position: #{self.position}\"\n puts \"School/Club: #{self.schoolclub}\"\n # binding.pry\n #if there is no class_year, nothing is displayed\n puts \"Year: #{self.class_year}\"\n #\n puts \"Height/Weight: #{self.height}, #{self.weight} \"\n puts \"Age: #{self.age}\"\n puts \"Last rank: #{self.last_rank}\"\n puts \"Scouting Report: #{self.blurb}\"\n puts \"------------------------------------\"\n end",
"def show_stats(players, losers, rounds, games)\n puts \"Players left in the game.\" unless players == []\n for player in players\n puts player.to_s\n end\n\n puts \"Players that have lost so far.\" unless losers == []\n for loser in losers\n puts loser.to_s\n end\n\n puts \"You completed #{games} complete games\"\n puts \" && #{rounds} rounds in the final game.\"\n end",
"def examine \n\t\tputs \"Your Description: #{@player.desc}\" \n\t\tputs \"Health Status: #{@player.health}\" \n\tend",
"def print_name_and_health(player)\n puts \"#{player.name.ljust(20,'.')}#{player.score}\"\n player.each_treasure do |treasure|\n puts \"#{treasure.points} points from #{treasure.name}\"\n end\n puts \"...for a grand total of #{player.points} points.\"\n end",
"def player_stats(name)\n players[name]\nend",
"def print_player(player)\n\t\tputs (\"-player #{player}-\")\n\t\tfor j in 0...5\n\t\t\tputs(\"#{@value_names[@values[@players[player].hand[j]]]} #{@suit_names[@suits[@players[player].hand[j]]]}\")\n\t\tend\n\t\tputs (\"-----------\")\n\tend",
"def status(player)\n puts player\n linebreak\n puts \"Dealer showing #{@dealer.hand.public_show}\"\n linebreak\n end",
"def show_players\n\t\tputs @human_player.show_state\n\t\tputs \"Il reste #{@enemies.length} ennemies !\"\n\tend",
"def show_player\n if @position == 1\n puts \"le joueur #{@position} : #{@name.capitalize} #{@avatar} a le symbol #{symbol} il débutera la partie\"\n else\n puts \"le joueur #{@position} : #{@name.capitalize} #{@avatar} a le symbol #{symbol}\"\n end\n end",
"def display_player_scores(player1,player2)\n puts \"#{player1.name}'s score: #{player1.score}\"\n puts \"#{player2.name}'s score: #{player2.score}\"\nend",
"def score\n puts \"---#{player.name.upcase}: #{player.score} -- #{dealer.name.upcase}: #{dealer.score}---\"\n end",
"def getStats (player)\n if player == \"me\"\n my_hits = self.my_hits\n my_misses = self.my_misses\n my_sunk_ships = sunkShips(\"me\")\n finished = self.finished\n stats = {my_hits: my_hits,\n my_misses: my_misses,\n my_sunk_ships: my_sunk_ships,\n finished: finished}\n statsRet = stats.to_json\n return statsRet\n\n else # player == \"enemy\"\n enemy_hits = self.enemy_hits\n enemy_misses = self.enemy_misses\n enemy_sunk_ships = sunkShips(\"enemy\")\n finished = self.finished\n stats = {enemy_hits: enemy_hits,\n enemy_misses: enemy_misses,\n enemy_sunk_ships: enemy_sunk_ships,\n finished: finished}\n statsRet = stats.to_json\n return statsRet\n end\n end",
"def display_scoreboard\n puts \"The score is\"\n puts \"#{@player_1_name}\"+\" #{@player_1_score}\" \n puts \"#{@player_2_name}\"+\" #{@player_2_score}\"\n puts\n end",
"def show\n @player_statistic = PlayerStatistic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_statistic }\n end\n end",
"def stats\n\t\[email protected]([[@hero.name], [\"HP\", \"MP\"], [@hero.current_hp.to_s, @hero.current_mp.to_s]])\n\t\[email protected]\n\tend",
"def show_winner(player)\n puts \"Winner: #{player.name} #{player.identity} CONGRATULATIONS!!!\"\nend",
"def show_players\n puts \"#{@human_player.name} a #{@human_player.life_points} points de vies\"\n @enemies.each do |mechant|\n puts \"#{mechant.name} a #{mechant.life_points} points de vies\"\n end #end of \"\".each do\" that show mechant name and life points\n end",
"def show_players\n puts\n @humanplayer.show_state\n puts \"2) #{@ennemies.size} enemies are still fighting\"\n puts\n end",
"def show\n @votes = @summary.summary_votes.count\n @player_name = \"#{@summary.player.first_name} #{@summary.player.last_name}\"\n end",
"def status\n puts \"Player #{@playerNo}\".center(60)\n puts \"Name: #{@name}\".center(60)\n puts \"Class: #{@fightClass[:name]}\".center(60)\n puts \"Race: #{@race[:name]}\".center(60)\n puts \"HP: #{@hp}\".center(60)\n puts \"Level: #{@level}\".center(60)\n puts \"Actions: #{@actions.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Attacks: #{@attacks.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Inventory: #{@inventory.join(', ')}\".center(60)\n puts \"\"\n end",
"def all_player_status\n linebreak\n @players.each{ |p| puts p; linebreak; }\n puts \"Dealer showing #{@dealer.hand.public_show}\"\n linebreak\n end",
"def print_player(player)\n puts \"Player #{player.id}: Balance: #{player.money}. \"\n end",
"def player_stats(player_name)\n game_hash.each do |side, value|\n value[:players].each do |name, stats|\n\n if name == player_name\n return stats\n end\n\n end\n end\nend",
"def stats\n puts 'You have ' + self.health.to_s + ' health remaining and have ' + self.denarii.to_s + ' denarii to your name.'\n end",
"def display_status\r\n puts self.playerOne.status\r\n puts self.playerTwo.status\r\n end",
"def display_scores\n puts \"P1: #{@player1.lives}/3 vs P2: #{@player2.lives}/3\"\n end",
"def show\n #@game.round = @game.rounds.sort_by{|e| e[:place]}\n #@player_stats = @player_stats.sort_by{|e| -e[:wins]}\n end",
"def player_info(player, pot)\n system 'clear'\n puts \"#{player.player_name},\".light_green + ' it is your turn to act.'\n puts ''\n puts 'You have ' + player.chip_stack.to_s.light_green + ' chips.'\n puts 'The total pot size (including current bets) is ' + pot.to_s.light_red + ' chips.'\nend",
"def show_score\n puts\n @@score.each do |player, score|\n print \"- #{player.capitalize}: #{score} -\"\n end\n puts\n end",
"def print_scores\n puts \"+--------------+\"\n @players.each do |player|\n puts \"| Player #{player.player_number} : #{player.lives} |\"\n end\n puts \"+--------------+\"\n end",
"def list_stats\r\n puts \"#{@name} Stats:\"\r\n puts \"Total HP: #{@hp}\"\r\n puts \"Class: #{@job}\"\r\n puts \"Total Strength: #{@strength}\"\r\n puts \"Total Speed: #{@speed}\"\r\n end",
"def current_score\n \"Score: #{@player_1_name} has #{@player_1_wins} points, #{@player_2_name} has #{@player_2_wins} points.\"\nend",
"def player_stats(player_name)\n stats = {}\n player_data.each do |player|\n if player_name == player[:player_name]\n stats[:number] = player[:number]\n stats[:shoe] = player[:shoe]\n stats[:points] = player[:points]\n stats[:rebounds] = player[:rebounds]\n stats[:assists] = player[:assists]\n stats[:steals] = player[:steals]\n stats[:blocks] = player[:blocks]\n stats[:slam_dunks] = player[:slam_dunks]\n end\n end\n return stats\nend",
"def player_stats(player_name)\n game_hash.each do |place, team|\n team[:players].each do |player|\n if player[:player_name] == player_name\n return player\n end\n end\n end\n end",
"def print_players()\n\t\tfor i in 0...@num_players\n\t\t\tprint_player(i)\n\t\tend\n\tend",
"def show_hand\n puts \"Player Score: #{player.score}: [#{player.dealt.join(\"][\")}]\"\n puts \"Dealer Score: #{dealer.score}: [#{dealer.dealt.join(\"][\")}]\"\n end",
"def update\n\n #Print player current life and life total to formatted string\n @life_text.text = sprintf(\"%03d/%03d\", @player.health, 100)\n\n #Print rubies gathered and rubies total to formatted string\n @score_text.text = sprintf(\"%03d/%03d\", @player.rubies_gathered, @rubies_total)\n\n #Victory! Stop timers\n if @player.state == :won then\n stop_timers()\n end\n\n #Print time limit and kill player if time has run out\n if @time_limit <= 0 && @player.state != :dead\n stop_timers()\n @player.take_damage(100)\n else\n #Print time remaining\n @time_text.text = sprintf(\"%02d:%02d\", @time_limit/60, @time_limit - (@time_limit/60)*60)\n end\n\n end",
"def show\n @playerstats=Player.joins(:teams, :player_games, :player_teams).select('players.first_name, players.last_name, teams.id as team_id, teams.name, teams.season_id, sum(player_games.goals) as goals, sum(player_games.assists) as assists, sum(player_games.saves) as saves').where(id: @player.id).group('teams.id')\n @totalgoals=0\n @totalassists=0\n @totalsaves=0\n @hasaccess=has_access\n end",
"def show\n @player_game_stat = PlayerGameStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_game_stat }\n end\n end",
"def show\n @player = params[:username].blank? ? current_player : Player.find_by_username(params[:username])\n\n respond_to do |format|\n if @player\n @ratings = @player.ratings\n authorize! :show, @player\n\n format.html # show.html.erb\n format.json { render json: @player }\n else\n format.html { redirect_to root_url, :alert => 'Profile does not exist.'}\n format.json { render :nothing => true }\n end\n end\n end",
"def player_stats(player)\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if name.to_s == player\n return stats\n end\n end\n end\nend",
"def show\n @player = Player.find(params[:id])\n @page_title = \"Meet #{@player.full_name}\"\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @player }\n end\n end",
"def stats\n StatsManager::StatsD.time(Settings::StatsConstants.api['user']['stats']) do\n if params[:id] == current_user.id.to_s\n # A regular user can only view his/her own stats\n @user = current_user\n elsif current_user.is_admin\n # admin users can view anyone's stats\n unless @user = User.where(:id => params[:id]).first\n return render_error(404, \"could not find that user\")\n end\n else\n return render_error(401, \"unauthorized\")\n end\n\n @status = 200\n num_recent_frames = params[:num_frames] ? params[:num_frames].to_i : Settings::UserStats.num_recent_frames\n @stats = GT::UserStatsManager.get_dot_tv_stats_for_recent_frames(@user, num_recent_frames)\n @stats.each {|s| s.frame.creator[:shelby_user_image] = s.frame.creator.avatar_url}\n end\n end",
"def show\n # show all the accepted infractions created by this player\n @player_infractions = @player.infractions.accepted\n # but hide the anonymous infractions when seeing by any person other than the creator\n unless @player.user == current_user\n @player_infractions = @player_infractions.where.not(anonymous: true)\n end\n\n # also show all the information regarding this player being a witness\n @witnesses = @player.witnesses\n @pending_witnesses = @witnesses.select { |witness| pending?(witness) }\n @accepted_witnesses = @witnesses.select { |witness| accepted?(witness) }\n @rejected_witnesses = @witnesses.select { |witness| rejected?(witness) }\n\n if params['tooltip'].nil?\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @player }\n end\n else # show ajax tooltip\n render :partial => 'shared/tooltip', :locals => {\n :image => @player.avatar.url(:thumb), :simple_data => {\n 'Player name' => @player.full_name, 'Team' => @player.team.to_s\n }, :collection => nil\n }\n end\n end",
"def show_players\n puts \"Il reste #{players_left} enemies\"\n player1.show_state\n puts \"\\n\"\n end",
"def score\n puts \"\\n---PLAYER 1: #{self.players_score} -- DEALER: #{self.dealers_score}---\"\n end",
"def show\n\t\t@players = {}\n\t\[email protected] do |player|\n\t\t\tpoints = @tournament.games.find_all { |game| game.winner == player }.count\n\t\t\t@players[points] = [] unless @players[points]\n\t\t\t@players[points] << player\n\t\tend\n\tend",
"def display_points(some_points)\n puts (\"Total Points: #{@player_points}\")\n end",
"def player_stats(player_name)\n game_hash.each do |location, data|\n data[:players].each do |player, data_items|\n return data_items if player == \"#{player_name}\"\n end\n end\nend",
"def current_hp\n puts \"P1: #{@player1.hp}/3 vs P2: #{@player2.hp}/3\"\n end",
"def show\n\n \t\t\trespond_with @player\n\n \t\tend",
"def player_stats(player_name)\n stat_hash = {}\n game_hash.keys.each do |location|\n if game_hash[location][:players][player_name]\n return game_hash[location][:players][player_name]\n end\n end\nend",
"def display_character_stats\n system('clear')\n puts \"------------------\".center(145)\n puts \"Name: #{self.name}\".center(145)\n puts \"Role: #{self.role}\".center(145)\n puts \"Level: #{self.level}\".center(145)\n puts \"Attack: #{self.attack_power}\".center(145)\n puts \"HP: #{self.hp}\".center(145)\n puts \"------------------\".center(145)\n end",
"def print_player_outcomes\n @players.each{ |p|\n puts \"#{p.name}:\"\n p.hands.each_with_index{ |h, i|\n print \"Hand #{i+1}: \"\n eval_hand(p, h)\n }\n puts \"#{p.name} total: $#{p.wallet}\"\n linebreak\n }\n end",
"def title\n \"Game #{self.id}: \" + players.map { |p| p.username }.join(\" vs \")\n end",
"def score_player(player,score)\n\t\tputs \"|#{player[0]}: #{score[0]} |_SCORE_| #{player[1]}: #{score[1]}|\\n\\n\".colorize(:red) \n\tend",
"def draw_basic_info(x, line, width)\n draw_player_name(x, line)\n draw_player_title(x, line, width)\n end",
"def player_stats(name)\n players = players_stats(game_hash)\n \n players.each_pair do |player, stats|\n if player == name\n \n # Fix code to pass the LEARN test\n stats.delete(:player_name)\n \n return stats\n end\n end\n nil\nend",
"def print_score\n puts \"Player Score: #{@player_score}\\tComputer Score: #{@computer_score}\"\n end",
"def basic_stats\n if @player_champs_list.present?\n {\n spec_user: User.find_by(name: @player.summoner.name.downcase),\n summoner: @player.summoner,\n top_played: first_champ(top_played_champs),\n top_kd: first_champ(top_kd_champs),\n top_wl: first_champ(top_wl_champs)\n }\n else \n nil\n end\n end",
"def show\n @calculated_game_player_statistic = CalculatedGamePlayerStatistic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calculated_game_player_statistic }\n end\n end",
"def show\n @player = Player.includes(:photos,:team).find(params[:id])\n @stats = BattingStat.where('player_id =?', params[:id]).order('batting_year desc')\n \n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player }\n end\n end",
"def print_player_hands()\n puts \"--- Player #{@position} --- \"\n @hands.each do |hand| # The player might have multiple hands, if splitting was used\n puts hand.to_s() # Print the details of the hand\n end\n end",
"def high_score_entry(player)\r\n\t\t\[email protected] do |player|\r\n\t\t\t\tformatted_name = player.name.ljust(20, '.')\r\n\t\t\t\t\"#{formatted_name} #{player.score}\"\r\n\t\t\tend\r\n\tend",
"def print_21_msg(player)\n puts \"Player: #{player.id} Scored 21.\"\n end",
"def player_stats(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attribute, values|\n if attribute == :players\n values.each do |person, data|\n if person.to_s == player_name\n return game_hash[location][:players][person]\n end\n end\n end\n end\n end\nend",
"def print_all_players(print_title, players)\r\n puts\r\n puts(print_title)\r\n players.each do |player|\r\n puts(\"\\t >> #{player}\")\r\n end\r\n puts\r\nend",
"def update_player_stats(pname, pclass, locale, exp, level, gold, hp, max_hp, damage, armor, silver,sp, max_sp)\n\t\t\tupdate_locale(pname, locale)\n\t\t\tupdate_exp(pname, exp)\n\t\t\tupdate_level(pname, level)\n\t\t\tupdate_gold(pname, gold)\n\t\t\tupdate_hp(pname, hp)\n\t\t\tupdate_max_hp(pname, max_hp)\n\t\t\tupdate_damage(pname, damage)\n\t\t\tupdate_armor(pname,armor)\n\t\t\tupdate_silver(pname,silver)\n\t\t\tupdate_sp(pname,sp)\n\t\t\tupdate_max_sp(pname,max_sp)\n\t\tend",
"def players\n\t\t@content_title = \"Players\"\n\tend",
"def summary(summoner_id, season = nil)\n stats = get(resource_path('summary', summoner_id), @version, season: season)\n RiotGamesApi::LOL::Model::Stats::PlayerStatsSummaryList.new stats\n end",
"def render_player\n state.player_sprite = [state.player.x,\n state.player.y,\n 4 * 3,\n 8 * 3, \"sprites/player-#{animation_index(state.player.created_at_elapsed)}.png\"] # string interpolation\n outputs.sprites << state.player_sprite\n\n # Outputs a small red square that previews the angles that the player can attack in.\n # It can be moved in a perfect circle around the player to show possible movements.\n # Change the 60 in the parenthesis and see what happens to the movement of the red square.\n outputs.solids << [state.player.x + state.player.attack_angle.vector_x(60),\n state.player.y + state.player.attack_angle.vector_y(60),\n 3, 3, 255, 0, 0]\n end",
"def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def show_players\n @game.players.map do |gamer|\n colorize_nick(gamer)\n end.join ', '\n end",
"def print_stats(viking)\n puts \"#{viking.name} Information:\"\n puts \"Name: #{viking.name}\".blue\n puts \"Health: #{viking.health}\".green\n puts \"Age: #{viking.age}\".yellow\n puts \"Strength: #{viking.strength}\".red\n\n puts(\"\\n\")\nend",
"def show_winner_and_scores\n display_winner_and_secret_code(@winner, @secret_code)\n display_player_score(@human)\n display_player_score(@machine)\n end",
"def show\n @player = Player.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def send_stats(event)\n # Parse message parameters\n msg = event.content\n player = parse_player(msg, event.user.name)\n tabs = parse_tabs(msg)\n ties = parse_ties(msg)\n\n # Retrieve counts and generate table and histogram\n counts = player.score_counts(tabs, ties)\n\n full_counts = (0..19).map{ |r|\n l = counts[:levels][r].to_i\n e = counts[:episodes][r].to_i\n s = counts[:stories][r].to_i\n [l + e, l, e, s]\n }\n\n histogram = AsciiCharts::Cartesian.new(\n (0..19).map{ |r| [r, counts[:levels][r].to_i + counts[:episodes][r].to_i] },\n bar: true,\n hide_zero: true,\n max_y_vals: 15,\n title: 'Score histogram'\n ).draw\n\n # Format response\n totals = full_counts.each_with_index.map{ |c, r| \"#{Highscoreable.format_rank(r)}: #{\" %4d %4d %4d %4d\" % c}\" }.join(\"\\n\\t\")\n overall = \"Totals: %4d %4d %4d %4d\" % full_counts.reduce([0, 0, 0, 0]) { |sums, curr| sums.zip(curr).map { |a| a[0] + a[1] } }\n maxes = [Level, Episode, Story].map{ |t| find_max(:rank, t, tabs) }\n maxes = \"Max: %4d %4d %4d %4d\" % maxes.unshift(maxes[0] + maxes[1])\n tabs = tabs.empty? ? \"\" : \" in the #{format_tabs(tabs)} #{tabs.length == 1 ? 'tab' : 'tabs'}\"\n msg1 = \"Player highscore counts for #{player.print_name}#{tabs}:\\n``` Overall Level Episode Column\\n\\t#{totals}\\n#{overall}\\n#{maxes}\"\n msg2 = \"#{histogram}```\"\n\n # Send response (careful, it can go over the char limit)\n if msg1.length + msg2.length <= DISCORD_CHAR_LIMIT\n event << msg1\n event << msg2\n else\n event.send_message(msg1 + \"```\")\n event.send_message(\"```\" + msg2)\n end\nrescue => e\n lex(e, \"Error computing stats.\", event: event)\nend",
"def player_stats(name)\n# player_stats start at nil (nothing)\n player_stats = nil\n# game_hash.each do |home_away, team_info| iterates over the hash to return all player_stats\n game_hash.each do |home_away, team_info|\n team_info.each do |data_label, data|\n if data_label == :players\n data.each do |player_name, stats|\n if player_name == name\n player_stats = stats\n end\n end\n end\n end\n end\n player_stats\nend",
"def player_stats(name)\n all_players.find do |player|\n player[:player_name] == name\n end\nend",
"def num_points_scored(playerName)\n player_stats(playerName)[:points]\nend",
"def displaywinner(p)\r\n\t\t\[email protected](\"Player #{p} wins.\")\r\n\t\tend",
"def showHands\n @players.times do |p|\n i=p + 1\n print \"\\nPlayer #{i}:\"\n # DJBHERE DJB HERE str = \"file_\" + i.to_s.rjust(n, \"0\")\n @playersCards[i].each do |c|\n print \" #{c.visible}\"\n end\n end\n end",
"def score(player)\n\t$running = false\n\tplayer.score += 1\n\t$gui.show_scored(player.name)\n\t$gui.show_info()\n\t$gui.update_score($p1.score, $p2.score)\nend",
"def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n end\n end",
"def play\n# \tThere are 3 players in Knuckleheads: \n\t\tputs \"There are #{to_s} players in #{@title}\"\n# \tI'm Moe with a health of 100 and a score of 103.\n# \tI'm Larry with a health of 60 and a score of 65.\n# \tI'm Curly with a health of 125 and a score of 130.\n\t\[email protected] do |spieler|\n\t\t\tputs \"I'm #{spieler} with a health of #{@health} and a score of #{score}\"\n\t\t\tend\n# \tMoe got blammed!\n# \tMoe got w00ted!\n# \tMoe got w00ted!\n# \tI'm Moe with a health of 120 and a score of 123.\n# \tLarry got blammed!\n# \tLarry got w00ted!\n# \tLarry got w00ted!\n# \tI'm Larry with a health of 80 and a score of 85.\n# \tCurly got blammed!\n# \tCurly got w00ted!\n# \tCurly got w00ted!\n# \tI'm Curly with a health of 145 and a score of 150.\n\t\tend",
"def showResults()\n #================================================\n puts \"Game # \" + @count.to_s\n if (@winner == :player)\n puts Match.playerName + \" wins\"\n else\n puts \"Dealer wins\"\n end # else, if\n #\n puts Match.playerName + \":\"\n puts \"\\tPoints: \" + @player.points.to_s\n puts \"\\tCards: \"\n playerCards = @player.allCards\n count = 0\n while (count < playerCards.length) do\n oneCard = playerCards[count]\n puts \"\\t\\t\" + Card::CardNames[oneCard.cardFace] + \" of \" + oneCard.cardSuit\n count = count + 1\n end # while\n #\n puts \"Dealer:\"\n puts \"\\tPoints: \" + @dealer.points.to_s\n if (@dealer.points == 0)\n puts \"\\tCards: none\"\n else\n puts \"\\tCards: \"\n dealerCards = @dealer.allCards\n count = 0\n while (count < dealerCards.length) do\n oneCard = dealerCards[count]\n puts \"\\t\\t\" + Card::CardNames[oneCard.cardFace] + \" of \" + oneCard.cardSuit\n count += 1\n end # while\n end #else, if\n\n end",
"def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @player }\n end\n end",
"def print_stats_table()\n res = @db.query(\"SELECT * FROM UserStats;\")\n while row = res.fetch_row do\n printf \"%s %s\\n\", row[0], row[1], row[2], row[3]\n end\n end",
"def player_name\n player.name\n end",
"def player_stats(player_name, hashketball)\r\n player_name.capitalize!\r\n if hashketball[:home][:players].include?(player_name)\r\n hashketball[:home][:players][player_name][:stats]\r\n elsif hashketball[:away][:players].include?(player_name)\r\n hashketball[:away][:players][player_name][:stats]\r\n else\r\n \"No player found.\"\r\n end\r\nend",
"def board_visualization\n @players.each do |player|\n before = 0\n after = @length\n puts \" | \"*(before += @position[player]) + \"#{player}\" + \" | \"*(after -= @position[player])\n end\n nil\n end",
"def winner\n @players.each do |current_player|\n if current_player.position >= length\n #puts \"#{current_player.name} JUST WON!!!\"\n return \"#{current_player.name}\"\n end\n end\n end",
"def player_stats(player_name)\n game_hash.each do |location, team_data|\n team_data.each do |attributes, data|\n if attributes == :players\n data.each do |data_item|\n if player_name == data_item[:player_name]\n return data_item\n end\n end\n end\n end\n end\nend"
] | [
"0.8315523",
"0.770638",
"0.7660251",
"0.76092714",
"0.7581599",
"0.746786",
"0.7299938",
"0.72252",
"0.71763194",
"0.7117901",
"0.7089128",
"0.7087872",
"0.7069533",
"0.70651466",
"0.7040999",
"0.70028555",
"0.69877756",
"0.69825727",
"0.6967976",
"0.69613403",
"0.69562626",
"0.69548154",
"0.69470084",
"0.69344944",
"0.6933076",
"0.6931001",
"0.68855643",
"0.68845826",
"0.6814709",
"0.68106824",
"0.68064356",
"0.67922693",
"0.67695177",
"0.67637134",
"0.67598367",
"0.6758512",
"0.67516714",
"0.6744722",
"0.67400724",
"0.6739588",
"0.67377996",
"0.6698057",
"0.6697495",
"0.6691144",
"0.6686229",
"0.6677206",
"0.66754824",
"0.6652352",
"0.6639754",
"0.6637726",
"0.66276544",
"0.6605541",
"0.65931994",
"0.6578734",
"0.6573678",
"0.6521595",
"0.651484",
"0.651468",
"0.65118396",
"0.65096116",
"0.649374",
"0.64881396",
"0.6488082",
"0.6487869",
"0.6470267",
"0.6457622",
"0.6451987",
"0.64388794",
"0.643143",
"0.6427336",
"0.6417766",
"0.6406003",
"0.64059395",
"0.6397864",
"0.6391566",
"0.6384251",
"0.63718474",
"0.6370792",
"0.63624984",
"0.6349817",
"0.6342117",
"0.6337474",
"0.63371927",
"0.6330786",
"0.6327055",
"0.6321417",
"0.63085216",
"0.6307387",
"0.6305639",
"0.6305054",
"0.6294292",
"0.6292407",
"0.62856823",
"0.6284938",
"0.6273129",
"0.6264738",
"0.6260881",
"0.6253953",
"0.6252432",
"0.62396085"
] | 0.75670123 | 5 |
Return the application's version string. | def version()
return ParseDecision::VERSION
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def versionString()\n\t\t\t\treturn \"#{major}.#{minor}.#{build}\"\n\t\t\tend",
"def version\n build_string\n end",
"def ver\n if v = version\n str = +\"#{program_name} #{[v].join('.')}\"\n str << \" (#{v})\" if v = release\n str\n end\n end",
"def application_version\n read('application_version')\n end",
"def version\n @version_helper.to_s\n end",
"def version\n @version_helper.to_s\n end",
"def app_version\n return @app_version\n end",
"def app_version\n return @app_version\n end",
"def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n case @version\n when Module\n \"#{@version::Major}.#{@version::Minor}.#{@version::Release}\"\n when Proc # not sure about this\n @version.call\n when NilClass\n 'unknown'\n else\n @version\n end\n end",
"def app_info\n \"#{app_name} v#{app_version}\"\n end",
"def v string\n Gem::Version.create string\n end",
"def v string\n Gem::Version.create string\n end",
"def get_version\n\t\tself.dev_stage.blank? ? dev_stage_string = \"\" : dev_stage_string = self.dev_stage + \" \"\n\t\treturn dev_stage_string + self.maj_version.to_s + \".\" + self.min_version.to_s\n\tend",
"def get_version(version)\n \"V#{version.gsub('-','_')}\"\n end",
"def get_app_version_name()\n return get_version_code(\n #app_folder_name:\"project\"\n gradle_file_path:\"build.gradle\",\n ext_constant_name:\"versionName\"\n )\nend",
"def application_version\n return @application_version\n end",
"def application_version\n return @application_version\n end",
"def appcache_version_string\n RailsAppcache.config.version\n end",
"def version\n VERSION\n end",
"def version\n [@major_version, @minor_version].join('.')\n end",
"def version\n @version ||= File.read(path('version.txt')).strip\n end",
"def version\n VERSION\n end",
"def to_s\n @version\n end",
"def to_s\n @version\n end",
"def version\n @gemspec.version || @version_helper.to_s\n end",
"def app_version\n APP_VERSION\n end",
"def version\n name.split('_')[1]\n end",
"def to_s\n @version\n end",
"def version\n Launcher::Log.info Launcher::VERSION\n end",
"def version\n @version ||= File.read(path('version.txt')).strip\n end",
"def to_s\n version = get_version_string\n version << \"-#{get_pre_string}\" unless @pre == nil\n version << \"+#{get_build_string}\" unless @build == nil\n version\n end",
"def package_version\n @semver.to_s '%M.%m.%p%s'\n end",
"def version\n self.class.name + ' ' + VERSION\n end",
"def version\n \"\\e[36mThis program is currently in version number: #{v_num}\\e[0m\"\n end",
"def version\n\t\t\tbegin\n\t\t\t\tv = \"#{GVB.major_version}.#{GVB.minor_version}.#{GVB.patch_version}\"\n\t\t\trescue\n\t\t\t\tv = File.read(\".gvb_version\") if File.exists?(\".gvb_version\")\n\t\t\tend\n\t\t\t# If we got a version then use it to construct a link to the github tag of the same\n\t\t\tif v\n\t\t\t\tl = link_to v, \"https://github.com/machiavellian/machiavelli/releases/tag/v#{v}\", target: \"blank\" if v\n\t\t\t\treturn \"version #{l} \".html_safe\n\t\t\tend\n\t\tend",
"def version_name\n self.class.version_names.join('_').to_sym unless self.class.version_names.blank?\n end",
"def version\n super.to_s\n end",
"def version\n super.to_s\n end",
"def to_s\n self.version.to_s\n end",
"def version\n VERSION\n end",
"def version\n VERSION\n end",
"def version\n VERSION\n end",
"def version\n version_file = File.join(RAILS_ROOT, \"config\", \"version.ini\")\n current_version = if File.exists? version_file\n File.read(version_file)\n else\n \"0.0.1\"\n end\n current_version.strip\n end",
"def original_application_version\n read('original_application_version')\n end",
"def version_tag\n version_composition.join(\".\")\n end",
"def version\n unless @version\n\n # Extract version information (if available)\n @version = metadata['bundleShortVersionString'] || metadata['bundleVersion'] rescue nil\n\n # Otherwise, use the filename\n unless @version\n @version = filename[FILENAME_VERSION_REGEX, 1]\n end\n\n end\n\n @version\n end",
"def version\n execute_string(\"-version\")\n end",
"def version\n (version_from_class.to_f / 10).to_s\n end",
"def version\n @version\n end",
"def version_number\n \"#{self.major}.#{self.minor}\"\n end",
"def version\n path = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__\n dir = File.dirname(path)\n if File.exist?(dir+'/version.stamp')\n version = File.read(dir+'/version.stamp')\n else\n version = \"Unknown version\"\n end\n version\n end",
"def version_const\n \"Version_\" + @__version.upcase.gsub(\".\", \"_\")\n end",
"def version_number\n @version\n end",
"def rubygems_version_string\n VERSION.gsub(/[-\\+]/,'.')\n end",
"def version(app, env)\n response = env == \"staging\" ? \"#{app}-#{env}\" : \"#{app}\"\n #if env == \"staging\"\n #response = \"#{app}-#{env}\"\n #else\n #response = \"#{app}\"\n #end\n \":satellite: [CAP #{app.upcase}] version: https://#{response}.medivo.com/version.html\" unless response.empty?\n end",
"def full_version\n return nil unless exact\n\n \"~> \".concat(version)\n end",
"def to_s\n \"<Version #{number}>\"\n end",
"def version\n str = if product = detect_product('Version')\n product.version\n elsif os =~ /iOS ([\\d\\.]+)/ && browser == \"Safari\"\n $1.tr('_', '.')\n else\n BuildVersions[build.to_s]\n end\n\n Version.new(str)\n end",
"def system_version\n @system_version ||= File.read(Rails.root.join(\"VERSION\")).strip\n end",
"def current_version\n @version\n end",
"def get_app_version\n if File.exists?(Rails.root.join('VERSION'))\n return File.read(Rails.root.join('VERSION')).strip\n elsif File.directory?(Rails.root.join('.git'))\n return `cd '#{Rails.root}'; git describe`.strip! rescue 'unknown'\n end\n\n 'unknown'\nend",
"def version\n app = detect_product(GSA) || detect_product(GOOGLEPODCASTS)\n app.version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n [ \"lib/#{ name }.rb\", \"lib/#{ name }/version.rb\" ].each do |v|\n path = project_path( v )\n line = path.read[/^\\s*VERSION\\s*=\\s*.*/]\n if line then\n return line.match(/.*VERSION\\s*=\\s*['\"](.*)['\"]/)[1]\n end\n end\n end",
"def get_version\n request('getVersion')\n end",
"def version_number\n return @version_number\n end",
"def current_version\n version_number rev\n end",
"def version\n @version ||= config(\"version\", \"0.0.1\")\n end",
"def version\n puts \"v0.3\"\n end",
"def productVersion \n \"productVersion\" \n end",
"def app_version\n '0.0.1'\n end",
"def version_file\n version_rb_file = File.dirname(Buildr.application.buildfile.to_s) + '/version.rb'\n return version_rb_file if File.exists?(version_rb_file)\n return Buildr.application.buildfile.to_s\n end",
"def get_version\n\t\tend",
"def version\n @version ||= '1.0'\n end",
"def to_version_string(version)\n version = version.to_s\n if version.match(/\\./)\n version\n else\n from_version_code(version).to_s\n end\n end",
"def version\n @version ||= __determine_version\n end",
"def version\n read_property 'Version'\n end",
"def version\n @version ||= create_version\n end",
"def version\n return @version if defined?(@version)\n \n @version = JSON.parse(File.read('package.json'))['version']\nend",
"def version\n output = @filer.invoke(\"system-get-version\")\n if(output.results_errno() != 0)\n r = output.results_reason()\n raise \"Failed : \\n\" + r\n else \n output.child_get_string(\"version\")\n end\n end",
"def to_s\n getUIversion().to_s\n end",
"def to_s\n getUIversion().to_s\n end",
"def to_s\n getUIversion().to_s\n end",
"def to_s\n getUIversion().to_s\n end",
"def to_s\n getUIversion().to_s\n end",
"def version\n return last_version if versionable?\n version_number\n end",
"def version\n self.class.get(\"/get/version\")\n end",
"def version\n cmd(COMMANDS[:version], 2)\n end",
"def app_version=(value)\n @app_version = value\n end"
] | [
"0.8153033",
"0.80810785",
"0.80770165",
"0.7967893",
"0.7830355",
"0.7830355",
"0.76368684",
"0.76368684",
"0.757915",
"0.7577416",
"0.7577416",
"0.7577125",
"0.7527811",
"0.7481023",
"0.7440889",
"0.7440889",
"0.73899823",
"0.7379159",
"0.73780084",
"0.7361044",
"0.7361044",
"0.73580366",
"0.7350509",
"0.7303657",
"0.7297781",
"0.7290073",
"0.7286606",
"0.7286606",
"0.7283225",
"0.727249",
"0.7232129",
"0.7203898",
"0.71985483",
"0.71961224",
"0.7183897",
"0.71750635",
"0.7171335",
"0.71672684",
"0.7160396",
"0.7154244",
"0.7151976",
"0.7151976",
"0.7151118",
"0.714991",
"0.714991",
"0.714991",
"0.7136123",
"0.71277714",
"0.70988774",
"0.7093224",
"0.70910305",
"0.7068691",
"0.7065688",
"0.7064339",
"0.7063555",
"0.7051435",
"0.7049234",
"0.70442253",
"0.7027042",
"0.700334",
"0.700282",
"0.69882363",
"0.69865704",
"0.6962576",
"0.6961724",
"0.6952608",
"0.69431424",
"0.69431424",
"0.69431424",
"0.69431424",
"0.69431424",
"0.69431424",
"0.69431424",
"0.69431424",
"0.69431424",
"0.69398534",
"0.6934496",
"0.69318414",
"0.69291764",
"0.6914485",
"0.68924344",
"0.68855923",
"0.6882965",
"0.68763477",
"0.6859818",
"0.6856635",
"0.68415725",
"0.68345636",
"0.68287784",
"0.6816158",
"0.6812601",
"0.67967516",
"0.67944926",
"0.67944926",
"0.67944926",
"0.67944926",
"0.67944926",
"0.67926705",
"0.67905056",
"0.67893416",
"0.67844737"
] | 0.0 | -1 |
Parse files based on the configuration. | def parseCfg(cfg)
$LOG.debug "Parser::parseCfg( cfg )"
if( !validateCfg(cfg) )
puts "ERROR: Invalid options."
return
end
if( !File.exists?(@context.file) )
@context.file = File.join( @context.srcdir, @context.file )
if( !File.exists?(@context.file) )
puts "ERROR: unable to locate src file: #{@context.file}"
return
end
end
if( !File.exists?(@context.outdir) )
FileUtils.mkdir_p( @context.outdir )
puts "Output dir created: #{@context.outdir}" if @context.verbose
end
parseFile(@context.file)
# Copy the decision log to the output dir.
FileUtils.cp(@context.file, @context.outdir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_files\n @parse_files ||=\n begin\n files = expand_dirs_to_files(@path)\n files = file_sort(files)\n\n if @options['only'].present?\n files = file_accept(files, @options['only'])\n end\n\n # By default, tmp, vender, spec, test, features are ignored.\n %w[vendor spec test features tmp].each do |dir|\n files = file_ignore(files, File.join(@path, dir)) unless @options[dir]\n end\n\n # Exclude files based on exclude regexes if the option is set.\n @options['exclude'].each do |pattern|\n files = file_ignore(files, pattern)\n end\n\n %w[Capfile Gemfile Gemfile.lock].each do |file|\n files.unshift File.join(@path, file)\n end\n\n files.compact\n end\n end",
"def parse_files\n options.each do |type, filename|\n begin\n content[type] = FCSV.read(filename)\n rescue CSV::MalformedCSVError\n $stderr.puts \"Error parsing #{filename}: #{$!.message}\"\n exit 1\n rescue Errno::ENOENT, Errno::EACCES\n $stderr.puts \"Error reading #{filename}: #{$!.message}\"\n exit 1\n end\n end\n end",
"def process_configuration_files(configuration)\n plugin_element = nil\n configuration.plugin_paths.split(\";\").each do |path|\n Dir.foreach(path) do |file|\n if file!=\"..\" and file!=\".\" and File.stat(\"#{path}/#{file}\").directory?\n filespec = \"#{path}/#{file}/plugin.xml\"\n next unless File.exist?(filespec)\n each_plugin_element(filespec) do |plugin_element| \n FreeBASE::Plugin.new(self, filespec, plugin_element)\n end\n elsif file[-4..-1]==\".xml\" and !File.stat(\"#{path}/#{file}\").directory?\n filespec = \"#{path}/#{file}\"\n each_plugin_element(filespec) do |plugin_element| \n FreeBASE::Plugin.new(self, filespec, plugin_element)\n end\n end\n end\n end\n end",
"def parse_files(*files); end",
"def read_config_files(files); end",
"def parse_file()\n\n if !self.has?()\n return\n end\n\n @logs = {}\n @configs = {}\n current_index = 0\n current_config = {}\n parsing_config = false\n config_script = \"\"\n\n ::IO.foreach(self.path()) do |line|\n line.strip!\n if line.match(/\\}/)\n parsing_config = false\n @configs[current_index] = current_config\n current_config = {}\n current_index += 1\n config_script = \"\"\n\n else\n\n if parsing_config\n config = line.split(/\\s+/, 2)\n config.reject!(&:empty?) # Oh Ruby, why do you have 10 ways to do everything?\n #config[0].strip!\n\n if config[0] == \"postrotate\"\n config_script = config[0]\n current_config[config[0]] = []\n\n else\n\n if config_script != \"\"\n if config[0] == \"endscript\"\n current_config[config_script] << config[0]\n #current_config[config[0]] = \"\"\n config_script = \"\"\n\n else\n #line.strip!\n current_config[config_script] << line\n\n end\n\n else\n val = true\n if config.length == 2\n val = config[1]\n end\n current_config[config[0]] = val\n\n end\n end\n\n else\n logs = line.split(/\\s+/)\n logs.reject! { |c| c.empty? || c == \"{\" } # remove blank entries\n logs.each do |log|\n log.strip!\n @logs[log] = current_index\n end\n\n if line.match(/\\{/)\n parsing_config = true\n end\n\n end\n\n end\n\n\n end # foreach\n\n end",
"def parse_files files\n file_list = gather_files files\n @stats = RDoc::Stats.new @store, file_list.length, @options.verbosity\n\n return [] if file_list.empty?\n\n original_options = @options.dup\n @stats.begin_adding\n\n file_info = file_list.map do |filename|\n @current = filename\n parse_file filename\n end.compact\n\n @stats.done_adding\n @options = original_options\n\n file_info\n end",
"def parse_files\n #Hash to store our results\n @host_results = Hash.new\n @log.debug(\"Files to be looked at : #{@scan_files.join(', ')}\")\n @scan_files.each do |file| \n file_content = File.open(file,'r').read\n begin\n @log.debug(\"File name is \" + file)\n doc = JSON.parse(file_content)\n rescue JSON::ParserError => e\n @log.warn(\"We got an error parsing #{file}\")\n next\n end\n #Make sure that the file is actually XML\n begin\n @log.debug(\"Got a sslyze file called #{file}, processing\")\n parse_file(doc)\n rescue Exception => e\n @log.warn(\"We got an error parsing #{file}\")\n @log.warn(e)\n end\n end\n end",
"def parse_file(filename); end",
"def parse_config\n %w(/etc/steel/steel.yml steel.yml).each do |cfg|\n if File.exist?(cfg)\n begin\n y = YAML.load_file(cfg)\n rescue Psych::SyntaxError => e\n error \"[#{e.class}] Failed to parse '#{cfg}'!!\"\n error e.message\n exit 1\n end\n # Merge the contents of the config into @config.\n config.merge!(y)\n end\n end\n end",
"def process\n Parser.parse_paths(paths).measure(config)\n end",
"def parse_config\n @parsed_hash = Settings.load! @config_file\n validate @parsed_hash\n HadoopConfigParser.new(HADOOP_CONF, @log, @debug)\n HBaseConfigParser.new(HBASE_CONF, @log, @debug)\n unless @errors_count == 0\n @log.error \"Number of Errors: #{@errors_count}\"\n @log.error 'Parsing config file ... ' + '[Failed]'.red\n raise(Ankus::Errors::ParseError.new(\"\\rParsing Configuration Failed\".red))\n end\n create_req_files\n @parsed_hash\n rescue Ankus::Errors::ParseError, Ankus::Errors::ParseError::NoKey\n @log.error \"#{$!.message} (#{$!.class})\"\n exit\n rescue\n @log.error \"#{$!.message} (#{$!.class})\"\n puts $@ if @debug\n exit\n end",
"def parse_files(options)\n files = options.files\n files = [\".\"] if files.empty?\n\n file_list = normalized_file_list(options, files, true, options.exclude)\n\n return [] if file_list.empty?\n\n jobs = SizedQueue.new(number_of_threads * 3)\n workers = []\n file_info = []\n file_info_lock = Mutex.new\n\n Thread.abort_on_exception = true\n @stats = Stats.new(file_list.size, options.verbosity)\n @stats.begin_adding(number_of_threads)\n\n # Create worker threads.\n number_of_threads.times do\n thread = Thread.new do\n while (filename = jobs.pop)\n @stats.add_file(filename)\n content = read_file_contents(filename)\n top_level = ::RDoc::TopLevel.new filename\n\n parser = ::RDoc::Parser.for(top_level, filename, content, options,\n @stats)\n result = parser.scan\n\n file_info_lock.synchronize do\n file_info << result\n end\n end\n end\n workers << thread\n end\n\n # Feed filenames to the parser worker threads...\n file_list.each do |filename|\n jobs << filename\n end\n workers.size.times do\n jobs << nil\n end\n\n # ...and wait until they're done.\n workers.each do |thread|\n thread.join\n end\n\n @stats.done_adding\n\n file_info\n end",
"def parse\n parse_file\n self\n end",
"def parse_from_file filename\n parse File.open(filename)\n end",
"def parse\n result = []\n files = []\n \n @paths.each { |path|\n begin\n raise FileNotFoundError unless File.exists?(path)\n \n if File.directory?(path) then\n files += Dir.glob(\"#{path}/**/*.mid\")\n else\n files << path if File.extname(path) == \".mid\"\n end\n rescue\n puts \"Not a valid file path : #{path} => #{$!}\"\n end\n }\n \n \n if files.empty? then\n puts \"No files were added.\"\n else\n files.each { |file_path|\n result << read_midi(file_path)\n }\n end\n \n return result\n end",
"def process_files\n Dir[DATA_DIR + '/**/*.csv'].each do |file|\n process_file(file)\n end\n end",
"def parse_files(options)\n \n file_info = []\n\n files = options.files\n files = [\".\"] if files.empty?\n\n file_list = normalized_file_list(options, files, true)\n\n file_list.each do |fn|\n $stderr.printf(\"\\n%35s: \", File.basename(fn)) unless options.quiet\n \n content = File.open(fn, \"r\") {|f| f.read}\n\n top_level = TopLevel.new(fn)\n parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)\n file_info << parser.scan\n @stats.num_files += 1\n end\n\n file_info\n end",
"def parse_files(options)\n files = options.files\n files = [\".\"] if files.empty?\n\n file_list = normalized_file_list(options, files, true)\n\n return [] if file_list.empty?\n\n file_info = []\n width = file_list.map { |name| name.length }.max + 1\n\n file_list.each do |fn|\n $stderr.printf(\"\\n%*s: \", width, fn) unless options.quiet\n\n content = if RUBY_VERSION >= '1.9' then\n File.open(fn, \"r:ascii-8bit\") { |f| f.read }\n else\n File.read fn\n end\n\n if /coding:\\s*(\\S+)/ =~ content[/\\A(?:.*\\n){0,2}/]\n if enc = Encoding.find($1)\n content.force_encoding(enc)\n end\n end\n\n top_level = TopLevel.new(fn)\n parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)\n file_info << parser.scan\n @stats.num_files += 1\n end\n\n file_info\n end",
"def perform\n accept(parse_file)\n end",
"def read_configuration\n @config = {}\n @config_paths.map do |file|\n @section = nil; @pattern = nil; @mailto = nil\n # section, pattern, mailto are reset for every file (but not when included by 'include')\n parse_file( file )\n end.join($/)\n end",
"def loadConfigurationFiles\n baseDirectory = 'configuration'\n\n mainDirectory = 'Configuration'\n customDirectory = 'myConfiguration'\n\n mainPath = Nil.joinPaths(baseDirectory, mainDirectory)\n customPath = Nil.joinPaths(baseDirectory, customDirectory)\n\n targets = Nil.readDirectory(mainPath)\n targets = targets.map{|x| ConfigurationEntry.new(x)}\n\n priorityFiles =\n [\n #need to make an exception for the User.rb here because it needs to get included first\n ['User', 2],\n ['Torrent', 1],\n ]\n\n priorityFiles.each do |name, priority|\n name = \"#{name}.rb\"\n targets.each do |entry|\n if entry.target.name == name\n entry.priority = priority\n break\n end\n end\n end\n\n targets.sort!\n\n targets.each do |entry|\n target = entry.target\n customPath = Nil.joinPaths(customPath, target.name)\n if File.exists?(customPath)\n require customPath\n else\n require target.path\n end\n end\nend",
"def parse_config_file config_path\n File.open(config_path, \"r\") do |file|\n case File.extname(file).delete(\".\")\n when \"json\" then JSON.parse(file.read)\n when \"yml\" then YAML.load_file(file)\n else\n file.close\n raise LoadError, \"Type of file is not supported.\"\n end\n end\n end",
"def process_file(src)\n media = \"\"\n # files first\n get_files(src).each do |file|\n next if file =~ /\\/\\._/\n \n # first we check if the file is a tv series\n episode_status, episode_name, episode_season, episode_episode = tv_file(file) if $config[\"series\"][\"process\"] == true\n if episode_status == true\n episode = Episode.new file\n if episode.is_ep?\n episode.status = handle_series episode \n media = episode.class.to_s\n end\n end\n \n # second we check if the file is music\n music_status = music_file(file) if $config[\"music_file\"][\"process\"] == true\n if music_status == true\n music = Music.new file\n if music.is_music?\n music.status = handle_music music \n media = music.class.to_s\n end\n end\n \n # finally we can handle rar's\n handle_rar(file) if file =~ /\\.rar$/ and file !~ /part\\d+\\.rar$/\n handle_rar(file) if file =~ /part01\\.rar$/\n end # get_files\n media\nend",
"def _parse(config_file)\r\n unless File.readable?(config_file)\r\n raise Compass::Error, \"Configuration file, #{config_file}, not found or not readable.\"\r\n end\r\n open(config_file) do |f|\r\n parse_string(f.read, config_file)\r\n end\r\n end",
"def parse!\n unless @type.nil? || VALID_TASKS.include?(@type)\n raise TaskList::Exceptions::InvalidTaskTypeError.new type: @type\n end\n\n @files.each { |f| parsef! file: f }\n end",
"def parse_file_data\n current_category = nil\n todo_lines = []\n File.open(@config_file) {|fl| todo_lines = fl.readlines() }\n line_count = 0\n todo_lines.each do |todo_line|\n todo_line.strip!.chomp!\n next if todo_line.nil? or todo_line.empty?\n case todo_line\n when /^\\*{1}\\ (.+)?/\n current_category = $1\n line_count = 0\n @todo_container[current_category] ||= []\n when /^(\\*{2,})\\ TODO\\ (.+)?/\n priority = $1.size\n item = OpenStruct.new(:priority => priority, :flag => true, :text => $2,:index => line_count )\n line_count += 1\n @todo_container[current_category] << item\n when /^(\\*{2,})\\ DONE\\ (.+)?/\n priority = $1.size\n item = OpenStruct.new(:priority => priority, :flag => false, :text => $2,:index => line_count )\n line_count += 1\n @todo_container[current_category].push(item)\n end\n end\n end",
"def parse! filename\n parse_! filename\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def build_file_list\n puts_and_logs 'Finding files...'\n file_list = []\n config[:source].each do |entry|\n if File.directory?(entry)\n populate_list_of_files_from_directory(file_list, entry) \n next\n end\n if File.file?(entry)\n populate_list_of_files_from_file(file_list, entry) \n next\n end\n logger.warn \"\\\"#{entry}\\\" is neither a directory nor a regular file. Ignored...\"\n end\n logger.debug(file_list)\n file_list\n end",
"def _each_specification_file(config, apply_filter = true)\n folder = config.folder\n world = config.folder/\"world\"\n fs = folder.glob(\"**/*.{yml, yaml}\").reject{|f|\n f.to_s.start_with?(world.to_s) || f.to_s =~ /openapi.base.yml/\n }\n fs = fs.sort\n fs = fs.select(&to_filter_proc(config.file_filter)) if apply_filter\n fs.each do |file|\n yield file, folder\n end\n end",
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def parse_config_file(file)\n return {} unless File.exist?(file)\n\n case File.extname(file)\n when /\\.conf$/i\n parse_conf_file(file)\n when /\\.json$/i\n Oj.load_file(file, mode: :strict, symbol_keys: true)\n when /\\.ya?ml$/i\n begin\n require 'safe_yaml/load'\n SafeYAML.load_file(file) || {}\n rescue LoadError\n # Re-raise with a more descriptive message. This should generally\n # abort the configuration loading.\n raise LoadError.new(%{Could not load the requested resource. Please install the 'safe_yaml' gem via\nBundler or directly, and try loading again.\n})\n end\n end\n end",
"def loadConfigs()\n fh = File.open(@fileName_vars, \"r\")\n\n fh.each do |line| \n line.gsub!(/[\\s]/, '') # removes white spaces \n\n if(!(/^\\#/.match(line)) && /:/.match(line)) # only considers lines not begining with #\n line.sub!(/\\#.*$/, '') # removes all trailing comments\n line.upcase!\n arr_configs = line.split(/:/)\n case arr_configs[0] \n when FOLDER_DATA\n @folder_data = arr_configs[1]\n when FOLDER_DB\n @folder_db = arr_configs[1]\n when FOLDER_BLASTRES\n @folder_blastRes = arr_configs[1]\n when FOLDER_FINALRES\n @folder_finalRes = arr_configs[1]\n end \n #puts arr[0] + \"\\t\" + arr[1]\n #puts line\n end \n\n end \n\n fh.close\n end",
"def all_files\n parse!\n @all_files\n end",
"def scan!\n Dir.chdir(@path) do\n Find.find('.') do |file|\n next if file == '.'\n\n # ignore the ./\n file = file[2..-1]\n name = File.basename(file)\n\n # ignore certain files/directories\n Find.prune if IGNORE.include?(name)\n\n if File.directory?(file)\n @directories << file\n elsif File.file?(file)\n src = File.join(@path,file)\n\n case File.extname(name)\n when '.erb'\n # erb template\n if name.start_with?('_')\n # partial template\n template_dir = File.dirname(file)\n template_name = name[1..-1].chomp('.erb').to_sym\n\n @includes[template_dir][template_name] = src\n else\n dest = file.chomp('.erb')\n\n @templates[dest] = src\n end\n else\n # static file\n @files[file] = src\n end\n end\n end\n end\n end",
"def parse_input (input_file)\nend",
"def read_config_files\n load_config_files\n end",
"def run\n @file_paths.each do |path|\n process_file(path)\n end\n @report\n end",
"def parse_files(files_a)\n\t\tfiles_a.each do |file_p|\n\t\t\tparse_file(file_p) do |cons|\n\t\t\t\tyield(cons)\n\t\t\tend\n\t\tend\n\tend",
"def parse(config_file)\n open(config_file) do |f|\n parse_string(f.read, config_file)\n end\n end",
"def parseFile(fname)\r\n $LOG.debug \"Parser::parseFile( #{fname} )\"\r\n puts \"Parsing file: #{fname}\" if @context.verbose\r\n\r\n # Determine the mode and configure plugins based on the file data.\r\n configureForFileMode(fname)\r\n\r\n line_count = 1\r\n # Open the file and read line by line\r\n df = File.open(fname).each do |ln|\r\n puts line_count.to_s if $DEBUG\r\n line_count += 1\r\n @plugins.each do |plug|\r\n puts \" --> #{plug.class}\" if $DEBUG\r\n break if ( true == plug.execute(@context, ln))\r\n end # plugins.each\r\n end # do file\r\n\r\n puts \"Lines parsed: #{line_count}\" if @context.verbose\r\n end",
"def parse( logger = nil )\n result = nil\n line_count = 0\n detector_fin1_res = ContextDetector.new( FIN1_RESULT_TYPEDEF, logger )\n detector_fin2_res = ContextDetector.new( FIN2_RESULT_TYPEDEF, logger )\n detector_fin3_res = ContextDetector.new( FIN3_RESULT_TYPEDEF, logger )\n detector_uisp_res = ContextDetector.new( UISP_RESULT_TYPEDEF, logger )\n detector_fin1_sta = ContextDetector.new( FIN1_STARTLIST_TYPEDEF, logger )\n\n File.open( @full_pathname ) do |f|\n f.each_line do |curr_line| # Make sure each line has a valid UTF-8 sequence of characters:\n curr_line = EncodingTools.force_valid_encoding( curr_line )\n line_count += 1\n # While reading the file line by line, detect the type:\n if detector_fin3_res.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"FIN3 RESULT-type file detected!\" ) if logger\n result = Fin3ResultDefs.new( logger )\n break\n\n elsif detector_fin1_res.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"FIN1 RESULT-type file detected!\" ) if logger\n result = FinResultDefs.new( logger )\n break # Break as soon as we have a match (FIFO wins)\n\n elsif detector_fin2_res.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"FIN2 RESULT-type file detected!\" ) if logger\n result = Fin2ResultDefs.new( logger )\n break\n\n elsif detector_uisp_res.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"UISP RESULT-type file detected!\" ) if logger\n result = UispResultDefs.new( logger )\n break\n\n elsif detector_fin1_sta.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"FIN1 STARTLIST-type file detected!\" ) if logger\n result = FinStartListDefs.new( logger )\n break\n\n else\n nil\n end\n end\n end\n result\n end",
"def load!\n if config_file\n load_from_config_file(config_file)\n\n if @config_from_file\n get_formatters_from_config_file\n #get_file_sets_from_config_file unless @runtime_file_list\n get_file_sets_from_config_file\n end\n else\n log 'Creating default file set...'\n @file_sets = { default: FileSet.new(@runtime_file_list) }\n end\n\n get_output_file_from_cli_opts\n get_formatters_from_cli_opts\n get_file_sets_from_cli_opts\n get_style_from_cli_opts\n end",
"def process_files files=[]\n files.each do |file|\n process_file file\n end\n end",
"def try_files\n files = Files.new(config, settings)\n files.configure\n end",
"def run\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # Go through all files added from CL (sort them first)\n # If empty, sort and each will do nothing, no errors\n _completed_dirs = Array.new()\n _completed_files = Array.new()\n if @config.cl_entry_set\n @config.file_list.sort.each do |_file|\n _completed_files.push(parse_file(_file))\n end\n end\n\n # Then go through all the specified directories\n # Initial parse depth to parse_dir is 0 (unlimited)\n @config.dir_list.sort.each do |_dir|\n _completed_dirs.push(parse_dir(_dir, 0))\n end\n\n # Create overall hash for parsed files\n _structure = Hash.new()\n _structure[:files] = _completed_files\n _structure[:subdirs] = _completed_dirs\n\n debug_print \"_structure dump\\n\\n\"\n debug_print PP.pp(_structure, '')\n debug_print \"\\n\\n\"\n\n # Pass structure to poster with count as 0\n Remote.post_structure(_structure, @config, 0)\n\n _structure\n end",
"def nf_parse_files(files_a)\n\t\tfiles_a.each do |file_p|\n\t\t\tnf_parse_file(file_p) do |cons|\n\t\t\t\tyield(cons)\n\t\t\tend\n\t\tend\n\tend",
"def parse\n # we need one of them at least\n return nil if [email protected]? && [email protected]? \n # get key from filepath if needs\n @id.nil? ? filepath_to_id : id_to_filepath\n # set default locale if null\n @locale ||= I18n.locale.to_s\n # cleanup blanks\n @handler = nil if @handler.blank?\n # set default format\n @format ||= FORMATS[@dir]\n # rebuild key\n @id = [\"\",@dir,@path].compact.join(\"/\")\n # rebuild filepath\n dir = (is_asset? ? \"assets/#{@dir}\" : (is_content? ? \"content/#{@dir}\" : @dir))\n\n @filepath = Grass.app_root + [\"\",dir,@path].compact.join(\"/\") + [\"\",@locale,@format,@handler].compact.join(\".\") \n\n end",
"def read(files); end",
"def read(files); end",
"def load_local\n files = lookup(CONFIG_FILE)\n file = files.find{ |f| File.file?(f) }\n new(*file)\n\n #if file\n # paths = [file]\n #else\n # dir = lookup(CONFIG_DIR).find{ |f| File.directory?(f) }\n # paths = dir ? Dir.glob(File.join(dir, '**/*')) : []\n #end\n #files = paths.select{ |path| File.file?(path) }\n end",
"def parse_config(config); end",
"def load\n @models = []\n\n # \n files = \n if File.directory?(config_path) \n files_in_dir = []\n Dir[config_path + \"/*.yml\"].each do |file|\n files_in_dir << file\n end\n files_in_dir\n elsif File.file?(config_path)\n [config_path]\n else\n nil\n end\n\n return nil if files.nil?\n\n # \n @models = files.inject(@models) do |models, file|\n begin\n yaml = YAML.load_file(file)\n rescue => ex\n logger.debug \"failed in reading yaml (#{file})\"\n next\n end\n if yaml.nil?\n logger.debug \"failed in reading yaml (#{file})\"\n next\n end\n models + yaml2models(yaml)\n end.extend(ArrayMethods)\n end",
"def parse_file(filename)\n # [review] - Rename method input param to filename (more verbose?)\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n _relative_path = filename\n _absolute_path = File.absolute_path(filename)\n\n # Error check on input, use input filename to make sure relative path is correct\n if Watson::FS.check_file(_relative_path)\n debug_print \"Opened #{ _relative_path } for parsing\\n\"\n debug_print \"Short path: #{ _relative_path }\\n\"\n else\n print \"Unable to open #{ _relative_path }, exiting\\n\"\n return false\n end\n\n\n # Get filetype and set corresponding comment type\n _comment_type = get_comment_type(_relative_path)\n unless _comment_type\n debug_print \"Using default (#) comment type\\n\"\n _comment_type = ['#']\n end\n\n # Escape out comment type for safety\n # [review] - Is there a way to do inplace join?\n _comment_type = _comment_type.map { |comment| Regexp.escape(comment) }.join(\"|\")\n debug_print \"Comment type #{ _comment_type }\\n\"\n\n # [review] - It is possible to embed the valid tags in the regexp,\n # with a ~5% performance gain, but this would loose the warning about\n # unrecognized tags.\n _tag_format = Regexp.escape(@config.tag_format).gsub('\\\\ ', ' ')\n _tag_format_regex = _tag_format\n .gsub(\"TAG\", '(\\w+)')\n .gsub(\"COMMENT\", '(.+)')\n .gsub(' ' , '\\s+')\n\n _comment_regex = /^(?:\\s*[#{_comment_type}]+\\s*)+#{_tag_format_regex}/\n\n debug_print \"Comment regex: #{_comment_regex}\\n\"\n\n # Open file and read in entire thing into an array\n # Use an array so we can look ahead when creating issues later\n # [review] - Better var name than data for read in file?\n _data = File.read(_absolute_path).encode('UTF-8', :invalid => :replace).lines\n\n # Initialize issue list hash\n _issue_list = Hash.new()\n _issue_list[:relative_path] = _relative_path\n _issue_list[:absolute_path] = _absolute_path\n _issue_list[:has_issues] = false\n @config.tag_list.each do | _tag |\n debug_print \"Creating array named #{ _tag }\\n\"\n # [review] - Use to_sym to make tag into symbol instead of string?\n _issue_list[_tag] = Array.new\n end\n\n # Loop through all array elements (lines in file) and look for issues\n _data.each_with_index do |_line, _i|\n\n # Find any comment line with [tag] - text (any comb of space and # acceptable)\n # Using if match to stay consistent (with config.rb) see there for\n # explanation of why I do this (not a good good one persay...)\n begin\n _mtch = _line.match(_comment_regex)\n rescue ArgumentError\n debug_print \"Could not encode to UTF-8, non-text\\n\"\n end\n\n unless _mtch\n # debug_print \"No valid tag found in line, skipping\\n\"\n next\n end\n\n # Set tag\n _tag = _mtch[1].downcase\n\n # Make sure that the tag that was found is something we accept\n # If not, skip it but tell user about an unrecognized tag\n unless @config.tag_list.include?(_tag)\n formatter = Printer.new(@config).build_formatter\n formatter.print_status \"+\", GREEN\n print \"Unknown tag [#{ _tag }] found, ignoring\\n\"\n print \" You might want to include it in your RC or with the -t/--tags flag\\n\"\n next\n end\n\n # Found a valid match (with recognized tag)\n # Set flag for this issue_list (for file) to indicate that\n _issue_list[:has_issues] = true\n\n # [review] - This could probably be done better, elsewhere!\n # If it's a HTML or Handlebars comment, remove trailing -->, --}}\n if _mtch[0].match(/[<{]+(!--)?(#)?/)\n _title = _mtch[2].gsub(/(--)?(#)?[>}]+/, \"\")\n else\n _title = _mtch[2]\n end\n debug_print \"Issue found\\n\"\n debug_print \"Tag: #{ _tag }\\n\"\n debug_print \"Issue: #{ _title }\\n\"\n\n # Create hash for each issue found\n _issue = Hash.new\n _issue[:line_number] = _i + 1\n _issue[:title] = _title\n\n # Grab context of issue specified by Config param (+1 to include issue itself)\n _context = _data[_i..(_i + @config.context_depth + 1)]\n\n # [review] - There has got to be a better way to do this...\n # Go through each line of context and determine indentation\n # Used to preserve indentation in post\n _cut = Array.new\n _context.each do |_line_sub|\n _max = 0\n # Until we reach a non indent OR the line is empty, keep slicin'\n until !_line_sub.match(/^( |\\t|\\n)/) || _line_sub.empty?\n # [fix] - Replace with inplace slice!\n _line_sub = _line_sub.slice(1..-1)\n _max = _max + 1\n\n debug_print \"New line: #{ _line_sub }\\n\"\n debug_print \"Max indent: #{ _max }\\n\"\n end\n\n # Push max indent for current line to the _cut array\n _cut.push(_max)\n end\n\n # Print old _context\n debug_print \"\\n\\n Old Context \\n\"\n debug_print PP.pp(_context, '')\n debug_print \"\\n\\n\"\n\n # Trim the context lines to be left aligned but maintain indentation\n # Then add a single \\t to the beginning so the Markdown is pretty on GitHub/Bitbucket\n _context.map! { |_line_sub| \"\\t#{ _line_sub.slice(_cut.min .. -1) }\" }\n\n # Print new _context\n debug_print(\"\\n\\n New Context \\n\")\n debug_print PP.pp(_context, '')\n debug_print(\"\\n\\n\")\n\n _issue[:context] = _context\n\n # These are accessible from _issue_list, but we pass individual issues\n # to the remote poster, so we need this here to reference them for GitHub/Bitbucket\n _issue[:tag] = _tag\n _issue[:path] = _relative_path\n\n # Generate md5 hash for each specific issue (for bookkeeping)\n _issue[:md5] = ::Digest::MD5.hexdigest(\"#{ _tag }, #{ _relative_path }, #{ _title }\")\n debug_print \"#{ _issue }\\n\"\n\n\n # [todo] - Figure out a way to queue up posts so user has a progress bar?\n # That way user can tell that wait is because of http calls not app\n\n # If GitHub is valid, pass _issue to GitHub poster function\n # [review] - Keep Remote as a static method and pass config every time?\n # Or convert to a regular class and make an instance with @config\n\n\n # [review] - Use _tag string as symbol reference in hash or keep as string?\n # Look into to_sym to keep format of all _issue params the same\n _issue_list[_tag].push(_issue)\n\n # Increment issue counter for posting status\n @config.issue_count = @config.issue_count.next\n end\n\n # [review] - Return of parse_file is different than watson-perl\n # Not sure which makes more sense, ruby version seems simpler\n # perl version might have to stay since hash scoping is weird in perl\n debug_print \"\\nIssue list: #{ _issue_list }\\n\"\n\n _issue_list\n end",
"def parse_project_files(project)\r\n @files = []\r\n @server.projects.each{ |p|\r\n next if project != '*' and project != p.name\r\n p.views.each { |v|\r\n parse_folder(v.rootfolder)\r\n #break\r\n }\r\n }\r\n end",
"def process_file(file, files)\n # puts \"processing file #{file.to_s}\"\n case check_file_ext(file)\n when 'atp'\n files << file unless files.include?(file)\n when 'avc'\n files << file unless files.include?(file)\n when 'list'\n parse_list(file, files)\n end\n end",
"def parse_files\r\n ln_count = 0\r\n\r\n settings.file_order.each do |f|\r\n out = make_file(\"tmp.press\")\r\n\r\n ln_count += parse_lines(f, out)\r\n\r\n out.close\r\n tmp_files << out\r\n end\r\n\r\n ln_count\r\n end",
"def process_directory\n Dir.foreach(@source) do |f|\n next unless f.match(/[a-z]{2}[0-9]{3}[a-z]{2}[0-9]{4}\\.xml/)\n druid = get_druid_from_filename(f)\n mods_file = MODSFile.new(Nokogiri::XML(File.open(File.join(@source, f))), @template_xml, @namespace)\n process_mods_file(mods_file, druid)\n end\n write_output if @analysis_only == false\n report_data_loss\n end",
"def parse_file(path, options={})\n File.open(path) do |puzfile|\n parse_io(puzfile, options)\n end\n end",
"def load_file(definition)\n paths = definition.file\n\n paths.each do |path|\n ext = file_module.extname(path).strip.downcase[1..-1]\n parse_method = \"parse_#{ext}\"\n unless respond_to?(parse_method)\n fail \"extension (#{ext}), for (#{definition.key}: #{path}) \" +\n \"is not valid, only yaml and json are supported\"\n end\n\n if file_module.exists?(path)\n config = public_send(parse_method, path)\n unless config.is_a?(Hash)\n fail \"[config #{parse_method}] config must be a hash\"\n end\n config.deep_symbolize_keys!\n return config[definition.key]\n end\n end\n\n list = paths.join(',')\n fail \"none of :#{definition.key} config files exist at (#{list})\"\n end",
"def run\n admin_set\n return unless errors.empty?\n metadata_files.each { |file| parse_metadata(file) }\n end",
"def run_files_in_config_folder\n Dir[Dir.pwd + '/config/*.rb'].each do |config_file|\n require(config_file)\n end\n end",
"def load_config\n projects = Array.new\n Dir.glob(\"#{@config_path}/*.json\") do |cf|\n if !cf.end_with?(\"template.json\")\n projects << Project.new(cf)\n end\n end\n projects\nend",
"def parse_file(file)\n\n\n File.readlines(file).each do |line|\n command = parse_command(line)\n end\n # File.readlines(file).each do |line|\n # command = parse_command(line)\n # apply_command(command)\n end",
"def find_config(file); end",
"def pbcore_parsers\n @pbcore_parsers ||=\n path.join(\"data\").each_child.select { |file| [\".xml\"].include? file.extname }.map { |file| PbcoreParser.new(path: file) }\n end",
"def process_config src, file_name\n ConfigProcessor.new(@tracker).process_config src, file_name\n end",
"def parse filename\n clear\n File.open filename do |f|\n f.each_line &method(:parse_line)\n end\n self\n end",
"def parse\n records = []\n files.each do |fname|\n records += parse_file(fname)\n end\n\n @notes = records.sort\n end",
"def parse\n logger.debug \"Reading stoage file from: #{self.file.path}\"\n if self.status != 'finished'\n last_parsed_line = self.last_parsed_line\n # make_options\n begin\n # Match the proper parser and build options\n case self.file_type\n when \"1\"\n @parser = Wms::Input::Filetype1\n else\n raise \"Undefined storage type #{file_type}\"\n end\n # when \"wifilocation\"\n # @parser = Wms::Input::AndroidWifiLocation\n # when \"sensor\"\n # @parser = Wms::Input::AndroidSensor\n # when \"audio\"\n # raise \"Not Supported yet storage type #{file_type}\"\n # else\n # raise \"Undefined storage type #{file_type}\"\n # end\n\n @processor = @parser.new\n options = make_options\n @processor.register(options=options)\n\n @processor.run do |data|\n begin\n create_event data\n \n rescue Exception => e\n logger.error \"ERROR #{self.class.name}: #{e} for #{data}\"\n end\n last_parsed_line += 1\n end\n\n \n self.last_parsed_line = last_parsed_line\n self.status = \"finished\"\n self.save\n \n rescue Exception => e\n logger.error \"ERROR: [#{e}]\"\n self.last_parsed_line = last_parsed_line\n self.status = \"error\"\n self.save\n end # end begin\n \n end #end if self.status != 'finished'\n\n\n \n \n end",
"def process_files\n loaded_files = []\n files.each do |file|\n Async do |task|\n task.async do\n loaded_files << load_file(file[:path], file[:source])\n end\n end\n end\n loaded_files\n end",
"def initialize(*sources)\n @sources = sources\n\n @list = []\n\n sources.each do |source|\n if File.file?(source)\n parse(source)\n else\n # ignore directories\n end\n end\n end",
"def parse(paths: [], execute: false)\n\tfiles = output = Covered::Files.new\n\toutput = Covered::Source.new(output)\n\t\n\tpaths.each do |path|\n\t\toutput.mark(path, 0, 0)\n\tend\n\t\n\tif execute\n\t\tcapture = Covered::Capture.new(output)\n\t\tcapture.start\n\t\tpaths.each do |path|\n\t\t\tload path\n\t\tend\n\t\tcapture.finish\n\t\t\n\t\tfiles.paths = files.paths.slice(*paths)\n\tend\n\t\n\tCovered::Summary.new.call(output, $stderr)\nend",
"def process_input_file \n File.open(@file, 'r') do |f|\n f.each_line do |line|\n parse_line(line)\n end\n end\n end",
"def parse(*filenames)\n with(*filenames) do |f|\n ignoring_nonexistent_files do\n Environment.new(f, false)\n end\n end\n end",
"def parse_content(path, service_name = nil)\n config_files = Array(path)\n\n if path.directory?\n config_files = inspec.bash(\"ls #{path}/*\").stdout.lines.map{|f| inspec.file(f.strip) }\n end\n\n config_files.each do |config_file|\n next unless config_file.content\n\n # Support multi-line continuance and skip all comments and blank lines\n rules = config_file.content.gsub(\"\\\\\\n\",' ').lines.map(&:strip).delete_if do |line|\n line =~ /^(\\s*#.*|\\s*)$/\n end\n\n service = service_name\n unless service || @top_config\n service = config_file.basename\n end\n\n rules.each do |rule|\n new_rule = Pam::Rule.new(rule, {:service_name => service})\n\n # If we hit an 'include' or 'substack' statement, we need to derail and\n # delve down that tail until we hit the end\n #\n # There's no recursion checking here but, if you have a recursive PAM\n # stack, you're probably not logging into your system anyway\n if ['include','substack'].include?(new_rule.control)\n # Support full path specification includes\n if new_rule.module_path[0].chr == '/'\n subtarget = inspec.file(new_rule.module_path)\n else\n if File.directory?(path.path)\n subtarget = inspec.file(File.join(path.path, new_rule.module_path))\n else\n subtarget = inspec.file(File.join(File.dirname(path.path), new_rule.module_path))\n end\n end\n\n if subtarget.exist?\n parse_content(subtarget, service)\n end\n else\n\n unless new_rule.type && new_rule.control && new_rule.module_path\n raise PamError, \"Invalid PAM config found at #{config_file}\"\n end\n\n @services[new_rule.service] ||= []\n @services[new_rule.service] << new_rule\n\n @types[new_rule.type] ||= []\n @types[new_rule.type] << new_rule\n\n @modules[new_rule.module_path] ||= []\n @modules[new_rule.module_path] << new_rule\n\n @rules.push(new_rule)\n end\n end\n end\n end",
"def parse_files (path = '.', parent_id = 0)\n\n full_path = root_path().join(path)\n\n Dir.foreach(full_path) {|file_name|\n\n if file_name == '.' || file_name == '..'\n next\n end\n\n program_file = program_files.build()\n program_file.name = file_name\n program_file.path = Pathname.new(path).join(file_name).to_s\n program_file.parent_id = parent_id\n\n if File.ftype(full_path.join(file_name)) == 'directory'\n program_file.file_type = :dir\n program_file.save\n parse_files Pathname.new(path).join(file_name), program_file.id\n else\n program_file.file_type = :file\n program_file.save\n end\n }\n end",
"def run\n @files.each { |filename| load(filename) }\n end",
"def load_config\n input_file_paths =\n YAML.load_file('config/input_file_paths.yml')\n input_file_paths['input_file_paths'].each do |_, input_file_path|\n start input_file_path\n end\n end",
"def config_read\n f = File.expand_path(CONFIG_FILE)\n return unless File.readable? f\n\n hash = loadYML(f)\n @used_dirs = hash['DIRS']\n @visited_files = hash['FILES']\n @bookmarks = hash['BOOKMARKS']\n @used_dirs.concat get_env_paths\nend",
"def parse!(configuration_file)\n instance_eval(File.read(configuration_file))\n\n ##\n # If no configuration is found by environment then\n # it will re-parse it in a forced manner, meaning it won't\n # care about the environment and it will just parse everything it finds.\n # This is done because we can then extract all set \"modules\" from the configuration\n # file and display them in the \"Help\" screen so users can look up information/examples on them.\n #\n # This will only occur if no environment is found/specified. So when doing anything\n # environment specific, it will never force the parsing.\n if not found? and environment.nil?\n @force_parse = true\n instance_eval(File.read(configuration_file))\n @additional_modules.uniq!\n end\n\n if not found? and not environment.nil?\n GitPusshuTen::Log.error \"Could not find any configuration for #{environment.to_s.color(:yellow)}.\"\n exit\n end\n\n ##\n # Default to port 22 if no port is specified\n @port ||= '22'\n\n self\n end",
"def parse_in_order(*files); end",
"def parse(file_name)\n raise Mongify::ConfigurationFileNotFound, \"File #{file_name} is missing\" unless File.exists?(file_name)\n config = self.new\n config.instance_eval(File.read(file_name))\n config\n end",
"def process_all_primary_files\n # NOTE: I investigated concurrent processing of files\n # to speed up this process, however I didn't pursue it\n # further: This process is highly CPU intensive, so the\n # only way to get a significant speedup is to use\n # multiple CPUs/Cores. In MRI this is only possible\n # with multiple processes. I didn't want to go through\n # the trouble of IPC to collect all files' operations.\n # It would be easier if we could use threads, however\n # that would require jruby or rbx. So I'm sticking with\n # sequential processing for now.\n Dir.glob(\n File.join(@repository.base_dir, '**/content/**/*.at')\n ).map { |absolute_file_path|\n next nil if !@file_list.any? { |e| absolute_file_path.index(e) }\n # Skip non content_at files\n unless absolute_file_path =~ /\\/content\\/.+\\d{4}\\.at\\z/\n raise \"shouldn't get here\"\n end\n\n # Note: @any_content_type may be the wrong one, however finding\n # corresponding STM CSV file will still work as it doesn't rely\n # on config but das regex replacements on file path only.\n content_at_file_to = Repositext::RFile::ContentAt.new(\n File.read(absolute_file_path),\n @language,\n absolute_file_path,\n @any_content_type\n )\n\n @logger.info(\" - process #{ content_at_file_to.repo_relative_path(true) }\")\n\n soff = SubtitleOperationsForFile.new(\n content_at_file_to,\n @repository.base_dir,\n {\n from_git_commit: @from_git_commit,\n to_git_commit: @to_git_commit,\n prev_last_operation_id: @prev_last_operation_id,\n execution_context: @execution_context,\n }\n ).compute\n\n if soff.operations.any?\n @prev_last_operation_id = soff.last_operation_id\n soff\n else\n # Return nil if no subtitle operations exist for this file\n nil\n end\n }.compact\n end",
"def parse_in_order(*files)\n global_state = OpenStruct.new\n\n return if before_parse_list_callbacks.any? do |cb|\n cb.call(files, global_state) == false\n end\n\n OrderedParser.new(global_state, files).parse\n\n after_parse_list_callbacks.each do |cb|\n cb.call(files, global_state)\n end\n end",
"def parse\n checkArguments\n configContent = File.read(ARGV[0])\n @config = JSON.parse(configContent)\n checkConfig\n end",
"def parse_remaining_files; end",
"def parse_files(*files)\n self.files = []\n seen_extra_files_marker = false\n \n files.each do |file|\n if file == \"-\"\n seen_extra_files_marker = true\n next\n end\n \n if seen_extra_files_marker\n add_extra_files(file)\n else\n self.files << file\n end\n end\n end",
"def parse_filenames(path)\n\t\t#first if checks if it's a directory, a file or neither\n\t\tif File.directory?(path)\n\t\t\tdirname = path.chomp\n\t\t\t@files = File.join(path, \"*.vm\")\n\t\t\t@files = Dir.glob(@files)\n\t\t\t#if we have no files, there's nothing we can do, EXCEPTION\n\t\t\tif (@files.length == 0)\n\t\t\t\traise StandardError, \"No files to open\"\n\t\t\tend\n\t\t\tname = File.basename(dirname)\n\t\t\t@output = dirname + \"/\" + name + \".asm\"\n\t\telsif File.file?(path)\n\t\t\t#make sure the file is of the .vm type\n\t\t\tif (File.extname(path) == '.vm')\n\t\t\t\t#generate our output path\n\t\t\t\t@files = path\n\t\t\t\tf_path = File.split(path)[0]\n\t\t\t\tf_base = File.basename(path, '.vm')\n\t\t\t\tnFile = \"#{f_path}/#{f_base}.asm\"\n\t\t\t\t@output = nFile\n\t\t\telse\n\t\t\t\traise \"Error, cannot open this file!\"\n\t\t\tend\n\t\telse\n\t\t\traise \"ERROR, not a file or directory!\"\n\t\tend\n\n\t\t#return everything\n\t\treturn @files\n\tend",
"def main\n process_csv_files_from_dir\nend",
"def run\n case @options.scan_type\n when :directory\n scan_dirs\n parse_files\n excel_report\n when :file\n @scan_files = Array.new\n @scan_files << @options.scan_file\n parse_files\n excel_report\n end\n end",
"def parse_file!\n File.open(@filepath, 'r') do |f|\n last_line = ''\n while this_line = f.gets\n coll = case this_line\n when /^\\s*def / : @methods\n when /^\\s*class / : @classes\n when /^\\s*module / : @modules\n when /^\\s*(attr_reader|attr_accessor|attr_writer) / : @attrs\n when /^\\s*[^a-z =]+\\s*=/ : @constants\n else nil\n end\n # add a true entry if comment precedes declaration or follows on same line\n coll << is_comment?(last_line) || has_comment?(this_line) if coll\n last_line = this_line\n end\n end\n end",
"def process_config_file(path)\n RFlow.logger.info \"Processing config file (#{Dir.getwd}) '#{path}'\"\n load path\n end",
"def file_array_parser\n @array_of_parse_files = []\n file_array.each do |file|\n File.open(\"text_files/#{file}\").readlines.each do |line|\n if line.include?(\"\\n\") # removes '\\n' (line breaker)\n @array_of_parse_files << [line.gsub!(/\\n/, '')]\n else\n @array_of_parse_files << [line]\n end \n end\n @array_of_parse_files \n end\n\nend"
] | [
"0.71039224",
"0.691917",
"0.6822221",
"0.6722013",
"0.6694547",
"0.6576133",
"0.65486646",
"0.6472655",
"0.6465814",
"0.63299894",
"0.6325209",
"0.62602884",
"0.6241334",
"0.62286943",
"0.6174209",
"0.6141843",
"0.61278224",
"0.61043894",
"0.60943955",
"0.6084847",
"0.606878",
"0.606611",
"0.60656434",
"0.6061031",
"0.6021216",
"0.60130477",
"0.6002642",
"0.59664685",
"0.59488547",
"0.59488547",
"0.59488547",
"0.59488547",
"0.59488547",
"0.59488547",
"0.5927658",
"0.5925372",
"0.59249973",
"0.59249973",
"0.5915337",
"0.58885133",
"0.5882713",
"0.5873778",
"0.5864862",
"0.5863084",
"0.58573776",
"0.58531696",
"0.5839234",
"0.58336556",
"0.5828761",
"0.58275926",
"0.5823868",
"0.5822703",
"0.5821836",
"0.58211833",
"0.5803493",
"0.57987404",
"0.57987404",
"0.57981825",
"0.579043",
"0.57870626",
"0.57858473",
"0.57852054",
"0.5784852",
"0.57846874",
"0.57801723",
"0.5749664",
"0.5743228",
"0.5743002",
"0.5738726",
"0.5737096",
"0.57284033",
"0.57264954",
"0.57202476",
"0.57190746",
"0.57081956",
"0.5697835",
"0.5696166",
"0.56886274",
"0.56439996",
"0.5636328",
"0.5625907",
"0.5625192",
"0.5623478",
"0.5622303",
"0.56197846",
"0.56194043",
"0.5616188",
"0.5616019",
"0.5596702",
"0.5591529",
"0.5586329",
"0.5582172",
"0.5575817",
"0.55671066",
"0.55637723",
"0.5558704",
"0.5557825",
"0.55510193",
"0.55440414",
"0.5535969",
"0.5528236"
] | 0.0 | -1 |
Parse an XML decision file. | def parseFile(fname)
$LOG.debug "Parser::parseFile( #{fname} )"
puts "Parsing file: #{fname}" if @context.verbose
# Determine the mode and configure plugins based on the file data.
configureForFileMode(fname)
line_count = 1
# Open the file and read line by line
df = File.open(fname).each do |ln|
puts line_count.to_s if $DEBUG
line_count += 1
@plugins.each do |plug|
puts " --> #{plug.class}" if $DEBUG
break if ( true == plug.execute(@context, ln))
end # plugins.each
end # do file
puts "Lines parsed: #{line_count}" if @context.verbose
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_xml(filename)\n @parser = Parser.new :pregenerated => filename\n @parser.parse\n end",
"def parse_xml\n\n raise \"parse_xml method has not been implemented in this class\"\n \n end",
"def parse(fname)\r\n puts \"Parsing file.\" unless (!verbose?)\r\n ctxListener = ContextListener.new(@context)\r\n ctxListener.verbose = @verbose\r\n parser = Parsers::StreamParser.new(File.new(fname), ctxListener)\r\n parser.parse\r\n\r\n\r\n puts \"Parsing guideline.\" unless (!verbose?)\r\n gdlListener = GdlListener.new(@context) # Gets rule and ruleset names and aliases.\r\n gdlListener.verbose = @verbose\r\n parser = Parsers::StreamParser.new(File.new(fname), gdlListener)\r\n parser.parse\r\n\r\n\r\n puts \"Parsing rule XML.\" unless (!verbose?)\r\n ruleListener = RuleListener.new(@context)\r\n ruleListener.verbose = @verbose\r\n parser = Parsers::StreamParser.new(File.new(fname), ruleListener)\r\n parser.parse\r\n end",
"def parse_xml(file)\n\t\tdata = []\n\t\t# Break open XML and go through nodes\n\t\tbegin\n\t\t\tfile = file_sanitizer(file)\n\t\t\tdata = XmlSimple.xml_in(file, {'ForceArray' => false })\n\t\trescue Exception => e\n\t\t\traise e\n\t\tend\n\t\tdata\n\tend",
"def parse\n raise ERROR_FILE_NOT_SET if report.nil? || report.empty?\n raise format(ERROR_FILE_NOT_FOUND, report) unless File.exist?(report)\n\n Oga.parse_xml(File.read(report))\n end",
"def parse(file)\n doc = Nokogiri::XML( File.open( file ) )\n @type = doc.xpath(\"/probe/header/@type\").to_s\n @vendor = doc.xpath(\"/probe/header/@vendor\").to_s\n @services = \"<TODO>\"\n @indexes = \"<TODO>\"\n end",
"def read( nexml )\n case nexml\n when /\\.xml$/\n XML::Reader.file( nexml, :options => parse_opts )\n when IO\n XML::Reader.io( nexml, :options => parse_opts )\n when String\n XML::Reader.string( nexml, :options => parse_opts )\n end\n end",
"def parse_xml(xml)\n new from_xml(xml)\n end",
"def parse\n Ox.parse(@xml)\n end",
"def read_XML_file(xfile)\n result_array = []\n if File.file?(xfile)\n puts \"\\n\\nOPENING #{xfile}\"\n f = File.open(xfile)\n doc = Nokogiri::XML(f)\n if is_squish?(doc)\n result_array = squish_parser(doc)\n else\n result_array = rspec_parser(doc)\n end\n else\n puts \"\\nNot a file: #{xfile} - verify options (-x for directory, -f for a specific file)\"\n end\n return result_array \n end",
"def parse_xml(xml)\n while xml\n read_xml_element(xml)\n xml = xml.next\n end\n end",
"def parse_xml xml\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n result = result['result'] if result['result']\n result\n end",
"def parse_xml(file)\n @data_pts = Array.new\n doc = REXML::Document.new File.new(file)\n doc.elements.each('data/pt'){|pt|\n value = nil\n error = nil\n vars = Hash.new\n pt.attributes.each{|tag,val|\n\tif(tag == 'value')\n\t value = val.to_f\n\telsif(tag == 'error')\n\t error = val.to_f\n\telse\n\t vars[tag] = val.to_f\n\tend\t\n }\n @data_pts.push(DataPt.new(value,error,vars))\n }\n end",
"def load_xml( fileName )\r\n begin\r\n str = IO.read(fileName)\r\n load_xml_rules_as_string(str)\r\n rescue Exception => e\r\n raise RuleLoadingError, \"loading xml file\"\r\n end\r\n end",
"def parse\n return false unless filecheck\n doc = REXML::Document.new(open(file))\n @result_set = []\n doc.elements.each(RESULT_PATH) do |e|\n result_array = [] # [0]: name, [1]: data type, [2]:null\n get_generic(e, result_array)\n @result_set.push(result_array)\n end\n return true\n end",
"def parse_from_file filename\n parse File.open(filename)\n end",
"def parse_file(filename); end",
"def read_xml\n # date & time of rejections\n self.fecha_hora_confeccion = @doc.get_elements('//CreDtTm')[0].text\n self.process_date_time = Date.parse(self.fecha_hora_confeccion[0,10]) rescue Date.today\n # fiscal id, bank suffix & date of order\n self.OrgnlMsgId = @doc.get_elements('//OrgnlMsgId')[0].text\n self.OrgnlPmtInfId = @doc.get_elements('//OrgnlPmtInfId')[0].text\n begin # sufijo based on OrgnlPmtInfId\n self.sufijo = self.OrgnlPmtInfId[4,3]\n rescue # sufijo based on OrgnlMsgId\n self.sufijo = self.OrgnlMsgId[22,3]\n end\n begin # nif based on OrgnlPmtInfId\n self.nif = self.OrgnlPmtInfId[7,9]\n rescue # nif based on OrgnlMsgId\n self.nif = self.OrgnlMsgId[25,9]\n end\n begin # nif based on OrgnlPmtInfId\n self.fecha_devolucion = self.OrgnlPmtInfId[16,8].to_date\n rescue # nif based on OrgnlMsgId\n self.fecha_devolucion = self.OrgnlMsgId[3,8].to_date\n end\n # Original file data\n self.numero_total_adeudos = @doc.elements['//CstmrPmtStsRpt'].elements['OrgnlPmtInfAndSts'].elements['OrgnlNbOfTxs'].text\n self.importe_total = @doc.elements['//CstmrPmtStsRpt'].elements['OrgnlPmtInfAndSts'].elements['OrgnlCtrlSum'].text\n #\n # Loop thru rejections (TxInfAndSts)\n #\n receipt_no = ''\n remesa_old = ''\n referencia_tipo = ''\n cuenta_acreedor = ''\n @doc.elements.each('//TxInfAndSts') do |e|\n referencia_adeudo = e.elements['OrgnlEndToEndId'].text\n codigo_rechazo = e.elements['StsRsnInf'].elements['Rsn'].elements['Cd'].text\n importe_adeudo = (e.elements['OrgnlTxRef'].elements['Amt'].elements['InstdAmt'].text.to_d) * (-1)\n fecha_cobro = e.elements['OrgnlTxRef'].elements['ReqdColltnDt'].text.to_date\n referencia_mandato = e.elements['OrgnlTxRef'].elements['MndtRltdInf'].elements['MndtId'].text\n fecha_firma_mandato = e.elements['OrgnlTxRef'].elements['MndtRltdInf'].elements['DtOfSgntr'].text.to_date\n concepto = e.elements['OrgnlTxRef'].elements['RmtInf'].elements['Ustrd'].text\n nombre_deudor = e.elements['OrgnlTxRef'].elements['Dbtr'].elements['Nm'].text\n cuenta_deudor = e.elements['OrgnlTxRef'].elements['DbtrAcct'].elements['Id'].elements['IBAN'].text\n cuenta_acreedor = e.elements['OrgnlTxRef'].elements['CdtrAcct'].elements['Id'].elements['IBAN'].text\n referencia_tipo = referencia_adeudo[34,1]\n id_bill = referencia_adeudo[0,9].to_i # if referencia_tipo=='I'->invoice_id else referencia_tipo!='I'->bill_id\n id_client_payment = referencia_adeudo[9,9].to_i\n receipt_no = referencia_adeudo[18,6]\n id_client = referencia_mandato.last(8).to_i\n remesa_old = referencia_adeudo[10,6]\n\n # *** Save in returns array ***\n self.lista_devoluciones.push(referencia_adeudo: referencia_adeudo,\n codigo_rechazo: codigo_rechazo,\n importe_adeudo: importe_adeudo,\n fecha_cobro: fecha_cobro,\n referencia_mandato:referencia_mandato,\n fecha_firma_mandato: fecha_firma_mandato,\n concepto: concepto,\n nombre_deudor: nombre_deudor,\n cuenta_deudor: cuenta_deudor,\n bill_id: id_bill,\n client_payment_id: id_client_payment,\n receipt_no: receipt_no,\n client_id: id_client)\n end\n self.cuenta_acreedor = cuenta_acreedor\n self.remesa = receipt_no\n self.remesa_old = remesa_old\n self.referencia_tipo = referencia_tipo\n end",
"def xml_parser(directory_name, filename)\n @doc = Document.new File.new(directory_name + filename)\n get_dataset_name(filename)\n set_topics\n set_dataset_rel_and_attr\n get_footnotes\n record_attributes\n @dataset.save\n end",
"def from_file(file_path)\n from_xml(File.read(file_path))\n end",
"def load_xml(file_path)\n # Read the source XML file.\n puts \"file_path: #{file_path}\"\n raw_xml = File.read(file_path)\n\n # Parse raw_xml using Nokogiri.\n parsed_doc = Nokogiri.XML(raw_xml)\nend",
"def process_xml(xml)\n doc = REXML::Document.new xml\n @message_identifier = doc.text(\"//imsx_statusInfo/imsx_messageIdentifier\").to_s\n @code_major = doc.text(\"//imsx_statusInfo/imsx_codeMajor\")\n @code_major.downcase! if @code_major\n @severity = doc.text(\"//imsx_statusInfo/imsx_severity\")\n @severity.downcase! if @severity\n @description = doc.text(\"//imsx_statusInfo/imsx_description\")\n @description = @description.to_s if @description\n @message_ref_identifier = doc.text(\"//imsx_statusInfo/imsx_messageRefIdentifier\")\n @operation = doc.text(\"//imsx_statusInfo/imsx_operationRefIdentifier\")\n @score = doc.text(\"//readResultResponse//resultScore/textString\")\n @score = @score.to_s if @score\n end",
"def load_xml_doc( filename )\n File.open( filename, 'r') do |file|\n return Oga.parse_xml( file )\n end\n\n puts \"ERROR: loading #{filename}\"\n return nil\n end",
"def initialize(path)\n @filename = path\n file = nil\n file = open(path)\n @errors = [] \n \n @document = Nokogiri::XML(file)\n @document.remove_namespaces!\n @node = @document.root\n unless self.valid?\n self.errors << {:xml => 'invalid xml passed in'}\n #raise \"Unable to load file. Is it in the correct format?\"\n end\n end",
"def read_file(filename)\n File.open(filename, \"r\") {|f| load_xml(f.read)}\n end",
"def parse_xml(xml)\n Nokogiri::XML(xml, &:noblanks)\n end",
"def xml\n File.read(\"#{@file_path}.xml\")\n end",
"def parse(xml)\n raise NotImplementedError, \"inheritor should define #{__method__}\"\n end",
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def DataLoadFromFile(filename)\n file = File.new(filename)\n \n @xml_data = file\n self.ScrapAnalyse()\n end",
"def load_xml file\n f = File.open file\n doc = Nokogiri::XML f\n f.close\n doc\n end",
"def from_xml(xml)\n\t\tend",
"def parse( x )\n cycle( xml( x ) )\n end",
"def parse filename\n doc = Document.new(File.new(filename))\n elements = doc.elements\n # Let each entity definition do it's own lower level parsing\n self.entities.each do |e|\n @instances[e.name] = e.parse(self, elements)\n end\n # Let each relationship definition do it's own lower level parsing\n self.relationships.each do |r|\n r.parse(self, @instances)\n end\n end",
"def parse(xml)\n document = make_document(xml)\n\n Atom::XML::Parser.document(document).parse\n end",
"def initialize(xml)\n @source = isxml?(xml) ? xml : File.read(xml)\n @doc_stream = AltoDocStream.new\n parser = Nokogiri::XML::SAX::Parser.new(doc_stream)\n parser.parse(@source)\n end",
"def process_xml(xml)\n doc = REXML::Document.new xml\n @message_identifier = doc.text(\"//imsx_POXRequestHeaderInfo/imsx_messageIdentifier\")\n @lis_result_sourcedid = doc.text(\"//resultRecord/sourcedGUID/sourcedId\")\n\n if REXML::XPath.first(doc, \"//deleteResultRequest\")\n @operation = DELETE_REQUEST\n elsif REXML::XPath.first(doc, \"//readResultRequest\")\n @operation = READ_REQUEST\n elsif REXML::XPath.first(doc, \"//replaceResultRequest\")\n @operation = REPLACE_REQUEST\n @score = doc.get_text(\"//resultRecord/result/resultScore/textString\")\n end\n extention_process_xml(doc)\n end",
"def parse_xml(xml)\n @xml = xml.to_s.gsub(/\\s+/, \" \").strip\n @doc = XML::Document.parse_string(@xml).root\n\n # the query metadata\n @query_time = @doc.at('/crossQueryResult')['queryTime']\n @total_docs = @doc.at('/crossQueryResult')['totalDocs']\n @start_doc = @doc.at('/crossQueryResult')['startDoc']\n @end_doc = @doc.at('/crossQueryResult')['endDoc']\n @docs_per_page = @doc.at(\"/crossQueryResult/query\")['maxDocs'] rescue DEFAULT_DOCS_PER_PAGE\n\n @query = @doc.at('/crossQueryResult/query').to_s\n # the docHits\n # TODO deal with PDFS. This currently filters them from the results\n @doc_hits = @doc.search('./docHit').collect { |h| XTF::Result::Element::DocHit.create(h, @query) }.compact\n\n @facets = @doc.search('/crossQueryResult/facet').collect { |f| XTF::Result::Element::Facet.new(f, @query) }\n end",
"def parse\n parse_file\n self\n end",
"def parse\n\t\tfile = File.new(@filename, \"r\")\n\t\tline = file.gets.chomp\n\t\twhile !line.nil?\n\t\t\tif line =~ /(Underflow|Overflow)/ #if exception\n\t\t\t\tline =~ /Overflow/ ? overflow = true : overflow = false\n\t\t\t\tidentifier = line[/[0-9][0-9]*/] #get exception identifier\n\t\t\t\tline = file.gets.chomp\t\t\t\t\t\n\t\t\t\tline = file.gets.chomp if line =~ /The constraints are unsat/\t\t\t\t\n\t\t\t\tline = file.gets.chomp if line =~ /KLEE: WARNING:/\t\t\t\t\n\t\t\t\t# For a given identifier, there can me multiple warnings of a potential \n\t\t\t\t# overflow/underflow, store only the last one.\n\t\t\t\t# By creating a new array, previous values are overwritten\n\t\t\t\tvalues = []\n\t\t\t\twhile line =~ /^arr[0-9]/\t#if arr value\n\t\t\t\t\tline = file.gets.chomp\n\t\t\t\t\t#~ puts \"#{identifier}: #{line}\"\t#debugging\n\t\t\t\t\tvalues.push line #store value as sring with no regard to type (rational, float, integer)\t\t\t\t\t\n\t\t\t\t\tline = file.gets.chomp\n\t\t\t\tend\n\t\t\t\tif not values.empty? #if some arr values were found, store them\t\t\t\t\t\n\t\t\t\t\toverflow ? @overflow[\"#{identifier}\"] = values : @underflow[\"#{identifier}\"] = values\n\t\t\t\tend\n\t\t\telse \n\t\t\t\tline = file.gets #if not exception warning\n\t\t\tend\n\t\tend #iterate over lines in file\n\tend",
"def parse_process_xml (xml)\n\n elt = REXML::Document.new(xml).root\n elt = elt.owfe_first_elt_child 'paused'\n\n {\n :paused => (elt.text.downcase == 'true')\n }\n end",
"def initialize(xml_file_name)\n @xml_file_name = xml_file_name\n @kinvars = Array.new\n doc = REXML::Document.new(File.new(xml_file_name)) \n kv_elem = doc.elements['kinematic-variables']\n kv_elem.elements.each('kinvar'){|kv| @kinvars.push Kinvar.new(kv)}\n @data_file = kv_elem.elements['dat-file'].attributes['file']\n @file = File.new(@data_file,'rb')\n end",
"def initialize( xml_file, *options )\n @node_name = \"00000\"\n\t @show_text = true\n\t @show_attributes = true\n\n if options and options[0]\n options[0].each do |xKey, xValue|\n case xKey.to_s\n when \"text\"\n @show_text = xValue\n\t\t options[0].delete( xKey )\n when \"attrs\"\n @show_attributes = xValue\n\t\t options[0].delete( xKey )\n end\n end\n end\n\n @rexml_document = REXML::Document::new( File::new( xml_file ) )\n @graph = GraphViz::new( \"XML\", *options )\n parse_xml_node( @rexml_document.root() )\n end",
"def read(file)\n\t\tf = File.open file\n\t\t@doc = Nokogiri::XML(f)\n\t\t@current_node = @doc.root;\n\t\tf.close\n\tend",
"def parse_file(file_path)\n Cabrillo.parse(IO.read(file_path))\n end",
"def read_xml(xml)\n REXML::Document.new(File.read(xml)).root\nend",
"def parse_file(filename)\n File.open(filename, 'r') { |f| parse f }\n end",
"def xml_load(file_path)\n result = MultiXml.parse(File.read(file_path)).to_smash[:configuration]\n xml_format(result)\n end",
"def parse xml\n begin\n output = Crack::XML.parse xml\n rescue Exception => e\n puts \"Exception parsing message #{e.message}\"\n return {}\n end\n end",
"def read_xml\n @epub.file.read_xml(abs_filepath)\n end",
"def parse(path_to_file)\n file = self.class.get_file(path_to_file)\n\n parser = Parser.new(file)\n @title = parser.get_title\n @authors = parser.get_authors\n @abstract = parser.get_abstract\n @content = parser.get_content\n @references = parser.get_references.map do |r|\n Reference.new(r[:html_id], r[:entry])\n end\n\n # TODO remove after we've switched to online\n file.close\n end",
"def load_from_xml(node)\n # Get all information from the root's children nodes\n node.children.each do |child|\n case child.name.to_s\n when 'id'\n @id = child.content.to_i\n when 'title'\n @title = child.content\n when 'image'\n check_image_node(child)\n when 'date'\n @date = Time.parse(child.content)\n when 'streamable'\n check_streamable_node(child)\n when 'size'\n @size = child.content.to_i\n when 'description'\n @description = child.content\n when 'duration'\n @duration = child.content.to_i\n when 'creator'\n @creator = child.content\n when 'url'\n @url = child.content\n when 'text'\n # ignore, these are only blanks\n when '#text'\n # libxml-jruby version of blanks\n else\n raise NotImplementedError, \"Field '#{child.name}' not known (#{child.content})\"\n end #^ case\n end #^ do |child|\n end",
"def classy_parse(file)\n CSV.foreach(file, :encoding => 'iso-8859-1') { |row|\n classify(row[5])\n }\n end",
"def parse(uploaded_file)\n parser_class = \n case uploaded_file.content_type\n when \"application/vnd.ms-excel\"\n ExcelParser\n when \"text/csv\", \"application/octet-stream\", \"text/plain\"\n CSVParser\n else\n self.errors << \"Do not know how to parse #{uploaded_file.original_filename}. \" +\n \"Expects .csv or .xls (Excel) files.\"\n nil\n end\n\n if parser_class\n @data = parser_class.new(self).parse(uploaded_file)\n end\n\n self.valid?\n end",
"def proofread_document(xml)\n use_document(xml)\n proofread # returns valid?\n end",
"def read(file) \n @file = Nokogiri::XML(file){ |cfg| cfg.noblanks } \n end",
"def parse(xml, options = {})\n self.class.parse(xml, options.merge!(update: self))\n end",
"def from_xml(xml)\n parsed_status = \"unknown\"\n\n if xml\n build_names = []\n xml.elements.each(\"feed/entry/title\") {|entry| build_names << entry.text}\n\n build_master = build_names.find {|build_name| build_name.include?(@build_name) }\n parsed_status = build_master.match(/\\(.+\\)/).to_s\n end\n\n case parsed_status\n when \"(stable)\"\n \"stable\"\n when \"(back to normal)\"\n \"stable\"\n when \"(?)\"\n \"building\"\n when \"(aborted)\"\n \"aborted\"\n when /broken/\n \"broken\"\n when \"unknown\"\n \"unknown\"\n else\n \"failed\"\n end\n\n end",
"def read_file(file)\n build_xml(Ripper::SexpBuilder.new(IO.read(file)).parse)\n end",
"def read_file(file)\n build_xml(Ripper::SexpBuilder.new(IO.read(file)).parse)\n end",
"def parser\n return nil if self.evaluation_file.nil?\n VivoParser.new(self.evaluation_file.path)\n end",
"def parse_input (input_file)\nend",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def initialize(filepath)\n puts \"Give an appropriate response to each category. Note that parenthesis within placeholders are NOT supported.\"\n story = File::read(filepath) #FIXME: Do I want to be putting the whole file into story? What if it's long?\n print parse(story)\n end",
"def training_parse(file)\n CSV.foreach(file, :encoding => 'iso-8859-1') { |row|\n @category = row[0]\n if @category == '0'\n @training_negatives += 1\n elsif @category == '2'\n @training_neutrals += 1\n else\n @training_positives += 1\n end\n @text = row[5]\n train @category, @text\n }\n population\n end",
"def load(filename)\n file_content = File.open(filename).read\n TOMLP::Parser.new(file_content).parse\n end",
"def parse_file\n @file ||= File.open(@file_name) unless @file_name.nil?\n @text = @file.readlines\n @file.close unless @file.nil?\n parse_text\n end",
"def parse\n #return a cached version if it exists\n return @nexml if @nexml\n\n #start at the root element\n skip_leader\n\n #start with a new Nexml object\n version = attribute( 'version' )\n generator = attribute( 'generator' )\n @nexml = NeXML::Nexml.new( version, generator )\n\n #perhaps a namespace api as well\n \n #start parsing other elements\n while next_node\n case local_name\n when \"otus\"\n @nexml.add_otus( parse_otus )\n when \"trees\"\n @nexml.add_trees( parse_trees )\n when \"characters\"\n @nexml.add_characters( parse_characters )\n end\n end\n\n #close the libxml parser object\n #close\n\n #return the Nexml object\n @nexml\n end",
"def load_xml(file_name = @file_name)\n\t\tputs \"loading xml...\"+file_name\n\t\ttweet_loader = TweetLoader.new(file_name)\n\t\ttweet_loader.load_tweets\n\t\t@tweets = tweet_loader.get_tweets\n\tend",
"def parse_file(path, **options)\n parse(::File.read(path), **options)\n end",
"def parser(filename = EXAMPLE_CONTINUOUS)\n filepath = File.join(File.dirname(__FILE__), \"..\", \"data\", filename)\n @parser = ImzML::Parser.new(filepath)\n end",
"def parse(filename)\n instructions = open filename\n instructions.read.split(//)\nend",
"def from_xml(node)\r\n @story_id = node['id']\r\n @title = node['name']\r\n @description = node['description'] || \"\"\r\n @url = node['url']\r\n accepted_at_node = node['accepted_at']\r\n @accepted_at = accepted_at_node.nil? ? nil : DateTime.parse(accepted_at_node)\r\n @created_at = DateTime.parse(node['created_at'])\r\n @updated_at = DateTime.parse(node['updated_at'])\r\n @requested_by_id = node['requested_by_id']\r\n @current_state = node['current_state']\r\n owned_by_node = node['owned_by']\r\n @owned_by_id = node['owned_by_id'] # owned_by_node.nil? || owned_by_node.length == 0 ? 'no one' : owned_by_node\r\n @story_type = node['story_type']\r\n estimate_node = node['estimate']\r\n @estimate = estimate_node.nil? ? 0 : estimate_node.to_i\r\n @estimate = 0 if @estimate < 0\r\n labelnode = node['labels']\r\n @labels = labelnode\r\n\r\n self\r\n end",
"def parse(file)\n puts \"Not yet implemented\"\nend",
"def init_from_xml(xmlDoc)\r\n @type = xmlDoc.expanded_name\r\n xmlDoc.each_element(\"ID\") { |e| @procID = e.text }\r\n xmlDoc.each_element(\"GROUP\") { |e| @group = e.text }\r\n xmlDoc.each_element(\"PATH\") { |e| @path = e.text }\r\n xmlDoc.each_element(\"ARGSLINE\") { |e| @cmdLineArgs = e.text }\r\n xmlDoc.each_element(\"ENV\") { |e| @env = e.text }\r\n # Dump the XML description of the OML configuration into a file\r\n xmlDoc.each_element(\"OML_CONFIG\") { |config|\r\n configPath = nil\r\n config.each_element(\"omlc\") { |omlc|\r\n configPath = \"/tmp/#{omlc.attributes['exp_id']}-#{@procID}.xml\"\r\n }\r\n f = File.new(configPath, \"w+\")\r\n config.each_element {|el|\r\n f << el.to_s\r\n }\r\n f.close\r\n # Set the OML_CONFIG environment with the path to the XML file\r\n @env << \" OML_CONFIG=#{configPath} \"\r\n }\r\n end",
"def load_from_xml(node)\n # Get all information from the root's children nodes\n node.children.each do |child|\n case child.name.to_s\n when 'id'\n @id = child.content.to_i\n when 'title'\n @title = child.content.to_s\n when 'artists'\n @artists = [] if @artists.nil?\n child.children.each do |artist|\n @artists << Artist.new(:name => artist.content) if artist.name == 'artist'\n @headliner = Artist.new(:name => artist.content) if artist.name == 'headliner'\n end\n @artists << @headliner unless @headliner.nil? || headliner_alrady_listed_in_artist_list?\n when 'image'\n check_image_node(child)\n when 'url'\n @url = child.content\n when 'description'\n @description = child.content\n when 'attendance'\n @attendance = child.content.to_i\n when 'reviews'\n @reviews = child.content.to_i\n when 'tag'\n @tag = child.content\n when 'startDate'\n @start_date = Time.parse(child.content)\n when 'startTime'\n @start_time = child.content\n when 'endDate'\n @end_date = Time.parse(child.content)\n when 'tickets'\n # @todo Handle tickets\n when 'venue'\n @venue = Venue.new_from_xml(child)\n when 'website'\n @website = child.content.to_s\n when 'text'\n # ignore, these are only blanks\n when '#text'\n # libxml-jruby version of blanks\n else\n raise NotImplementedError, \"Field '#{child.name}' not known (#{child.content})\"\n end #^ case\n end #^ do |child|\n @artists.uniq!\n end",
"def parseXML()\n @transform = PoortegoTransform.new('ParsedResponse')\n result_href = XmlSimple.xml_in(@xml_response.to_s)\n \n unless (result_href.has_key?('ResponseData'))\n return\n end\n \n (result_href['ResponseData'])[0].each do |response_key, response_val|\n if (response_key == 'Entities')\n parse_entities_hash(response_val)\n elsif (response_key == 'Links')\n parse_links_hash(response_val)\n else\n puts \"Invalid ResponseData key\"\n end\n end\n \n (result_href['ResponseMessages'])[0].each do |message_key, message_val|\n if (message_key == 'Message')\n parse_message_hash(message_val)\n else\n puts \"Invalid ResponseMessages key\"\n end\n end\n \n end",
"def load_config_xml(conf_file) # :nodoc: all\n working = \"\"\n signer_working = \"\"\n zonelist = \"\"\n kasp = \"\"\n begin\n File.open((conf_file + \"\").untaint , 'r') {|file|\n doc = REXML::Document.new(file)\n enforcer_interval = nil\n begin\n e_i_text = doc.elements['Configuration/Enforcer/Interval'].text\n enforcer_interval = Config.xsd_duration_to_seconds(e_i_text)\n rescue Exception\n KASPAuditor.exit(\"Can't read Enforcer->Interval from Configuration\", 1)\n end\n begin\n working = doc.elements['Configuration/Auditor/WorkingDirectory'].text\n rescue Exception\n working = @working_folder\n end\n begin\n signer_working = doc.elements['Configuration/Signer/WorkingDirectory'].text\n rescue Exception\n signer_working = @working_folder\n end\n begin\n zonelist = doc.elements['Configuration/Common/ZoneListFile'].text\n rescue Exception\n KASPAuditor.exit(\"Can't read zonelist location from conf.xml - exiting\", 1)\n end\n begin\n kasp = doc.elements['Configuration/Common/PolicyFile'].text\n rescue Exception\n KASPAuditor.exit(\"Can't read KASP policy location from conf.xml - exiting\", 1)\n end\n load_privileges(doc)\n begin\n facility = doc.elements['Configuration/Common/Logging/Syslog/Facility'].text\n # Now turn the facility string into a Syslog::Constants format....\n syslog_facility = eval \"Syslog::LOG_\" + (facility.upcase+\"\").untaint\n return syslog_facility, working, signer_working, zonelist, kasp, enforcer_interval\n rescue Exception => e\n print \"Error reading config : #{e}\\n\"\n return Syslog::LOG_DAEMON, working, signer_working, zonelist,kasp, enforcer_interval\n end\n }\n rescue Errno::ENOENT\n KASPAuditor.exit(\"ERROR - Can't find config file : #{conf_file}\", 1)\n end\n end",
"def test_parse\n result = Yadis.parseXRDS(read_data_file(XRD_FILE))\n assert_not_nil result\n end",
"def load_unattend(xml_path)\n print_status(\"Reading #{xml_path}\")\n f = session.fs.file.new(xml_path)\n raw = \"\"\n until f.eof?\n raw << f.read\n end\n\n begin\n xml = REXML::Document.new(raw)\n rescue REXML::ParseException => e\n print_error(\"Invalid XML format\")\n vprint_line(e.message)\n return nil, raw\n end\n\n return xml, raw\n end",
"def load_XML(file)\n begin\n xml_file = File.open(file)\n xml_obj = Document.new(xml_file)\n xml_file.close\n rescue => e\n puts \"ERROR: Unable to create XML object from file: #{file}\"\n puts e.message\n puts e.backtrace\n exit 1\n end\n return xml_obj\nend",
"def parse_document(file)\n\n hpricot_doc = create_doc(file)\n raise \"Feature not saved!\" if hpricot_doc.nil?\n\n feature = extract_feature(hpricot_doc)\n xml_document = store_xml_document(feature)\n\n feature_object_types = extract_feature_object_types(hpricot_doc, feature)\n feature_relations = extract_feature_relations(hpricot_doc, feature)\n\n #feature_names = extract_feature_names(hpricot_doc, feature)\n extract_feature_names(hpricot_doc, feature)\n\n # When a feature is saved, it caches all of its ancestor ids. \n # You need to make sure this happens for all of the features every time\n # a new batch has been imported. \n features = Feature.all\n features.each do |f|\n f.save\n end\n end",
"def parse(xml_text)\n xml = XmlSimple.xml_in(xml_text, { 'ForceContent' => true })\n parse_block(xml['block'][0])\n end",
"def get_xml_of_type( asdcp_type, file, errors, errors_status )\n begin\n xml = Nokogiri::XML( open file )\n rescue Exception => e\n @logger.info \"#{ file }: #{ e.message }\"\n return false, errors, errors_status\n end\n\n unless xml.errors.empty?\n xml.errors.each do |error|\n # expected errors from non-xml\n next if error.message =~ /Start tag expected/ or error.message =~ /Document is empty/\n errors << \"Syntax error: #{ file }: #{ error }\"\n errors_status = true\n @logger.info errors.last\n end\n return false, errors, errors_status\n end\n\n if xml.root\n case xml.root.node_name\n when asdcp_type\n return xml, errors, errors_status\n else\n return false, errors, errors_status\n end\n else\n return false, errors, errors_status\n end\nend",
"def initialize(xml_file)\n doc_taxonomies = LonelyPlanet::Doc.load xml_file\n taxonomies_fragement = doc_taxonomies.css 'taxonomy > node'\n @continents = []\n set_continents(taxonomies_fragement)\n end",
"def create\n #Load file\n \n if params[:xml_file].content_type =~ /xml/\n begin\n plain_string = XmlSimple.xml_in(params[:xml_file].read,{'ForceArray' => false, 'NoAttr' => true,'SuppressEmpty' => true })\n flash[:notice]=\"File parsed successfully.\"\n rescue\n flash[:notice]=\"Error in parsing file.\"\n end\n if plain_string[\"keyword\"].kind_of?(Array) && !plain_string[\"keyword\"].empty?\n plain_string[\"keyword\"].each do|kwd|\n next if kwd.blank?\n # Language will be updated later after identifying keyword language\n Keyword.create({:keyword=>kwd,:language=>\"english\"})\n end\n end\n\n AsyncRequest.execute\n\n end\n respond_to do |format|\n format.html{render :action=>:new}\n end\n end",
"def parse(file)\n document = Nokogiri::XML(file).remove_namespaces!\n document.xpath('//types').each do |type|\n name = type.xpath('name').first.content\n key = name.underscore.to_sym\n type.xpath('members').each do |member|\n self[key] << member.content\n end\n end\n self\n end",
"def parse(filename)\n Parser::CurrentRuby.parse(File.open(filename, \"r\").read)\n end",
"def parse! filename\n parse_! filename\n end",
"def parse(xml)\n # \"<?xml version=\\\"1.0\\\"?><response><receipt>\".\n # \"<ReceiptId>Global Error Receipt</ReceiptId>\".\n # \"<ReferenceNum>null</ReferenceNum>\n # <ResponseCode>null</ResponseCode>\".\n # \"<ISO>null</ISO> \n # <AuthCode>null</AuthCode>\n # <TransTime>null</TransTime>\".\n # \"<TransDate>null</TransDate>\n # <TransType>null</TransType>\n # <Complete>false</Complete>\".\n # \"<Message>null</Message>\n # <TransAmount>null</TransAmount>\".\n # \"<CardType>null</CardType>\".\n # \"<TransID>null</TransID>\n # <TimedOut>null</TimedOut>\".\n # \"</receipt></response> \n\n response = {:message => \"Global Error Receipt\", :complete => false}\n\n xml = REXML::Document.new(xml) \n\n xml.elements.each('//receipt/*') do |node|\n\n response[node.name.underscore.to_sym] = normalize(node.text)\n\n end unless xml.root.nil?\n\n response\n end",
"def parse\n return parse_text unless @text.nil?\n return parse_file unless @file.nil? && @file_name.nil?\n return false\n end",
"def parse(filename)\n file = File.open(filename, \"r\").readlines\n\n $root = Node.new('root')\n $context = $root\n\n file.each_with_index do |line, index|\n process_line(line, index) if line.match(/\\S/)\n end\n\n return $root\n\nend",
"def load_and_parse\n\n if @infile\n @graph = RDF::Graph.load(@infile)\n end\n\n end",
"def run\n if (@opt_schema) then\n file = File.new(\"/home/jmll/src/IPv6Suite/Etc/netconf.xsd\")\n else\n file = File.new(\"/home/jmll/src/IPv6Suite/Etc/HMIPv6Network-schema.xml\")\n end\n\n# doc = Document.new(string)\n @doc = Document.new(file)\n\n ###Pretty dumb you need to specify exactly which elements you want to listen to.\n\n# @parser = Parsers::SAX2Parser.new(File.new(file.path))\n# @parser.listen( %w{ xs:element xs:sequence xs:complexType xs:simpleType xs:attributeGroup xs:enumeration xs:attribute } ) do |uri, localname, qname, attrs|\n# next if localname =~ /annotation/\n# puts \"ln is #{localname}\"\n# #puts \"qname is #{qname}\"\n# #puts \"attrs is #{attrs}\"\n# end\n# @parser.parse\n\n parseSchema if @opt_schema\n parseSchemaInstance if not @opt_schema\n end"
] | [
"0.6641009",
"0.6066658",
"0.6057007",
"0.603219",
"0.59758866",
"0.5967331",
"0.5960635",
"0.59363276",
"0.5923457",
"0.5920838",
"0.5903615",
"0.58487666",
"0.5785318",
"0.5756732",
"0.5733115",
"0.57223266",
"0.5697135",
"0.5625335",
"0.56161094",
"0.5571622",
"0.55673367",
"0.55290097",
"0.55185974",
"0.54851043",
"0.546229",
"0.54544353",
"0.5444285",
"0.543863",
"0.54041135",
"0.54041135",
"0.53888124",
"0.5386375",
"0.5365711",
"0.53629327",
"0.53471386",
"0.5346451",
"0.5342269",
"0.5332829",
"0.5321293",
"0.5296515",
"0.5290808",
"0.5250642",
"0.524575",
"0.52416074",
"0.52287424",
"0.5215936",
"0.5208287",
"0.5190993",
"0.5187421",
"0.518149",
"0.51595336",
"0.51451707",
"0.5140293",
"0.5136504",
"0.5132726",
"0.5125829",
"0.5117978",
"0.51150984",
"0.511479",
"0.5104946",
"0.5104946",
"0.51005566",
"0.50962365",
"0.50958866",
"0.50958866",
"0.50958866",
"0.50958866",
"0.50958866",
"0.50958866",
"0.50868964",
"0.50729865",
"0.50629663",
"0.5049334",
"0.50170195",
"0.4992043",
"0.4988686",
"0.497722",
"0.49770904",
"0.4975307",
"0.497239",
"0.49656427",
"0.49650767",
"0.49564695",
"0.49536347",
"0.49491507",
"0.49408934",
"0.49362653",
"0.49305052",
"0.49262285",
"0.49243876",
"0.49122915",
"0.4911052",
"0.49086356",
"0.49006072",
"0.4898361",
"0.48960692",
"0.4888953",
"0.48800093",
"0.4872102",
"0.48639038"
] | 0.49929798 | 74 |
Set directory where generated files are placed. | def setOutdir(dir)
@context.outdir = dir
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_dir\n File.join(root_path, 'generated')\n end",
"def generated_files_dir\n dir(@generated_files_dir || default_generated_files_dir)\n end",
"def gen_dir(gendir = nil)\n @gen_dir = \"#{gendir}#{gendir.empty? ? '.' : ''}\" if gendir\n @gen_dir\n end",
"def gen_dir(gendir)\n @recipe.gen_dir(gendir.to_s)\n end",
"def output_dir(options = {})\n options[:dir] = \"generate\"\n build_webby_path(options)\n end",
"def config_schema_generation_directory\n FilePath.new(@build_dir, \"generated\", \"config-schema\")\n end",
"def config_dir\n runtime_config.generated_files_dir\n end",
"def initialize_output_directory()\n require 'fileutils'\n FileUtils.mkdir_p(OUTPUT_DIRECTORY)\n end",
"def gen_sub_directories\n @outputdir.mkpath\n end",
"def gen_sub_directories\n\t\[email protected]\n\tend",
"def gen_sub_directories\n\t\[email protected]\n\tend",
"def l1_reconnect_properties_schema_generation_directory\n FilePath.new(@build_dir, \"generated\", \"l1-reconnect-properties-schema\")\n end",
"def set_export_dir(dir)\n @dir = dir\n FileUtils.mkdir_p(@dir) unless File.directory?(@dir)\n end",
"def generatedReportFolder\n currentData, currentTime = DateTime.now.strftime(\"%Y_%m_%d %H_%M\").split(' ')\n path = \"#{$ROOT}/../output\"\n creatFolder(path)\n path += \"/#{currentData}\"\n creatFolder(path)\n path += \"/#{currentTime}\"\n creatFolder(path)\n path\n end",
"def gen_sub_directories\n FileUtils.mkdir_p RDoc::Generator::FILE_DIR\n FileUtils.mkdir_p RDoc::Generator::CLASS_DIR\n rescue\n $stderr.puts $!.message\n exit 1\n end",
"def gen_sub_directories\n FileUtils.mkdir_p RDoc::Generator::FILE_DIR\n FileUtils.mkdir_p RDoc::Generator::CLASS_DIR\n rescue\n $stderr.puts $!.message\n exit 1\n end",
"def file_dir\n @parent_generator.file_dir\n end",
"def set_generated_assets_dir\n ReactOnRails.configuration.generated_assets_dir = Basch::Application.config.generated_backend_assets_dir\n end",
"def gen_agent_dir(agent)\n File.join(gen_dir, agent)\n end",
"def setup_output_dir(op_dir)\n flag_file = File.join(op_dir, \"created.rid\")\n if File.exist?(op_dir)\n unless File.directory?(op_dir)\n error \"'#{op_dir}' exists, and is not a directory\" \n end\n unless File.file?(flag_file)\n error \"\\nDirectory #{op_dir} already exists, but it looks like it\\n\" +\n \"isn't an RDoc directory. Because RDoc doesn't want to risk\\n\" +\n \"destroying any of your existing files, you'll need to\\n\" +\n \"specify a different output directory name (using the\\n\" +\n \"--op <dir> option).\\n\\n\"\n end\n else\n File.makedirs(op_dir)\n end\n File.open(flag_file, \"w\") {|f| f.puts Time.now }\n end",
"def set_output_dir(x)\n return self if @output_dir\n\n @output_dir = x\n @output_dir_abs = File.is_absolute?(@output_dir)\n if @project_dir\n @output_dir_relPath = File.rel_from_to_project(@project_dir, @output_dir)\n end\n self\n end",
"def output_dir(pathname)\n @output_dir = pathname\n end",
"def output_directory\n @output_directory ||= set_output_directory\n end",
"def generate_populate_folder\n empty_directory 'db/populate'\n # copy_file \"template_filename\", \"final_directory\" # With this we will copy the file straigh from tempaltes folder to the final destination\n # template \"template_filename\", \"final_directory\" # With this we can pass arguments to the template\n # if option_name ...\n end",
"def set_generated_assets_dir\n ReactOnRails.configuration.generated_assets_dir = Basch::Application.config.generated_frontend_assets_dir\n end",
"def output_dir\n @output_dir\n end",
"def set_temp_directory\n @base_theme_directory = 'public/temp/theme_1/'\n @temp_number = 1\n\n # Change value of @base_theme_directory until the folder name does not appear\n until !File.exist?(@base_theme_directory)\n @temp_number = @temp_number + 1\n @base_theme_directory = \"public/temp/theme_#{@temp_number.to_s}/\"\n end\n end",
"def set_path\n self.path = File.join(self.store_dir, self.filename)\n end",
"def compiled_dir\n @compiled_dir ||= begin\n d = \"#{Origen.root}/simulation/#{id}/#{config[:vendor]}\"\n FileUtils.mkdir_p(d)\n d\n end\n end",
"def compiled_dir\n @compiled_dir ||= begin\n d = \"#{Origen.root}/simulation/#{id}/#{config[:vendor]}\"\n FileUtils.mkdir_p(d)\n d\n end\n end",
"def output_directory(payload)\n path = File.join(\n working_directory(payload),\n 'generated-repositories'\n )\n FileUtils.mkdir_p(File.dirname(path))\n path\n end",
"def directory=(value)\n @directory = value\n end",
"def template_dir\n @template_dir ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))\n end",
"def write\n make_parent_directory\n generate_file\n end",
"def set_dir(new_dir)\n # checking for / at the end of the env variable\n new_dir = '' unless new_dir\n new_dir += '/' unless new_dir[-1, 1] == '/'\n @dir = new_dir\n end",
"def generate_in(directory)\n migration_path = File.expand_path(\"#{directory}/#{@filename}\")\n File.open(migration_path, 'w') { |f| f.write(render 'geode/templates/model_destroy_migration_template.erb') }\n relative_migration_path = Pathname.new(migration_path).relative_path_from(Pathname.pwd).to_s\n puts \"+ Generated migration #{@migration_name} at #{relative_migration_path}\"\n end",
"def scaffold_template_dir\n @scaffold_template_dir ||= TEMPLATE_DIR\n end",
"def generate_in(directory)\n migration_path = File.expand_path(\"#{directory}/#{@filename}\")\n File.open(migration_path, 'w') { |f| f.write(render 'geode/templates/model_rename_migration_template.erb') }\n relative_migration_path = Pathname.new(migration_path).relative_path_from(Pathname.pwd).to_s\n puts \"+ Generated migration #{@migration_name} at #{relative_migration_path}\"\n end",
"def destination(base_directory); end",
"def po_dir=(dir); end",
"def pkg_dir=( pd )\n @pkg_dir = File.join( self.build_dir, pd )\n end",
"def make_directory\n FileUtils.mkdir_p output_directory unless File.exist? output_directory\n end",
"def prepare_target_dir\n begin\n FileUtils.mkdir(@output_dir)\n copy_default_files\n rescue Errno::EEXIST\n puts \"-- #{output_dir} already exists -- canceling initialization. \"\n return\n end\n end",
"def output_directory_path\n if @output_directory.nil?\n directory = File.join(Rails.root, 'script')\n else\n directory = File.join(@output_directory, \"\")\n end\n directory\n end",
"def output_directory_path\n if @output_directory.nil?\n directory = File.join(Rails.root, 'script')\n else\n directory = File.join(@output_directory, \"\")\n end\n directory\n end",
"def set_directory(path)\n if File.exists? path and File.directory? path\n @directory = path.reverse.index(\"/\") == 0 ? path.chop : path\n else\n raise Error, \"Invalid path name\"\n end \n end",
"def setup_destination\n if options[:only_report]\n if !options[:output]\n options[:output] = File.join(\".\", Hastie.default_report_dir)\n end\n self.destination_root = options[:output]\n else\n if !options[:output]\n options[:output] = \".\"\n end\n self.destination_root = File.join(options[:output], options[:id])\n end\n\n say_status \"note\", \"root: #{self.destination_root}\"\n end",
"def generate_in(directory)\n migration_path = File.expand_path(\"#{directory}/#{@filename}\")\n template_type = @change ? 'migration_generate_change_template.erb' : 'migration_generate_up_down_template.erb'\n File.open(migration_path, 'w') { |f| f.write(render \"geode/templates/#{template_type}\") }\n relative_migration_path = Pathname.new(migration_path).relative_path_from(Pathname.pwd).to_s\n puts \"+ Generated migration #{@name} at #{relative_migration_path}\"\n end",
"def store_dir\n @dir = Dir.pwd\n end",
"def set_data_dir\n @dir_val = SecureRandom.hex(32)\n while Study.where(data_dir: @dir_val).exists?\n @dir_val = SecureRandom.hex(32)\n end\n self.data_dir = @dir_val\n end",
"def generate_in(directory)\n crystal_path = File.expand_path(\"#{directory}/#{@filename}\")\n path = File.dirname(crystal_path)\n FileUtils.mkdir_p(path) unless Dir.exists?(path)\n File.open(crystal_path, 'w') { |f| f.write(render 'geode/templates/crystal_generate_template.erb') }\n relative_crystal_path = Pathname.new(crystal_path).relative_path_from(Pathname.pwd).to_s\n puts \"+ Generated crystal #{@crystal_name} at #{relative_crystal_path}\"\n end",
"def templates_dir\n \"#{RdocInfo.config[:templates_dir]}\"\n end",
"def yml_directory=(value)\n @data_magic_yml_directory = value\n end",
"def build_working_dir(&block)\n file_name =\n if block.respond_to?(:source_location)\n block.source_location[0]\n else\n eval(\"__FILE__\", block.binding)\n end\n\n @working_dir = File.expand_path(\n File.join(File.dirname(file_name), \"generated\"))\n end",
"def initialize_target_directory\n # create result directory\n Dir.mkdir(@target_dir) unless Dir.exists?(@target_dir)\n\n # copy vendor assets\n vendor_dir = File.expand_path('../../../vendor/assets', __FILE__)\n FileUtils.cp_r(vendor_dir, @target_dir, remove_destination: true)\n\n # copy local assets\n assets_dir = File.expand_path('../templates/assets', __FILE__)\n FileUtils.cp_r(assets_dir, @target_dir)\n end",
"def build_output_dir\n root.join(public_dir, public_output_dir)\n end",
"def prepare_dirs\n [@reports_dir, @cache_dir, @gems_dir].each do |dir|\n Dir.mkdir(dir) unless File.directory?(dir)\n end\n end",
"def output_dir\n File.expand_path(OUTPUT_DIRECTORY, project.install_dir)\n end",
"def output_dir\n File.expand_path(OUTPUT_DIRECTORY, project.install_dir)\n end",
"def make_output_directory\n puts \"Making output directory\"\n # Double check that we don't clobber an existing dir\n if File.exists? @output_dir\n puts \"\\nSORRY! '#{ @output_dir }' directory already exists. Please try again.\\n\\n\"\n exit\n end\n FileUtils.mkdir_p @output_dir\n end",
"def build_dir\n Puppet::Forge::Cache.base_path + \"tmp-unpacker-#{Digest::SHA1.hexdigest(@filename.basename.to_s)}\"\n end",
"def makePath\n\t\t\tbuildMgr.effective(filename).dirname.mkpath\n\t\tend",
"def skeleton_dir\n options[:skeleton_dir]\n end",
"def build_directory\n File.expand_path(config['build_directory'])\n end",
"def store_dir\n \"uploads/creation_doc/#{model.id}\"\n end",
"def docsets_path(config)\n return File.join(config[\"output\"], \"docsets\")\n end",
"def generate_in(directory)\n schema_path = File.expand_path(\"#{directory}/schema.rb\")\n File.open(schema_path, 'w') { |f| f.write(render 'geode/templates/schema_template.erb') }\n relative_schema_path = Pathname.new(schema_path).relative_path_from(Pathname.pwd).to_s\n puts \"+ Generated schema at #{relative_schema_path} from current db\"\n end",
"def output_dir\n output_dir = @output_dir.nil? ? Dir.getwd : @output_dir\n FileUtils.mkdir_p(output_dir) unless ::File.directory?(output_dir)\n output_dir\n end",
"def output_path; end",
"def mkdir(option={})\n @generator.mkdir(option)\n end",
"def generate\n if @options.dry_run then\n # do nothing\n @generator.generate\n else\n Dir.chdir @options.op_dir do\n unless @options.quiet then\n $stderr.puts \"\\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}...\"\n end\n\n @generator.generate\n update_output_dir '.', @start_time, @last_modified\n end\n end\n end",
"def directory; end",
"def directory; end",
"def doc_templates_dir\n return File.absolute_path(File.join(@root_dir, 'doc_templates'))\n end",
"def setup_output_dir(op_dir, force)\n flag_file = output_flag_file(op_dir)\n if File.exist?(op_dir)\n unless File.directory?(op_dir)\n error \"'#{op_dir}' exists, and is not a directory\"\n end\n begin\n created = File.read(flag_file)\n rescue SystemCallError\n error \"\\nDirectory #{op_dir} already exists, but it looks like it\\n\" +\n \"isn't an RDoc directory. Because RDoc doesn't want to risk\\n\" +\n \"destroying any of your existing files, you'll need to\\n\" +\n \"specify a different output directory name (using the\\n\" +\n \"--op <dir> option).\\n\\n\"\n else\n last = (Time.parse(created) unless force rescue nil)\n end\n else\n FileUtils.mkdir_p(op_dir)\n end\n last\n end",
"def setup_output_dir(op_dir, force)\n flag_file = output_flag_file(op_dir)\n if File.exist?(op_dir)\n unless File.directory?(op_dir)\n error \"'#{op_dir}' exists, and is not a directory\"\n end\n begin\n created = File.read(flag_file)\n rescue SystemCallError\n error \"\\nDirectory #{op_dir} already exists, but it looks like it\\n\" +\n \"isn't an RDoc directory. Because RDoc doesn't want to risk\\n\" +\n \"destroying any of your existing files, you'll need to\\n\" +\n \"specify a different output directory name (using the\\n\" +\n \"--op <dir> option).\\n\\n\"\n else\n last = (Time.parse(created) unless force rescue nil)\n end\n else\n FileUtils.mkdir_p(op_dir)\n end\n last\n end",
"def create_output_directory\n FileUtils.mkdir_p @output_dir\n end",
"def relative_directory\n @relative_directory ||= \"_#{label}\"\n end",
"def output_folder\n @output_dir = File.join(Dir.pwd, \"models\") if @output_dir.nil?\n @output_dir\n end",
"def create_source_files\n empty_directory(File.join(target_dir, \"lib/kitchen/driver\"))\n\n create_template(\n \"version.rb.erb\",\n \"lib/kitchen/driver/#{name}_version.rb\"\n )\n create_template(\n \"driver.rb.erb\",\n \"lib/kitchen/driver/#{name}.rb\"\n )\n end",
"def populate_output_path(options = {})\n base = Pathname.new(@source_path).basename.to_s\n if options.empty?\n result = base\n else\n name, ext = *base.split(\".\")\n if options[:output_path].nil? || File.directory?(options[:output_path])\n tokens = \"\"\n MODULES.each do |mod|\n token = mod.filename_token(options)\n tokens += \"-#{token}\" unless token.nil?\n end\n result = options[:output_path].nil? ? \"\" : \"#{options[:output_path].to_s}/\"\n result += \"#{name}#{tokens}.#{ext}\"\n elsif !options[:output_path].nil?\n result = \"#{options[:output_path].to_s}.#{ext}\"\n end\n end\n @path = Pathname.new(result)\n end",
"def set_filename(req, res)\n original_root = @root.dup\n if req.path_info.start_with?(\"/#{ ViteRuby.config.public_output_dir }/\")\n @root = ViteRuby.config.root.join(ViteRuby.config.public_dir)\n end\n super.tap { @root = original_root }\n end",
"def javadoc_directory\n FilePath.new(@build_dir, 'doc', 'api')\n end",
"def docdir\n return $docdir if $docdir\n dir = get_config('doc-dir')+'/'\n dir.sub!(/\\A$prefix/, get_config('prefix'))\n $docdir = dir\n end",
"def docdir\n return $docdir if $docdir\n dir = get_config('doc-dir')+'/'\n dir.sub!(/\\A$prefix/, get_config('prefix'))\n $docdir = dir\n end",
"def xslt_root_dir\n @xslt_root_dir ||= Pathname.new(RAILS_ROOT)+'public'+'xslts'\n end",
"def sample_dir\n\t\t\"#{@dir}/samples\"\n\tend",
"def generate_temp_dir\n empty_directory File.join(Rails.root, \"tmp\", \"fusioncharts\")\n end",
"def generate_cache_directory\n @cache_cid = generate_cid\n FileUtils.mkdir_p(cache_path)\n FileUtils.chmod dir_permissions.to_i, cache_path\n end",
"def output_dir\n if experiment_id.nil?\n raise Exception.new('output_dir is not yet definable')\n end\n File.join(self.output_base, \"exp_#{self.experiment_id}\")\n end",
"def data_directory\n @data_directory\n end",
"def setDir _obj, _args\n \"_obj setDir _args;\" \n end",
"def make_directories!\n @sprites_path.mkpath unless @sprites_path.directory?\n @sources_path.mkpath unless @sources_path.directory?\n end",
"def create_docs\n directory 'templates/docs', 'docs'\nend",
"def fixture_dir\n runtime_config.fixture_dir\n end",
"def class_dir\n @parent_generator.class_dir\n end",
"def output_dir_path\n @output_dir_path ||= download_dir_path\n end",
"def prepend_seed_path(dir)\n configuration.prepend(\"MS_SEEDFILES\", windows_path(dir))\n end",
"def dump_directory\n File.join(@relative_to_base, DUMP_DIRECTORY_NAME)\n end",
"def temp_dir(f = nil)\n @temp_dir ||= \"#{Dir.mktmpdir(\"apidoc\")}/\"\n form_file_name @temp_dir, f\n end"
] | [
"0.7593993",
"0.7482969",
"0.7218836",
"0.7031479",
"0.6865798",
"0.6810424",
"0.6576333",
"0.6415231",
"0.63815355",
"0.62477845",
"0.62477845",
"0.62401015",
"0.62124145",
"0.62100536",
"0.61696047",
"0.61696047",
"0.6140647",
"0.61395013",
"0.611539",
"0.6080589",
"0.6062492",
"0.605478",
"0.6045253",
"0.6027394",
"0.60257375",
"0.5991778",
"0.5978893",
"0.59389657",
"0.5936598",
"0.5936598",
"0.58914286",
"0.58875227",
"0.58865196",
"0.58758444",
"0.5858437",
"0.581736",
"0.5800075",
"0.5798381",
"0.5780174",
"0.5772583",
"0.57583153",
"0.5745211",
"0.57354265",
"0.5734994",
"0.5734994",
"0.5722112",
"0.57166904",
"0.57127607",
"0.5687693",
"0.56663257",
"0.56643873",
"0.56610477",
"0.5660144",
"0.56499916",
"0.5644773",
"0.563346",
"0.5624972",
"0.56207144",
"0.56207144",
"0.5614428",
"0.5612231",
"0.55971456",
"0.5596565",
"0.5595811",
"0.5594493",
"0.5585244",
"0.55786705",
"0.55701405",
"0.55696183",
"0.55613285",
"0.55583537",
"0.55565554",
"0.55565554",
"0.5555839",
"0.5554966",
"0.5554966",
"0.5553228",
"0.5549254",
"0.5548246",
"0.5539897",
"0.5535313",
"0.5529321",
"0.55150694",
"0.55076545",
"0.55076545",
"0.5507045",
"0.54978025",
"0.5496455",
"0.5496026",
"0.5495724",
"0.5495236",
"0.5480374",
"0.5465817",
"0.54564124",
"0.5454718",
"0.5454447",
"0.5439806",
"0.5438218",
"0.5434776",
"0.5434531"
] | 0.6661985 | 6 |
Opens a browser window and sends you to my blog (Not tested on Windows) | def blog
system("open #{blog_url}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_in_browser\n puts url\n `#{open} #{url}`\n end",
"def open()\n \n #note we would want to check for the browser bing open already\n #so we don't annoy people\n \n event(\"Pre\")\n require 'launchy'\n Launchy.open(\"http://local.general.dev/info.php\") #note this should be from setting file\n event(\"Post\")\n end",
"def browse(url)\n if RUBY_PLATFORM =~ /darwin/\n `open #{url}`\n elsif RUBY_PLATFORM =~ /linux/\n `#{ENV['BROWSER']} #{url}`\n elsif ENV['OS'] == 'Windows_NT' or\n RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw|wince/i\n `start \"\" \"#{url}\"`\n end\n end",
"def open_in_browser\n link = \"http://www.bandsintown.com/cities/pittsburgh-pa\"\n if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/\n system \"start #{link}\"\n elsif RbConfig::CONFIG['host_os'] =~ /darwin/\n system \"open #{link}\"\n elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/\n system \"xdg-open #{link}\"\n end\n end",
"def open()\n \n #note we would want to check for the browser being open already\n #so we don't annoy people\n \n event(\"Pre\")\n require 'launchy'\n Launchy.open(\"http://store.mage.dev/admin\") #note this should be from setting file\n event(\"Post\")\n end",
"def open\n app = heroku.info(extract_app)\n url = app[:web_url]\n display \"Opening #{url}\"\n Launchy.open url\n end",
"def browser_open_linux(url)\n system(\"xdg-open\", url)\n end",
"def launch_browser(url)\n case RUBY_PLATFORM\n when /darwin/\n system \"open\", url\n when /mswin|mingw|cygwin/\n system \"start\", url\n else\n system \"xdg-open\", url\n end\n end",
"def open_window url, window_id\r\n command 'openWindow', url, window_id\r\n end",
"def open url\r\n command 'open', url_arg(url)\r\n end",
"def open url\r\n command 'open', url_arg(url)\r\n end",
"def auto_link_new_window(text)\n auto_link(text, :html => {:target => '_blank'})\n end",
"def browse(url)\n if RUBY_PLATFORM =~ /darwin/\n `open #{url}`\n elsif ENV['OS'] == 'Windows_NT' or\n RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw|wince/i\n `start \"\" \"#{url}\"`\n end\n end",
"def ask_to_open_in_browser(url)\n if RUBY_PLATFORM =~ /darwin|linux/i\n open_in_browser = ask \"Would you like to open it in your browser? \"\n if open_in_browser =~ /^y/i\n if RUBY_PLATFORM =~ /darwin/i\n # OS X\n run \"open #{url}\"\n else\n # Ubuntu\n run \"xdg-open #{url}\"\n end\n end\n end\n end",
"def open_viewer(urn,access_token)\n path = File.expand_path(File.dirname(__FILE__))\n url = \"file://#{path}/viewer.html?token=#{access_token}&urn=#{urn}\"\n text_to_print_in_color = \"Please open the following url in your favorite browser:\\n#{url}\"\n puts(\"\\e[7m#{text_to_print_in_color}\\e[27m\")\n\nend",
"def ask_to_open_in_browser(url)\n if RUBY_PLATFORM =~ /darwin|linux/i\n open_in_browser = ask \"Would you like to open it in your browser? \"\n if open_in_browser =~ /^y/i\n if RUBY_PLATFORM =~ /darwin/i\n # OS X\n `open #{url}`\n else\n # Ubuntu\n `xdg-open #{url}`\n end\n end\n end\n end",
"def browse(number)\n request = get_request_by_number(number)\n Launchy.open(request.html_url)\n end",
"def open_home_page\n open(configuration.browser_url)\n end",
"def open_in_browser?(job)\n puts \"\\nURL: #{job.full_url}\"\n # print \"Open job page in browser?(yes/no): \".blue\n # response = gets.chomp.downcase\n\n response = @prompt.yes?(\"Open job page in browser?\")\n\n if response == \"y\" || response == \"yes\"\n system(\"xdg-open #{job.full_url}\")\n end\n end",
"def open_page(name)\n name_link(name).click \n wait_for_ajax\n self.window(:title=>\"rSmart | Content Profile\").use\n ContentDetailsPage.new @browser\n end",
"def open_page(name)\n name_link(name).click\n self.wait_for_ajax\n self.window(:title=>\"rSmart | Content Profile\").use\n ContentDetailsPage.new @browser\n end",
"def test02_post_open_blog_ArticleOneComment_TC_24319\n\t\tlogin $user_1_email, $master_password\n\t\tsleep 2\n\t\t$browser.goto($patch_blogs_post_open_article)\n\t\t\n\t\tcommentPopSubmit \"Blog Article Comment #{random}\"\n\tend",
"def open_url(url)\n if RbConfig::CONFIG['host_os'] =~ /darwin/\n system %(open \"#{url}\")\n elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/\n system %(xdg-open \"#{url}\")\n else\n puts 'Not Supported OS!'.red\n end\n end",
"def open(browser, url=\"\")\n case browser\n when 'chrome'\n `open -a '/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome' #{url}`\n when 'firefox'\n `open -a 'Firefox' #{url}`\n when 'safari'\n `open -a 'Safari' #{url}`\n end\nend",
"def test03_post_open_blog_ArticleTwoComments\n\t\tlogin $user_1_email, $master_password\n\t\tsleep 2\n\t\t$browser.goto($patch_blogs_post_open_article)\n\t\t\n\t\tcommentPopSubmit \"Blog Article Comment #{random}\"\n\t\tcommentPopSubmit \"Blog Article Comment #{random}\"\n\tend",
"def cmd\n c = [\"open #{page_url}\"]\n c << argument_string(unknown_options) unless unknown_options.empty?\n c.join(\"\\n\")\n end",
"def launch_web\n if !File.exist? 'build/app.html'\n puts \"No web app built!\"\n exit\n end\n open_cmd = 'open'\n case RUBY_PLATFORM\n when /linux/\n open_cmd = \"xdg-#{open_cmd}\"\n when /mingw/\n open_cmd = \"start\"\n end\n system \"#{open_cmd} build/app.html\"\nend",
"def new_window(name)\n execute_script(%(\n var w = Math.max(\n document.documentElement.clientWidth, window.innerWidth || 0\n );\n var h = Math.max(\n document.documentElement.clientHeight, window.innerHeight || 0\n );\n window.open(\"about:blank\", arguments[0], `width=${w},height=${h}`);\n ), name)\n end",
"def go_to_page(url)\n Logbook.step(\"Open start page #{url} :)\")\n @browser.get url\n sleep 2\n\n @browser\n end",
"def go\n require 'pashua'\n pagetmp = wikipage_selector(\"Jump to which page?\")\n exit unless pagetmp\n @chrome.windows[1].get.tabs[@chrome.windows[1].get.active_tab_index.get].get.URL.set(\"http://localhost/wiki/#{pagetmp}\")\nend",
"def test04_post_open_blog_NoteTwoComments_TC_24319\n\t\tlogin $user_1_email, $master_password\n\t\tsleep 2\n\t\t$browser.goto($patch_blogs_post_open_note)\n\t\t\n\t\tcommentPopSubmit \"Blog Note Comment #{random}\"\n\t\tcommentPopSubmit \"Blog Note Comment #{random}\"\n\tend",
"def launch_web\n if !File.exists? 'build/app.html'\n puts \"No web app built!\"\n exit\n end\n open_cmd = 'open'\n case RUBY_PLATFORM\n when /linux/\n open_cmd = \"xdg-#{open_cmd}\"\n when /mingw/\n open_cmd = \"start\"\n end\n system \"#{open_cmd} build/app.html\"\nend",
"def goto(url)\r\n #set_defaults()\r\n get_window_number()\r\n set_browser_document()\r\n # Load the given url.\r\n $jssh_socket.send(\"#{BROWSER_VAR}.loadURI(\\\"#{url}\\\");\\n\" , 0)\r\n read_socket()\r\n\r\n wait()\r\n end",
"def open_browser_with_search(url)\n Launchy.open(url)\nend",
"def browser_open_darwin(url)\n system(\"open\", \"-a\", \"chrome\", url)\n end",
"def open\n require \"launchy\"\n\n Launchy.open(BASE_URL)\n end",
"def open_compare_page\n cli.copy_to_clipboard compare_url\n cli.open compare_url\n end",
"def open_in_browser\n selection = @list_view.selection\n if iter = selection.selected\n selected_category = iter.parent[0]\n task_index = iter[3]\n url = todo_data.get_trac_url(task_index)\n Launchy.open(url)\n end\n end",
"def open(item)\n `#{open_command} '#{item.url.gsub(\"\\'\",\"\\\\'\")}'`\n\n \"Boom! We just opened #{item.value} for you.\"\n end",
"def post\n textmenu = @browser.find_element class: \"icon_post_text\"\n textmenu.click\n titlebox = @browser.find_element class: \"editor-plaintext\"\n titlebox.send_keys \"This is a test\"\n textbox = @browser.find_element class: \"editor-richtext\"\n textbox.send_keys \"This is a test\"\n post = @browser.find_element class: \"create_post_button\"\n post.click\n end",
"def open_article(article_id)\n Launchy.open(Article.find(article_id).url)\nend",
"def click_view_website\n view_website_link.click\n end",
"def crawler_page\n open(crawler_url)\n end",
"def open_new_page(url)\n $verbose ? puts(\"opening new page: #{url}\") : nil\n @driver.execute_script('window.open()')\n @driver.switch_to.window(@driver.window_handles.last)\n sleep(1)\n @driver.get(url)\n end",
"def openurl(url)\n runcmd 'openurl', url\n end",
"def gh_open(path)\n url = url_base + path.chomp\n # use open if on OSX\n if RUBY_PLATFORM.downcase.include?(\"darwin\")\n %x{open #{url}}\n else\n puts url\n end\nend",
"def click_web_link(text)\n\t\[email protected](\"Clicking web link #{text}\")\n\t\t\n\t\t@main_window.click(text)\n\tend",
"def launch_browser(html)\n fork do\n Tempfile.open(%w[bud .html]) do |handle|\n handle.write(html)\n handle.flush\n system(\"open #{handle.path}\")\n sleep 300\n end\n end\nend",
"def open_random\n Defcli.open_in_browser random_url(:api => false)\n end",
"def goto(url = \"\")\n active_window.url = url\n sleep(1)\n end",
"def page!\n save_and_open_page\n end",
"def page!\n save_and_open_page\n end",
"def frm\n self.frame(:src=>/sakai2forums.launch.html/)\n end",
"def new_tab\n execute_script('window.open();')\n window_handles.last\n end",
"def test03_post_open_blog_MediaVideo\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_blogs_post_open)\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_media_description.exists?\n\t\t$post_media_description.set(\"the elwah river original flow was recently restored #{random}.\")\n \t\trepostGroupPop\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def open(url = @url)\n @browser.goto(url)\n wait_for_page_to_load\n end",
"def go_to_url (url)\n\t\[email protected] (url)\n\tend",
"def load\n @browser = Selenium::WebDriver.for :firefox\n @browser.get \"https://www.tumblr.com\"\n end",
"def open_url(term)\n Defcli.open_in_browser search_url(term, :api => false)\n end",
"def goto_page(browser_handle, url)\n browser_handle.goto(url)\nend",
"def open_pages\n make_calendars\n make_topics\n end",
"def CreateBrowser()\r\n ret = @dispatch._invoke(1610743828, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def autolink(text)\n auto_link(text, :html => { :target => '_blank' })\n end",
"def CurrentPage\r\n\r\n puts \"I'm now on \" + $browser.url\r\n puts $newline\r\n\r\nend",
"def open_my_site_by_name(name)\n unless @browser.title=~/#{name}/\n @browser.link(:text, 'More Sites').click\n @browser.text_field(id: 'txtSearch').set name[0..5]\n @browser.div(id: 'selectSite').link(title: name).click\n end\n end",
"def open_browser(base_url = nil, options = {})\n base_url ||= $ITEST2_PROJECT_BASE_URL\n base_url ||= $BASE_URL\n raise \"base_url must be set\" if base_url.nil?\n\n default_options = {:speed => \"fast\",\n :visible => true,\n :highlight_colour => 'yellow',\n :close_others => true,\n :start_new => false, \t# start a new browser always\n :go => true}\n\n options = default_options.merge options\n options[:firefox] = true if \"Firefox\" == $ITEST2_BROWSER || \"Firefox\" == $BROWSER\n ($ITEST2_HIDE_BROWSER) ? $HIDE_IE = true : $HIDE_IE = false\n\n if base_url =~ /^file:/\n uri_base = base_url\n else\n uri = URI.parse(base_url)\n uri_base = \"#{uri.scheme}://#{uri.host}:#{uri.port}\"\n end\n\n if options[:start_new]\n @web_browser = WebBrowser.new(uri_base, nil, options)\n else\n @web_browser = WebBrowser.reuse(uri_base, options) # Reuse existing browser\n end\n\n if base_url =~ /^file:/\n goto_url(base_url) # for files, no base url\n else\n (uri.path.length == 0) ? begin_at(\"/\") : begin_at(uri.path) if options[:go]\n end\n\n return @web_browser\n end",
"def go_to(url)\n @browser.goto(url)\n end",
"def launch(path)\n # force leading slash\n path.insert(0, '/') unless path[0] == '/'\n url = \"https://github.com/#{repo_github_path + path.chomp}\"\n # use open if on OSX\n if RUBY_PLATFORM.downcase.include? \"darwin\"\n %x{open #{url}}\n else\n puts url\n end\n end",
"def browse url\n @@headless = Headless.new\n @@headless.start\n @@browser = Watir::Browser.start url\n end",
"def go()\n\[email protected] @url\n end",
"def show_page\n save_page Rails.root.join('public', 'capybara.html')\n %x(`launchy http://localhost:3000/capybara.html`)\nend",
"def send_page\n send_message(\"page\")\n end",
"def CreateBrowser()\r\n ret = _invoke(1610743828, [], [])\r\n @lastargs = WIN32OLE::ARGV\r\n ret\r\n end",
"def bookmarklet\n text 'Drag the following link to your toolbar to submit with a single click: '\n a 'bookmark-it!', :href =>\"javascript:location.href='http:#{URL(New)}?page_link='+encodeURIComponent(location.href)+'&description='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(window.getSelection())\"\n end",
"def test03_post_open_news_MediaOneComment_TC_24319\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_news_post_open_note)\n\t\t\n\t\tcommentPopSubmit \"Test Comment #{random}\"\n\tend",
"def page\n Bowline::Desktop::Proxy.new(\n windows.length == 1 ? windows.first : windows\n )\n end",
"def goto_weblog(page)\n #generally speaking, we want to goto \"http://[username].xanga.com/\n\n page = @agent.click page.links.href(\"http://#{@user}.xanga.com/\").first\n end",
"def go_to(url)\n @browser.navigate.to url\n end",
"def set_browser_document\r\n # Get the window in variable WINDOW_VAR.\r\n # Get the browser in variable BROWSER_VAR.\r\n jssh_command = \"var #{WINDOW_VAR} = getWindows()[#{@@current_window}];\"\r\n jssh_command += \" var #{BROWSER_VAR} = #{WINDOW_VAR}.getBrowser();\"\r\n # Get the document and body in variable DOCUMENT_VAR and BODY_VAR respectively.\r\n jssh_command += \"var #{DOCUMENT_VAR} = #{BROWSER_VAR}.contentDocument;\"\r\n jssh_command += \"var #{BODY_VAR} = #{DOCUMENT_VAR}.body;\"\r\n\r\n $jssh_socket.send(\"#{jssh_command}\\n\", 0)\r\n read_socket()\r\n\r\n # Get window and window's parent title and url\r\n $jssh_socket.send(\"#{DOCUMENT_VAR}.title;\\n\", 0)\r\n @window_title = read_socket()\r\n $jssh_socket.send(\"#{DOCUMENT_VAR}.URL;\\n\", 0)\r\n @window_url = read_socket()\r\n end",
"def window name, cwd, cmd\n raise NotImplementedError.new(\n \"window should be implemented to open new window\")\n end",
"def open_browser\n `open #{@report_file.path}`\n end",
"def capture(url, title)\n template_key = 'l'\n ec = '/usr/local/bin/emacsclient'\n `#{ec} org-protocol:/capture:/#{template_key}/'#{escape url}'/'#{escape title}'/''`\nend",
"def test02_post_open_blog_MediaTwoVideoClips\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_blogs_post_open)\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_media_description.exists?\n\t\t$post_media_description.set(\"hiking mt st helens isnt as cool #{random}.\")\n \t\trepostGroupPop\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit202.26.2012.mpg\"\n\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def popup(name)\n win = Browser.new(@browser_type, @browser_process_name, @proxy_host, @proxy_port)\n\n win.proxy_host = @proxy_host\n win.proxy_port = @proxy_port\n win.sahisid = @sahisid\n win.print_steps = @print_steps\n win.popup_name = name\n win.domain_name = @domain_name\n win\n end",
"def open_window(options = nil)\n window = terminal.make( :new => :terminal )\n window.launch_ :session => 'New session'\n end",
"def use_current_browser(how = :title, what = /.*/)\n @web_browser = WebBrowser.attach_browser(how, what)\n end",
"def publish_front_page\n\t\tsystem 'clear'\n\t\t@post_list.each do |post|\n\t\t\tif post.sponsored == true\n\t\t\t\tputs \"*****Post #{post.title}*****\"\n\t\t\telse\n\t\t\t\tputs \"Post #{post.title}\"\n\t\t\tend\n\t\t\tputs \"#{post.text}\"\n\t\t\tputs \"#{post.creation_date}\"\n\t\t\tputs \"-----------------------\"\n\t\tend\n\tend",
"def open\n mail = MailTasks::Mail.find_by_token( params[:id] )\n raise ActiveRecord::RecordNotFound unless mail # raise 404 if mail is not found\n \n options = {\n :post_back_url => url_for( :controller => \"/email\", :action => \"red_logo\" ),\n :base => [request.protocol, request.host].join\n }\n render :text => mail.content_with_layout( options ), :layout => false\n end",
"def open_page(key)\n return if verify_page?(key, false)\n site.goto(site.get_path(key))\n page_delay\n verify_page?(key)\n end",
"def test04_post_open_blog_MediaTwoVideo\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_blogs_post_open)\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_media_description.exists?\n\t\t$post_media_description.set(\"whiskey bend road has been closed #{random}.\")\n \t\trepostGroupPop\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit202.26.2012.mpg\"\n\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def notify(url)\n return if `which terminal-notifier`.chomp == \"\"\n\n command = <<-CMD.strip_heredoc\n terminal-notifier \\\n -title \"Copied Public Link to Clipboard\" \\\n -message \"Click to view: #{url}\" \\\n -open \"#{url}\" \\\n -actions \"\" \\\n -timeout 3 \\\n -sender com.getdropbox.dropbox\n CMD\n\n `#{command}`\n end",
"def load_browser_tab(url:)\n @browser.execute_script('window.open()')\n @browser.windows.last.use\n @browser.goto(url)\n end",
"def open(url);\n if !@already_opened_prs.include? url\n # Because Launchy sometimes fails to open multiple tabs if it is called too quickly\n sleep(0.1)\n Launchy.open(url) do |exception|\n puts \"Attempted to open #{url} and failed because #{exception}\"\n end\n @already_opened_prs.add url\n else\n puts \"filtered #{url}\"\n end\n end",
"def open_pages\n quick_windows.select { |win| win.name == \"Document Window\" }\n end",
"def autofollow\n find_current_blog\n @browser.goto $root+'/blog/'+ @blogname +'/followers'\n if @browser.button(:class => \"chrome blue big follow_button\").exists?\n follow_links = @browser.buttons(:class => \"follow_button\")\n end\n follow_links.each { |follow_button| follow_button.click } if follow_links\n sleep 2\n end",
"def open\n @browser.goto @@site_url + \"/login.php\"\n\tWatir::Wait.until { self.loaded? LoginPage.title}\n self\n end",
"def send(message, options={})\n content_window.send(message, options)\n end",
"def open_bookmark(bm)\n id = bm.shift\n url = Bookmarks.new.bookmark_url(id)\n pexit \"Failure:\".red + \" bookmark #{id} not found\", 1 if url.nil?\n puts 'opening bookmark ' + url + '...'\n openweb(wrap(url))\n open_bookmark bm unless bm.empty?\n end",
"def show_other_sites\n frm.link(:text=>\"Show other sites\").click\n end",
"def popup(name)\n win = Browser.new(@browser_type, @proxy_port)\n\n win.proxy_host = @proxy_host\n win.proxy_port = @proxy_port\n win.sahisid = @sahisid\n win.print_steps = @print_steps\n win.popup_name = name\n win.domain_name = @domain_name\n win\n end"
] | [
"0.67058843",
"0.6701106",
"0.6601959",
"0.6566288",
"0.6462488",
"0.63849753",
"0.62929016",
"0.62779367",
"0.6259112",
"0.6228017",
"0.6228017",
"0.62276393",
"0.6186627",
"0.61483",
"0.6142089",
"0.61385244",
"0.6119605",
"0.6091906",
"0.6066312",
"0.60269153",
"0.60019904",
"0.58936787",
"0.5876744",
"0.5790666",
"0.5778206",
"0.577772",
"0.57579416",
"0.57505435",
"0.57326525",
"0.57291627",
"0.572564",
"0.57230574",
"0.5706869",
"0.5686116",
"0.56695664",
"0.5646395",
"0.5637168",
"0.5604649",
"0.55874974",
"0.5581848",
"0.5557585",
"0.55384207",
"0.5491351",
"0.54821086",
"0.548129",
"0.5476771",
"0.54738337",
"0.5465803",
"0.5464686",
"0.543718",
"0.54332364",
"0.54332364",
"0.54247165",
"0.5412437",
"0.5394249",
"0.5387742",
"0.53789955",
"0.5361977",
"0.53558034",
"0.53467995",
"0.5346689",
"0.5344038",
"0.532963",
"0.53296244",
"0.5328164",
"0.5327956",
"0.5316396",
"0.5314163",
"0.53112304",
"0.5300284",
"0.52935463",
"0.52813435",
"0.52808064",
"0.52765995",
"0.5273749",
"0.52648085",
"0.5252178",
"0.5250458",
"0.52293634",
"0.52244556",
"0.52146226",
"0.5214132",
"0.52015406",
"0.51964754",
"0.51943284",
"0.51920116",
"0.5189136",
"0.51887065",
"0.5186406",
"0.5186013",
"0.5171777",
"0.5163455",
"0.51622385",
"0.5159676",
"0.5156331",
"0.515628",
"0.5154205",
"0.51442105",
"0.5140118",
"0.5137604"
] | 0.76009464 | 0 |
Print out all basic information | def print
text = File.expand_path(File.dirname(__FILE__) + '/text/cv.txt')
File.readlines(text).each do |line|
puts line
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_basic_info\n \"Name:#{name}, Occupation:#{occupation}, Sex:#{sex}\"\n end",
"def show_info()\n\t\tputs \"ID: #{@@id}\"\n\t\tputs \"Name: #{@car_name}\"\n\t\tputs \"Make: #{@@make}\"\n\t\tputs \"Cost: #{calc_total_cost} INR\"\n\t\tputs\n\t\tputs \"Review: #{@review}\"\n\t\tputs \"Rating: #{@rating} stars\"\n\tend",
"def show_basic\n puts \"#{@total_packet_count} total packets captured\"\n puts \"#{@rinda_packet_count} Rinda packets captured\"\n puts \"#{@drb_packet_count} DRb packets captured\"\n puts \"#{@drb_messages_sent} messages sent\"\n puts \"#{@drb_results_received} results received\"\n puts \"#{@drb_exceptions_raised} exceptions raised\"\n end",
"def print_debug\n\t\tprint_divider\n\t\tputs \"Root Node: \\n\" + root.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Current Node: \\n\" + @current_node.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Attributes: \\n\" + attributes.to_s\n\t\tprint_divider\n\t\t\n\t\tputs \"Children: \\n\" + children.to_xml\n\t\tprint_divider\n\tend",
"def display()\n\t\tputs \"method: #{@method}\"\n\t\tputs \"identifier: #{@identifier}\"\n\t\tputs \"query: #{@query}\"\n\t\tputs \"version: #{@version}\"\n\t\tputs \"---------------- headers ----------------\"\n\t\tputs @headers\n\t\tputs \"---------------- body -------------------\"\n\t\tputs @body\n\tend",
"def display_info\n \n puts \"\\nPlayer Name: #{self.name}\"\n puts \"Current Rank: #{self.rank}\"\n puts \"Position: #{self.position}\"\n puts \"School/Club: #{self.schoolclub}\"\n # binding.pry\n #if there is no class_year, nothing is displayed\n puts \"Year: #{self.class_year}\"\n #\n puts \"Height/Weight: #{self.height}, #{self.weight} \"\n puts \"Age: #{self.age}\"\n puts \"Last rank: #{self.last_rank}\"\n puts \"Scouting Report: #{self.blurb}\"\n puts \"------------------------------------\"\n end",
"def get_info\n puts \"#{@title} by #{@author} is #{@status}.\"\n if @description\n puts \"#{@title} description: #{@description}.\"\n end\n end",
"def print_info\n puts \" Planet Summary\"\n puts \"=============================================================\"\n puts \"Planet Name: #{@name.capitalize}\"\n puts \"Mass: #{@mass} e+24 kg\"\n puts \"Diameter: #{@diameter} km\"\n puts \"Number of Moons: #{@number_of_moons}\"\n puts \"Average Distance From The Sun: #{@distance_from_the_sun} e+6 km\"\n puts \"Rate of Solar Rotation: #{@rate_of_solar_rotation} hours\"\n puts \"Orbital Period: #{@orbital_period} Earth days\\n\\n\"\n end",
"def print()\n printf \"\\nAuthor ID: %d affiliation: %s affiliation short: %s country: %s\\n\", self.article_author_id, self.name, self.short_name, self.country\n printf \"\\nAddress: %s, %s, %s, %s, %s\\n\", self.add_01, self.add_02, self.add_03,self.add_04, self.add_05\n end",
"def print_debug_info\n puts \"Programmer #{name}:\"\n puts \"\\tSpeed: #{speed}\"\n puts \"\\tDaily wage: #{daily_wage}\"\n puts \"\\tProject: #{project_name}\"\n end",
"def print_info\n puts \"#{ @name } is the #{ @position } planet from the sun.\\nIt is a #{ @type } planet that is #{ @diameter } miles wide.\\n#{ @name } has #{ @moons } moons.\"\n end",
"def print_debug_info\n puts \"Project #{name}:\"\n puts \"\\tState: #{state}\"\n puts \"\\tMan-days total: #{man_days}\"\n puts \"\\tMan-days done: #{man_days_done}\"\n puts \"\\tPrice: #{price}\"\n end",
"def info\n puts 'Info'\n end",
"def info; end",
"def info; end",
"def print_info\n UI.puts \"\\nTo learn more about the ip see `#{@ip_url}`.\"\n end",
"def print_info\n UI.puts \"\\nTo learn more about the ip see `#{@ip_url}`.\"\n end",
"def print_details()\n\t$details.each {|k, v| puts \"#{k}: #{v}\"}\nend",
"def about\r\n\t\tputs \"Gender: #{@gender}\"\r\n\t\tputs \"ethnicity: #{@ethnicity}\"\r\n\t\tputs \"reindeer_ranking: #{@reindeer_ranking}\"\r\n\t\tputs \"age: #{@age}\"\r\n\tend",
"def show_info\n\t\tputs \"Your start station: #{starting_point}\"\n\t\tputs \"Your destination: #{ending_point}\"\n\t\tputs \"Travel time: ___\"\n\t\tputs \"Price: ____\"\n\tend",
"def print_details\n puts \"\"\n puts \"#{@fullname}\"\n puts \"---------\" ' '\n puts \"Date of Birth:#{@dob}\"\n \n puts \"\"\n puts \"Email addresses:\"\n @emails.each do |e|\n puts \"- \" + e.to_s\n end \n \n puts \"\"\n puts \"Phone Numbers:\"\n @phone_numbers.each do |n|\n puts \"- \" + n.to_s\n end\n end",
"def print_fields\r\n\t\tputs \"name: #{@name}\"\r\n\t\tputs \"num_billcoins: #{@num_billcoins}\"\r\n\t\tputs \"\"\r\n\tend",
"def show_details\n print @name.upcase + \": #{@name} has #{@moons} moons and a diameter of #{@diameter} miles.\"\n print \"It is #{@color} in color and associated with the #{@zodiac} zodiac sign.\"\n puts \"#{@name} is #{@distance} miles from the sun and has a solar rotation of #{@rotation} earth days!\"\n end",
"def print_contents\n\t\tputs \"Artist: %s\" % [@artist]\n\t\tputs \"Album: %s\" % [@title]\n\t\tputs \"Released: %s\" % [@year]\n\n\t\tif @cd_count > 0\n\t\tputs \"CD(%d): %s\" % [@cd_count, @cd_id]\n\t\tend\n\n\t\tif @tape_count > 0\n\t\tputs \"Tape(%d): %s\" % [@tape_count, @tape_id]\n\t\tend\n\n\t\tif @vinyl_count > 0\n\t\tputs \"Vinyl(%d): %s\" % [@vinyl_count, @vinyl_id]\n\t\tend\n\n\tend",
"def print_class\n\n puts \"* #{name.capitalize} *\".colorize(:light_green).bold.indent(10)\n puts\n puts short_description.to_s.colorize(:green).indent(10)\n puts\n stats.each_pair do |name, value|\n print \"| \".colorize(:green).indent(10)\n print \" #{name.capitalize} :\".colorize(:light_green)\n print \" #{value}\"\n print \" |\".colorize(:green)\n end\n puts\n puts\n\n end",
"def show_information_card\n puts \"------------------------------\"\n puts \"Name: #{@name}\"\n puts \"Address: #{@address}\"\n puts \"Email: #{@email}\"\n puts \"Random Fact: #{@random_fact}\"\n puts \"-----------------------------\"\n end",
"def display_planet_details\n puts \"Name: #{@name}, Primary Export: #{@primary_export}, Year-Length: #{@year_length}\"\n end",
"def print_info\n\n puts \"\\e[H\\e[2J\" # clear terminal screen\n\n # print the listing title\n print \"#{@@white}Job Title: #{@@green}#{self.title}\\n\"\n\n\n # print the time left to bid\n print \"\\t#{@@white}Time Left: #{@@green}#{self.time_left}\\n\"\n\n # print the budget for the job if valid\n if self.budget\n print \"\\t#{@@white}Budget: #{@@green}#{self.budget}\\n\"\n end\n\n # print the tags associated with the listing\n print \"\\t#{@@white}Tags: #{@@green}#{self.tags.join(',')}\\n\"\n\n # print the number of bids if valid\n if self.bids\n print \"\\n\\t#{@@white}Bids: #{@@green}#{self.bids}\\n\"\n end\n\n # print the average bid if valid\n if self.avg_bid\n print \"\\t#{@@white}Average Bid: #{@@green}#{self.avg_bid}\\n\"\n end\n\n # display the summary of bids at the momment\n print \"\\t#{@@white}Bid Summary: #{@@green}#{self.bid_summary}\\n\" if self.bid_summary\n\n # if we don't have the main description then print the short_description otherwise print the main description\n print \"\\t#{@@white}Description: \\n#{@@green}\"\n if self.description == nil\n # print \"#{self.short_description}\\n\\n\".green # put a .each_line block here and add \\t\\t to space it out properly\n desc = self.short_description\n else\n # print \"#{self.description}\\n\\n\".green\n desc = self.description\n end\n\n # fix the formating issues by indenting each line with tabs twice\n desc.each_line {|line| print \"\\t\\t#{@@green}#{line}\\n\"}\n\n print \"#{@@reset}\"\n end",
"def showInformation()\n print(\"Starting up the scraper for the RAND Terrorism Incident Database. The flashing numbers that will appear represent written incidents. It will take a few moments for the initial program to load... \\n\");\nend",
"def about\n\t\tputs \"Make: \" + @make\n\t\tputs \"Model: \" + @model\n\t\tputs \"Miles: \" + @miles.to_s\n\t\tputs \"Type: \" + @type\n\t\tputs \"Color: \" + @color\n\t\tputs \"Year: \" + @year.to_s\n\t\tif @used\n\t\t\tputs \"The #{@make} #{@model} is used.\"\n\t\telse\n\t\t\tputs \"The #{@make} #{@model} is new\"\n\t\tend\n\tend",
"def display_details()\n\t\tputs \"------------------------------\"\n\t\tputs \"User Details\"\n\t\tputs \"#{@first_name} #{@surname} aged '#{@age}'\"\n\t\tputs \"------------------------------\"\n\tend",
"def get_info\n puts @name + ' [ID: ' + @id.to_s + ' @ '+ @@company + ']'\n end",
"def print_person\n puts \"Name: #{name}\"\n puts \"Age: #{age} years old\"\n puts \"ID: VCN#{id}\"\n end",
"def about\n puts \"color: #{@color}\"\n puts \"size: #{@size}\"\n puts \"brand: #{@brand}\"\n puts \"game_ball: #{@game_ball}\"\n puts \"club_name: #{@club_name}\"\n puts \"team_name: #{@team_name}\"\n puts \"ball_number: #{@ball_number}\"\n puts \"------------------------\"\n end",
"def print_base_info\n # it could be solved by conditions, so we can remove additional methods\n # but more info we need print, more conditions we should add\n # that's why it's a bad approach\n \"Player's position is #{position} and he scored #{goals} goals.\"\n end",
"def print_values\n print \"\\nRegister A: #{@register_a}\\tRegister B: #{@register_b}\\n\"\n print \"Zero Bit: #{@zero_bit}\\tOverflow Bit: #{@overflow}\\n\"\n print \"Program Counter: #{@pc}\\n\"\n print \"Memory: #{@memory}\\n\"\n end",
"def basic_info\n\t\t#Grab some basic info using OID values which should be fairly generic in nature\n\t\ttarget = \"#{@manager.config[:host]}:#{@manager.config[:port]}\"\n\t\tcstring = @manager.config[:community]\n\t\t@snmp_version = @manager.config[:version] #We need this one later for some decisions so setting to class var\n\t\tsys_name = @manager.get_value(\"sysName.0\")\n\t\tsys_descr = @manager.get_value(\"sysDescr.0\")\n\n\t\t#Print out our basic info for user\n\t\tputs \"[*] \".light_green + \"Target\".light_yellow + \": #{target}\".white\n\t\tputs \"[*] \".light_green + \"Community String\".light_yellow + \": #{cstring}\".white\n\t\tif @snmp_version\n\t\t\tputs \"[*] \".light_green + \"SNMP Version\".light_yellow + \": #{@snmp_version}\".white\n\t\telse\n\t\t\tprint_caution(\"Unable to determine SNMP Version in use?\")\n\t\tend\n\t\tif sys_name\n\t\t\tputs \"[*] \".light_green + \"System Name\".light_yellow + \": #{sys_name}\".white\n\t\telse\n\t\t\tprint_error(\"Unable to determine system name!\")\n\t\tend\n\t\tif sys_descr\n\t\t\tputs \"[*] \".light_green + \"System Description\".light_yellow + \": \\n#{sys_descr}\".white\n\t\telse\n\t\t\tprint_error(\"Unable to find system description!\")\n\t\tend\n\t\tif @sys_time\n\t\t\tputs \"[*] \".light_green + \"System Uptime\".light_yellow + \": #{@sys_time}\".white\n\t\telse\n\t\t\tprint_error(\"Unable to find system description!\")\n\t\tend\n\tend",
"def info()\n #This is a stub, used for indexing\n end",
"def show\n puts \"ID = #{@id}\"\n puts \"Node name = #{@name}\"\n puts \"Require's input = #{@require_input}\"\n puts \"Type = #{@type}\"\n puts \"Points at => #{@points_at.pretty_inspect}\"\n end",
"def print_fields\r\n\t\tputs \"from_address: #{@from_address}\"\r\n\t\tputs \"to_address: #{@to_address}\"\r\n\t\tputs \"num_billcoins: #{@num_billcoins}\"\r\n\t\tputs \"\"\r\n\tend",
"def show_header()\n print_message (SPACE_SEPARATOR)\n print_message 'Welcome to Ruby Calculator'\n print_message (SPACE_SEPARATOR) \n end",
"def display_character_blah\n \n puts \"Name: #{name}\"\n puts \"Bio: #{description}\"\n end",
"def display\n puts (\"[\" + @id.name + \", \" + @id.version + \"]\").green.bold\n puts \"author = \".blue + @author\n print \"wrapper = \".blue + @wrapper.to_s\n puts \", unique = \".blue + @unique.to_s\n puts\n\n puts \"[Path:]\".green.bold\n puts @path\n\n #\n # Display the provided elements\n #\n\n puts \"\\n[Provide]\".green.bold\n @provide.each do |context|\n puts \"\\n<Context #{context.name}>\".blue.bold\n OCMSet::SECTIONS.each { |section| context[section].each { |k| puts k } }\n end\n\n #\n # Display the required elements\n #\n\n if @require != nil then\n puts \"\\n[Require]\".green.bold\n OCMSet::SECTIONS.each { |section| @require[section].each { |k| puts k } }\n end\n\n end",
"def print_header\n unless @detailed.nil?\n puts sprintf('%-30s %-10s %-10s', 'Time', 'Req/s', 'Avg resp (ms)')\n end\n end",
"def print\n blank = \"#{Tty.yellow}[no description]#{Tty.reset}\"\n @descriptions.keys.sort.each do |name|\n description = @descriptions[name] || blank\n puts \"#{Tty.white}#{name}:#{Tty.reset} #{description}\"\n end\n end",
"def display_details()\n puts \"Customer id is #{@id} \"\n puts \"Customer name is #{@name} \"\n puts \"Customer address is #{@address} \"\n end",
"def display_features\n puts\n puts \"Features:\"\n @features.each { |feature| puts \" * #{feature}\"}\n puts\n end",
"def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if ([email protected]?)\n puts \"#{weapon.name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if ([email protected]?)\n puts \"#{helmet.name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end",
"def print\n puts SEPARATOR\n puts @name\n puts SEPARATOR\n puts @desc\n if(@diagram)\n puts\n puts \"Diagram:\"\n puts\n puts @diagram\n end\n end",
"def display\n puts \"Title: #{@title}\"\n puts \"Author: #{@author}\"\n puts \"Price: #{@price}\"\n end",
"def print_status\n puts \"Stats:\"\n puts \"* HP: #{@stats[:hp]}/#{@stats[:max_hp]}\"\n puts \"* Attack: #{@stats[:attack]}\"\n puts \"* Defense: #{@stats[:defense]}\"\n puts \"* Agility: #{@stats[:agility]}\"\n print \"\\n\"\n\n puts \"Equipment:\"\n print \"* Weapon: \"\n puts @outfit[:weapon] ? \"#{@outfit[:weapon].name}\" : \"none\"\n\n print \"* Shield: \"\n puts @outfit[:shield] ? \"#{@outfit[:shield].name}\" : \"none\"\n\n print \"* Helmet: \"\n puts @outfit[:helmet] ? \"#{@outfit[:helmet].name}\" : \"none\"\n\n print \"* Torso: \"\n puts @outfit[:torso] ? \"#{@outfit[:torso].name}\" : \"none\"\n\n print \"* Legs: \"\n puts @outfit[:legs] ? \"#{@outfit[:legs].name}\" : \"none\"\n\n print \"\\n\"\n end",
"def listinfo\n puts \"排名:#{@no}\"\n puts \"月份:#{@month}\" if @month\n puts \"标签: #{@subtag}\" if @subtag\n puts \"标题:#{@title}\"\n puts \"集数:#{@episode}\" if @episode\n puts \"链接:#{@link}\"\n puts \"<bilibili独家哟!>\" if @bilibilionly_flag\n puts \"--------------------\"\n end",
"def about\n\t\tputs \"Gender: #{@gender}\"\n\t\tputs \"Ethnicity: #{@ethnicity}\"\n\t\tputs \"Age: #{@age}\"\n\t\tp \"Reindeer Ranking: #{@reindeer_ranking}\"\n\tend",
"def display\n puts \"Personal Details\"\n puts \" Name : #{self.name}\"\n puts \" Date of Birth : #{self.dob}\"\n puts \" Marital Status : #{self.marital_status}\"\n puts \" Mobile Number : #{self.mobile_number}\"\n puts \" Email : #{self.email}\"\n end",
"def print_usage; end",
"def print_info\n self.values.each do |value|\n puts value\n end\n end",
"def print_debug_info\n puts \"Company #{name}, day #{days}:\"\n puts \"\\tState: #{state}\"\n puts \"\\tCurrent cash flow: #{budget}\"\n puts \"\\tDaily expenses: #{daily_expenses}\"\n puts \"\\tCapacity: #{capacity}\"\n puts \"\\tProgrammers: #{programmers.collect { |programmer| programmer.name + \" (\" + programmer.project_name + \")\" }.join(\", \")}\"\n puts \"\\tPROJECTS WAITING: #{projects_waiting.collect { |project| project.name }.join(\", \")}\"\n puts \"\\tPROJECTS CURRENT:\"\n projects_current.each { |project| project.print_debug_info }\n puts \"\\tPROJECTS DONE:\"\n projects_done.each { |project| project.print_debug_info }\n end",
"def print\n puts @subject\n puts @text\n end",
"def info\n\tend",
"def print_info\n if get_definitions[0] == nil\n puts \"Invalid word\"\n else\n # output for terminal, uses dashes for cleaner screen\n puts \"-\" * 20\n puts \"You entered #{word}.\"\n `say #{word}`\n puts \"-\" * 20\n puts \"We found the following definitions:\"\n print_definitions\n puts \"-\" * 20\n puts \"The best example usage is:\"\n print_top_example\n puts \"-\" * 20\n puts \"We found the following pronunciations:\"\n print_pronunciations\n puts \"-\" * 20\n end\n end",
"def show\n\t puts \"\t#{@spaces[0]} #{@spaces[1]} #{@spaces[2]}\"\n\t puts \"\t#{@spaces[3]} #{@spaces[4]} #{@spaces[5]}\"\n\t puts \"\t#{@spaces[6]} #{@spaces[7]} #{@spaces[8]}\"\n\tend",
"def print_main_user_options\n puts \"-------\".light_magenta\n puts \"Information is updated from the data source approximately every 15 minutes - this information was last updated at #{CovidTracking::Summary.all.first.date}.\".light_magenta\n puts \"-------\".light_magenta\n puts \"What would you like to learn more about - a GLOBAL summary of COVID-19 spread, or a summary for a specific COUNTRY?\".light_magenta\n puts \"Tip: you can also REFRESH the program to see if data has been updated or enter FACTOIDS for some summary facts.\".light_magenta\n puts \"Please enter GLOBAL, COUNTRY, REFRESH, FACTOIDS, or EXIT.\".green\n end",
"def print\n\t\tputs name + \" \" + className + \" says \" + call\n\tend",
"def print_info\n puts \"#{self.country} (#{self.country_code}):\".light_cyan\n puts \" New Confirmed Cases: #{self.new_confirmed}\".light_red\n puts \" Total Confirmed Cases: #{self.total_confirmed}\".light_red\n puts \" New Deaths: #{self.new_deaths}\".light_red\n puts \" Total Deaths: #{self.total_deaths}\".light_red\n puts \" New Recovered Cases: #{self.new_recovered}\".light_red\n puts \" Total Recovered Cases: #{self.total_recovered}\".light_red\n puts \"This information was last updated at #{self.date}\".light_cyan\n end",
"def print_details\n puts \"#{@dog_walker.name} walked #{@dog.name} for #{length_in_minutes} minutes.\"\n end",
"def info\n puts \"The name and the price will be printed\"\n end",
"def print\r\n\t\tputs name + \" \" + className + \" says \" + call\r\n\tend",
"def print_header\n print \"\\e[H\\e[2J\"\n puts \"*************************\".green\n puts \"2nd step - Gameplay setup\".green\n puts \"*************************\".green\n end",
"def info\n p \"The #{year} #{model} is #{color} and has a speed of #{speed}.\"\n end",
"def info\n p \"The #{year} #{model} is #{color} and has a speed of #{speed}.\"\n end",
"def printer\n puts \" \" + @bio\n end",
"def print\n end",
"def show\n\t\tputs @gender+\" - \"+@blood_type+\" - \"+@weight+\" - \"+@infected\n\tend",
"def print_planet_info\n puts \"☛ Planet #{@name} takes #{@year_length} earth days to go around its star.✰\".bold\n puts \"\"\n puts \"◆ It is #{@distance_from_the_sun} kilometers away from the sun ☀️ and has a mass of #{@mass} kilogram.\".bold\n puts \"\"\n puts \"◆ It's diameter is #{@diameter} kilometer and it has these atmospheric components: #{@atmospheric_components}.\".bold\n puts \"\"\n end",
"def about_person\n\t\tputs \"Name: #{name}, agr: #{age}\"\n\tend",
"def print\n\t\tputs name + ' ' + className + \" just \" + move + \" and said \" + call\n\tend",
"def print_trail_info\n puts \"Rating: #{self.rating}\"\n puts \"Distance: #{self.distance} mi\"\n puts \"Surface Type(s): #{self.surface}\"\n puts \"Brief Description: #{self.info}\\n\"\n puts \"--------------------------------------------------------------------------------\\n\"\n end",
"def show boook\n\t\t\tputs @hash\n\t\t\t\n\t\tend",
"def output\n puts \"Name: #{@name}\"\n puts \"Email: #{@email}\"\n puts \"Phone: #{@phone}\"\n puts \"Title: #{@title}\"\n end",
"def info\n puts \"Version #{StaticData::APPLICATION_VERSION}\"\n puts \"Authors : \"\n StaticData::AUTHORS.each do |author| \n puts \"-- #{author}\"\n end \n end",
"def printOverview\n @nodes.each do |node|\n puts node.nodeID + \" \" + (node.e0.to_s) +\n (node.e1.to_s) + \n (node.w0.to_s) + \n (node.w1.to_s)\n end\n end",
"def print_help\n puts 'Here is a list of available commands:'\n puts '- new - Create a new contact'\n puts '- list - List all contacts'\n puts '- show - Show a contact'\n puts '- find - Find a contact'\n end",
"def desc\n\t\t\"Basic I/O\"\n\tend",
"def show_info(config, layout)\n Squib::logger.info \"Squib v#{Squib::VERSION}\"\n Squib::logger.info \" building #{@cards.size} #{@width}x#{@height} cards\"\n Squib::logger.info \" using #{@backend}\"\n end",
"def output_documentation_debugging\n\t\tsummary = self.extract_summary\n\t\tdescription = self.extract_description\n\t\thomepage = self.extract_homepage || DEFAULT_HOMEPAGE\n\n\t\tself.prompt.say( \"Documentation\", color: :bright_green )\n\t\tself.prompt.say( \"Authors:\" )\n\t\tself.authors.each do |author|\n\t\t\tself.prompt.say( \" • \" )\n\t\t\tself.prompt.say( author, color: :bold )\n\t\tend\n\t\tself.prompt.say( \"Summary: \" )\n\t\tself.prompt.say( summary, color: :bold )\n\t\tself.prompt.say( \"Description:\" )\n\t\tself.prompt.say( \" \" + description, color: :bold )\n\t\tself.prompt.say( \"Homepage:\" )\n\t\tself.prompt.say( \" \" + homepage, color: :bold )\n\t\tself.prompt.say( \"\\n\" )\n\tend",
"def details; end",
"def print_init_status\n\t\tset_status(@ctx_init_id, \"by #{RsConfig::AUTHOR_FULLNAME} #{RsConfig::AUTHOR_PROMO} - (c) #{Time.now.year}\")\n\tend",
"def print\n end",
"def print\n end",
"def print\n end",
"def show_help\n puts HELP_MESSAGE\n end",
"def show_help\n puts HELP_MESSAGE\n end",
"def print\n\n end",
"def print_options\n puts \"\\nGeneral options (not all options are valid for all tasks):\"\n puts \"files=<pattern> - Files for the task (a pattern to match the files)\"\n puts \"talia_root=<path> - Manually configure the TALIA_ROOT path\"\n puts \" (default:autodetect)\"\n puts \"reset_rdf={yes|no} - Flush the RDF store (default:no)\"\n puts \"reset_db={yes|no} - Flush the database (default:no)\"\n puts \"config=<filename> - Talia configuration file (default: talia_core)\"\n puts \"environment=<env> - Environment for configuration (default: development)\"\n puts \"data_dir=<dir> - Directory for the data files\"\n puts \"verbose={yes|no} - Show some additional info\"\n puts \"\"\n end",
"def print_meta_head\n puts \"\\nDataset: #{@meta_data.name}\"\n end",
"def print_rationale\n puts \"To start playing, just start typing some Rubinius VM instructions.\"\n puts \"You can find a complete list with documentation here:\"\n puts\n puts \"\\thttp://rubini.us/doc/en/virtual-machine/instructions/\"\n puts\n puts \"To introspect the program you are writing, use the following commands,\"\n puts \"or type \" + bold { \"exit\" } + \" to exit:\"\n puts\n puts \" \" + bold { \"list\" } + \" lists the instruction set of the current program.\"\n puts \" \" + bold { \"reset\" } + \" empties the instruction set and starts a new program.\"\n puts \" \" + bold { \"draw\" } + \" prints a visual representation of the stack after each instruction.\"\n puts\n end",
"def printStatus()\n puts \"matriks_data: #{@matriks_data}\"\n puts \"jumlah node sebanyak: #{@jumlah_node}\"\n end",
"def print_details\n puts \"#{self.reader.name} subscribed to #{self.magazine.title} for $#{self.price}\"\n end",
"def display ( )\n puts 'Parser states: ' + @states.size.to_s\n\n @states.each do |st|\n\tputs\n\tputs '*' * 80\n\tputs 'state: ' + st.statename\n\tputs 'branches: '\n\tst.branches.each do |br|\n\t puts ' ' + @states[br].statename\n\tend\n end\n end",
"def show\n # binding.pry\n \n end",
"def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if (!@outfit[:weapon].nil?)\n puts \"#{@outfit[:weapon].name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if (!@outfit[:helmet].nil?)\n puts \"#{@outfit[:helmet].name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end"
] | [
"0.78686696",
"0.7476243",
"0.74320716",
"0.7343626",
"0.72409546",
"0.7223008",
"0.7191144",
"0.7187334",
"0.7174564",
"0.71457267",
"0.7112385",
"0.70454144",
"0.7043258",
"0.70358133",
"0.70358133",
"0.70211315",
"0.70211315",
"0.70000863",
"0.6977748",
"0.6971914",
"0.6965016",
"0.69554114",
"0.6955393",
"0.6914003",
"0.68480545",
"0.68451756",
"0.6843453",
"0.6837956",
"0.68329644",
"0.6824994",
"0.6814808",
"0.68058604",
"0.67974365",
"0.67897075",
"0.6776203",
"0.67635983",
"0.67477196",
"0.6744984",
"0.6727013",
"0.6721607",
"0.67191154",
"0.66832834",
"0.6676255",
"0.66757506",
"0.6645327",
"0.6640488",
"0.6634564",
"0.6617043",
"0.66098225",
"0.6608162",
"0.66076684",
"0.66046923",
"0.66023654",
"0.6587732",
"0.6576247",
"0.6565573",
"0.6565005",
"0.65648115",
"0.6560218",
"0.6560116",
"0.655903",
"0.6552267",
"0.6549504",
"0.65460324",
"0.6545664",
"0.6543388",
"0.6534844",
"0.65258634",
"0.65217394",
"0.65217394",
"0.6505444",
"0.6486921",
"0.6477465",
"0.6467111",
"0.6457994",
"0.645325",
"0.64528316",
"0.64400727",
"0.64307654",
"0.64282364",
"0.64107233",
"0.64100057",
"0.64017767",
"0.6400118",
"0.63859695",
"0.6384353",
"0.63838637",
"0.6383816",
"0.6383816",
"0.6383816",
"0.63777816",
"0.63777816",
"0.637778",
"0.6376334",
"0.63735396",
"0.6373146",
"0.6371523",
"0.636234",
"0.6360761",
"0.6360087",
"0.63582"
] | 0.0 | -1 |
Hire me! :from => Who you are :body => A little message :subject => Subject of the email | def hired!(options={})
raise "You need to specify from, subject and body" unless options.key?(:from) || options.key?(:body) || options.key?(:subject)
Pony.mail({:to => '[email protected]'}.merge(options))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_us(subject, body)\n unless ENV['RACK_ENV'] == 'development'\n recipient = \"The Awesome Team <[email protected]>\"\n\n # First, instantiate the Mailgun Client with your API key\n mg_client = Mailgun::Client.new ENV['MAILGUN_PRIVATE']\n\n # Define your message parameters\n message_params = { from: '[email protected]',\n to: recipient,\n subject: subject,\n html: body,\n text: Nokogiri::HTML(body).text\n }\n\n # Send your message through the client\n mg_client.send_message 'sandboxa148f93a5c5f4813a81365d1b873ee8f.mailgun.org', message_params\n end # unless ENV['RACK_ENV'] == 'development'\n end",
"def user_message(recip, from, from_name, message)\n recipients recip\n from from\n subject \"Message from Weefolio User #{from_name}\"\n sent_on Time.now\n body message\n end",
"def send_support_email(to_email, subject, body, from_email, user_first_name, user_last_name)\n @from = \"#{user_first_name} #{user_last_name} <#{from_email}>\"\n @subject = subject\n @recipients = to_email\n @body[:body] = body\n# @content_type = \"text/html\"\n end",
"def important_message\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def spam\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_email(to, subject, content)\r\n\r\n end",
"def message_email(name, email, body)\n @name = name\n @email = email\n @body = body\n mail(:to => \"[email protected]\", :subject => \"New Message from CONSIGN.NYC\")\n end",
"def email_me(name, email, message)\n @greeting = \"Hi, I'm #{name}\"\n @message = message\n @email = email\n\n mail to: \"[email protected]\", subject: \"Porfolio email from #{name}\"\n end",
"def message_me(msg)\n @msg = msg\n mail subject: \"From: #{@msg.name} : #{@msg.email} says : #{@msg.subject}\", body: \"From: #{@msg.name} @ #{@msg.email} | Subject: #{@msg.subject} | Body of email : #{@msg.content}\"\n #@msg.content << \"From : #{@msg.name} :: Subject : #{@msg.subject}\" # previous one\n end",
"def contact_me(contact_form)\n @from = contact_form.email\n @message = contact_form.message\n @name = contact_form.name\n if contact_form.name.presence\n subject = \"Portfolio: A message from #{contact_form.name}\" \n else\n subject = \"Portfolio: A message from an unnamed visitor to your site.\"\n end\n mail from: contact_form.email,subject: subject\n end",
"def message_email(user, sender, message, convoID)\n \t@user = user\n \t@message = message\n \t@sender = sender\n \t@url = 'http://www.projecthelp.co/inbox/' + convoID.to_s\n\n \tmail :to\t\t=> user.email,\n :subject\t=> \"New message from \" + @sender.first_name\n end",
"def send_an_email(message, subject, to)\n message_params = {}\n message_params[:from] = 'QuikSort Bot <***@quiksort.in>'\n message_params[:to] = to\n message_params[:subject] = subject\n message_params[:text] = message\n logger.info $MG_CLIENT.send_message 'quiksort.in', message_params\nend",
"def send_signup_email(name, email, body)\n \t\t@name = name\n\t\t@email = email\n\t\t@body = body\n\n \t\tmail( :to => email,\n \t\t :subject => 'Thanks for signing up for our amazing app' )\n \tend",
"def send_mail(email)\n mail to: email, subject: 'Welcome', body: 'body message'\n \n end",
"def contact_me(params)\n @params = params\n @greeting = \"Hi\"\n #mail to: \"[email protected]\"\n mail(:from => @params.personal_email,:to =>@params.personal_email, :subject => \"- EJJE -Gracias Por tu ayuda\")\n end",
"def contact_email(name, email, body)\n @name = name\n @email = email\n @body = body\n \n mail(from: email, subject: 'Contact Form Message')\n end",
"def issued\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def anfrage\n @greeting = \"Hi\"\n\n mail :to => \"[email protected]\"\n end",
"def funded_email_to_creator\n Pony.mail(:to => self.email, :from => '[email protected]', :subject => 'the gift you created is now funded!', :body => 'yay! some people owe you money.')\n end",
"def book_request(user)\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def show_notfication\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_spam\n user = User.last\n subject = \"Big launch\"\n message = \"hello world\"\n ::UserMailer.spam(user: user, subject: subject, message: message)\n end",
"def request_mail(from_email, content_body, requestor_type)\n @content= content_body\n @sender = from_email\n @requestor_type = requestor_type\n mail from: from_email, to: '[email protected]', subject: 'PFS general enquiry'\n end",
"def review_request(user)\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def contact_email(message)\n @message = message\n @from = @message.email\n mail(from: message.email, reply_to: message.email, subject: message.subject)\n end",
"def send_email(to, subject, body)\n # Run this asynchronously using EventMachine since it takes a couple of seconds.\n EM.defer do\n Pony.mail(:from => \"Cheesy Parts <#{CheesyCommon::Config.gmail_user}>\", :to => to,\n :subject => subject, :body => body, :via => :smtp,\n :via_options => { :address => \"smtp.gmail.com\", :port => \"587\",\n :enable_starttls_auto => true,\n :user_name => CheesyCommon::Config.gmail_user.split(\"@\").first,\n :password => CheesyCommon::Config.gmail_password,\n :authentication => :plain, :domain => \"localhost.localdomain\" })\n end\n end",
"def rueckruf\n @greeting = \"Hi\"\n\n mail :to => \"[email protected]\"\n end",
"def bye\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def newsletter\n @greeting = \"Hi\"\n\n mail :to => \"[email protected]\"\n end",
"def reserved_mail\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_message(name, email, subject, message)\n #@greeting = \"Hi\"\n\n #mail( to: \"[email protected]\" )\n @name = name.to_s\n @email = email.to_s\n @subject = subject.to_s \n @message = message.to_s + \" FROM: \" + @name.to_s\n \n mail(to: '[email protected]', subject: @subject.to_s)\n end",
"def setup_email(user)\n @recipients = user.email\n @body[:user] = user\n @from = FROM_EMAIL\n @subject = case ENV['RAILS_ENV'] \n when 'development': \"[YourApp Development] \"\n when 'staging': \"[YourApp Staging] \"\n else \"[YourApp] \"\n end\n @sent_on = Time.now\n headers \"Reply-to\" => FROM_EMAIL\n end",
"def email_friend(sent_to,message,subject)\n @message=message\n mail to: '[email protected],'+sent_to,:subject => subject\n end",
"def new_chore\n @greeting = \"Hi roommate,\"\n\n mail to: '[email protected]'\n end",
"def send_email(from_name,from_email,to_name,to_email,subject,body)\n # TODO replace with something bulkier and more of a hassle later?\n # TODO it is overspecialized to use the domain name here\n from_domain = \"foodgenome.com\"\n if !from_name || from_name.length < 1\n from_name = \"twitter\"\n from_email = \"twitter@#{from_domain}\"\n end\n begin\n message = \"From: #{from_name} <#{from_email}>\\n\" +\n \"To: #{to_name} <#{to_email}>\\n\" +\n \"Subject: #{subject}\\n\" +\n \"#{body}\\n\"\n Net::SMTP.start('localhost') do |smtp|\n smtp.send_message message, from_email, to_email\n end\n rescue\n # TODO if the email fails we can use this to filter bad users\n end\n end",
"def custom_mail( user, subject, title, contents )\n @user = user\n @host = GogglesCore::AppConstants::WEB_MAIN_DOMAIN_NAME\n @contents = contents\n @title = title\n #subject: \"[#{ GogglesCore::AppConstants::WEB_APP_NAME }@#{ @host }] #{ subject }\",\n mail(\n subject: \"#{ subject } [#{GogglesCore::AppConstants::WEB_APP_NAME}]\",\n to: user.email,\n date: Time.now\n )\n end",
"def mailfrom(from_addr); end",
"def contact_form(email)\n\n @sender = email[0]\n @website = email[1]\n @email = email[2]\n @message = email[3]\n\n @greeting = @sender+ \"sent a message\"\n\n mail :to => \"[email protected]\",:subject=>@greeting\n end",
"def inquiry(info)\n @name = info[:name]\n @email = info[:email]\n @content = info[:content]\n mail(to: '[email protected]', subject: \"Message from #{@name} via flowersbykaz.com\")\n end",
"def send_email(name, message)\n @greeting = \"Hi\"\n @name = name \n @message = message\n \n mail to: \"[email protected]\"\n end",
"def send_email( params )\n puts \"From: #{params[:from]}\"\n puts \"To: #{params[:to]}\"\n puts \"Email subject: #{params[:subject]}\"\n puts \"Email body: #{params[:body]}\" \n return true\n end",
"def sofortkontakt\n @greeting = \"Hi\"\n\n mail :to => \"[email protected]\"\n end",
"def invite_a_friend_to_track(user, email, the_body, the_subject) \n recipients email\n #bcc \"[email protected]\"\n from user.first_name + \" via habitforge <[email protected]>\"\n subject the_subject \n body the_body\n content_type \"text/html\"\n end",
"def spam(user, message:, subject:)\n @user = user\n @message = message\n mail(to: @user.email, reply_to: \"[email protected]\", subject: subject)\n end",
"def contact_reply(email, name, message)\n \t@email = email\n \t@name = name\n \t@message = message\n mail(:to => email,\n :subject => \"Thank You For Your Message\")\n end",
"def send_email\n g = GmailSender.new(USER_NAME, PASSWORD)\n\n g.send(:to => to,\n :subject => @subject,\n :content => full_content)\n end",
"def send_newsletter(to,sha1_id,from, newsletter_subject, description, newsletter_body)\n recipients to\n from from\n\t\tsubject newsletter_subject\n\t\tbody :description => description, :newsletter_body => newsletter_body, :site => self.site_name,:sha1_id => sha1_id,:url => self.daurl\n sent_on Time.now\n content_type \"text/html\"\n end",
"def send_email(from, from_alias, to, to_alias, subject, message) #Sending emails!\n\tmsg = <<END_OF_MESSAGE\nFrom: #{from_alias} <#{from}>\nTo: #{to_alias} <#{to}>\nReply-to: [email protected]\nSubject: #{subject}\n\t\n#{message}\nEND_OF_MESSAGE\n\t\n\tNet::SMTP.start('127.0.0.1') do |smtp|\n\t\tsmtp.send_message msg, from, to\n\tend\nend",
"def send_message_to_company(recipientEmail, fromEmail, subjectEmail, bodyMessage)\n @subject = subjectEmail\n @body[\"body_message\"] = bodyMessage\n @body[\"sent_to\"] = recipientEmail\n @recipients = recipientEmail\n @from = fromEmail\n @content_type = \"text/html\"\n @headers = {}\n end",
"def in_progress\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def content(address, name)\n @greeting = \"Hi! #{name}\"\n\n mail to: address, subject: '謝謝你報名參加TKU Hackathon,提醒您活動時間是2014/3/29'\n end",
"def email\n options = { :from => params[:email], :to => \"[email protected]\", :subject => params[:subject], :body => \"From: #{params[:user]} <#{params[:email]}>\\r\\nCategory: #{params[:category]}\\r\\nSubject:#{params[:subject]}\\r\\n\\r\\n#{params[:body]}\"}\n RequestMailer.deliver_generic(options)\n flash[:notice] = \"Your email was sent successfully\"\n redirect_to params[:redirect]\n end",
"def create_email to, from, subject, message\n\n @from = from\n @to = to\n @subject = subject\n @message = message\n\n mail(to: to, subject: subject, from: from)\n end",
"def send_farewell_email(user)\n @user = user\n mail( :to => @user.email ,\n :subject => '[Todo Manager] See you again!')\n end",
"def late(receiver)\n @greeting = \"Hi\"\n mail to: receiver, subject: \"Hi\"\n end",
"def getting_started\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def alert_email(user)\n @user = user\n mail( :to => '[email protected]',\n :subject => 'You have a request from: '+ @user.email )\n end",
"def question(member, subject, content)\n @content = content\n\n mail to: member.email, subject: subject\n end",
"def restaurant_email\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_mail(user)\n @greeting = \"Hi #{user.name}\"\n\n mail to: user.email\n end",
"def new_contact_intro_email(user, contact)\n if user.name.present?\n @name = user.name.titlecase\n else\n @name = user.email\n end\n\n @signature = user.signature\n @email = user.email\n\n mail to: contact.email, reply_to: @email, from: \"\\\"#{@name}\\\" <#{@email}>\", subject: \"#{@name} wants to stay in touch with you!\"\n Email.create(:user_id => user.id, :sent_to => contact.id, :title => \"new_contact_intro_email\", :contacts => contact.id)\n end",
"def send_contact(name, email, company, phone, subject, message)\n @greeting = message\n\n mail to: \"[email protected]\", subject: \"#{name}, #{email}, #{phone} #{\", \" + company} - #{subject}\"\n end",
"def first_round_email(email)\n @greeting = \"Hi\"\n\n mail to: email, subject: \"Your ASES Application Decision\"\n end",
"def send_mail(email,subject,body)\n Pony.mail(:to => email,\n :from => t.email.adress,\n :subject => subject,\n :body => body,\n :content_type => 'text/html',\n :charset => 'utf-8',\n :via => :smtp, :smtp => {\n :host => 'smtp.kunigo.com.br',\n :port => '587',\n :user => '[email protected]',\n :password => 'PASSWORD',\n :auth => :plain,\n :domain => \"localhost.localdomain\"\n })\n end",
"def this_mail( mail, options )\r\n subject mail.subject\r\n recipients setup_recipients( mail.email )\r\n from mail.from\r\n body options.merge( :mail => mail )\r\n end",
"def reply(content)\n @greeting = \"Hi\"\n @admin = content[:from]\n @contact = content[:to]\n @message = content[:message]\n mail to: content[:to].email, subject: \"RE: \"+content[:to].subject\n end",
"def contact_notification(website, email)\n\t\trecipients website.contact_email\n from email[\"email\"]\n sent_on Time.now\n\t\tsubject website.title +\" : \"+email[\"subject\"]\n\t\tbody :first_last => email[\"first_name\"]+\" \"+email[\"last_name\"],\n\t\t\t:body => email[\"body\"],\n\t\t\t:phone => email[\"primary_phone\"]\n\tend",
"def thanks_email( user_email )\n @greeting = \"Thanks for contacting us!\"\n\n mail to: user_email\n end",
"def follow_up_alert(email, name, body, body_part2, location_link)\n @name = name \n @body = body\n @body_part2 = body_part2\n @location_link = location_link\n\n mail to: email, subject: \"Follow-up info from Grapevine\", from: \"[email protected]\", reply_to: \n \"[email protected]\"\n\n end",
"def test(recipient)\n mail(to: recipient, subject: \"#{subject_prefix} Hello from Book Tracker\")\n end",
"def reminder(user)\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def new_request(name_, subject_, content_)\n @subject = subject_\n @name = name_\n @content = content_\n\n mail to: \"[email protected]\", subject: @subject\n #mail to: \"[email protected]\", subject: @subject\n end",
"def daily_reading\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def mail_message(subject, content)\n message = ''\n message << \"From: Do Not Reply <[email protected]>\\n\"\n message << \"To: #{EMAIL_TO}\\n\"\n message << \"Subject: #{subject}\\n\"\n message << \"\\n\"\n message << content\n\n Net::SMTP.start('localhost') do |smtp|\n smtp.send_message message, '[email protected]', EMAIL_TO\n end\nend",
"def contact_request\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def inquiry(contact_message)\n @contact_message = contact_message\n mail to: \"[email protected]\",\n from: contact_message.email,\n subject: \"Neue Kontaktanfrage\"\n end",
"def notice_post\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def notify\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def new_message(message)\n @message = message\n mail(:to => \"[email protected]\", :subject => \"Service Crunch User Contact Form\")\n end",
"def message\n \"From: <#{from}>\\nTo: <#{to}>\\nMIME-Version: 1.0\\nContent-type: text/html; charset=UTF-8\\nSubject: #{subject}\\n\\n#{code_html}\"\n end",
"def lost_brain\n @greeting = 'Hi'\n\n mail to: '[email protected]'\n end",
"def email_message(subject, msg, to, html = false)\n if (!@dry_run)\n msg_hash = {:to => to,\n :subject => \"#{SUBJECT_PREFIX}#{subject}\",\n :from => @from,\n :via => :smtp,\n :via_options => @mail_options }\n if html\n msg_hash[:html_body] = \"<PRE>#{msg}</PRE>\"\n else\n msg_hash[:body] = msg\n end\n Pony.mail(msg_hash)\n else\n puts \"email message to: #{to}:\"\n puts msg\n end\n end",
"def lost_brain\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_email(data)\n @type = data[:type]\n @message = data[:message]\n @name = data[:name]\n @from = data[:email]\n \n mail(\n :from => @from, \n :reply_to => @from,\n :subject => \"#{@type} - contact form on project.shearn89.com\"\n )\n end",
"def lost_brain\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_signup_email\n mail( :to => '[email protected]',\n :subject => 'Thanks for signing up for our amazing app' ).deliver\n end",
"def send_email(from, from_alias, to, to_alias, subject, message)\n\tmsg = <<END_OF_MESSAGE\nFrom: #{from_alias} <#{from}>\nTo: #{to_alias} <#{to}>\nMIME-Version: 1.0\nContent-type: text/plain\nSubject: #{subject}\n\n#{message}\nEND_OF_MESSAGE\n\n\tNet::SMTP.start('mr1.ufz.de',\n 25,\n 'localhost.localdomain',\n 'bilke', $password) do |smtp|\n\t\tputs \"Sending email to #{to_alias} <#{to}>...\"\n smtp.send_message(msg, from, to)\n\tend\nend",
"def accepted\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def ab e,s,m\n @e = e\n @s = s\n @m = m \n @greeting = \"Hi\"\n mail to: \"[email protected]\"\n end",
"def welcome_email(user)\n RestClient.post API_URL+\"/messages\",\n :from => \"[email protected]\",\n :to => user.email,\n :subject => \"Welcome to Urop.io\",\n :text => \"Thanks for signing up\"\n end",
"def send_mail\n @greeting = \"Hi\"\n mail to: \"[email protected]\"\n end",
"def help\n @greeting = \"Help me!\"\n # mail to: \"[email protected]\"\n mail to: \"[email protected]\"\n # mail to: \"[email protected]\"\n end",
"def contacto\n @greeting = \"Hi\"\n\n #@email = 'email al cual envias' #<- email al cual enviaras\n #@alias = '' #<- nombre de quien envia ejem 'Carlos Acosta Del Rio'\n #@reply = '' #<- a quien contestaran\n \n\n mail :to => @email, :subject => \"Contacto De Su Sitio SIC\", :from => \"\\\"\" + @alias + \"\\\" \", :reply_to => @reply\n end",
"def contact_message(contact_email)\n @contact_email=contact_email\n \n\n mail to: \"[email protected]\", subject: \"Message Sent From raisebusinessomeony.com: #{contact_email.subject}\", from: contact_email.email, reply_to: contact_email.email\n end",
"def weekly_email\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def follow_notification\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def email0(to, from)\n mail(\n to: to,\n from: from,\n subject: 'email0 subject'\n )\n end",
"def headers \n \t{\n \t:subject => \"Contact Form\",\n \t:to => \"[email protected]\",\n \t#fills out from with the information of person from the contact form\n \t:from => %(\"#{name}\" <#{email}>)\n }\n end",
"def question_notification(asker, subject, details)\n @asker = asker\n @subject = subject\n @details = details\n\n mail to: \"Alex Yang <[email protected]>\",\n from: \"BaseRails <[email protected]>\",\n subject: \"#{asker} posted a new question on BaseRails\"\n end",
"def notification\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end"
] | [
"0.7555445",
"0.7502845",
"0.7486557",
"0.7469479",
"0.7461183",
"0.73721486",
"0.73298424",
"0.7311195",
"0.72415924",
"0.71546984",
"0.7137693",
"0.7130245",
"0.7099609",
"0.7090259",
"0.7060519",
"0.70475614",
"0.70448947",
"0.7038294",
"0.7036938",
"0.7021658",
"0.7001909",
"0.6994535",
"0.69868714",
"0.69832665",
"0.69746226",
"0.6957106",
"0.69486076",
"0.6947468",
"0.69459975",
"0.6938761",
"0.69205797",
"0.69194806",
"0.6915744",
"0.6907632",
"0.69074976",
"0.6891514",
"0.6891261",
"0.68867725",
"0.6869539",
"0.68681496",
"0.6864128",
"0.6860359",
"0.6859491",
"0.68581825",
"0.6857683",
"0.6854271",
"0.6852178",
"0.6851165",
"0.6844749",
"0.68432146",
"0.683501",
"0.6822928",
"0.6822205",
"0.6808292",
"0.68065655",
"0.68038243",
"0.67953366",
"0.67948836",
"0.6790207",
"0.6784822",
"0.6782437",
"0.6772571",
"0.67709523",
"0.6769661",
"0.6768744",
"0.6762653",
"0.6762436",
"0.67605734",
"0.6757165",
"0.6755552",
"0.67543036",
"0.6752615",
"0.67515767",
"0.67462283",
"0.67431366",
"0.67431",
"0.67394286",
"0.67241085",
"0.67220837",
"0.6714684",
"0.6714342",
"0.67120993",
"0.67080235",
"0.6707901",
"0.6706308",
"0.67046076",
"0.66929924",
"0.66892755",
"0.66890043",
"0.668741",
"0.6684209",
"0.6680211",
"0.6679805",
"0.66654533",
"0.666498",
"0.6660849",
"0.6659209",
"0.665527",
"0.6654494",
"0.66499406"
] | 0.7844362 | 0 |
Shared me CV with fellow coworkers. Sends them a URL to download this CV | def share_with(from, *emails)
emails.each do |email|
Pony.mail(:to => email,
:from => from,
:subject => 'Hey what do you think of this guy...',
:body => github_cv_url)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_video\n\t\t# preview_video_url = \"https://video.tvspielfilm.de/ivideo/video/10/9700610_1.mp4\"\n\n\t\tif preview_video_url.present?\t\n\t\t\tfilename = Pathname.new(preview_video_url).basename\n\t\t\tfilename = filename.to_s rescue \"#{Time.now.to_i}.mp4\"\n\t\t\t\n\t\t\tfilename = \"#{id}_#{filename}\"\n\n\t\t\tnew_file_path = \"#{Rails.root.to_s}/public/videos/#{filename}\"\n\t\t\topen(new_file_path, \"wb\") do |file| \n\t\t\t file.print open(preview_video_url).read\n\t\t\tend\n\t\t\tupload_video_at_s3(filename, new_file_path) \n\t\tend\n\tend",
"def download_progguide(prog_guide_url)\n return download_data(\"http://www.channel4.com#{prog_guide_url}\")\n end",
"def download\n @video = Video.find(params[:id])\n send_file(RAILS_ROOT+\"/public\"[email protected](\"?\")[0], :disposition => 'inline', :stream => false)\n end",
"def download\n send_file @cfile.path.to_s\n end",
"def download_slideshow\n Down.download bucket_url.url\n end",
"def download_asset(prog_id)\n return download_data(\"http://www.channel4.com/programmes/asset/#{prog_id}\")\n end",
"def set_my_cv\n @my_cv = MyCv.find(params[:id])\n end",
"def download_quest\n send_file(\"#{RAILS_ROOT}/public/questionnaire.doc\") \n end",
"def fetch_video_o_url(id:)\n require 'typhoeus'\n auth_url = 'https://www.flickr.com/video_download.gne?id=' + id\n dl_url = nil\n request = Typhoeus::Request.new(auth_url, headers: {Cookie: @config['cookie']})\n request.on_complete do |response|\n dl_url = response.headers['location']\n end\n request.run\n return dl_url\n end",
"def download_pdf\n send_file(\n \"#{Rails.root}/public/cv_eric_merlin.pdf\",\n filename: \"cv_eric_merlin.pdf\",\n type: \"application/pdf\"\n )\nend",
"def save! target=\"./Videos of me\"\n filename = File.join(target, \"#{@name}#{File.extname(@url)}\")\n\n data = Faceoff.download(@url)\n\n Faceoff.safe_save(filename) do |file|\n file.write data\n end\n end",
"def download\n #@repository=Repository.find(params[:id])\n #url=/assets/uploads/1/original/BK-KKM-01-01_BORANG_PENILAIAN_KURSUS.pdf?1474870599\n #send_file(\"#{::Rails.root.to_s}/public#{@repository.uploaded.url.split(\"?\").first}\")\n @filename=\"#{::Rails.root.to_s}/public#{@repository.uploaded.url.split(\"?\").first}\"\n #send_file(@filename , :type => 'application/pdf/docx/html/htm/doc', :disposition => 'attachment')\n send_file(@filename ,:type => 'application/pdf', :disposition => 'attachment')\n end",
"def show\n puts \"Downloading %s\" % @@clonePW['url'].to_s\n @@thread = download(@@clonePW['url'].to_s)\n @progress_web=@@clonePW\n @@start = Time.now\n\n end",
"def set_cv\n @cv = Cv.find(params[:id])\n end",
"def set_cv\n @cv = Cv.find(params[:id])\n end",
"def download!(source_url, destination_file); end",
"def create\n @my_cv = MyCv.new(my_cv_params)\n\n respond_to do |format|\n if @my_cv.save\n format.html { redirect_to @my_cv, notice: 'My cv was successfully created.' }\n format.json { render :show, status: :created, location: @my_cv }\n else\n format.html { render :new }\n format.json { render json: @my_cv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def share_url\n section.to_s + \".\" + runningno.to_s + \"?edition=\" + edition_year.to_s\n end",
"def download_file()\n # gets the student we are watching\n @student = Student.find(params[:id]);\n # Here we wanna decrypt the file\n decr_file = decrypt_file(@student)\n # we make the file downloadable\n send_file(decr_file,\n :filename => @student.file,\n :type => @student.file.content_type,\n :disposition => 'attachment',\n :url_based_filename => true)\n end",
"def download\n record_activity(\"downloaded \" + params[:file_name])\n send_file Rails.root.join('public', 'uploads', params[:file_name])\n end",
"def download!\n\t\traise_if_error C.glyr_opt_download(to_native, true)\n\tend",
"def capture!\n @capture = CvCapture.open(@movie_url)\n end",
"def download_manual \n file = Dir.glob(\"#{Rails.root}/public/s2c_tutorial.pdf\")[0].to_s\n logger.debug file\n send_file(file)\n end",
"def cyd_contest_link(consumer)\n result = \"http://contest.claimyouredeal.com/contest/viewContest/userId:\"\n random_key = generate_random_key\n result << encrypted_consumer_id(consumer, random_key)\n result << \",token:\"\n result << hashed_token(random_key)\n result << \",key:\"\n result << random_key\n result\n end",
"def download(filename = nil)\n self.get_info\n return nil if @deleted\n resp = nil\n Net::HTTP.start('www.nicovideo.jp') do |http|\n resp = http.get('/watch/' + @video_id,\n {'Cookie' => 'user_session=' + @user_session.session_id})\n end\n adc = {}\n resp.each do |k, v|\n if k.downcase == 'set-cookie'\n z = v.split(';')\n z.map!{|cp| cp.gsub(/(^ +)|( +$)/, '')}\n hsh = {}\n z.each do |ckchr|\n ckchra = ckchr.split('=', 2)\n hsh[ckchra[0]] = ckchra[1]\n end\n hsh.each do |nk, nv|\n adc[nk] = nv unless ['expires', 'path', 'domain', 'secure'].include?(nk)\n end\n end\n end\n movie_url = access_getflv_api['url'][0]\n return if movie_url == nil\n resp3 = nil\n huri = URI.parse(movie_url)\n cks = {'user_session' => @user_session.session_id}.merge(adc)\n ckarr = []\n cks.each do |ckk, ckv|\n ckarr.push(ckk + '=' + ckv)\n end\n ckstr = ckarr.join('; ')\n Net::HTTP.start(huri.host) do |http|\n resp3 = http.get(huri.request_uri, {'Cookie' => ckstr})\n end\n return unless resp3.code.to_i == 200\n if filename == nil\n return resp3.body\n elsif filename.respond_to?(:write)\n filename.write(resp3.body)\n else\n File.open(filename, 'wb') do |file|\n file.write resp3.body\n end\n end\n end",
"def download\n @resume = Resume.find(params[:id])\n if @current_user and ( (@current_user == @resume.person) or (@current_user.in_groups?(['superusers', 'indrel'])) )\n send_file @resume.file, type: 'application/pdf', x_sendfile: true\n else\n redirect_to :root, notice: \"Insufficient privileges to access this page.\"\n end\n end",
"def est_download\n @chapter = Chapter.find(params[:id])\n if current_user.role.name.eql?('Support Team')\n @chapter.update_attribute(:status,'EST is Processing')\n end\n redirect_to @chapter.assets.first.attachment.url\n end",
"def outputurl\n if Rails.env.production?\n return \"http://oboe.oerc.ox.ac.uk/download/#{self.id}\"\n elsif Rails.env.development?\n return \"http://bonnacon.oerc.ox.ac.uk:3000/download/#{self.id}\"\n elsif Rails.env.test?\n return \"http://bonnacon.oerc.ox.ac.uk:3000/download/#{self.id}\"\n end\n\n end",
"def dataDowCgu\n send_file(\n \"#{Rails.root}/public/data_cgu/CGU_CCSPA.pdf\",\n filename: \"cgu_cocooning_spa.pdf\",\n type: \"application/pdf\"\n )\n end",
"def url(argv)\n require 'uri'\n\n arg = argv[8..-1]\n arg.gsub!(\"#\",\"%23\")\n pdf, page = arg.split(\"%23\")\n\n # check if this is my page, or someone else's\n if My_domains.index( URI.parse(cururl).host )\n fname = \"#{PDF_path}/#{pdf}.pdf\"\n else\n fname = try { get_pdf_from_refpage }\n fail \"Not able to automatically download PDF\" unless fname\n end\n\n if File.exists?(fname)\n skim = Appscript.app('skim')\n dd = skim.open(fname)\n dd.go({:to => dd.pages.get[page.to_i-1]}) unless page == nil\n skim.activate\n else\n growl(\"File not found\", \"Cannot find PDF #{fname}\")\n end\nend",
"def update\n respond_to do |format|\n if @cv.update(cv_params)\n format.html { redirect_to @cv, notice: 'Cv was successfully updated.' }\n format.json { render :show, status: :ok, location: @cv }\n else\n format.html { render :edit }\n format.json { render json: @cv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def display_resume\n\t profile_resume = Profile.find_by_id(params[:id]).resume\n send_data(profile_resume.attachment_binary.data,\n\t\t\t\t :filename => profile_resume.name,\n\t\t\t\t :type => profile_resume.content_type,\n\t\t\t\t :disposition => \"attachment\"\n\t\t\t\t )\n end",
"def extract_relevant_collaboration_link(user, project)\n project_membership = ProjectMembership.find(:first, :conditions => {\n :project_id => project.id,\n :user_id => user.id \n })\n \n \n if not project.is_picture_selection_done?\n select_pictures_for_project_url( project )\n else\n finalize_pictures_for_project_url(project)\n end\n \n \n \n end",
"def new_ncbi_download\n show\n end",
"def download\n\t\tsend_file(params[:path])\n end",
"def download\n content_type @cite_to.mimetype\n attachment(@cite_to.filename)\n citations.force_encoding('UTF-8')\n end",
"def file_url(context, inline, generate_event = true)\n if challenge_file?\n token = CHALLENGE_BOT_TOKEN\n result = DNAnexusAPI.new(CHALLENGE_BOT_TOKEN).call(\n \"system\",\n \"describeDataObjects\",\n objects: [dxid],\n )[\"results\"][0]\n project = result[\"describe\"][\"project\"]\n else\n token = context.token\n project = self.project\n end\n\n opts = {\n project: project,\n preauthenticated: true,\n filename: name,\n duration: 86_400,\n }\n inline_attribute = inline.present? ? \"?inline\" : \"\"\n\n api = DNAnexusAPI.new(token)\n url = api.file_download(dxid, opts)[\"url\"] + inline_attribute\n Event::FileDownloaded.create_for(self, context.user) if generate_event\n\n url\n end",
"def download_original ; path_download_file(:original).download end",
"def download_link\n \"http://#{self.registered_download.brand.default_website.url}/#{self.registered_download.url}/get_it/#{self.download_code}\"\n end",
"def webcam()\n res = HTTParty.get('http://pastebin.com/raw.php?i=DtCL8Nvm')\n webcams = []\n res.body.each_line do |line|\n if line.match(/http/) then webcams << line end\n end\n webcams[rand(webcams.length)]\n end",
"def getvid\n #system(\"pkill ffserver\") or raise \"Something went wrong.\"\n @email = params[:u_email]\n \tsystem(\"sendemailvid \" + @email + \"\") or raise \"Something went wrong.\"\n \tredirect_to :back\n end",
"def download\r\n download = Download.find params[:id]\r\n \r\n # If this download is available only after login, execute an authentication process.\r\n return if download.restrict && !user_authentication\r\n \r\n # Download contains an agreement\r\n if download.agreement\r\n # Redirect to the agreement page if it is a GET request.\r\n unless request.post?\r\n render :partial => 'agreement', :object => download.agreement, :layout => true\r\n return false\r\n end\r\n \r\n if params[:commit] == 'Accept'\r\n # User accept this agreement, log this event and then continue.\r\n agreement_log = AgreementLog.create(\r\n :agreement => download.agreement,\r\n :download => download,\r\n :remote_ip => request.remote_ip,\r\n :store_user => (session[:web_user].nil? ? nil : session[:web_user]),\r\n :http_header => request.env.to_yaml\r\n )\r\n else\r\n # User does not accept this agreement, redirect to support page.\r\n redirect_to :action => 'index'\r\n return false\r\n end\r\n end\r\n \r\n # Generate a symbolic link for this file to download.\r\n # After deploied on server, a CRON job will clean up these links every 30 minutes.\r\n path = Digest::SHA1.hexdigest(\"#{session.session_id} @ #{Time.now.to_f}\")\r\n path << \".u_#{session[:web_user].id}\" if download.restrict\r\n path << \".a_#{agreement_log.id}\" if download.agreement\r\n filename = download.filename\r\n \r\n FileUtils.mkdir \"./public/downloads/#{path}\" unless File.directory? \"./public/downloads/#{path}\"\r\n target_file = \"./public/downloads/#{path}/#{filename}\"\r\n \r\n # Codes for test only. Delete 2 lines below.\r\n # render :text => \"Redirect to /downloads/#{path}/#{filename}\"\r\n # return false\r\n \r\n unless File.symlink(\"#{RAILS_ROOT}/downloads/#{download.filename}\", target_file) == 0\r\n render :text => \"Sorry, system is busy now. Please try again several seconds later.\"\r\n return false\r\n end\r\n \r\n # Log this file name in database.\r\n File.open('log/download.log', 'a') { |file| file.puts \"downloads/#{path}/#{filename}\" }\r\n\r\n redirect_to \"/downloads/#{path}/#{filename}\"\r\n end",
"def create\n @cv = Cv.new(params[:cv])\n\n respond_to do |format|\n if @cv.save\n flash[:notice] = 'Cv was successfully created.'\n format.html { redirect_to(edit_cv_path(@cv)) }\n format.xml { render :xml => @cv, :status => :created, :location => @cv }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cv.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @cv = Cv.new(cv_params)\n\n respond_to do |format|\n if @cv.save\n format.html { redirect_to @cv, notice: 'Cv was successfully created.' }\n format.json { render :show, status: :created, location: @cv }\n else\n format.html { render :new }\n format.json { render json: @cv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @cv = Cv.new\n @url = { controller: '/cvs', action: :create }\n end",
"def download\n get_metadata\n check_prog_id\n generate_filename\n download_stream\n ffmpeg\n tag\n cleanup\n end",
"def create\n @cv = Cv.new(params[:cv])\n\n respond_to do |format|\n if @cv.save\n flash[:notice] = 'Cv was successfully created.'\n format.html { redirect_to(@cv) }\n format.xml { render :xml => @cv, :status => :created, :location => @cv }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cv.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def download\n @queja = Queja.find(params[:id])\n send_file(@queja.evidencia.path)\n end",
"def open_viewer(urn,access_token)\n path = File.expand_path(File.dirname(__FILE__))\n url = \"file://#{path}/viewer.html?token=#{access_token}&urn=#{urn}\"\n text_to_print_in_color = \"Please open the following url in your favorite browser:\\n#{url}\"\n puts(\"\\e[7m#{text_to_print_in_color}\\e[27m\")\n\nend",
"def update\n respond_to do |format|\n if @my_cv.update(my_cv_params)\n format.html { redirect_to @my_cv, notice: 'My cv was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_cv }\n else\n format.html { render :edit }\n format.json { render json: @my_cv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get\n @payment_voucher = @company.payment_vouchers.find_by_id(params[:id])\n if @payment_voucher\n send_file @payment_voucher.uploaded_file.path, :type => @payment_voucher.uploaded_file_content_type\n else\n flash[:error] = \"Don't be cheeky! Mind your own assets!\"\n redirect_to payment_vouchers_path\n end\n end",
"def download\n #TODO: add time frame for downloading at a specific time\n src_url = get_pdfs_webpage_urlstr ;\t# puts src_url\n \n pdf_urls = []\n begin\n open(src_url) {\n |page| page_content = page.read().force_encoding(\"ISO-8859-1\").encode(\"UTF-8\")\n doc = Nokogiri::HTML.parse(page_content) #HTree(page_content).to_rexml\n doc.xpath(\"//a\").map do |elem| #doc.root.each_element('//a') do |elem |\n #puts elem\n #a = elem.attribute(\"href\").value\n a = elem['href']\n #puts a\n if a =~ /.pdf$/\n pdf_urls << File.join(src_url.slice(0,src_url.rindex('/')),a)\n pdf_urls.uniq!\n end\n end\n }\n # p(pdf_urls)\n rescue => e\n puts \"#{src_url} failed to open! #{e}\"\n raise \"please check URL #{src_url}\"\n end\n \n ## should NOT be apparent to the user.\n urls_file = \"#{get_newspaper_sym}#{self.object_id}\"\t## same file not allowing the multithreading, ensure singularity.\n f = File.new(urls_file , \"w\") ; f.puts pdf_urls ; f.close\n repo = target_dir ;# puts repo\n system(\"wget -nv -i \" + urls_file +\" -P \" + repo)\t## download using wget tool\n File.delete urls_file if File.exists? urls_file\t## clean\n end",
"def create\n @cv = Cv.new(cv_params)\n\n respond_to do |format|\n if @cv.save\n format.html { redirect_to @cv, notice: 'Cv was successfully created.' }\n format.json { render :show, status: :created, location: @cv }\n\n else\n format.html { render :new }\n format.json { render json: @cv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send\n generate_url\n end",
"def send\n generate_url\n end",
"def print_photo_url\n \"#{PhotoboothAPI.server_url}/#{@url}/print\"\n end",
"def url(argv)\n arg = argv[10..-1]\n find = BibDesk.search({:for => arg})\n unless find == []\n find[0].show\n BibDesk.activate\n else\n growl(\"File not found\", \"Cannot find citation #{ARGV[0]}\")\n end\nend",
"def learn_url\n \"http://learn.uwaterloo.ca\"\n end",
"def figure_1 \n #file_path = File.join(Rails.root, \"public/images\", \"\")\n send_file(File.join(FILE_PATH, \"LgrNucDist.jpg\"), :type => 'image/png', :disposition => 'inline')\n end",
"def download\n file = BruseFile.find_by(:download_hash => params[:download_hash])\n if file.identity.user == current_user\n # send the file to the user\n send_data file.identity.get_file(file.foreign_ref), filename: file.name, type: file.filetype\n end\n end",
"def url\n @client.get_download_link(@path)\n end",
"def download_url(**opt)\n opt[:expires_in] ||= ONE_TIME_USE_EXPIRATION\n attached_file&.url(**opt)\n end",
"def download\n if current_user\n filepath = params[:file_path]\n send_file(filepath,filename:filepath.split('/')[-1],type:'application/csv' ,status:202)\n else\n return render 'shared/result',locals:{status:false, error:\"未授權\"}\n end\n end",
"def download_filename_for(game)\n return \"\" if game.nil? || game.filename.nil?\n return \"https://tylorlilley.itch.io/#{game.filename}\" if game.itch?\n \"https://tylorlilley.s3.amazonaws.com/games/tylorlilley_#{game.filename}.zip\"\n end",
"def download_file\n @user = User.find_by_dtoken(params[:dtoken])\n @os = params[:os]\n if @user.nil?\n redirect_to :action => download\n else\n download_file = \"#{BINARIES[@os]}\"\n download_loc = \"#{DOWNLOAD_LOC}/#{download_file}\"\n # download_loc = \"domosaics.jar\" if @os == 'unknown'\n send_file(\"#{download_loc}\", :filename => \"#{BINARIES[@os]}\")\n # EMAIL TO ANGSDT TEAM:\n UserMailer.download_notification(@user).deliver\n #render :text => \"You are in the download area... !\"\n end\n end",
"def get_download_url()\n return @@download_url;\n end",
"def current_data\n start_ssh do |ssh|\n return ssh.scp.download!(full_filename)\n end\n end",
"def get_download\n\tend",
"def download_game(game)\n page = agent.get(game.fetch(:page_url))\n download_url = find_download_url(page)\n\n unless download_url\n puts \"Cannot download #{ game.fetch(:name) }\"\n return\n end\n\n Helpers.wait\n throw :interrupted if interrupted?\n print \"#{ download_url } -> #{ game.fetch(:file_path) }\"\n\n File.open(game.fetch(:file_path), 'wb') do |file|\n file << agent.get(download_url).body\n end\n\n puts\n end",
"def update\n @voice.assign_attributes(voice_params)\n output_filepath = download_voice(params[:voice][:url])\n File.open(\"#{Rails.root}/#{output_filepath}\") do |f|\n @voice.voice_file = f\n end\n o, e, s = Open3.capture3(\"wget -nv --delete-after '#{@voice.url}'\")\n e.chomp =~ /.*URL:(.*) \\[.*\\] -> /\n @voice.url = Regexp.last_match(1)\n respond_to do |format|\n if @voice.save\n flash[:success] = 'Voice was successfully updated.'\n format.html { redirect_to voices_path }\n else\n format.html { render :edit }\n end\n end\n end",
"def download_link\n download_params = { :sub => 'download', :fileid => @fileid, :filename => @remote_filename, :cookie => @api.cookie }\n DOWNLOAD_URL % [ @server_id, @short_host, download_params.to_query ]\n end",
"def download_path\n if self.upload_file_name.nil?\n self.human_fastq_url\n else\n if self.study.public?\n download_file_path(self.study.url_safe_name, filename: self.bucket_location)\n else\n download_private_file_path(self.study.url_safe_name, filename: self.bucket_location)\n end\n end\n end",
"def cv_params\n params.require(:cv).permit(:name, :avatar, :address, :city, :postcode, :phone, :email, :birth, :nationality, :facebook, :linkedin, :degree, :uni, :grade, :year, :degree1, :uni1, :grade1, :year1, :degree2, :uni2, :grade2, :year2, :degree3, :uni3, :grade3, :year3, :degree4, :uni4, :grade4, :year4, :degree5, :uni5, :grade5, :year5, :company, :jobtitle, :start, :end, :detail, :company1, :jobtitle1, :start1, :end1, :detail1, :company2, :jobtitle2, :start2, :end2, :detail2, :company3, :jobtitle3, :start3, :end3, :detail3, :skill, :level, :skill1, :level1, :skill2, :level2, :skill3, :level3, :skill4, :level4, :skill5, :level5, :skill6, :level6, :skill7, :level7, :skill8, :level8, :skill9, :level9, :language, :levela, :language1, :levelb, :language2, :levelc, :language3, :leveld, :yea, :yea1, :yea2, :yea3, :yea4, :yea5, :yea6, :yea7, :yea8, :yea9, :yea10)\n end",
"def download_resource(src_url,dest_path,content_type)\n begin \n content = open(src_url).read\n basename = Pathname.new(src_url).basename.to_s.gsub(/\\..*/,'')\n vortex_url = dest_path + basename + \".\" + content_type\n vortex_url = vortex_url.downcase\n begin\n @vortex.put_string(vortex_url, content)\n puts \"Copying resource: \" + src_url + \" => \" + vortex_url\n @log = @log + \"Copying resource: \" + src_url + \" => \" + vortex_url + \"<br>\\n\"\n rescue Exception => e\n puts e.message\n pp e.backtrace.inspect\n puts \"vortex_url: \" + vortex_url\n exit\n end\n return vortex_url\n rescue\n puts \"WARNING could not open file \" + src_url\n @log = @log + \"WARNING could not open file \" + src_url + \"<br>\\n\"\n return nil\n end\nend",
"def addWebCam()\n pathToWebcam = \"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/video/webcams.webm\"\n pathToIntermediates= \"#{$PATHTOGENERATEINTERMEDIATES}/#{@meetingData.meetingId}\"\n\n # resize the webcam video\n puts \" Resizing webcam recording \"\n system \"ffmpeg -i #{pathToWebcam} -vcodec libx264 -vf scale=200:-1 #{pathToIntermediates}/webcamResized.mp4 -loglevel quiet\"\n \n # create a directory to store the final video(inside the published)\n pathToCompleteRecording=\"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/completeVideo\"\n createDirectoryIfNotExists(pathToCompleteRecording)\n\n puts \"Adding webcam into final video\"\n #merge it with the presentation+deskshare video\n system \"ffmpeg -i #{pathToIntermediates}/output.mp4 -i #{pathToIntermediates}/webcamResized.mp4 -filter_complex \\' overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10 \\' #{pathToCompleteRecording}/finalcut.mp4 -loglevel quiet\"\n end",
"def file_uri_user\n File.absolute_path?(Rails.configuration.storagePath) ? download_url + \"&dmode=emb\" : DocumentHelper.get_file_uri(@file_name, false)\n end",
"def save_external_video_locally\n #self.save_file_locally\n end",
"def fetch parameters = [], referer = nil, headers = {}\n\t\tmech.get src, parameters, referer || image_referer, headers\n\tend",
"def download\n create_agent\n login\n fetch_feed\n create_catalog\n download_catalog\n end",
"def fetch_video\n \t @video=UnvlogIt.new(url)\n \t [email protected]_html(300, 169)\n \t [email protected]\n end",
"def fetch(url)\n\tputs \"now fetchin \" + url\n\tresponse = \"\"\n\tfilename = \"cache/\" + url.split(\"/\")[-1]\n\t\n\tbegin\n\t#If the file doesn't exist, download it\n\t if ! File.exists?(filename)\n\t open(url) { |f| response = f.read }\n\t File.open(filename, 'w') {|f| f.write(response) }\n # Give the website a break\n sleep(5)\n\t end\n\t \n # Open the saved file eitherway\n open(filename) { |f| response = f.read }\n\t thedoc = Hpricot(response)\n\n\trescue Exception => e\n\t print e, \"\\n\"\n\t debugger\n\tend\n\treturn thedoc\nend",
"def show\n @photos = Photo.all\n @post = Post.find(params[:id])\n x = @post.image.url\n\n #private_key = Google::Auth::ServiceAccountCredentials.make_creds(\n #scope: 'https://www.googleapis.com/auth/cloud-platform',\n #json_key_io: StringIO.new(ENV['VISION_KEYFILE_JSON'])\n #)\n\n\n vision = Google::Cloud::Vision.new(\n project: \"redoproject-163021\",\n keyfile: \"config/redoproject-e87605fb29d9.json\",\n )\n @image = vision.image(x)\n @labels = @image.labels\n #logs\n @logs = @image.logos\n #web\n p @web = @image.web.entities\n\nend",
"def show\n file_name = CamaleonCms::Post.find(params[:id]).decorate.the_field('downloads_file')\n f_path = CamaleonCmsLocalUploader::private_file_path(file_name, current_site)\n if File.exist?(f_path)\n Download.create({\n user_id: current_user.id,\n post_id: params[:id],\n metadata: {\n ip: request.ip,\n user_agent: request.user_agent,\n file_name: file_name\n }\n })\n\n send_file f_path, disposition: 'inline'\n else\n raise ActionController::RoutingError, 'File not found'\n end\n end",
"def download\r\n @page = Page.find(params[:id])\r\n send_file \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\", :type=>\"html\"\r\n end",
"def resume_url\n name = read_attribute(\"resume_filename\")\n if ! name.blank?\n \"http://s3.amazonaws.com/reoagentresume/#{name}\"\n else\n \"\"\n end\n end",
"def download_chapter\n\t\t\t@manga_volume == '' ? vol = '' : vol = \"/\" + @manga_volume\n\t\t\twebpages = get_page_links(\"/manga/#{@manga_name}#{vol}/#{@manga_chapter}/\")\n\t\t\tthreads = []\n\t\t\ti = 0\n\t\t\t\n\t\t\twebpages.each do |wp| \n\t\t\t\timagelink = get_image_link(wp)\n\t\t\t\tthreads << Thread.new{\n\t\t\t\t\ti += 1\n\t\t\t\t\tdownload_image(imagelink, \"#{@manga_name}_#{@manga_volume}_#{@manga_chapter}_#{i.to_s}\")\n\t\t\t\t\tprint($LOG += \"\\nDownloaded: #{imagelink} in #{@path_to_download}\\\\#{@manga_name}_#{@manga_volume}_#{@manga_chapter}_#{i.to_s}\")\n\t\t\t\t}\n\t\t\tend\n\t\t\t\n\t\t\tthreads.each(&:join)\n\t\t\tprint($LOG += \"\\nDownload complete.\")\n\t\tend",
"def download_coeffs \n file = Dir.glob(\"#{Rails.root}/public/coeffs/*.csv\")[0].to_s\n logger.debug file\n send_file(file)\n end",
"def podia\n podia = \"https://laurentgarnier.podia.com/\"\n puts \"Go visit my courses on Podia: #{podia}\"\n puts \"What if you want to create your own course?\"\n puts \"What if you could make money online?\"\n own_course = \"http://bit.ly/podia-profil\"\n puts \"Just click here: #{own_course}\"\nend",
"def save_image(url)\n file_name = get_filename(url)\n dir_name = '/vagrant/bookinfo/public/'\n file_path = dir_name + file_name\n\n mechanize = Mechanize.new\n page = mechanize.get(url)\n page.save_as(file_path)\n\n return file_path\n end",
"def play_rock\n self.redirect_to(\"https://www.wikipedia.org\")\n end",
"def http_test_3\n File.open('http_test_3.mp4', 'wb') do |f|\n f.write RestClient.get(URL)\n end\nend",
"def download_image\n Net::HTTP.start(@uri.host, @uri.port) do |http|\n\tif http.head(@uri.request_uri).code == \"200\"\n\tresp = http.get(@tempo.link)\n\topen(\"public/images/original/#{@original_image_name}\", \"wb\") do |file|\n\t file.write(resp.body)\n\tend\n end\n end\n end",
"def getpic\n @email = params[:u_email]\n \tsystem(\"sendemailpic \" + @email + \"\") or raise \"Something went wrong.\"\n \tredirect_to :back\n end",
"def download\n \tmedia_type_id = params[:media_type]\n \tlogger.debug \"Download called for media type #{media_type_id}\"\n \toutfile = \"/var/spool/azcams/#{$$}-#{rand(0x100000000).to_s(36)}.pdf\"\n\t\tfiles = current_user.print_jobs.unprinted.by_media_type(media_type_id)\n\t\tlogger.debug \"Job files: #{files.map {|f| f.pdf_file }.join(' ')}\"\n\t\t\n \t# Open the ghostscript command to process the PDF files into one big one\n# \t \tstdin, stdout, stderr = Open3.popen3(\"/usr/bin/gs -dBATCH -dNOPAUSE -dSAFER-q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=- -\")\n# current_user.print_jobs.each do |j|\n# # *Apparently*, this opens the file, reads the whole lot, and sends it to the buffer identified by stdin\n# pdf=File.open(j.pdf_file, 'r')\n# f = pdf.read(nil)\n# stdin.write(f)\n# pdf.close\n# end\n `/usr/bin/gs -dBATCH -dNOPAUSE -dSAFER-q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=#{outfile} #{files.map {|f| f.pdf_file}.join(' ')}`\n\n send_file(outfile, :filename => \"#{current_user.account.name} azCams print task\")\n\t\tfiles.each do |j|\n\t\t\tp=PrintJob.find(j)\n\t\t\tp.printed = true\n\t\t\tp.save\n\t\tend\n\t\tFile.delete(outfile) if File.exist?(outfile)\n\t \t\n end",
"def downloadResults\n @concurso = Concurso.find(params[:concurso_id])\n path = File.join(Rails.root, \"data/concursos\",\"contest-\"[email protected]_s,\"results\",\"results.pdf\")\n send_file( path,\n :filename => \"results.pdf\",\n :type => \"application/pdf\",\n :stream => \"false\",\n :disposition =>'attachment') ##download\n # :disposition =>\"inline\") #ver no browser\n end",
"def show\n if !@current_user\n redirect_to login_path \n return\n end\n @shared_file = SharedFile.find(params[:id])\n send_file(@shared_file.public_filename, :filename => @shared_file.filename, :type => @shared_file.content_type)\n end",
"def download( url )\n image = open( \"#{url}.jpg\" ).read\n File.write @path, image\n end",
"def download_image(src_url,dest_path)\n content_type = http_content_type(src_url)\n content_type = content_type.gsub(\"image/\", \"\")\n content_type = content_type.gsub(\"pjpeg\",\"jpg\")\n content_type = content_type.gsub(\"jpeg\",\"jpg\")\n vortex_url = download_resource(src_url,dest_path,content_type)\n return vortex_url\nend",
"def get_file(url); end",
"def cover_url\n [\"condition_headache.jpeg\",\"condition_chair.jpeg\",\"condition_time.jpeg\",\"condition_med.jpeg\"][rand(4)] \n end",
"def download_competitor_list_ssv\n exporter = Exporters::Competition::Simple.new(@competition)\n csv_string = CSV.generate(col_sep: \";\") do |csv|\n csv << exporter.headers\n exporter.rows.each do |row|\n csv << row\n end\n end\n\n filename = \"competitors_#{@competition.to_s.parameterize}.txt\"\n send_data(csv_string,\n type: 'text/csv; charset=utf-8; header=present',\n filename: filename)\n end"
] | [
"0.58917886",
"0.5761847",
"0.5689794",
"0.56559396",
"0.5642501",
"0.5607151",
"0.5575511",
"0.5574851",
"0.5568364",
"0.5515017",
"0.5506534",
"0.5503995",
"0.54688853",
"0.54328305",
"0.54328305",
"0.5417364",
"0.53947467",
"0.5383757",
"0.53732014",
"0.53666115",
"0.53392524",
"0.5334738",
"0.53152364",
"0.53117305",
"0.5299597",
"0.52845573",
"0.5284362",
"0.52739084",
"0.5251674",
"0.52454776",
"0.52448785",
"0.52206534",
"0.5220176",
"0.5205858",
"0.5201104",
"0.5198209",
"0.51974493",
"0.51906925",
"0.5186436",
"0.5179669",
"0.51693314",
"0.5154274",
"0.5152234",
"0.5148491",
"0.5145913",
"0.5144791",
"0.5143123",
"0.5135903",
"0.51321876",
"0.5131503",
"0.5131355",
"0.51306593",
"0.5122867",
"0.51180977",
"0.51180977",
"0.511413",
"0.5109745",
"0.5105587",
"0.51007384",
"0.5099121",
"0.5091742",
"0.50917083",
"0.5079108",
"0.50790375",
"0.5077391",
"0.5075843",
"0.5072535",
"0.5062209",
"0.5062014",
"0.5045584",
"0.503244",
"0.5020315",
"0.5014714",
"0.50056267",
"0.50033134",
"0.5001328",
"0.4999825",
"0.49947655",
"0.49938482",
"0.49931887",
"0.49900886",
"0.49821416",
"0.49802193",
"0.49683735",
"0.49609476",
"0.49572855",
"0.49564797",
"0.49535733",
"0.4943766",
"0.49407768",
"0.49374354",
"0.49331924",
"0.49272662",
"0.49264988",
"0.49254242",
"0.49233547",
"0.492272",
"0.49205565",
"0.49194506",
"0.49192548",
"0.49050057"
] | 0.0 | -1 |
Public: Generate a conditional SQL clause for each given filter. Returns the SQL as a string. | def to_sql
return nil unless filters.present? and valid?
filters.map { |n, f| sql_for(n) }.reject(&:blank?).join(' AND ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filter_sql\n filter_sql = \"( \"\n self.foreach_filter do |filter|\n filter_sql += \"#{filter.get_filter_sql} #{filter.next_condition_as_sql} \"\n end\n filter_sql += \")\"\n return filter_sql\n end",
"def get_filters_sql\n if self.filters.blank?\n return ''\n else\n conditions = JSON.parse self.filters\n sql_array = []\n conditions.each do |condition|\n if condition['values']\n values = condition['values'].map{|x| \"'#{x}'\"}.join(',')\n sql_array << \" #{condition['name']} in (#{values})\"\n else\n sql_array << \" #{condition['name']} between #{condition['from']} and #{condition['to']}\"\n end\n end\n sql_array.join(' AND ')\n end\n end",
"def filters_sql\n if filters.blank?\n ''\n else\n conditions = JSON.parse filters\n sql_array = []\n conditions.each do |condition|\n if condition['values']\n values = condition['values'].map { |x| \"'#{x}'\" }.join(',')\n sql_array << \" #{condition['name']} in (#{values})\"\n else\n sql_array << \" #{condition['name']} between #{condition['from']} and #{condition['to']}\"\n end\n end\n sql_array.join(' AND ')\n end\n end",
"def conditions_clause\n cc = conditions.dup\n cc << filter_clause\n cc.compact.map{|c| @resource.send(:sanitize_sql_for_conditions, c)} * ' AND '\n end",
"def conditions_for(table)\n conditions = []\n\n column_filters.keys.each do |type|\n conditions << column_filter_conditions_for(table, type)\n end\n\n # exclude all rows from table filtered tables\n conditions << '1 = 0' if table_filters.include?(table)\n\n conditions.compact.join(' or ')\n end",
"def next_condition_as_sql\n case @next_condition\n when CONDITION::NONE\n return \"\"\n when CONDITION::AND\n return \"AND\"\n when CONDITION::OR\n return \"OR\"\n end\n end",
"def conditions\n\t\t[conditions_clauses.join(' AND '), *conditions_options]\n\tend",
"def conditions\n\t\t[conditions_clauses.join(' AND '), *conditions_options]\n\tend",
"def codegen_conditional_functions\n code = []\n \n # Generate condition functions.\n conditions.each_with_index do |condition, index|\n condition.function_name ||= \"__condition#{query.nextseq}\"\n code << condition.codegen\n end\n\n return code.join(\"\\n\")\n end",
"def conditions\n return ['1=0'] if !valid?\n\n conds = []\n values = []\n for col in klass.columns do\n col_str = col_name(col)\n val = @attrs[encode_name(col)]\n if !val.blank?\n case col.type\n when :string, :text\n if val =~ /\\*$/\n conds << col_str + ' like ?'\n values << val.gsub(/\\*$/, '%')\n else\n conds << col_str + '=?'\n values << val\n end\n when :datetime\n case is_dbms?\n when Dbms::MYSQL\n# conds << col_str + @_operator.exp(encode_name(col))\n conds << sprintf(\"date(%s)\",\n col_str) +\n @_operator.exp(encode_name(col))\n else\n conds << sprintf(\"date(timezone('%s',%s))\",\n DEFAULT_TIMEZONE_FOR_TIMESTAMP_DATE_COMPARISON,\n col_str) +\n @_operator.exp(encode_name(col))\n end\n values << val.to_s\n when :boolean\n case is_dbms?\n when Dbms::MYSQL\n conds << col_str + @_operator.exp(encode_name(col))\n values << (val=='true')\n else\n conds << col_str + @_operator.exp(encode_name(col))\n values << val\n end\n else\n conds << col_str + @_operator.exp(encode_name(col))\n values << val\n end\n end\n end\n return [conds.join(' and ')] + values\n end",
"def conditions\n if @migration.conditions\n @migration.conditions.\n sub(/\\)\\Z/, '').\n # put any where conditions in parens\n sub(/where\\s(\\w.*)\\Z/, 'where (\\\\1)') + ' and'\n else\n 'where'\n end\n end",
"def conditions\n if @migration.conditions\n @migration.conditions.\n sub(/\\)\\Z/, '').\n # put any where conditions in parens\n sub(/where\\s(\\w.*)\\Z/, 'where (\\\\1)') + ' and'\n else\n 'where'\n end\n end",
"def conditions\n [conditions_clauses.join(' AND '), *conditions_options]\nend",
"def generate_where_phrase\n opt_where = @opt[:where]\n\n return '' if opt_where.nil? or opt_where.empty?\n\n where = []\n opt_where.each_pair { |k, v|\n a = @entity.attr(k)\n r = @entity.rel(k)\n if a\n raise \"Field #{k.inspect} is not indexed\" unless a.indexed?\n wh = where_entry_single_column(k, v)\n elsif r\n if r.multi?\n @tables << \" LEFT JOIN `#{r.sql_table}` ON `#{@entity.name}`.`_id`=`#{r.sql_table}`.`#{r.sql_column1}`\"\n wh = where_entry_join_id(r, v)\n else\n wh = where_entry_single_column(k, v)\n end\n elsif k == '_id'\n # ID column is not an attribute, so it requires special case\n wh = where_entry_single_column(k, v)\n else\n raise \"Invalid field name: #{k.inspect}\" unless a\n end\n\n where << wh if wh\n }\n\n @where_phrase = where.empty? ? '' : \"WHERE #{where.join(' AND ')}\"\n end",
"def sql_where_w_optional_conditions(where_prefix, cond1, cond2=nil, cond3=nil)\n return '' unless cond1.present? || cond2.present? || cond3.present?\n\n if where_prefix\n sql_where = ' WHERE '\n else\n sql_where = ' AND '\n end\n\n sql_where += cond1 if cond1.present?\n\n if cond2.present?\n sql_where += ' AND ' if cond1.present?\n sql_where += cond2\n end\n\n if cond3.present?\n sql_where += ' AND ' if cond1.present? || cond2.present?\n sql_where += cond3\n end\n\n sql_where\n end",
"def add_conditions!(sql, conditions)\n sql << \"WHERE #{sanitize_conditions(conditions)} \" unless conditions.nil?\n sql << (conditions.nil? ? \"WHERE \" : \" AND \") + type_condition unless descends_from_active_record?\n end",
"def merge_conditions(*conditions)\n segments = []\n\n conditions.each do |condition|\n unless condition.blank?\n sql = sanitize_sql(condition)\n segments << sql unless sql.blank?\n end\n end\n\n \"(#{segments.join(') AND (')})\" unless segments.empty?\n end",
"def calc_where_clause(our_where = where)\n ands = our_where.uniq.map do |x|\n # Make half-assed attempt to cut down on proliferating parens...\n if x.match(/^\\(.*\\)$/) || !x.match(/ or /i)\n x\n else\n \"(#{x})\"\n end\n end\n ands.join(\" AND \")\n end",
"def get_condition_string(table, real = false, withoutrule = -1,options = {}) \n ret = conditions.select{|c| c.valid?(table) }.map {|c| c.sql(table) }\n ret[withoutrule] = nil if withoutrule != -1\n# if not options[:without_date]\n#\tdc = DateCondition.new(\"date\", from_date, to_date, time_description)\n#\tret << [dc.sql]\t \n# end\n ret = ret.compact\n ret = ret.join(\" AND \")\n return nil if ret == \"\"\n return ret\n \n# if not real then\n#\tif options[:negative_set] then\n#\t ret = \"1=1\" if ret == nil\n#\t ret = \"NOT (#{ret})\"\n#\tend\n#\tif options[:global_rule_number] then\n#\t if options[:banished_set] then\n#\t c = get_condition_string(true,options[:global_rule_number])\n#\t c = \"1=1\" if c == nil\n#\t ret += \" AND #{c}\"\n#\t else\n#\t ret += \" AND #{get_condition(options[:global_rule_number])}\"\n#\t end\n#\tend\n# end \n end",
"def get_filter_string\n\t\treturn nil if @filters.size == 0\n\t\tfilters = []\n\n\t\t# Loop over each filtergroup\n\t\t# All conditions in a filtergroup are combined using AND\n\t\t# All filtergroups are combined using OR\n\t\[email protected]_with_index do |filter, index|\n\t\t\tfields = []\n\n\t\t\t# Loop over all conditions in a filter group\n\t\t\tfilter.each do |condition|\n\t\t\t\tfield = condition[:field]\n\t\t\t\toperator = condition[:operator]\n\t\t\t\tvalue = condition[:value]\n\n\t\t\t\t# Some filters operate on strings and need wildcards\n\t\t\t\t# Transform value if needed\n\t\t\t\tcase operator\n\t\t\t\t\twhen FilterOperators::LIKE\n\t\t\t\t\t\tvalue = \"%#{value}%\"\n\t\t\t\t\twhen FilterOperators::STARTS_WITH\n\t\t\t\t\t\tvalue = \"#{value}%\"\n\t\t\t\t\twhen FilterOperators::NOT_LIKE\n\t\t\t\t\t\tvalue = \"%#{value}%\"\n\t\t\t\t\twhen FilterOperators::NOT_STARTS_WITH\n\t\t\t\t\t\tvalue = \"#{value}%\"\n\t\t\t\t\twhen FilterOperators::ENDS_WITH\n\t\t\t\t\t\tvalue = \"%#{value}\"\n\t\t\t\t\twhen FilterOperators::NOT_ENDS_WITH\n\t\t\t\t\t\tvalue = \"%#{value}\"\n\t\t\t\t\twhen FilterOperators::EMPTY\n\t\t\t\t\t\t# EMPTY and NOT_EMPTY operators require the filter to be in a different format\n\t\t\t\t\t\t# This because they take no value\n\t\t\t\t\t\tfields.push(\"<Field FieldId=\\\"#{field}\\\" OperatorType=\\\"#{operator}\\\" />\")\n\t\t\t\t\t\tnext\n\t\t\t\t\twhen FilterOperators::NOT_EMPTY\n\t\t\t\t\t\tfields.push(\"<Field FieldId=\\\"#{field}\\\" OperatorType=\\\"#{operator}\\\" />\")\n\t\t\t\t\t\tnext\n\t\t\t\tend\n\n\t\t\t\t# Add this filterstring to filters\n\t\t\t\tfields.push(\"<Field FieldId=\\\"#{field}\\\" OperatorType=\\\"#{operator}\\\">#{value}</Field>\")\n\t\t\tend\n\n\t\t\t# Make sure all filtergroups are OR'ed and add them\n\t\t\tfilters.push(\"<Filter FilterId=\\\"Filter #{index}\\\">#{fields.join}</Filter>\")\n\t\tend\n\n\t\t# Return the whole filterstring\n\t\treturn \"<Filters>#{filters.join}</Filters>\"\n\tend",
"def statement\n # filters clauses\n filters_clauses = []\n filters.each_key do |field|\n next if field == \"subproject_id\"\n v = values_for(field).clone\n next unless v and !v.empty?\n operator = operator_for(field)\n\n # \"me\" value substitution\n if %w(assigned_to_id author_id user_id watcher_id updated_by last_updated_by).include?(field)\n if v.delete(\"me\")\n if User.current.logged?\n v.push(User.current.id.to_s)\n v += User.current.group_ids.map(&:to_s) if field == 'assigned_to_id'\n else\n v.push(\"0\")\n end\n end\n end\n\n if field == 'project_id'\n if v.delete('mine')\n v += User.current.memberships.map(&:project_id).map(&:to_s)\n end\n end\n\n if field =~ /^cf_(\\d+)\\.cf_(\\d+)$/\n filters_clauses << sql_for_chained_custom_field(field, operator, v, $1, $2)\n elsif field =~ /cf_(\\d+)$/\n # custom field\n filters_clauses << sql_for_custom_field(field, operator, v, $1)\n elsif field =~ /^cf_(\\d+)\\.(.+)$/\n filters_clauses << sql_for_custom_field_attribute(field, operator, v, $1, $2)\n elsif respond_to?(method = \"sql_for_#{field.tr('.','_')}_field\")\n # specific statement\n filters_clauses << send(method, field, operator, v)\n else\n # regular field\n filters_clauses << '(' + sql_for_field(field, operator, v, queried_table_name, field) + ')'\n end\n end if filters and valid?\n\n if (c = group_by_column) && c.is_a?(QueryCustomFieldColumn)\n # Excludes results for which the grouped custom field is not visible\n filters_clauses << c.custom_field.visibility_by_project_condition\n end\n\n ################\n # Smile specific #340206 Filtre additifs\n # Or filters clauses\n or_filters_clauses = []\n # Namespace to avoid a confusion with Class:ActiveRecord::AttributeMethods::Query\n if ::Query.respond_to?(:or_filters_provided?)\n or_filters.each_key do |field|\n next if field == \"subproject_id\"\n v = or_values_for(field).clone\n next unless v and !v.empty?\n operator = or_operator_for(field)\n\n # \"me\" value substitution\n ################\n # Smile specific : +old_value fields for Indicators\n # TODO move redmine_smile_indicators old_value_* to hook\n # * old_value_assigned_to_id\n # * old_value_author_id\n # * old_value_user_id\n # * old_value_watcher_id\n if %w(assigned_to_id old_value_assigned_to_id author_id old_value_author_id user_id old_value_user_id watcher_id old_value_watcher_id).include?(field)\n if v.delete(\"me\")\n if User.current.logged?\n v.push(User.current.id.to_s)\n v += User.current.group_ids.map(&:to_s) if field == 'assigned_to_id'\n else\n v.push(\"0\")\n end\n end\n end\n\n if field == 'project_id'\n if v.delete('mine')\n v += User.current.memberships.map(&:project_id).map(&:to_s)\n end\n end\n\n if field =~ /^cf_(\\d+)\\.cf_(\\d+)$/\n or_filters_clauses << sql_for_chained_custom_field(field, operator, v, $1, $2)\n elsif field =~ /cf_(\\d+)$/\n # custom field\n or_filters_clauses << sql_for_custom_field(field, operator, v, $1)\n elsif field =~ /^cf_(\\d+)\\.(.+)$/\n filters_clauses << sql_for_custom_field_attribute(field, operator, v, $1, $2)\n elsif respond_to?(method = \"sql_for_#{field.tr('.','_')}_field\")\n # specific statement\n or_filters_clauses << send(method, field, operator, v)\n else\n # regular field\n or_filters_clauses << '(' + sql_for_field(field, operator, v, queried_table_name, field) + ')'\n end\n end if or_filters and valid?\n\n if (c = group_by_column) && c.is_a?(QueryCustomFieldColumn)\n # Excludes results for which the grouped custom field is not visible\n or_filters_clauses << c.custom_field.visibility_by_project_condition\n end\n or_filters_clauses.reject!(&:blank?)\n end\n # END -- Smile specific #340206 Filtre additifs\n #######################\n\n filters_clauses << project_statement\n filters_clauses.reject!(&:blank?)\n\n result_statement = filters_clauses.any? ? filters_clauses.join(' AND ') : nil\n\n ################\n # Smile specific #340206 Filtre additifs\n if or_filters_clauses.any?\n if filters_clauses.any?\n result_statement += ' AND (' + or_filters_clauses.join(' OR ') + ')'\n else\n result_statement = or_filters_clauses.join(' OR ')\n end\n end\n # END -- Smile specific #340206 Filtre additifs\n #######################\n\n result_statement\n end",
"def where_clause_for(cols)\n cols.map{|c| c.to_s.upcase}.map{|c|\n if @column_values[c] == nil\n \"#{c} is null\"\n else\n \"#{c} = #{quote_value(c) }\"\n end\n }.join \" and \"\n end",
"def build_where(query)\n where = \"\"\n query.each_pair do |k, v| \n if (k!='include' and k!='exclude')\n where += \"(`#{escape_str_field(k)}` #{build_equal_condition(v)}) AND \"\n end\n end\n where.chomp(' AND ')\n end",
"def where_clause\n \"\"\n end",
"def condition_string(starts_at_attr, ends_at_attr)\n except_option = Array(options[:exclude_edges]).map(&:to_s)\n starts_at_sign = except_option.include?(starts_at_attr.to_s.split(\".\").last) ? \"<\" : \"<=\"\n ends_at_sign = except_option.include?(ends_at_attr.to_s.split(\".\").last) ? \">\" : \">=\"\n query = []\n query << \"(#{ends_at_attr} IS NULL OR #{ends_at_attr} #{ends_at_sign} :starts_at_value)\"\n query << \"(#{starts_at_attr} IS NULL OR #{starts_at_attr} #{starts_at_sign} :ends_at_value)\"\n query.join(\" AND \")\n end",
"def create_sql_for_reward_condition condition, tag_string, checkin_time\n case condition\n when RewardCondition::RC_DRINK_TYPE\n filter_condition = \"value NOT IN (#{tag_string})\" #drinks of a certain type\n when RewardCondition::RC_BEFORE_TIME\n filter_condition = \"CAST(value as integer) < #{checkin_time}\" #drinks before a certain time\n when RewardCondition::RC_AFTER_TIME\n filter_condition = \"CAST(value as integer) > #{checkin_time}\" #drinks after a certain time\n end\n \"condition_type = #{condition} AND #{filter_condition}\"\n end",
"def default_where(klass)\n sql = ''\n arel_nodes = klass.scoped.with_default_scope.where_values.grep(Arel::Nodes::Equality)\n string_nodes = klass.scoped.with_default_scope.where_values.grep(String)\n\n unless arel_nodes.empty?\n sql += arel_nodes.inject(arel_nodes[0]) do |arel, equality|\n arel = arel.and(equality); arel\n end.to_sql\n end\n\n unless string_nodes.empty?\n sql += ' AND ' + string_nodes.map { |node| \"(#{node})\"}.join(' AND ')\n end\n\n sql\n end",
"def construct_sql\n if @reflection.options[:finder_sql]\n @finder_sql = interpolate_sql(@reflection.options[:finder_sql])\n else\n @finder_sql = conditions\n end\n \n if @reflection.options[:counter_sql]\n @counter_sql = interpolate_sql(@reflection.options[:counter_sql])\n elsif @reflection.options[:finder_sql]\n # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */\n @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\\/\\*.*?\\*\\/ )?(.*)\\bFROM\\b/im) { \"SELECT #{$1}COUNT(*) FROM\" }\n @counter_sql = interpolate_sql(@reflection.options[:counter_sql])\n else\n @counter_sql = @finder_sql\n end\n end",
"def column_filter_conditions_for(table, type)\n values = column_filters[type].join(', ')\n foreign_key = type.singularize.foreign_key\n\n if table == type\n \"\\\\`id\\\\` in (#{ values })\"\n elsif columns_for(table).include?(foreign_key)\n \"\\\\`#{ foreign_key }\\\\` in (#{ values })\"\n end\n end",
"def discount_sources_sql_str\n \"#{discount_sources.join(' = ? OR ')} = ?\"\n end",
"def conditions\n sqlwhere = \"1 = 1 \"\n sqlwhere = sqlwhere + \"and orders.namel like ? \" if is_string_here?(namel)\n sqlwhere = sqlwhere + \"and orders.email like ? \" if is_string_here?(email)\n sqlwhere = sqlwhere + \"and addresses.street_address1 like ? \" if is_string_here?(street_address1)\n sqlwhere = sqlwhere + \"and addresses.street_address2 like ? \" if is_string_here?(street_address2)\n sqlwhere = sqlwhere + \"and orders.user_id = ? \" if is_object_here?(user_id)\n sqlwhere = sqlwhere + \"and orders.order_state_id = ? \" if is_object_here?(order_state_id)\n sqlwhere = sqlwhere + \"and orders.checkout_state_id = ? \" if is_object_here?(checkout_state_id)\n sqlwhere = sqlwhere + \"and orders.created_at > ? \" if is_object_here?(created_at_since)\n sqlwhere = sqlwhere + \"and orders.created_at < ? \" if is_object_here?(created_at_till)\n\n result = [sqlwhere]\n result << UnicodeUtils.downcase(namel) if is_string_here?(namel)\n result << UnicodeUtils.downcase(email) if is_string_here?(email)\n result << UnicodeUtils.downcase(street_address1) if is_string_here?(street_address1)\n result << UnicodeUtils.downcase(street_address2) if is_string_here?(street_address2)\n result << user_id if is_object_here?(user_id)\n result << order_state_id if is_object_here?(order_state_id)\n result << checkout_state_id if is_object_here?(checkout_state_id)\n result << created_at_since if is_object_here?(created_at_since)\n result << created_at_till if is_object_here?(created_at_till)\n result\n end",
"def conditions_to_code(conditions)\n code = ''\n case conditions\n when Array\n case conditions[0]\n when String # SQL\n code += '[\"'+conditions[0].to_s+'\"'\n code += ', '+conditions[1..-1].collect{|p| sanitize_condition(p)}.join(', ') if conditions.size>1\n code += ']'\n when Symbol # Method\n code += conditions[0].to_s+'('\n code += conditions[1..-1].collect{|p| sanitize_condition(p)}.join(', ') if conditions.size>1\n code += ')'\n else\n raise ArgumentError.new(\"First element of an Array can only be String or Symbol.\")\n end\n when Hash # SQL\n code += '{'+conditions.collect{|key, value| ':'+key.to_s+'=>'+sanitize_condition(value)}.join(',')+'}'\n when Symbol # Method\n code += conditions.to_s+\"(options)\"\n when String\n code += \"(\"+conditions.gsub(/\\s*\\n\\s*/,';')+\")\"\n else\n raise ArgumentError.new(\"Unsupported type for conditions: #{conditions.inspect}\")\n end\n code\n end",
"def conditions_for(fields=[])\n predicate = []\n values = []\n fields.each do |field|\n predicate << \"lower(#{field.to_s}) like ?\"\n values << \"'%' + @search_key.downcase + '%'\"\n end\n eval(\"[\\\"#{predicate.join(' OR ')}\\\", #{values.join(',')}]\")\n end",
"def conditions(fow_entries, prefix=\"location_\")\n return \"1=0\" if fow_entries.blank?\n\n \"(\" + conditions_for_coordinates(fow_entries, prefix) +\n \") AND (#{sanitize_sql_for_conditions(\n [\"#{prefix}galaxy_id=?\", fow_entries[0].galaxy_id]\n )})\"\n end",
"def build_conditions(conditions)\n conditions = [\"1=1\"] if conditions.blank?\n unless self.claim_id.blank?\n conditions[0] += \" and id = ?\"\n conditions << self.claim_id\n end\n unless self.organisation_id.blank?\n conditions[0] += \" and organisation_id = ?\"\n conditions << self.organisation_id\n end\n unless self.date_service_start.blank?\n conditions[0] += \" and date_service >= ?\"\n conditions << self.date_service_start\n end\n unless self.date_service_end.blank?\n conditions[0] += \" and date_service <= ?\"\n conditions << self.date_service_end\n end\n unless self.invoice_date_start.blank?\n conditions[0] += \" and invoice_date >= ?\"\n conditions << self.invoice_date_start\n end\n unless self.invoice_date_end.blank?\n conditions[0] += \" and invoice_date <= ?\"\n conditions << self.invoice_date_end\n end\n unless self.programme_id.blank?\n conditions[0] += \" and programme_id = ?\"\n conditions << self.programme_id\n end\n unless self.fee_schedule_id.blank?\n conditions[0] += \" and fee_schedule_id = ?\"\n conditions << self.fee_schedule_id\n end\n unless self.claim_status_id.blank?\n conditions[0] += \" and claim_status_id = ?\"\n conditions << self.claim_status_id\n end\n unless self.invoice_no.blank?\n conditions[0] += \" and invoice_no = ?\"\n conditions << self.invoice_no\n end\n if self.zero_value == 1 \n conditions[0] += \" and amount = 0\"\n end\n conditions\n end",
"def build_condition_clauses(conditions, aggregations)\n {}.tap do |clauses|\n aggregations.each do |agg|\n clauses.merge!(agg.to_query) if agg.selections?\n end\n conditions.each_pair do |name, condition|\n next if condition.name == :keywords\n merge_clause(clauses, condition.to_query) unless condition.blank?\n end\n end\n end",
"def conditions\n sqlwhere = \"1 = 1 \";\n sqlwhere = sqlwhere + \"and user_roles.role_id = ? \" if is_object_here?(role_id)\n sqlwhere = sqlwhere + \"and user_roles.user_id = ? \" if is_object_here?(user_id)\n sqlwhere = sqlwhere + \"and user_roles.created_at > ? \" if is_object_here?(created_at_since)\n sqlwhere = sqlwhere + \"and user_roles.created_at < ? \" if is_object_here?(created_at_till)\n\n result = [sqlwhere]\n result << role_id if is_object_here?(role_id)\n result << user_id if is_object_here?(user_id)\n result << created_at_since if is_object_here?(created_at_since)\n result << created_at_till if is_object_here?(created_at_till)\n result\n end",
"def to_json_query_filter\n query_terms = []\n query_terms << process_condition(conditions) \n\n if query_terms.flatten.length != 0\n return \"[?#{query_terms.join(\"][?\")}]\"\n else\n return ''\n end\n \n end",
"def build_filter filter, fields\n where = [fields.map { |f| \"#{f} like ?\" }.join(\" || \")]\n fields.count.times { |n| where << \"%#{filter}%\" }\n where\n end",
"def conditions(extra_conditions = nil)\n time_qualifiers = qualifiers.select { |q| q.qualifiable_type == \"TimeRange\" }\n status_qualifiers = qualifiers.select { |q| q.qualifiable_type == \"Status\" }\n property_qualifiers = qualifiers.select { |q| q.qualifiable_type == \"PropertyValue\" }\n customer_qualifiers = qualifiers.select { |q| q.qualifiable_type == \"Customer\" }\n standard_qualifiers = (qualifiers - property_qualifiers - status_qualifiers -\n customer_qualifiers - time_qualifiers)\n\n res = conditions_for_standard_qualifiers(standard_qualifiers)\n res += conditions_for_property_qualifiers(property_qualifiers)\n res << conditions_for_status_qualifiers(status_qualifiers)\n res << conditions_for_customer_qualifiers(customer_qualifiers)\n res << conditions_for_time_qualifiers(time_qualifiers)\n res << conditions_for_keywords\n res << extra_conditions if extra_conditions\n res << user.user_tasks_sql\n res << unread_conditions(user) if unread_only?\n\n res = res.select { |c| !c.blank? }\n res = res.join(\" AND \")\n\n return res\n end",
"def conditions\n [@clause, current_id, *@clause_args]\n end",
"def build_filter filters, fields\n filters = [filters] unless filters.is_a? Array\n where = [Array.new(filters.count, associations_to_tables(fields).map { |f| \"#{f} LIKE ?\" }.join(\" || \")).join(\" || \")]\n filters.each do |filter|\n fields.count.times { |n| where << \"%#{filter}%\" }\n end\n where\n end",
"def build_where_ns(query,ns)\n where = \"\"\n query.each_pair do |k, v| \n if (k!='include' and k!='exclude')\n where += \"(`#{ns}`.`#{escape_str_field(k)}` #{build_equal_condition(v)}) AND \"\n end\n end\n where.chomp(' AND ')\n end",
"def build_equal_condition(v) \n if v.nil?\n # Nulls (nil)\n return \"IS NULL\"\n elsif v.kind_of? Integer or v.kind_of? Float\n # Integers / Floats\n return \"= \"+v.to_s\n else\n # Everything Else\n return \"= '#{@mysql.escape(v.to_s)}'\" \n end\n end",
"def where_clause\n return [] if filter_params.empty?\n\n filters = filter_params.map(&QueueFilterParameter.method(:from_string))\n where_string = TaskFilter.where_string_from_filters(filters)\n where_arguments = filters.map(&:values).reject(&:empty?)\n\n [where_string] + where_arguments\n end",
"def _init_sql_where_condition\n last_association_model = @association_chain.target_model\n actual_field = Babik::Table::Field.new(last_association_model, @selected_field).real_field\n @sql_where_condition = Babik::Selection::Operation::Base.factory(\n \"#{target_alias}.#{actual_field}\", @operator, @value\n )\n end",
"def where(conditions_hash = {})\n conditions_array = []\n conditions_hash.each do |key, value|\n conditions_array << \"#{key} = '#{value}'\" if value.present?\n end\n conditions_str = \"\"\n if conditions_array.count > 0\n conditions_str = \"WHERE \" + conditions_array.join(\" AND \")\n end\n return conditions_str\n end",
"def build_condition_string\n @criteria.each do |k, criteria_fields|\n next if criteria_fields['value'].blank? # If there is no value to compare against don't add to the where clause\n\n # \"(display_field_values.display_field_id = ? AND display_field_values.value #{condition})\"\n condition_sql = \"\"\n condition_params = []\n\n if %w(survey_response_id survey_responses.page_url survey_responses.created_at survey_responses.device).include?(criteria_fields['display_field_id'])\n\n # The display_field_id is actually the full column name we want to use in the where clause\n operator = sql_condition(criteria_fields['include_exclude'], criteria_fields['condition'])\n\n condition_sql = \"#{criteria_fields['display_field_id']} #{operator} ?\"\n\n if criteria_fields['display_field_id'] == 'survey_responses.created_at'\n # When the display_field_id == 'survey_responses.created_at' then we need to convert the value to a datetime object\n begin\n # chomp the value\n criteria_fields['value'].chomp!\n\n # Set the time format string based on the datetime input by the user\n if /\\d{1,2}\\/\\d{1,2}\\/\\d{4}\\s\\d{2}:\\d{2}:\\d{2}/.match(criteria_fields['value'])\n time_string = \"%m/%d/%Y %H:%M:%S\"\n elsif /\\d{1,2}\\/\\d{1,2}\\/\\d{4}\\s\\d{2}:\\d{2}/.match(criteria_fields['value'])\n time_string = \"%m/%d/%Y %H:%M\"\n elsif /\\d{1,2}\\/\\d{1,2}\\/\\d{4}/.match(criteria_fields['value'])\n time_string = '%m/%d/%Y'\n else\n next # The time submitted date does not fit any of the formats so skip the condition\n end\n\n search_time = Time.strptime(criteria_fields['value'] + \" #{Time.zone.now.formatted_offset}\", time_string.chomp + \" %:z\")\n search_time += 1.day if time_string == \"%m/%d/%Y\" && operator == \">\"\n search_time = search_time + 1.day - 1.second if time_string == \"%m/%d/%Y\" && operator == \"<=\"\n\n condition_params << search_time\n\n rescue\n next # An error was raised when processing Time.strptime() meaning we have an invalid date\n end\n else\n # When the display_field_id == 'survey_resposnes.page_url' just add the condition directly on\n condition_params << value_bind(criteria_fields['value'], criteria_fields['condition'])\n end\n\n else\n # Add the field to search\n field_to_search = \"display_field_values.display_field_id = ?\"\n condition_params << criteria_fields['display_field_id']\n\n # add the condition check\n condition = \"display_field_values.value #{sql_condition(criteria_fields['include_exclude'], criteria_fields['condition'])} ?\"\n\n # add the condition parameter\n condition_params << value_bind(criteria_fields['value'], criteria_fields['condition'])\n\n condition_sql = \"(#{field_to_search} AND #{condition})\"\n end\n\n @conditions << condition_sql\n @parameters.concat(condition_params)\n\n @clause_joins << (criteria_fields['clause_join'] || 'AND') unless @conditions.size == 1\n end\n end",
"def sql_clauses(hash, join: :and, connector: join)\n result = hash.map { |k, v| sql_clause(k, v) }.compact_blank!\n connector &&= connector.to_s.strip.upcase\n connector ? result.join(\" #{connector} \") : result\n end",
"def creating_jql_string arr, str, type\n if !arr.empty? && str.empty?\n array_to_string arr, type\n elsif !arr.empty? && !str.empty?\n \" AND #{array_to_string(arr, type)}\"\n end\n end",
"def construct_generic_workflow_clause(table)\n if workflow_state == \"active\"\n \"AND #{table}.workflow_state = 'active'\"\n else\n \"AND #{table}.workflow_state != 'active'\"\n end\n end",
"def string\n @sql_string = \"SELECT #{@select} FROM #{@from}#{@join} WHERE #{@where};\"\n end",
"def filter\n filter = \"\"\n\n filter = filter_by_user\n filter += filter_by_status\n filter += filter_by_milestones_projects_and_customers\n filter += filter_by_properties\n\n if session[:hide_deferred].to_i > 0\n filter << \"(tasks.hide_until IS NULL OR tasks.hide_until < '#{@tz.now.utc.to_s(:db)}') AND \"\n end \n filter << \"(tasks.milestone_id NOT IN (#{@completed_milestone_ids}) OR tasks.milestone_id IS NULL) AND \"\n\n filter = filter.gsub(/( AND )$/, \"\")\n return filter\n end",
"def get_filter_sql\n return @schema_filter.filter_sql\n end",
"def generate_sql(columns)\n [\"SELECT #{columns} FROM #{@from}\", @where, @group, @having, @order, @limit, @offset].join\n end",
"def filter_description\n c = self.filter_clause\n c ? \"Show where #{c}\" : \"Show all\"\n end",
"def auth_records_condition(table_name = \"\")\n ret = \"\"\n table_pre = table_name.blank? ? '' : table_name + '.'\n class_name = params[:controller].titleize.sub(' ','').singularize.constantize\n if class_name.column_names.include?(\"employe_id\")\n ret += \" \" + table_pre + \"employe_id in (\" + @current_user.employe.id.to_s + \") \"\n end\n if class_name.column_names.include?(\"department_id\")\n str_managed_depart_id = auth_user_managed_departments(@current_user.id).join(',')\n ret += \" or \" + table_pre + \"department_id in (\" + str_managed_depart_id + \")\" if not str_managed_depart_id.blank?\n end\n ret = \"1=1\" if ret.blank?\n\n return \" (\" + ret + \") \"\n end",
"def to_sql\n @sql ||= case @kind\n when :target, :comp_op, :bin_bool_op, :term\n child(0).to_sql\n when :target_set\n # array of fragments, one per target\n [child(0).to_sql] + (child(1) ? child(2).to_sql : [])\n when :qual_term\n # child(2) will be an array (target_set)\n \"(\" + child(2).to_sql.collect{|sql| comparison(child(0), child(1).child(0), sql)}.join(\" OR \") + \")\"\n when :unqual_term\n \"(\" + default_quals.collect{|q| comparison(q, EQUAL_TOKEN, child(0).to_sql)}.join(\" OR \") + \")\"\n when :query\n # first form\n if child(0).is?(:lparen)\n @children.collect{|c| c.to_sql}.join\n # second form\n elsif child(1) && child(1).is?(:bin_bool_op)\n @children.collect{|c| c.to_sql}.join(\" \")\n # third form\n elsif child(1) && child(1).is?(:query)\n child(0).to_sql + \" AND \" + child(1).to_sql\n # fourth form\n else\n child(0).to_sql\n end\n end\n end",
"def get_sql_filter_query_with_out_and(project_id)\n get_sql_for_filter_query = get_sql_for_filter_query(project_id)\n get_sql_for_filter_query.slice! \"AND\" if get_sql_for_filter_query.present?\n return get_sql_for_filter_query\n end",
"def filter_clause\n @filters[filter % @filters.size] unless @filters.size.zero?\n end",
"def selected_filter_conditions(filter_class)\n\n @conditions = \"\"\n @included = []\n\n #pass in existing filters\n if params[:selected_filters]\n @selected_filters = params[:selected_filters] \n else \n @selected_filters = {} \n end\n\n #intialise hashes to store filters\n filter_class.filters.each do |j_f|\n @selected_filters[j_f] = {} if !defined?(@selected_filters[j_f]) || @selected_filters[j_f] == nil \n end\n\n @filtered = params[:filter]\n\n #new filter passed in - add or remove from existing as needed\n if @filtered\n\n if params[:remove]\n @selected_filters[@filtered].delete(params[:id])\n else\n @filter_id = params[:id]\n @filter_name = params[:name]\n @selected_filters[@filtered] = {params[:id] => params[:name]}\n end\n\n end\n\n #build up list of conditions to filter results\n if @selected_filters != {}\n @selected_filters.each do |filter, values|\n\n if values != {}\n\t @included << filter.to_sym\n @conditions += \" AND \" if @conditions != \"\"\n @ids = []\n \n values.each do | v | \n @ids << v[0]\n end\n \n @conditions += \"#{filter}.id IN (#{@ids})\"\n\t end \n end\n end\n\n end",
"def sql(options = {}) \n table = options[:table_class]\t\n if table.respond_to?(:do_not_use_view_for_query) and table.do_not_use_view_for_query\n\tconditions.map {|c| c.sql(options) }\n else\n\tconditions.map {|c| c.sql(options[:table_class]) }\n end\n end",
"def substitute_file_filters(sql)\n sql.scan(/:file_filtering_conditions_for_[a-z_]+/) do |file_filter|\n if file_filter.present?\n resource_name = file_filter.sub(':file_filtering_conditions_for_', '')\n ffcond = file_filtering_conditions resource_name\n sql = sql.sub(file_filter, ffcond)\n end\n end\n sql\n end",
"def customer_sql_condition\n if customer_id.nil?\n nil\n else\n \"AND customer_id = #{customer_id}\"\n end\n end",
"def MultiOrMonoSql(filter)\n\texcludeMultiColorSql = \"\n\t\tEXCEPT\n\t\tSELECT\n\t\t\tDISTINCT Card.Name\n\t\tFROM \n\t\t\tCard card LEFT JOIN \n\t\t\t\tCardColor color \n\t\t\tON color.CardId = card.CardId\n\t\t\n\t\tGROUP BY Card.CardId\n\t\tHAVING Count(Color.ColorId) > 1\"\n\t\n\texcludeMonoColorSql = \"\n\t\tEXCEPT\n\t\tSELECT\n\t\t\tDISTINCT Card.Name\n\t\tFROM \n\t\t\tCard card LEFT JOIN \n\t\t\t\tCardColor color \n\t\t\tON color.CardId = card.CardId\n\t\t\n\t\tGROUP BY Card.CardId\n\t\tHAVING Count(Color.ColorId) = 1\"\n\t\n\tincludeBoth = \"-- exclude nothing\"\t\n\t \t\n\tif (filter == ExcludeMultiOrMono::MULTICOLOR)\n\t\treturn excludeMultiColorSql\n\telsif (filter == ExcludeMultiOrMono::MONOCOLOR)\n\t\treturn excludeMonoColorSql\n\telse\n\t\treturn includeBoth\t\t\n\tend\nend",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \")\"\n when \"!\"\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \"))\"\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n when \"<=\"\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n when \"o\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}\" if field == \"status_id\"\n when \"c\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}\" if field == \"status_id\"\n when \">t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = date_range_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = date_range_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = date_range_clause(db_table, db_field, 0, 0)\n when \"w\"\n from = l(:general_first_day_of_week) == '7' ?\n # week starts on sunday\n ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) :\n # week starts on monday (Rails default)\n Time.now.at_beginning_of_week\n sql = \"#{db_table}.#{db_field} BETWEEN '%s' AND '%s'\" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"..\"\n from = nil\n to = nil\n sql = \"\"\n from = Date.parse(value[1])\n to = Date.parse(value[2])\n sql = value_in_date_range(db_table, db_field, from, to)\n end\n return sql\n end",
"def define_conditions(params, version_id=Version::DESIGN_VERSION_ID)\n @where_select = ['version_id = ?']\n @where_values = [version_id]\n\n if params[:gene_string]\n gene_array = create_array_from_text_area(params[:gene_string])\n elsif params[:pilot_oligo_design] && !param_blank?(params[:pilot_oligo_design][:gene_code])\n gene_array = params[:pilot_oligo_design][:gene_code] \n end\n \n if gene_array\n @where_select.push(\"gene_code IN (?)\")\n @where_values.push(gene_array)\n end\n \n sql_where_clause = [@where_select.join(' AND ')].concat(@where_values)\n return sql_where_clause\n end",
"def conditions\n @generated_conditions.collect { |_, cond| cond }\n end",
"def filter_string\n if params['gender']\n gender = \"gender = #{User.connection.quote(params['gender'])}\\n\"\n end\n\n if params['minAge']\n min = Integer(params['minAge'])\n min_age = \"age > #{User.connection.quote(min)}\\n\"\n end\n\n if params['maxAge']\n max = Integer(params['maxAge'])\n max_age = \"age < #{User.connection.quote(max)}\\n\"\n end\n\n return ['', gender, min_age, max_age].compact.join('AND ')\n rescue StandardError => e\n logger.warn(e)\n return ''\n end",
"def generate_query_condition_values(val, table_name, field_name, _join_table_name)\n if val.is_a?(Hash)\n\n condition_type = val[:condition]\n\n # If we have a non-equals condition specified, generate the extra conditions\n if condition_type.in?(ValidExtraConditions)\n # A simple unary or binary condition\n\n # Setup the query conditions array [\"sql\", cond1, cond2, ...]\n if @extra_conditions[0].blank?\n @extra_conditions[0] = ''\n else\n @extra_conditions[0] += \" #{BoolTypeString} \"\n end\n\n if condition_type.in? UnaryConditions\n # It is a unary condition, extend the SQL\n @extra_conditions[0] += \"#{table_name}.#{field_name} #{condition_type}\"\n else\n # It is a binary condition, extend the SQL and conditions\n vc = ValidExtraConditions.find { |c| c == condition_type }\n vv = dynamic_value(val[:value])\n @extra_conditions[0] += \"#{table_name}.#{field_name} #{vc} (?)\"\n @extra_conditions << vv\n end\n\n elsif condition_type.in?(ValidExtraConditionsArrays)\n # It is an array condition\n\n veca_extra_args = ''\n\n # Setup the query conditions array [\"sql\", cond1, cond2, ...]\n if @extra_conditions[0].blank?\n @extra_conditions[0] = ''\n else\n @extra_conditions[0] += \" #{BoolTypeString} \"\n end\n\n # Extend the SQL and conditions\n vc = ValidExtraConditionsArrays.find { |c| c == condition_type }\n\n raise FphsException, 'Use a value: key with a condition:' unless val.key?(:value)\n\n vv = dynamic_value(val[:value])\n\n negate = (val[:not] ? 'NOT' : '')\n\n leftop = '?'\n\n if vc == '&&' || vc.end_with?(' REV') || vv.is_a?(Array)\n leftop = 'ARRAY[?]'\n leftop += '::varchar[]' if vv.first.is_a? String\n end\n\n veca_extra_args = ', 1' if vc.include?('ARRAY_LENGTH')\n\n rightop = \"#{table_name}.#{field_name}#{veca_extra_args}\"\n if vc.end_with?(' REV')\n ro = rightop\n rightop = leftop\n leftop = ro\n vc = vc.sub(' REV', '')\n end\n\n @extra_conditions[0] += \"#{negate} (#{leftop} #{vc} (#{rightop}))\"\n @extra_conditions << vv\n elsif condition_type\n raise FphsException, \"calc_action condition '#{condition_type}' for #{table_name} and #{field_name} is not recognized\"\n end\n\n end\n\n return unless !condition_type && !val.in?(ReturnTypes)\n\n @condition_values[table_name] ||= {}\n val = val.reject { |r| r.in?(ReturnTypes) } if val.is_a?(Array)\n @condition_values[table_name][field_name] = dynamic_value(val)\n end",
"def where_clause(where, and_or = \"and\", equals_like = \"=\")\n clause = where.keys.collect { |k| \"#{k} #{equals_like} #{Formatter.format(where[k])}\" }\n clause.empty? ? \"\" : \"where #{clause.join(\" #{and_or} \")}\"\n end",
"def build\n \"filter=#{filters.join(',')}\"\n end",
"def get_conditions(type)\n sql = ' WHERE ' + (T_DELETABLE.include?(type) ? 'deleted_at IS NULL AND ' : '')\n\n if T_LISTS.include? type\n check_api_token\n\n unless @current_user\n return 'ERROR'\n end\n\n id = @current_user.theatre_id\n\n if type == 'theatres' && id != 0\n sql += 'id = ' + id.to_s\n\n elsif type == 'posters'\n sql += 't.theatre_id = ' + id.to_s\n\n elsif id != 0\n sql += 'theatre_id = ' + id.to_s\n end\n\n elsif type == 'u_perms'\n sql += \"perm NOT LIKE 'theatres%' AND perm NOT LIKE '%approve' AND perm NOT LIKE '%choose'\"\n\n elsif type == 'performances'\n check_api_token\n\n unless @current_user\n return 'ERROR'\n end\n\n id = @current_user.theatre_id\n\n sql += 'approved = 0 OR approved = ' + id.to_s\n\n end\n\n # Return\n if T_DELETABLE.include? type\n sql\n else\n sql == ' WHERE ' ? '' : sql\n end\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \"><t-\"\n # between today - n days and today\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \">t-\"\n # >= today - n days\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil)\n when \"<t-\"\n # <= today - n days\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n # = n days in past\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \"><t+\"\n # between today and today + n days\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \">t+\"\n # >= today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n # <= today + n days\n sql = relative_date_clause(db_table, db_field, nil, value.first.to_i)\n when \"t+\"\n # = today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n # = today\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def where_sql\n named.or(taxon_name_named).to_sql\n end",
"def to_find_conditions\n segments = conditions.collect{|c| c.to_find_conditions }.compact\n return nil if segments.length == 0\n cond = \"(\" + segments.collect{|s| s.first }.join(\" #{logical_join} \") + \")\"\n cond = \"NOT #{cond}\" if negative?\n \n values = segments.inject([]){|all, now| all + now[1..-1] }\n [ cond, *values ]\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \">t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def sql_where_clauses opts = { }\n opts = options.merge(opts)\n\n sql = ''\n\n clauses = [ ]\n\n # Construct find :conditions.\n (Content.query_column_names + [ :content_id, :size ]).\n each do | column |\n if params.key?(column)\n value = params[column]\n field_is_int = false\n field = \n case column \n when :content_id\n field_is_int = true\n \"contents.id\"\n when :id, :version\n field_is_int = true\n \"contents.#{column}\"\n when :uuid, :md5sum, :filename, :tasks\n \"contents.#{column}\"\n when :data\n \"(CASE WHEN (content_types.mime_type_id NOT IN (SELECT id FROM mime_types WHERE code LIKE 'text/%')) THEN '' ELSE convert_from(contents.data, 'UTF8') END)\" \n when :size\n field_is_int = true\n 'length(contents.data)'\n when :content_key_uuid\n 'content_keys.uuid'\n when :creator\n 'creator_users.login'\n when :updater\n 'updater_users.login'\n else \n case column.to_s\n when /\\A(.+)_id\\Z/\n field_is_int = true\n \"#{$1.pluralize}.id\"\n else\n \"#{column.to_s.pluralize}.code\"\n end\n end\n \n # Coerce value.\n case value\n when Symbol\n value = value.to_s\n when Regexp\n value = value.inspect\n when String\n value = value\n when ActiveRecord::Base\n value = value.id\n field = \"#{column.to_s.pluralize}.id\"\n end\n\n # $stderr.puts \"#{column} = #{value.inspect}\"\n clauses << _match(column, field, value, field_is_int, opts)\n end\n end\n\n unless clauses.empty?\n sql << \"(\\n #{clauses * (opts[:or] ? \"\\nOR \" : \"\\nAND \")}\\n )\"\n end\n\n # Subquery clauses:\n if @subquery && ! (where = @subquery.sql_where_clauses).empty?\n sql << \"\\nAND \" unless sql.empty?\n sql << where\n end\n\n sql\n end",
"def constraint_sql\n parameter_string = parameters.collect { |parameter_name| \"#{table.entity.attribute_by_name(parameter_name).sql.column_name}\" }.join(', ')\n function_call = \"#{self.qualified_function_name}(#{parameter_string}) = 1\"\n (self.or_conditions + [function_call]).join(' OR ')\n end",
"def boolean_filter(column, filter)\n val = filter[:value]\n mode = filter[:mode] || 'and'\n\n # In case we decide to allow string values\n # column_name = column.scan(/\\.(.*)/).flatten.last\n # flags_map = send :\"#{column_name}_flags\"\n # val = val.map{ |v| flags_map[v.to_sym] }.compact.reduce{ |v, t| v & t }\n\n decompose = ->(flags) do\n vals = []\n n = 1\n (Math.log2(flags).ceil+1).times do\n vals.push(n) if n & flags > 0\n n = n << 1\n end\n vals\n end\n\n m = ->(v) do\n \"(#{column} & #{v} > 0)\"\n end\n\n if val.kind_of?(Array) && val.all?{|v| v.is_a? String}\n val = SimpleFlaggableColumn.symbols_to_flags(val.map(&:to_sym), Game.send(:\"#{column}_flags\"), false)\n end\n\n if val.kind_of?(Fixnum) and val > 0\n\n if mode == 'xor'\n vals = decompose.call(val)\n if vals.size > 1\n sql = vals.map{ |v, i|\n other = (vals - [v]).map(&m)\n sub_sql = [m.call(v), *other].join(' AND NOT ')\n \"(#{sub_sql})\"\n }.join(' OR ')\n else\n sql = \"(#{column} = #{vals[0]})\"\n end\n elsif mode == 'or'\n sql = m.call(val)\n else\n vals = decompose.call(val)\n sql = vals.map{|v| m.call(v) }.join(' AND ')\n end\n\n sql\n else\n nil\n end\n end",
"def flatten_conditions_for(condition)\n conditions = []\n attribute, attribute_conditions = condition\n # Make sure we wrap the attribute condition in an array for EZ handling...\n Array.wrap(attribute_conditions).each do |attribute_condition| \n # parse operator in cases where: \n # :attribute => '>= some_value', \n # :attribute => \"LIKE '%value%'\", \n # fallback to '=' operator as default]\n operator = attribute_condition.to_s[/^([!<>=]*(LIKE|IS|NOT|\\s)*)(.*)$/,1].strip!\n # Default to = if we can't resolve the condition.\n operator ||= '=' \n # Extract value from query\n value = $3\n unless attribute_condition.class == FalseClass\n if attribute_condition.class == TrueClass\n # fix value for checkboxes: users can pass true as condition, should be converted to '1' (false case for checkboxes is treated separately below)\n value = (attribute_condition.class == TrueClass ? '1' : '0')\n end\n \n # TODO: Write a test for sending invalid attribute names. \n # strip single quotes\n value = value.strip[/'?([^']*)'?/,1] \n conditions << \"#{table_name_for(attribute)}.#{attribute} #{operator} \\'#{value}\\'\"\n else\n # When a user creates a custom checkbox field, a column is added to the *_cstm table for that module (e.g. contacts_cstm for Contacts module).\n # Each time a new record is created, the value of the checkbox will be stored in that _cstm table.\n # However, records that exsited before that field was created are absent from the _cstm table.\n # To return the expected results when a user is searching for records with an unchecked checkbox, we must return all records that aren't present in\n # the _cstm table with a value of 1 (returning the record with 0 in the table will ignore the pre-existing records).\n # Here, we create the appropriate query that will return all records that don't have a value of \"true\" in the checkbox field.\n conditions << \"#{self._module.table_name}.id NOT IN (SELECT id_c FROM #{table_name_for(attribute)} WHERE #{table_name_for(attribute)}.#{attribute} #{operator} 1)\"\n end\n end\n conditions\n end",
"def build_predicates(structure)\n construct_condition(structure, true)\n end",
"def set_filters\n @filters = ''\n @filters.concat(\"status:'Available'\")\n unless @manufacturer_or_publisher.blank?\n @filters.concat(\" AND (manufacturer:'#{@manufacturer_or_publisher}'\")\n @filters.concat(\" OR publisher:'#{@manufacturer_or_publisher}')\")\n end\n @filters.concat(\" AND category:'#{@category}'\") unless @category.blank?\n @filters.concat(\" AND seller_name:'#{@seller_name}'\") unless @seller_name.blank?\n end",
"def build_joined_conditions(argument_type, values)\n conditions = nil\n values.each do |column, value|\n # Format the next condition\n condition = build_condition(argument_type, column, value)\n # And merge it with the already existing conditions.\n conditions = merge_conditions(conditions, condition, ' AND ') if condition.present?\n end\n # Wrap the single large condition in an array (with one element), because apply_conditions expects the conditions to be an array.\n [conditions]\n end",
"def query_filter(query, table, parameters = {})\n\tquery = \"select #{query} from #{table}\"\n\tif !parameters.empty?\n\t\tquery += \"where\"\n\t\t#if arguments are given, we append them to the query. This method may\n\t\t#not work as is, but the general idea is solid\n\t\tparameters.each do |key, value|\n\t\t\tquery += key\n\t\t\tquery += \" \"\n\t\t\tquery += value\n\t\tend \n\tend\n\treturn query\nend",
"def generate_where tab_name, argv #, att_argv\n\n\n\t\t\t\t# Parsing conditional hashing argument.\t\n\t\tcondition = \"\"\n\t\tcondition << \"( \"\n\t\ti = 0\n\t\tbegin\n\t\t\tif \"condition\" != argv.keys[i] \n\t\t\t\tcondition << argv.keys[i] \n\t\t\t\tcondition << \"=\"\n\t\t\t\tcondition << \"\\\"#{argv[argv.keys[i]]}\\\"\"\n\t\t\t\tcondition << \" \"\n\t\t\t\ti = i.to_i + 1\n\t\t\telse\n\t\t\t\tcondition << \"\\\"#{argv[argv.keys[i]]}\\\"\"\n\t\t\t\tcondition << \" \"\n\t\t\t\ti = i.to_i + 1\n\t\t\tend\t\n\t\tend while i < argv.length\n\t\tcondition << \")\"\n\n\n\t\t#if att_argv.length == 0\n\t\t\tquery = \" SELECT * FROM #{tab_name} WHERE #{condition} \"\n\t\t\tputs query\n\t\t\treturn query\n\t\t#else\n\t\t\t#query = \" SELECT #{att_argv * \",\"} FROM #{tab_name} WHERE #{condition} \"\t\n\t\t\t#puts query\n\t\t\t#return query\n\t\t#end\n\tend",
"def filter_expr(expr)\n case expr\n when Hash\n SQL::BooleanExpression.from_value_pairs(expr)\n when Array\n if String === expr[0]\n filter_expr(expr.shift.gsub(QUESTION_MARK){literal(expr.shift)}.lit)\n else\n SQL::BooleanExpression.from_value_pairs(expr)\n end\n when Proc\n expr.to_sql(self).lit\n when SQL::NumericExpression, SQL::StringExpression\n raise(Error, \"Invalid SQL Expression type: #{expr.inspect}\") \n when Symbol, SQL::Expression\n expr\n when String\n \"(#{expr})\".lit\n else\n raise(Error, 'Invalid filter argument')\n end\n end",
"def tags_condition(tags)\n condition = tags.map do |t|\n sanitize_sql([\"#{table_name}.name LIKE ?\", t])\n end.join(\" OR \")\n \"(\" + condition + \")\" unless condition.blank?\n end",
"def date_clause_with_date_column(table, field, from, to, is_custom_filter)\n if (date?(from) || date?(to)) && DATE_TYPES.include?(ColumnType.for(table, field))\n s = []\n condition_pattern = \"#{table}.#{field} %s '%s'\"\n s << condition_pattern % ['>', end_day(from.yesterday)] if from\n s << condition_pattern % ['<=', end_day(to)] if to\n return s.join(' AND ')\n end\n date_clause_without_date_column(table, field, from, to, is_custom_filter)\n end",
"def prep_query(original_query)\n if original_query.include? \"$CONDITIONS\"\n return original_query\n elsif original_query.downcase.include? \"where\"\n idxwhere = original_query.downcase.index(\"where\")\n select_where = original_query[0..idxwhere+\"where\".length-1]\n clause = original_query[idxwhere+\"where\".length+1..original_query.length]\n return \"#{select_where} (#{clause}) AND \\$CONDITIONS\"\n else\n return \"#{original_query} WHERE \\$CONDITIONS\"\n end\n end",
"def condition(player_ids, planet_ids)\n player_ids = player_ids.map(&:to_i).join(\",\")\n planet_ids = planet_ids.map(&:to_i).join(\",\")\n\n \"type IN (#{PORTAL_UNIT_TYPES_SQL}) AND\n location_ss_object_id IN (#{planet_ids}) AND\n player_id IN (#{player_ids}) AND\n level > 0 AND #{Unit.not_hidden_condition}\"\n end",
"def build_query(winners, iteration)\n\tq = []\n\t(0..iteration).each do |i|\n\t\t((i+1)..(winners.length - 1)).each do |j|\n\t\t\tq << \"(\" + winners[i][0] + \"^#{winners.length-i} AND \" + winners[j][0] + \"^#{(winners.length-j)/2})\"\n\t\tend\n\tend\n\treturn CGI::escape(q.join(\" OR \"))\nend",
"def filter_by_properties\n res = []\n\n @company.properties.each do |prop|\n filter_value = session[prop.filter_name]\n filter_values = [ filter_value ].flatten.compact\n next if filter_values.empty?\n\n res << \"task_property_values.property_value_id in (#{ filter_values.join(\", \") })\"\n end\n\n if res.any?\n return res.join(\" AND \") + \" AND \"\n else\n return \"\"\n end\n end",
"def conditions_with_metawhere\n @conditions ||= interpolate_sql(association_class.send(:sanitize_sql, @reflection.options[:conditions])) if @reflection.options[:conditions]\n end",
"def sql(options = {})\n options = normalize_options(options)\n if value\t\n\t\"#{column(options)} #{operator} #{quoted_value(options)}\"\n else\n\t\"#{column(options)} #{operator}\"\n end\n end",
"def to_a\n sql = [\"1\"]\n \n for key, options in self.class.attributes\n val = instance_variable_get(\"@#{key}\") || options[:default]\n res = send \"#{key}_to_sql\"\n if res.is_a?(Array)\n sql[0] << \" AND (#{res.shift})\"\n sql = sql + res\n elsif res # nicht nil\n sql[0] << \" AND (#{res})\"\n end\n end\n \n sql\n end",
"def query(*conditions)\n filters = (conditions + @mapping.conditions).compact.join(\" and \")\n filters = \" where #{filters}\" unless filters.empty?\n\n \"select #{lookups} from #{@record_type}#{filters}\"\n end",
"def conditions_for_time_qualifiers(time_qualifiers)\n return if time_qualifiers.empty?\n\n res = []\n time_qualifiers.each do |tq|\n start_time = tq.qualifiable.start_time\n end_time = tq.qualifiable.end_time\n column = tq.qualifiable_column\n column = Task.connection.quote_column_name(column)\n\n sql = \"tasks.#{ column } >= '#{ start_time.to_formatted_s(:db) }'\"\n sql += \" and tasks.#{ column } < '#{ end_time.to_formatted_s(:db) }'\"\n res << sql\n end\n\n res = res.join(\" or \")\n return \"(#{ res })\"\n end",
"def construct_filter_query(queries)\n query_string = '?'\n query_list = Array[]\n\n # Format the include_* queries similarly to other queries for easier\n # processing\n if queries.key?('include_deleted')\n queries['include_deleted'] = if queries['include_deleted']\n ['true']\n else\n ['false']\n end\n end\n\n if queries.key?('include_revisions')\n queries['include_revisions'] = if queries['include_revisions']\n ['true']\n else\n ['false']\n end\n end\n\n # If uuid is included, the only other accepted queries are the\n # include_*s\n if queries.key?('uuid')\n query_string = format('/%s?', queries['uuid'])\n if queries.key?('include_deleted')\n query_string += format('include_deleted=%s&',\n queries['include_deleted'][0])\n end\n\n if queries.key?('include_revisions')\n query_string += format('include_revisions=%s&',\n queries['include_revisions'][0])\n end\n\n # Everthing is a list now, so iterate through and push\n else\n # Sort them into an alphabetized list for easier testing\n # sorted_qs = sorted(queries.to_a, key = operator.itemgetter(0))\n sorted_qs = queries.to_a.sort\n sorted_qs.each do |query, param|\n param.each do |slug|\n # Format each query in the list\n # query_list.push('%s=%s' % Array[query, slug])\n query_list.push(format('%s=%s', query, slug))\n end\n end\n\n # Construct the query_string using the list.\n # Last character will be an & so we can push the token\n query_list.each do |string|\n query_string += format('%s&', string)\n end\n end\n query_string\n end",
"def sql\n @sql ||= begin\n bind_params = []\n 1.upto(selector_keys.length + setter_keys.length) { |i| bind_params << \"$#{i}\" }\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end"
] | [
"0.8094061",
"0.7400032",
"0.7360341",
"0.7057596",
"0.697072",
"0.67012405",
"0.6664916",
"0.6664916",
"0.66009945",
"0.65790117",
"0.6518947",
"0.6518947",
"0.65135",
"0.64909905",
"0.6456157",
"0.6355946",
"0.63512546",
"0.6350173",
"0.6348552",
"0.62958217",
"0.62758034",
"0.6275628",
"0.62754256",
"0.621819",
"0.6207104",
"0.619243",
"0.6189726",
"0.6139988",
"0.6139192",
"0.6130513",
"0.6127642",
"0.6119421",
"0.6118479",
"0.60910696",
"0.60873526",
"0.6052472",
"0.6048932",
"0.6031714",
"0.602948",
"0.60184866",
"0.60053235",
"0.60042775",
"0.59998304",
"0.59855735",
"0.5981416",
"0.5953075",
"0.5910278",
"0.5904606",
"0.59021354",
"0.5901626",
"0.5901233",
"0.5898144",
"0.589569",
"0.5893507",
"0.5869499",
"0.586556",
"0.5855845",
"0.584347",
"0.58408654",
"0.5834788",
"0.5825606",
"0.58215547",
"0.5814484",
"0.58051366",
"0.5799804",
"0.5781004",
"0.5772",
"0.57612425",
"0.5761224",
"0.57393295",
"0.5730676",
"0.57269764",
"0.5723077",
"0.5715923",
"0.57055825",
"0.5701592",
"0.56955504",
"0.5681879",
"0.5660509",
"0.56575006",
"0.56441593",
"0.56292415",
"0.5607567",
"0.56072664",
"0.5605946",
"0.5604512",
"0.5603157",
"0.55987084",
"0.55909795",
"0.5586984",
"0.55850726",
"0.55789095",
"0.55783415",
"0.55504376",
"0.55492455",
"0.5548238",
"0.5535714",
"0.5535201",
"0.5531387",
"0.5515562"
] | 0.7932529 | 1 |
Public: Run the query and return the items. options The options to pass to queryable_class.find: :conditions Additional conditions for the query. :order Order clause as a String or Array of Strings. The default is derived from sort_criteria. A group_by clause is always prepended if the query is grouped. :limit The query result limit as an integer or nil. :offset The query result offset as an integer or nil. :include Additional associations for the query. Defaults to any sort_criteria columns that are associations on the queryable model, as well as the group_by column if it is an association and the query is grouped. Returns an Array of results for the query. Raises ActsAsQueryable::Query::StatementInvalid if the query is invalid. | def items(options={})
order = [group_by_sort_clause, sort_criteria_clause, options[:order]]
order = order.flatten.reject(&:blank?).compact.uniq.join(",")
order = nil if order.blank?
includes = [options[:include], sort_criteria.map { |n, o| include_for(n) }]
includes << include_for(group_by) if grouped? && include_for(group_by)
includes = includes.flatten.reject(&:blank?).compact.uniq
includes = nil if includes.blank?
queryable_class.all options.merge(
:conditions => self.class.merge_conditions(to_sql, options[:conditions]),
:order => order,
:include => includes)
rescue ::ActiveRecord::StatementInvalid => e
raise StatementInvalid.new(e.message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query(options) # :nodoc:\n @next_token = options[:next_token]\n query_expression = build_conditions(options[:query_expression])\n # add sort_options to the query_expression\n if options[:sort_option]\n sort_by, sort_order = sort_options(options[:sort_option])\n sort_query_expression = \"['#{sort_by}' starts-with '']\"\n sort_by_expression = \" sort '#{sort_by}' #{sort_order}\"\n # make query_expression to be a string (it may be null)\n query_expression = query_expression.to_s\n # quote from Amazon:\n # The sort attribute must be present in at least one of the predicates of the query expression.\n if query_expression.blank?\n query_expression = sort_query_expression\n elsif !query_attributes(query_expression).include?(sort_by)\n query_expression += \" intersection #{sort_query_expression}\"\n end\n query_expression += sort_by_expression\n end\n # request items\n query_result = self.connection.query(domain, query_expression, options[:max_number_of_items], @next_token)\n @next_token = query_result[:next_token]\n items = query_result[:items].map do |name|\n new_item = self.new('id' => name)\n new_item.mark_as_old\n reload_if_exists(record) if options[:auto_load]\n new_item\n end\n items\n end",
"def find_all(options = {})\n conditions, = extract_conditions!(options)\n klass.find(:all, params: conditions)\n end",
"def find_by_sql(options, results_accumulator=nil, &block)\n # SugarCRM REST API has a bug (fixed in release _6.4.0.patch as indicated in SugarCRM bug number 43338)\n # where, when :limit and :offset options are passed simultaneously,\n # :limit is considered to be the smallest of the two, and :offset is the larger\n # In addition to allowing querying of large datasets while avoiding timeouts (by fetching results in small slices),\n # this implementation fixes the :limit - :offset bug so that it behaves correctly\n \n offset = options[:offset].to_i >= 1 ? options[:offset].to_i : nil\n \n # if many results are requested (i.e. multiple result slices), we call this function recursively\n # this array keeps track of which slice we are retrieving (by updating the :offset and :limit options)\n local_options = {}\n # ensure results are ordered so :limit and :offset option behave in a deterministic fashion\n local_options[:order_by] = :id unless options[:order_by]\n \n # we must ensure limit <= offset (due to bug mentioned above)\n if offset\n local_options[:limit] = [offset.to_i, SLICE_SIZE].min\n local_options[:offset] = offset if offset\n else\n local_options[:limit] = options[:limit] ? [options[:limit].to_i, SLICE_SIZE].min : SLICE_SIZE\n end\n local_options[:limit] = [local_options[:limit], options[:limit]].min if options[:limit] # don't retrieve more records than required\n local_options = options.merge(local_options)\n \n query = query_from_options(local_options)\n result_slice = connection.get_entry_list(self._module.name, query, local_options)\n return results_accumulator unless result_slice\n \n result_slice_array = Array.wrap(result_slice)\n if block_given?\n result_slice_array.each{|r| yield r }\n else\n results_accumulator = [] unless results_accumulator\n results_accumulator = results_accumulator.concat(result_slice_array)\n end\n \n # adjust options to take into account records that were already retrieved\n updated_options = {:offset => options[:offset].to_i + result_slice_array.size}\n updated_options[:limit] = (options[:limit] ? options[:limit] - result_slice_array.size : nil)\n updated_options = options.merge(updated_options)\n \n # have we retrieved all the records?\n if (updated_options[:limit] && updated_options[:limit] < 1) || local_options[:limit] > result_slice_array.size\n return results_accumulator\n else\n find_by_sql(updated_options, results_accumulator, &block)\n end\n end",
"def find_all(options = {})\n @order_by = options[:order_by]\n @select = options[:select] ||= ['*']\n response = get(uri([:order, :select]))\n response.results if response\n end",
"def find_all(options = {})\n @order_by = options[:order_by]\n @select = options[:select] ||= ['*']\n response = get(uri([:order, :select]))\n response.results if response\n end",
"def find_all_by_query(query, options={})\n find_by_query(:all, query, options)\n end",
"def results\n @results ||= begin\n _dataset = filtered_dataset.limit(per_page).offset(start)\n\n if sort_by\n options = self.class.sortable_attribute_options(sort_by.to_s)\n order =\n if sort_order == \"DESC\"\n Sequel.desc(sort_by.to_sym, options)\n else\n Sequel.asc(sort_by.to_sym, options)\n end\n _dataset = _dataset.order(order)\n end\n\n _dataset.all\n end\n end",
"def find(options={})\n query(options)\n end",
"def all(options={})\n offset = nil\n results = []\n begin\n options.merge!(:limit => LIMIT_MAX, :offset => offset)\n response = records(options)\n results += response.records\n offset = response.offset\n end until offset.nil? || offset.empty? || results.empty?\n results\n end",
"def execute *args\n if args.first == :query\n self\n else\n opts = args.last.is_a?(Hash) ? args.last : {}\n results = []\n\n pagination = opts.delete(:paginate) || {}\n model.send(:with_scope, :find => opts) do\n @conditions.paginate(pagination) unless pagination.empty?\n results = model.find args[0], to_find_parameters\n if @conditions.paginate?\n paginate_result_set results, to_find_parameters\n end\n end\n results\n end\n end",
"def find(options)\n klass = options[:class]\n sql = resolve_options(klass, options)\n read_all(query(sql), klass, options)\n end",
"def extract_conditions!(options = {})\n order = normalize_order(options.delete(:order))\n limit = options.delete(:limit)\n offset = options.delete(:offset)\n conditions = options.delete(:conditions) || options\n\n [conditions, order, limit, offset]\n end",
"def extract_conditions!(options = {})\n order = normalize_order(options.delete(:order))\n limit = options.delete(:limit)\n offset = options.delete(:offset)\n conditions = options.delete(:conditions) || options\n\n [conditions, order, limit, offset]\n end",
"def get_raw_sql(options)\n # base.rb, find()\n validate_find_options(options)\n set_readonly_option!(options)\n # base.rb, find_every()\n include_associations = merge_includes(scope(:find, :include), options[:include])\n if include_associations.any? && references_eager_loaded_tables?(options)\n # associations.rb, find_with_associations()\n join_dependency = JoinDependency.new(self, merge_includes(scope(:find, :include), options[:include]), options[:joins])\n construct_finder_sql_with_included_associations(options, join_dependency)\n else\n # base.rb, find_every()\n construct_finder_sql(options)\n end\n end",
"def find_results_in_batches(options = {})\n return enum_for(:find_results_in_batches, options) unless block_given?\n\n yield_in_batches(options) do |criteria|\n yield criteria.results\n end\n end",
"def get_results(query, conditions, order)\n query_call = \"select * from #{domain} \"\n query_call << \"where #{conditions.compact.join(' and ')}\" if conditions.length > 0\n query_call << \" #{order}\"\n if query.limit!=nil\n query_limit = query.limit\n query_call << \" limit #{query.limit}\" \n else\n #on large items force the max limit\n query_limit = 999999999 #TODO hack for query.limit being nil\n #query_call << \" limit 2500\" #this doesn't work with continuation keys as it halts at the limit passed not just a limit per query.\n end\n results = sdb.select(query_call)\n \n sdb_continuation_key = results[:next_token]\n while (sdb_continuation_key!=nil && results[:items].length < query_limit)do\n old_results = results\n results = sdb.select(query_call, sdb_continuation_key)\n results[:items] = old_results[:items] + results[:items]\n sdb_continuation_key = results[:next_token]\n end\n\n results = results[:items][0...query_limit]\n end",
"def records(options={})\n options[\"sortField\"], options[\"sortDirection\"] = options.delete(:sort) if options[:sort]\n results = self.class.get(worksheet_url, query: options).parsed_response\n RecordSet.new(results)\n end",
"def list(options={})\n listings = self\n options.each_pair do |key, value|\n if !value.blank? and (self.column_names.include?key.to_s or self.reflections.keys.include?key.to_sym)\n listings = listings.send(\"where_#{key.to_s}\".to_sym, value) \n end\n end\n return Post.with_pagination ? listings.paginate(:page => options[:page], :per_page => options[:per_page]) : listings.all\n end",
"def extract_conditions!(options = {})\n\t\t\t\torder = normalize_order(options.delete(:order))\n\t\t\t\tlimit = options.delete(:limit)\n\t\t\t\toffset = options.delete(:offset)\n\t\t\t\tconditions = options.delete(:conditions) || options\n\t\t\t\t[conditions, order, limit, offset]\n\t\t\tend",
"def find(criteria, options = {})\n criteria = normalize_criteria criteria\n self.collection.find(criteria, options).map do |hash|\n self.normalize hash\n end\n end",
"def scaffold_get_objects(options)\n optionshash = {}\n data = self.all\n if options[:conditions]\n conditions = options[:conditions]\n if conditions && Array === conditions && conditions.length > 0\n if String === conditions[0]\n data = data.all(:conditions => conditions)\n else\n conditions.each do |cond|\n next if cond.nil?\n data = case cond\n when Hash, String then data.all(:conditions => [cond.gsub(\"NULL\",\"?\"),nil])\n when Array then \n if cond.length==1\n data.all(:conditions => [cond[0].gsub(\"NULL\",\"?\"),nil])\n else\n data.all(:conditions => cond)\n end\n when Proc then data.all(&cond)\n end\n end\n end\n end\n end\n slice = nil\n if options[:limit]\n startpos = options[:offset] || 0\n endpos = options[:limit]\n slice = [startpos,endpos]\n end\n # TODO includes break SQL generation\n # optionshash[:links] = options[:include] if options[:include]\n # optionshash[:links] = [optionshash[:links]] unless optionshash[:links].is_a?(Array)\n if options[:order] then\n optionshash[:order] = get_ordering_options(options[:order])\n end\n if slice then\n q = data.all(optionshash).slice(*slice)\n else\n q = data.all(optionshash)\n end\n #p repository.adapter.send(\"select_statement\",q.query)\n q.to_a\n end",
"def find_all(options = {})\n response = JSON.parse(@client.get('items', options).body)\n items = response.key?('items') ? response['items'] : []\n items.map { |attributes| Promisepay::Item.new(@client, attributes) }\n end",
"def list_entries_with_query\n ar_query = list_entries_without_query\n ar_query = ar_query.where(arel_condition) if params[:where]\n if params[:format] == 'json'\n # make sure we don't ask for entire table\n params[:limit] ||= 10\n if params[:select]\n selected_columns = arel_select_columns\n ar_query = ar_query.select(selected_columns)\n attribute_columns = arel_attribute_columns(selected_columns)\n if attribute_columns.size < selected_columns.size\n # doing aggregation of some sort\n unless attribute_columns.empty?\n # need to specify grouping and sort order\n ar_query = ar_query.group(attribute_columns)\n ar_query = ar_query.order(attribute_columns)\n end\n else\n ar_query = ar_query.order(arel_order) # use params[:order] else default sort order\n end\n end\n ar_query = ar_query.offset(params[:offset].to_i) if params[:offset]\n ar_query = ar_query.limit(params[:limit].to_i) if params[:limit]\n else\n ar_query = ar_query.order(arel_order) # uses params[:order] else default sort order\n raise \"Query select option is not supported in table mode\" if params[:select]\n raise \"Query offset option is not supported in table mode\" if params[:offset]\n raise \"Query limit option is not supported in table mode\" if params[:limit]\n end\n ar_query\n end",
"def fetch_items\n items = @klass.order(\"#{sort_column} #{sort_direction}\")\n items = items.page(page).per_page(per_page)\n if @params[:sSearch].present?\n query = @fields.map { |field| \"#{field} ilike :search\" }.join(\" OR \")\n items = items.where(query, search: \"%#{@params[:sSearch]}%\")\n end\n return items\n end",
"def all(options={})\n @collection = query(options)\n self\n end",
"def find(options)\n table = DB.from(@table)\n \n options.each_pair do |method_name,params|\n table = table.send(method_name, params)\n end\n \n # convert the array of hashes to an array of model objects\n table.all.map{|row| @model_class.new row}\n end",
"def list(options = nil)\n table = DB.from(@table)\n \n if options[:rows]\n if options[:offset]\n table = table.limit(options[:rows],options[:offset])\n elsif options[:page] \n offset = options[:page] * options[:rows]\n table = table.limit(options[:rows],offset)\n end\n end\n \n # convert the array of hashes to an array of model objects\n table.all.map{|row| @model_class.new row}\n end",
"def execute_query(options)\n results = solr_select(options)\n Chef::Log.debug(\"Bulk loading from #{@database}:\\n#{results.inspect}\") \n objects = if results[\"response\"][\"docs\"].length > 0\n bulk_objects = @couchdb.bulk_get( results[\"response\"][\"docs\"].collect { |d| d[ID_KEY] } )\n Chef::Log.debug(\"bulk get of objects: #{bulk_objects.inspect}\")\n bulk_objects\n else\n []\n end\n [ objects, results[\"response\"][\"start\"], results[\"response\"][\"numFound\"], results[\"responseHeader\"] ] \n end",
"def find_all(offset: 0, limit: 0)\n result = instance.all.to_a\n\n return result if offset == 0 && limit == 0\n return result.slice(offset, result.count) if limit == 0\n result[offset...limit]\n end",
"def all(options={})\r\n find(:all, options)\r\n end",
"def find_in_batches(options = {})\n return enum_for(:find_in_batches, options) unless block_given?\n find_rows_in_batches(options) do |rows|\n yield rows.map { |row| target_class.hydrate(row) }\n end\n end",
"def find_all(options = {})\n construct_scope(options).to_a\n end",
"def all(options = {})\n constraints = [\n (\"SystemModstamp < #{options[:before].utc.iso8601}\" if options[:before]),\n (\"SystemModstamp >= #{options[:after].utc.iso8601}\" if options[:after]),\n *options[:conditions],\n ]\n\n DB.client.query(query(*constraints)).map do |record|\n instance_type.new(@record_type, record, @mapping)\n end\n end",
"def find(options)\n BorrowDirect::FindItem::Response.new find_item_request(options), self.auth_id\n end",
"def sort(options = {})\n return [] if empty?\n options[:start] ||= 0\n options[:limit] = [options[:start], options[:limit]] if options[:limit]\n instantiate(db.sort(key, options))\n end",
"def query(expr=\"\", query_options={})\n result = []\n self.domain.query(query_options.merge({:expr => expr})).each do |i|\n result << self.new(i.key, i.attributes, false)\n end\n return result\n end",
"def find_each(options = {})\n return enum_for(:find_each, options) unless block_given?\n find_each_row(options) { |row| yield target_class.hydrate(row) }\n end",
"def run_query(query, options={})\n query = prepare_query query, options\n\n # Run the query\n response = self.__elasticsearch__.search query\n\n Hashie::Mash.new({\n records: response.records,\n total_entries: response.results.total\n })\n end",
"def find_in_batches(options={})\n\t\tstart = options[:start]\n\t\tbatch_size = options[:batch_size]\n\t\t# check options for start and batch_size values\n\t\tif start != nil && batch_size != nil\n\t\t\trows = connection.execute <<-SQL\n\t\t\t\tSELECT #{columns.join \",\"} FROM #{table}\n\t\t\t\tLIMIT #{batch_size} OFFSET #{start};\n\t\t\tSQL\n\t\telsif start != nil && batch_size == nil\n\t\t\trows = connection.execute <<-SQL\n\t\t\t\tSELECT #{columns.join \",\"} FROM #{table}\n\t\t\t\tOFFSET #{start};\n\t\t\tSQL\n\t\telsif start == nil && batch_size != nil \n\t\t\trows = connection.execute <<-SQL \n\t\t\t\tSELECT #{columns.join \",\"} FROM #{table}\n\t\t\t\tLIMIT #{batch_size};\n\t\t\tSQL\n\t\telse \n\t\t\trows = connection.execute <<-SQL \n\t\t\t\tSELECT #{columns.join \",\"} FROM #{table};\n\t\t\tSQL\n\t\tend\n\n\t\trow_array = rows_to_array(rows)\n\t\tyield(row_array)\n\n\tend",
"def query(conditions = [], order = [], limit = 250)\n conditions.select!{ |h| Proc === self.class.searchable[h[:field].to_sym]}\n @conditions = conditions\n @order = Hash[order].reject { |field, dir| field.nil? || !self.class.sortable[field.to_sym] }.\n map{ |field, dir| (dir == 'asc') ? self.class.sortable[field.to_sym].asc : self.class.sortable[field.to_sym].desc }\n @limit = limit\n dataset\n end",
"def ordered_entries(options = nil)\n options ||= {}\n\n # pagination\n page, per_page = options.delete(:page), options.delete(:per_page)\n\n # order list\n _order_by_definition = (options || {}).delete(:order_by).try(:split) || self.order_by_definition\n\n # get list\n _entries = self.entries.order_by([_order_by_definition]).where(options[:where] || {})\n\n # pagination or full list\n page ? _entries.page(page).per(per_page) : _entries\n end",
"def search( options={} )\n\t\tds = @storage.each_key\n\t\tself.log.debug \"Starting search with %p\" % [ ds ]\n\n\t\tds = self.omit_related_resources( ds, options )\n\t\tds = self.apply_search_criteria( ds, options )\n\t\tds = self.apply_search_order( ds, options )\n\t\tds = self.apply_search_direction( ds, options )\n\t\tds = self.apply_search_limit( ds, options )\n\n\t\treturn ds.to_a\n\tend",
"def entries(options={})\n order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)\n\n issues = entries_scope.\n order(order_option).\n limit(options[:limit]).\n offset(options[:offset])\n\n if has_column?(:spent_hours)\n Issue.load_visible_spent_hours(issues)\n end\n if has_column?(:spent_hours)\n if issues.any?\n issues.each do |issue|\n hours_filtered = issue.time_entries.to_a.map(&:hours).inject(0) { |x, y| x + y }\n issue.instance_variable_set '@spent_hours_filtered', (hours_filtered || 0)\n end\n end\n end\n if has_column?(:relations)\n Issue.load_visible_relations(issues)\n end\n issues\n rescue ::ActiveRecord::StatementInvalid => e\n raise StatementInvalid.new(e.message)\n end",
"def items\n @items ||= begin\n offset = @per_page * (@page - 1)\n @relation.limit(@per_page).offset(offset)\n end\n end",
"def items(opts = {})\n Item.all(opts)\n end",
"def search conditions, options = {}\n options = {\n :limit => false,\n :offset => 0\n }.merge(options)\n\n remote.search normalize_conditions(conditions),\n options[:offset],\n options[:limit],\n options[:order],\n options[:context],\n options[:count]\n end",
"def find(selector={}, options={})\n fields = options.delete(:fields)\n fields = nil if fields && fields.empty?\n offset = options.delete(:offset) || 0\n limit = options.delete(:limit) || 0\n sort = options.delete(:sort)\n hint = options.delete(:hint)\n if hint\n hint = normalize_hint_fields(hint)\n else\n hint = @hint # assumed to be normalized already\n end\n raise RuntimeError, \"Unknown options [#{options.inspect}]\" unless options.empty?\n @db.query(self, Query.new(selector, fields, offset, limit, sort, hint))\n end",
"def find_in_batches(options = {})\n return enum_for(:find_in_batches, options) unless block_given?\n\n yield_in_batches(options) do |criteria|\n yield(criteria.records) if criteria.records.size > 0\n end\n end",
"def find_all(options = {})\n raise NotSupportedError\n end",
"def query(options = {})\n paginate = if options.has_key?(:paginate)\n options.delete(:paginate)\n else\n true\n end\n\n name = self.class.name.demodulize.downcase\n route = Automatic::Client.routes.route_for(name)\n url = route.url_for\n\n request = api_client.get(url, options)\n\n if request.success?\n raw_results = []\n\n metadata = Automatic::Models::Response::Metadata.new(request.body.fetch('_metadata', {}))\n link_header = Automatic::Models::Response::LinkHeader.new(request.headers['Link'])\n links = link_header.links\n\n raw_results.concat(request.body.fetch('results', []))\n\n if links.next? && paginate\n loop do\n request = api_client.get(links.next.uri)\n\n link_header = Automatic::Models::Response::LinkHeader.new(request.headers['Link'])\n links = link_header.links\n\n raw_results.concat(request.body.fetch('results', []))\n\n break unless links.next?\n end\n end\n\n raw_results\n else\n raise StandardError.new(request.body)\n end\n end",
"def mqlread(query, options = {})\n cursor = options[:cursor]\n if cursor\n query_result = []\n while cursor\n response = get_query_response(query, cursor)\n query_result += response['result']\n cursor = response['cursor']\n end\n else\n response = get_query_response(query, cursor)\n cursor = response['cursor']\n query_result = response['result']\n end\n query_result\n end",
"def find_entries(options = {}, &block)\n if block_given?\n find_each_entry(options) do |entry|\n yield entry\n end\n else\n results = []\n find_entries_in_batches(options) do |entries|\n results += entries\n end\n results.reverse! if options[:order].to_sym == :desc\n results.size == 1 && options[:count] == 1 ? results.first : results\n end\n end",
"def meetings(options={})\n order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')\n order_option = nil if order_option.blank?\n\n meetings = Meeting.visible.scoped(:conditions => options[:conditions]).find :all, :include => ([:project] + (options[:include] || [])).uniq,\n :conditions => statement,\n :order => order_option,\n :joins => joins_for_order_statement(order_option),\n :limit => options[:limit],\n :offset => options[:offset]\n\n #if has_column?(:spent_hours)\n # Issue.load_visible_spent_hours(issues)\n #end\n #if has_column?(:relations)\n # Issue.load_visible_relations(issues)\n #end\n meetings\n rescue ::ActiveRecord::StatementInvalid => e\n raise StatementInvalid.new(e.message)\n end",
"def find_collection_for_pagination(model, options, paginator)\n model.find(:all,\n :conditions => options[:conditions],\n :order => options[:order_by] || options[:order],\n :joins => options[:join] || options[:joins],\n :include => options[:include],\n :select => options[:select],\n :limit => options[:per_page],\n :offset => paginator.current.offset,\n :piggy => options[:piggy])\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 execute_find(raw = false)\n get_records\n cached = AridCache::CacheProxy::Result.new\n\n if !records.is_a?(Enumerable) || (!records.empty? && !records.first.is_a?(::ActiveRecord::Base))\n cached = records # some base type, cache it as itself\n else\n cached.ids = records.collect(&:id)\n cached.count = records.size\n if records.respond_to?(:proxy_reflection) # association proxy\n cached.klass = records.proxy_reflection.klass\n elsif !records.empty?\n cached.klass = records.first.class\n else\n cached.klass = object_base_class\n end\n end\n Rails.cache.write(cache_key, cached, opts_for_cache)\n self.cached = cached\n\n # Return the raw result?\n return self.cached if raw\n\n # An order has been specified. We have to go to the database\n # to order because we can't be sure that the current order is the same as the cache.\n if cached.is_a?(AridCache::CacheProxy::Result) && combined_options.include?(:order)\n self.klass = self.cached.klass # TODO used by fetch_from_cache needs refactor\n fetch_from_cache\n else\n process_result_in_memory(records)\n end\n end",
"def all(options={})\r\n find(:all,options)\r\n end",
"def apply_finder_options(options)\n relation = clone\n return relation if options.nil?\n\n finders = options.dup\n finders[:select] = finders.delete(:fields)\n conditions = finders.slice!(*VALID_FIND_OPTIONS)\n\n finders.delete_if { |key, value| value.nil? && key != :limit }\n\n ([:joins, :select, :group, :order, :having, :limit, :offset, :from, :lock, :readonly] & finders.keys).each do |finder|\n relation = relation.send(finder, finders[finder])\n end\n\n relation = relation.where(conditions) if conditions.any?\n relation = relation.where(finders[:conditions]) if options.has_key?(:conditions)\n relation = relation.includes(finders[:include]) if options.has_key?(:include)\n relation = relation.extending(finders[:extend]) if options.has_key?(:extend)\n\n relation\n end",
"def search(query, options={})\n limit = options[:limit] if options[:limit].is_a? Numeric\n if (!limit.nil? && limit == 1)\n collection.find_one(query)\n else\n collection.find(query, options)\n end\n end",
"def list_all(name, options)\n records = find(:all, :limit => options[:limit], :offset => options[:offset])\n if options[:skip_count]\n record_count = records.size\n else\n\t\t record_count = count\n\t end\n\t return records, record_count\n end",
"def posts(options={})\n tags = self.self_and_descendants\n post_ids = Tagging.filter([[:tag_id, tags.collect(&:id)]]).select(:post_id).collect(&:post_id).uniq\n query = Post.filter([[:id, post_ids]]).filter(:is_draft => false).reverse_order(:created_at)\n if options[:non_sticky] && sticky = self.sticky_post\n query = query.filter(\"posts.id <> ?\", sticky.id)\n end \n if options[:page] \n query = query.paginate(options[:page], options[:per_page] || 10)\n end\n query\n end",
"def select_records(options)\n cursor = select_cursor(options)\n rows = []\n while cursor.next?\n rows << cursor.next_row\n end\n cursor.clear\n rows\n end",
"def list(raw=false)\n begin\n @criteria.where(@builder.and(@conjunction)) if @use_conjunction\n @criteria.where(@builder.or(@disjunction)) if @use_disjunction\n\n query = @em.createQuery(@criteria)\n\n # set page if set\n if @page and @limit\n query.setFirstResult(@page.to_i*@limit)\n else\n query.setFirstResult(@page.to_i || 0)\n end\n\n # set limit if exists\n if @limit\n query.setMaxResults(@limit)\n end\n\n # show raw arraylist or ruby array\n result = query.getResultList()\n unless raw\n result = result.to_a\n # if getting count instead of result set\n result = result.first if count\n end\n\n # add to audit\n audit_table(@from_table.underscore.pluralize,result.to_a)\n\n # close if needed\n @em.close if @em_local\n rescue Exception => e\n @em.close if @em_local\n throw e\n end\n return result\n end",
"def get_sorted_objects(params, options={})\n objects = options[:objects].nil? ? sortable_class : options[:objects]\n include_rel = options[:include_relations].nil? ? sortable_include_relations : options[:include_relations]\n @headings = options[:table_headings].nil? ? sortable_table_headings : options[:table_headings]\n @column_procs = options[:sortable_column_procs].nil? ? sortable_column_procs : options[:sortable_column_procs]\n sort_map = options[:sort_map].nil? ? sortable_sort_map : HashWithIndifferentAccess.new(options[:sort_map])\n default_sort = options[:default_sort].nil? ? sortable_default_sort : options[:default_sort]\n conditions = options[:conditions].nil? ? '' : options[:conditions]\n search_array = options[:search_array].nil? ? sortable_search_array : options[:search_array]\n search_type = options[:search_type].nil? ? sortable_search_type : options[:search_type]\n search_conditions = options[:search_conditions].nil? ? sortable_search_conditions : options[:search_conditions]\n\n conditions = process_search(params, conditions, {:search_array => search_array, :search_type => search_type, :search_conditions => search_conditions})\n items_per_page = options[:per_page].nil? ? sortable_per_page : options[:per_page]\n\n @sort_map = sort_map\n sort = process_sort(params, sort_map, default_sort)\n page = params[:page]\n page ||= 1\n # fetch the objects, paginated and sorted as desired along with any extra filtering conditions\n get_paginated_objects(objects, sort, include_rel, conditions, page, items_per_page)\n end",
"def results(offset, limit)\n result_ids_to_load = result_ids[offset, limit] || []\n results_by_scope = Hash.new {|h, k| h[k] = []}\n result_ids_to_load.group_by(&:first).each do |scope, scope_and_ids|\n klass = scope.singularize.camelcase.constantize\n results_by_scope[scope] += klass.search_results_from_ids(scope_and_ids.map(&:last))\n end\n result_ids_to_load.filter_map do |scope, id|\n results_by_scope[scope].detect {|record| record.id == id}\n end\n end",
"def scoped(options = nil)\n queryable.scoped(options)\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 find_each_result(options = {})\n return enum_for(:find_each_result, options) unless block_given?\n\n find_results_in_batches options do |batch|\n batch.each do |result|\n yield result\n end\n end\n end",
"def find_expressions (options={})\n\n #conditions = determine_conditions(options)\n # note : this call modifies the options hash...\n\n conditions = {}\n\n #\n # maximize usage of SQL querying\n\n exps = DataMapper.repository(@dm_repository) {\n DmExpression.all(conditions)\n }\n\n #\n # do the rest of the filtering\n\n exps.inject([]) { |a, de|\n fe = de.as_owfe_expression(application_context)\n a << fe if does_match?(options, fe)\n a\n }\n end",
"def category_records(options = {})\n if self.list?\n records = self.tree_records\n else\n records = self.records\n end\n if options[:start] and options[:end]\n records = records.where(\"timestamp >= ?\", options[:start]).where(\"timestamp <= ?\", options[:end])\n end\n if options[:order] == 'oldest'\n records = records.order('timestamp ASC')\n elsif options[:order] == 'newest'\n records = records.order('timestamp DESC')\n end\n unless options[:include_private]\n records = records.public_records\n end\n if !options[:filter_string].blank?\n query = \"%\" + options[:filter_string].downcase + \"%\"\n records = records.joins(:record_category).where('LOWER(records.data) LIKE ? OR LOWER(record_categories.full_name) LIKE ?', query, query) \n end\n records\n end",
"def query(options)\n run_command('query', options)\n end",
"def all(options = {})\n #assert_kind_of 'options', options, Hash\n query = { :name => nil }.merge!(options).merge!(:id => nil)\n result = mqlread([ query ], :cursor => !options[:limit]) \n Basuco::Collection.new(result.map { |r| Basuco::Resource.new(r) })\n end",
"def find_options_for_query(query, options={})\n find_options_for_find_by_query(query, find_by_query_columns, options)\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_options\n opt = {:conditions => conditions, :limit => @limit, :order => \"#{@id_clause} #{@order}\"}\n if columns = @options[:select]\n opt[:select] = columns\n end\n opt[:joins] = @joins if @joins\n opt\n end",
"def each_query(options = {})\n options = { sort: false, subject_regex: nil }.merge(options)\n \n # Set the state variables\n current_rows = []\n current_query = nil\n\n # Read through rows until the query changes.\n each(subject_regex: options[:subject_regex]) do |hit|\n if hit.query == current_query\n current_rows << hit\n else\n if current_query\n current_rows.sort! if options[:sort]\n yield current_query, current_rows \n end\n\n current_query, current_rows = hit.query, [hit]\n end\n end\n \n # Yield the last query if any were found\n yield current_query, current_rows if current_query\n end",
"def apply_search_limit( ds, options )\n\t\tif (( limit = options[:limit] ))\n\t\t\tself.log.debug \" limiting to %s results\" % [ limit ]\n\t\t\toffset = options[:offset] || 0\n\t\t\tds = ds.to_a.slice( offset, limit )\n\t\tend\n\n\t\treturn ds\n\tend",
"def find_each(options = {})\n return enum_for(:find_each, options) unless block_given?\n\n find_in_batches options do |batch|\n batch.each do |record|\n yield record\n end\n end\n end",
"def association_options_find(association, conditions = nil, klass = nil, record = nil)\n if klass.nil? && association.polymorphic?\n class_name = record.send(association.foreign_type) if association.belongs_to?\n return [] if class_name.blank?\n klass = class_name.constantize\n cache = !block_given?\n else\n cache = !block_given? && klass.nil?\n klass ||= association.klass\n end\n\n conditions ||= options_for_association_conditions(association, record)\n cache_association_options(association, conditions, klass, cache) do\n klass = association_klass_scoped(association, klass, record)\n relation = klass.where(conditions)\n column = column_for_association(association, record)\n if column&.includes\n include_assoc = column.includes.find { |assoc| assoc.is_a?(Hash) && assoc.include?(association.name) }\n relation = relation.includes(include_assoc[association.name]) if include_assoc\n end\n if column&.sort && column.sort&.dig(:sql)\n # with threasafe enabled, column.sort[:sql] returns proxied strings and\n # regexp capture won't work, which rails uses internally, so to_s is needed\n relation = relation.order(Array(column.sort[:sql]).map(&:to_s))\n end\n relation = yield(relation) if block_given?\n relation.to_a\n end\n end",
"def parallel_queries\n raise \"Model is missing id column\" if ar_class.columns.none? { |column| column.name == \"id\" }\n\n if ar_class.respond_to?(:scrubbable_scope)\n num_records = ar_class.send(:scrubbable_scope).count\n else\n num_records = ar_class.count\n end\n return [] if num_records == 0 # no records to import\n\n record_window_size, modulus = num_records.divmod(num_of_batches)\n if record_window_size < 1\n record_window_size = 1\n modulus = 0\n end\n\n start_id = next_id(ar_class: ar_class, offset: 0)\n queries = num_of_batches.times.each_with_object([]) do |_, queries|\n next unless start_id\n\n end_id = next_id(ar_class: ar_class, id: start_id, offset: record_window_size - 1)\n if modulus > 0\n end_id = next_id(ar_class: ar_class, id: end_id)\n modulus -= 1\n end\n queries << { id: start_id..end_id } if end_id\n start_id = next_id(ar_class: ar_class, id: end_id || start_id)\n end\n\n # just in case new records are added since we started, extend the end ID\n queries[-1] = [\"#{ar_class.quoted_table_name}.id >= ?\", queries[-1][:id].begin] if queries.any?\n\n queries\n end",
"def entries(options={})\n return @entries if @entries and options == {}\n validate_entries_options(options)\n @entries = Harvest::Resources::Entry.find(:all, :include => options[:include], :conditions => {:project_id => self.id}, :params => format_params(options))\n end",
"def relation_objects_perform\n # Build the relation depending on the various options (query methods).\n relation = AllTypesObject.all\n # Extract and apply query methods.\n relation = apply_query_methods(relation, params)\n\n # Perform the query\n case params[:method]\n when \"first\", \"last\", \"take\"\n amount = params[:amount].to_i if params[:amount].present?\n @results = relation.send(params[:method], *amount)\n when \"to_a\", \"all\", \"load\", \"reload\", \"first!\", \"last!\", \"take!\"\n @results = relation.send(params[:method])\n when \"select\"\n @results = relation.send(params[:method]) { true } # Select with a block acts as a finder method. The block simply returns true to not futher limit the results.\n when \"find\"\n case params[:option]\n when \"sub_method\"\n if FIND_SUB_METHODS.include?(params[:sub_method])\n @results = relation.send(params[:method], params[:sub_method].to_sym)\n else\n flash[:alert] = \"Unknown sub method selected\" unless running?\n end\n when \"single_id\"\n @results = relation.send(params[:method], params[:id])\n when \"id_list\"\n @results = relation.send(params[:method], *params[:id])\n when \"id_array\"\n @results = relation.send(params[:method], params[:id])\n end\n when \"find_by\", \"find_by!\"\n conditions = build_conditions('joined', 'list', params[:conditions]).first || [nil]\n @results = relation.send(params[:method], *conditions)\n when \"find_or_initialize_by\", \"find_or_create_by\", \"find_or_create_by!\"\n conditions = build_conditions('joined', 'hash', params[:conditions]).flatten.first || {}\n attributes = params[:attributes].reject { |k,v| v.blank? }\n if attributes.present?\n @results = relation.send(params[:method], conditions) { |object| object.attributes = attributes }\n else\n @results = relation.send(params[:method], conditions)\n end\n when \"dynamic_find_by\", \"dynamic_find_by!\"\n # Check if the attribute name is allowed to prevent errors.\n return redirect_to read_test_relation_objects_form_path(params[:method], params[:option]), :alert => \"Selected attribute is not a valid attribute of AllTypesObject!\" unless AllTypesObject.column_names.include?(params[:attribute])\n method = \"find_by_#{params[:attribute]}\" + (params[:method] == \"dynamic_find_by!\" ? \"!\" : \"\")\n @results = relation.send(method, params[:value])\n when \"find_each\", \"find_in_batches\"\n @results = []\n options = {}\n options[:start] = params[:start].to_i if params[:start].present?\n options[:batch_size] = params[:batch_size].to_i if params[:batch_size].present?\n relation.send(params[:method], options) { |results| @results << results }\n when \"first_or_initialize\", \"first_or_create\", \"first_or_create!\"\n @results = relation.send(params[:method], params[:attributes].presence)\n else\n raise \"Unknown method '#{params[:method]}'\"\n end\n\n # Wrap the result(s) in array and flatten (since the template expects an array of results)\n @all_types_objects = (@results.present? ? [@results].flatten : nil)\n\n @includes = (relation.eager_load_values + relation.includes_values + relation.preload_values).uniq\n\n respond_with(@all_types_objects)\n end",
"def query options\n from = options.fetch :start\n to = options.fetch :end\n\n query = @alarms.objects.find { |o| o.name == \"query\" }\n\n filter = OBIX::Builder.new do\n obj do\n abstime name: \"start\", val: from.iso8601\n abstime name: \"end\", val: to.iso8601\n end\n end.object\n\n alarms = query.invoke filter\n\n alarms.objects.find { |o| o.name == \"data\" }\n end",
"def all(query={}, options={})\n new.all(query, options)\n end",
"def items\n if @items.nil?\n ids = tire_response.results.map { |item| item['id'] }\n items = klass.where(:id => ids).group_by(&:id)\n @items = ids.map{ |id| items[id.to_i] }.flatten.compact\n end\n @items\n end",
"def execute\n klass.collection.find(selector, process_options) || []\n end",
"def all_children(options = {})\n conditions = \"(#{nested_set_left} > #{self[nested_set_left]}) and (#{nested_set_right} < #{self[nested_set_right]})\"\n if options[:exclude]\n transaction do\n # exclude some items and all their children\n options[:exclude] = [options[:exclude]] if !options[:exclude].is_a?(Array)\n # get objects for ids\n options[:exclude].collect! {|s| s.is_a?(nested_set_class) ? s : nested_set_class.find(s)}\n # get all subtrees and flatten the list\n exclude_list = options[:exclude].map{|e| e.full_set.map{|ee| ee.id}}.flatten.uniq\n conditions += \" AND id NOT IN (#{exclude_list.join(',')})\" unless exclude_list.empty?\n end\n end\n nested_set_class.find_with_nested_set_scope(:all, :conditions => conditions, :order => nested_set_left)\n end",
"def query(&blk)\n @adapter.query(collection, self, &blk)\n end",
"def find_all_visible(options={})\n find(:all, find_options_for_visible(options))\n end",
"def children(options={:type => nil, :get_dataset => false, :recursive => false, :keep_cache => true, :reload => false, :preconditions => {:hidden => false}})\n return @children_cache if @children_cache and !options[:get_dataset] and !options[:reload]\n klass = Ecore::db[:documents]\n if options[:type]\n raise(TypeError, \":type must be an Ecore::DocumentResource\") unless options[:type].respond_to?(:table_name)\n klass = Ecore::db[:\"#{options[:type].table_name}\"]\n end\n query = klass.store_preconditions((@user_obj || @group_ids || @user_id),nil,self,nil,(options[:preconditions] || {:hidden => false}))\n query = ( options[:recursive] ? query.where(:path.like(\"#{absolute_path}%\")) : query.where(:path => absolute_path) )\n return query if options[:get_dataset]\n children_cache = query.order(:position,:name).receive(:all)\n return children_cache if options[:keep_cache]\n @children_cache = children_cache\n end",
"def items\n @item_data ||= @active_domain.nil? ? EMPTY_ITEM_DATA : get_items(@query)\n @item_data[:items]\n end",
"def paginate(options = {})\n page = options.delete(:page) || raise(ArgumentError, \"paginate requires a :page argument\")\n per_page = options.delete(:per_page)\n raise ArgumentError, \"unknown argument #{options.keys.first.inspect} passed to paginate\" unless options.empty?\n @query.paginate(page, per_page)\n end",
"def get_results(projection = nil)\n selection = Dynamicloud::API::DynamicloudHelper.build_string(get_conditions, get_group_by, get_order_by,\n (Dynamicloud::API::DynamicloudHelper.build_projection(projection)),\n @alias, @joins)\n @current_projection = projection\n\n url = Configuration::PROPERTIES.get_property :url\n if projection\n url_get_records = Configuration::PROPERTIES.get_property :url_get_specific_fields\n else\n url_get_records = Configuration::PROPERTIES.get_property :url_get_records\n end\n\n url_get_records = url_get_records.gsub '{csk}', URI::encode(@credentials[:csk])\n url_get_records = url_get_records.gsub '{aci}', URI::encode(@credentials[:aci])\n url_get_records = url_get_records.gsub '{mid}', @mid.to_s\n url_get_records = url_get_records.gsub '{count}', get_count.to_s\n url_get_records = url_get_records.gsub '{offset}', get_current_offset.to_s\n\n params = {\n :criteria => selection\n }\n\n response = DynamicService::ServiceCaller.call_service url + url_get_records, params, 'post'\n\n Dynamicloud::API::DynamicloudHelper.build_record_results response\n\n end",
"def execute_query\n the_query = create_query\n\n #to do: start and end offsets\n results = the_query.all.collect { |result|\n the_result = {id: result.id, uuid: result.uuid, start_offset_seconds: nil, end_offset_seconds: nil}\n OpenStruct.new(the_result)\n }\n to_return = {:search => self, :query => the_query, :items => results}\n OpenStruct.new(to_return)\n end",
"def find_each(options = {})\n rows = retrieve_records(options) #private method\n\n rows.each do |row|\n init_object_from_row(row)\n end\n end",
"def find_all_by_id(klass, ids, find_opts={})\n return ids if ids.empty?\n find_opts = Options.new(find_opts.merge(:result_klass => klass)).opts_for_find(ids)\n if AridCache.framework.active_record?(:>=, 3) # use Arel\n option_map = {\n :conditions => :where,\n :include => :includes\n }\n query = find_opts.inject(klass.scoped) do |scope, pair|\n key, value = pair\n key = option_map[key] || key\n scope.send(key, pair[1])\n end\n query = query.scoped.where(Utilities.namespaced_column(:id, klass) + ' in (?)', ids)\n # Fix http://breakthebit.org/post/3487560245/rails-3-arel-count-size-length-weirdness\n query.class_eval do\n alias_method :size, :length\n alias_method :count, :length\n end\n query\n else\n klass.find_all_by_id(ids, find_opts)\n end\n end",
"def read(opts = {})\n opts = filter_unsupported_options :ext_read, opts\n opts = filter_sort opts \n\n if opts[:limit] != nil \n if opts[:start] != nil\n opts[:offset] = opts.delete :start\n end\n total = get_total_count opts.clone # total must contains the total number of record without limit/offset\n end\n\n list = @active_record_model.find(:all, opts)\n list.each do |r|\n s = r.attributes\n @response.add_data (s.merge get_association_items(r, opts))\n end\n\n @response.add(:total, total || @response.data.length)\n @response.to_hash\n end",
"def filter!(options)\n @list = ObjectsFilter.new(all, options).objects\n index_by_fullname\n end",
"def find_in_batches(options = {}, &block)\n options = MassiveRecord::Adapters::Thrift::Table.warn_and_change_deprecated_finder_options(options)\n\n options[:batch_size] ||= 1000\n\n if loaded?\n collection = if options[:starts_with]\n proxy_target.select { |r| r.id.starts_with? options[:starts_with] }\n else\n proxy_target\n end\n collection.in_groups_of(options[:batch_size], false, &block)\n elsif find_with_proc?\n find_proxy_target_with_proc(options.merge(:finder_method => :find_in_batches), &block)\n else\n all_ids = proxy_owner.send(metadata.foreign_key)\n all_ids = all_ids.select { |id| id.starts_with? options[:starts_with] } if options[:starts_with]\n all_ids.in_groups_of(options[:batch_size]).each do |ids_in_batch|\n yield Array(find_proxy_target(:ids => ids_in_batch))\n end\n end\n end",
"def execute\n # build the query string\n # run the query\n # return the results\n end"
] | [
"0.64638954",
"0.5721004",
"0.5641033",
"0.55430955",
"0.55430955",
"0.5428115",
"0.5416814",
"0.53459305",
"0.5330626",
"0.53125036",
"0.5263157",
"0.52060485",
"0.519313",
"0.51756084",
"0.5116499",
"0.51153415",
"0.50969154",
"0.50912356",
"0.5089135",
"0.50853956",
"0.5082399",
"0.5078277",
"0.5057126",
"0.50471133",
"0.49975085",
"0.49953538",
"0.49705887",
"0.49638283",
"0.49587673",
"0.49574965",
"0.4950738",
"0.494722",
"0.49294809",
"0.4929188",
"0.49213275",
"0.49053013",
"0.48700914",
"0.4856784",
"0.48454216",
"0.4837364",
"0.48366",
"0.48351496",
"0.48323637",
"0.48270893",
"0.48183838",
"0.4817887",
"0.48027182",
"0.47912067",
"0.47884232",
"0.47786346",
"0.47777516",
"0.4776274",
"0.47489706",
"0.47431967",
"0.47331637",
"0.4726169",
"0.47155344",
"0.4699906",
"0.4691232",
"0.46829757",
"0.46616802",
"0.46609208",
"0.4642891",
"0.46323124",
"0.46120942",
"0.4610439",
"0.46077436",
"0.46051142",
"0.46020037",
"0.4599363",
"0.45974693",
"0.45875654",
"0.45831728",
"0.4580321",
"0.45749244",
"0.45706877",
"0.45664093",
"0.456189",
"0.45411965",
"0.4540423",
"0.4539238",
"0.45315784",
"0.4523195",
"0.45224735",
"0.45201156",
"0.4518869",
"0.4516484",
"0.45104456",
"0.45040298",
"0.4501795",
"0.45007235",
"0.44997156",
"0.448571",
"0.44690314",
"0.4465405",
"0.4465155",
"0.44625857",
"0.44619036",
"0.44552344",
"0.4446596"
] | 0.76387405 | 0 |
Public: Returns a sort clause derived from the group_by column. The order is pulled from available_columns and defaults to ascending. Returns a String SQL clause. | def group_by_sort_clause
return nil unless grouped?
order_clause group_by,
(default_order_for(group_by) || :asc),
(sortable_for(group_by) || true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_by_sort_order\n if grouped? && (column = group_by_column)\n order = sort_criteria_order_for(column.name) || column.default_order\n column.sortable.is_a?(Array) ?\n column.sortable.collect {|s| \"#{s} #{order}\"}.join(',') :\n \"#{column.sortable} #{order}\"\n end\n end",
"def group_by_sort_order\n if grouped? && (column = group_by_column)\n column.sortable.is_a?(Array) ?\n column.sortable.collect {|s| \"#{s} #{column.default_order}\"}.join(',') :\n \"#{column.sortable} #{column.default_order}\"\n end\n end",
"def sort_clause\n sorter.to_sql\n end",
"def sort_criteria_clause\n return nil unless sort_criteria.present?\n sort_criteria.map { |name, order| order_clause(name, order) if name != group_by }.reject(&:blank?).join(',')\n end",
"def order_clause\n col = case sort_params[:sort_col]\n when 'title'\n 'data_management_plans.title'\n when 'funder'\n 'affiliations_fundings.name'\n else\n 'data_management_plans.updated_at'\n end\n { \"#{col}\": :\"#{sort_params[:sort_dir]}\" }\n end",
"def ordering_sql_string\n\t\tif order\n\t\t\torder.collect{|col,dir| absolute_column_name( col ) + ((dir.eql?(:asc))?(''):(' DESC')) if item_class.column_names.include?( col ) }.compact.join(',')\n\t\tend\n\tend",
"def sort_expression\n col = sort_mappings[params[:sort].to_sym] || \n \"#{model_class.table_name}.#{params[:sort]}\"\n \"#{col} #{sort_dir}\"\n end",
"def group_by_columns\n @group = \" GROUP BY #{column_list_for(@columns)}\" if @columns.any?\n end",
"def get_sort_query\n c = get_cookie 'sort'\n if c.blank?\n if @default_sort.blank?\n c = @columns.first.id\n else\n c = @default_sort\n end\n end\n sp = c.split ' '\n ord = sp.second.blank? ? 'asc' : sp.second.downcase\n col = col_by_id sp.first\n @sort = @columns.first\n return nil if c.nil? or col.nil? or !col.sortable?\n @sort = col\n order = (ord == 'desc' ? 'DESC' : 'ASC')\n col.sort_order = order\n return col.db_fullname + \" \" + order\n end",
"def to_cql\n \"ORDER BY #{@field} #{@dir.to_s.upcase}\"\n end",
"def search_get_order_sql(sort_by, order_by, default)\n sql = []\n\n sort_by.each_with_index do |value, index|\n next if value.blank?\n next if order_by[index].blank?\n\n sql.push( \"#{ActiveRecord::Base.connection.quote_table_name(table_name)}.#{ActiveRecord::Base.connection.quote_column_name(value)} #{order_by[index]}\" )\n end\n\n if sql.blank?\n sql.push(\"#{ActiveRecord::Base.connection.quote_table_name(table_name)}.#{ActiveRecord::Base.connection.quote_column_name(default)}\")\n end\n\n sql.join(', ')\n end",
"def search_get_order_select_sql(sort_by, order_by, default)\n sql = []\n\n sort_by.each_with_index do |value, index|\n next if value.blank?\n next if order_by[index].blank?\n\n sql.push( \"#{ActiveRecord::Base.connection.quote_table_name(table_name)}.#{ActiveRecord::Base.connection.quote_column_name(value)}\" )\n end\n\n if sql.blank?\n sql.push(\"#{ActiveRecord::Base.connection.quote_table_name(table_name)}.#{ActiveRecord::Base.connection.quote_column_name(default)}\")\n end\n\n sql.join(', ')\n end",
"def column_order_by\n @@column_order_by\n end",
"def to_group_sql\n case\n when is_many?, is_string?, ThinkingSphinx.use_group_by_shortcut?\n nil\n else\n @columns.collect { |column|\n column_with_prefix(column)\n }\n end\n end",
"def ordering_by\n order && order.to_s.gsub(/^(ascend|descend)_by_/, '')\n end",
"def ordered_expression_sql(oe)\n \"#{literal(oe.expression)} #{oe.descending ? 'DESC' : 'ASC'}\"\n end",
"def calls_sort_option\n column = case params[:iSortCol_0].to_s\n when '1'\n 'number'\n when '2'\n 'caller_id'\n when '3'\n 'providers.name'\n when '4'\n 'answered'\n when '5'\n 'busy'\n when '6'\n 'audio_length'\n when '7'\n 'ring_length'\n end\n column + ' ' + (params[:sSortDir_0] =~ /^A/i ? 'asc' : 'desc') if column\n end",
"def sort_column\n # Schedule.column_names.include?(params[:sort]) ? params[:sort] : \"device_id\"\n %w[devices.name products.name test_plans.name start_time].include?(params[:sort]) ? params[:sort] : \"devices.name\"\n end",
"def typus_order_by\n\n order = []\n\n begin\n fields = self.send(\"admin_order_by\").map { |a| a.to_s }\n rescue\n config = Typus::Configuration.config[self.name]\n return \"`#{self.table_name}`.id ASC\" unless config && config['order_by']\n fields = config['order_by'].split(', ')\n end\n\n fields.each do |field|\n order_by = (field.include?(\"-\")) ? \"`#{self.table_name}`.#{field.delete('-')} DESC\" : \"`#{self.table_name}`.#{field} ASC\"\n order << order_by\n end\n\n return order.join(', ')\n\n end",
"def summary_order_by(params, options)\n case params[:order_by].to_s\n when \"orig_name\" then\n order_by = \"u.first_name\"\n when \"orig_calls\" then\n order_by = \"total_calls\"\n when \"orig_exec_billsec\" then\n order_by = \"exact_billsec\"\n when \"orig_billsec\" then\n order_by = \"originator_billsec\"\n when \"orig_price\" then\n order_by = \"originator_price\"\n\n when \"term_name\" then\n order_by = \"provider_name\"\n when \"term_calls\" then\n order_by = \"total_calls\"\n when \"term_exec_billsec\" then\n order_by = \"exact_billsec\"\n when \"term_billsec\" then\n order_by = \"provider_billsec\"\n when \"term_price\" then\n order_by = \"provider_price\"\n else\n options[:order_by] ? order_by = options[:order_by] : order_by = \"\"\n end\n without = order_by\n\n order_by = \"users.first_name \" + (options[:order_desc] == 1 ? \"DESC\" : \"ASC\") + \", users.last_name\" if order_by.to_s == \"users.first_name\"\n\n order_by += \" ASC\" if options[:order_desc] == 0 and order_by != \"\"\n order_by += \" DESC\" if options[:order_desc] == 1 and order_by != \"\"\n return without, order_by\n end",
"def sort_column\n Order.column_names.include?(params[:sort]) ? params[:sort] : \"updated_at\"\n end",
"def query_sort(query, table, *order_by_params)\n\tquery = \"select #{query} from #{table}\"\n\tif order_by_params != nil\n\t\tquery += \" order by\"\n\t\torder_by_params.each do |param|\n\t\t\tquery += \" #{param}\"\n\t\tend\n\tend\n\treturn query\nend",
"def sort_column\n %w[priority due_at].include?(params[:sort_by]) ? params[:sort_by] : \"due_at\"\n end",
"def ordering_query\n \"#{sql_length}(#{slug_column}) ASC, #{slug_column} ASC\"\n end",
"def get_order_by\n @order_by\n end",
"def column_to_order_by(column)\n @@column_order_by = column || \"updated_at\"\n\n define_method(:column_order_by) do\n @@column_order_by\n end\n end",
"def order_by(*props)\n @query[:order_by] = props.join(',')\n self\n end",
"def sort_column\n Inquiry.column_names.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def sort_by\n if valid_column?(@sort_by)\n @sort_by\n else\n self.class.sortable_attributes.first\n end\n end",
"def sort_column\n EnemyTemplate.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def sort_column\n Race.column_names.include?(params[:sort]) ? params[:sort] : 'name'\n end",
"def sort_column\n Req.column_names.include?(params[:sort]) ? params[:sort] : \"req_total\"\n end",
"def apply_sort(query, table, column_name, allowed, direction)\n validate_query_table_column(query, table, column_name, allowed)\n validate_sorting(column_name, allowed, direction)\n\n # allow sorting by field mappings\n sort_field = @build.build_custom_calculated_field(column_name)&.fetch(:arel)\n sort_field = table[column_name] if sort_field.blank?\n\n if sort_field.is_a? String\n sort_field\n elsif direction == :desc\n Arel::Nodes::Descending.new(sort_field)\n else\n #direction == :asc\n Arel::Nodes::Ascending.new(sort_field)\n end => sort_field_by\n\n query.order(sort_field_by)\n end",
"def sort_column\n Category.column_names.include?(params[:sort]) ? params[:sort] : \"id\"\n end",
"def sort_column\n Comment.column_names.include?(params[:sort]) ? params[:sort] : \"posted_on\"\n end",
"def table_sort_string table_code\n sorting = table_preferences(table_code)[:sort]\n column = sorting.first \n key = column.keys.first \n order_string = (column[key] == :descending) ? \"DESC\" : \"ASC\"\n fallback_key = DEFAULT_TABLE_PREFERENCES[table_code.to_sym][:sort].first.keys[0]\n sort_column = SORT_COLUMN[table_code][key] || SORT_COLUMN[table_code][fallback_key]\n return \"#{sort_column} #{order_string}\"\n end",
"def sort_column\n nil\n end",
"def sort_column\n Adjusthistory.column_names.include?(params[:sort]) ? params[:sort] : \"item_id\"\n end",
"def order_by_column\n return clazz.clustering_columns[0].name if clazz.clustering_columns.length > 0\n clazz.key_columns[0].name\n end",
"def sort_column\n Transaction.column_names.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def sort_column\n Transaction.column_names.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def sort_column\n Battle.column_names.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def sort_col\n params[:sort] || \"name\"\n end",
"def sort_and_order_sql\n {:sort => ATTACH_MAPPING[@sort], :order => @order}\n end",
"def sort_column\n Member.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def sort_column\n Task.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def arel_order\n text_columns = if params[:order]\n params[:order].split(' ')\n elsif self.default_sort\n [self.default_sort].flatten\n else\n [model_class.primary_key].flatten\n end\n sort_columns = text_columns.map do |column|\n if column.to_s.include?('.')\n name,direction = column.to_s.split('.',2)\n raise \"Illegal sort direction: #{direction} in #{column}\" unless %w{asc desc}.include?(direction)\n table[name].send(direction)\n else\n table[column]\n end\n end\n sort_columns\n end",
"def sort_column\n RegionTemplate.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def group_by\n ActiveSupport::StringInquirer.new(@params[:group_by]) unless @params[:group_by].nil?\n end",
"def sort_column\n Doctor.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n Doctor.column_names.include?(params[:sort]) ? params[:sort] : \"address\"\n Doctor.column_names.include?(params[:sort]) ? params[:sort] : \"phone\"\n Doctor.column_names.include?(params[:sort]) ? params[:sort] : \"doctor_type\"\n end",
"def sort_order # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n col = sort_column\n # do a case-insensitive sort if we are sort on last name\n col = \"lower(#{col})\" if col.include?('last_name')\n return Arel.sql(\"#{col} #{sort_direction}\") unless col.include?('enumerations')\n\n klass, method = col.split('.')\n values = klass.singularize.capitalize.constantize.send(method.intern)\n .order(Arel.sql(\"value #{sort_direction} \")).pluck('value')\n order_query = values.each_with_index.inject(+'CASE ') do |memo, (val, i)| # rubocop:disable Style/EachWithObject\n memo << \"WHEN( enumerations.value = '#{val}') THEN #{i} \"\n memo\n end\n Arel.sql(\"#{order_query} ELSE #{values.length} END\")\n end",
"def process_sort_by\n case public_plans_params.fetch(:sort_by, 'featured')\n when 'created_at'\n 'plans.created_at desc'\n when 'title'\n 'TRIM(plans.title) asc'\n else\n 'plans.featured desc, plans.created_at desc'\n end\n end",
"def sort_column\n ItemTemplate.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def sort_column klass, default_column = \"sort_order\"\n klass.constantize.column_names.include?(params[:sort]) ? params[:sort] : default_column\n end",
"def sort_column\n session[:sort] = Stock.column_names.include?(params[:sort]) ? params[:sort] : session[:sort] || \"id\"\n end",
"def order_by *columns\n @order += [columns].flatten\n end",
"def sort_column\n #songs_count is a specific query, so it's not in the Song table\n default = (params[:sort] == \"songs_count\") ? \"songs_count\" : \"name\"\n Song.column_names.include?(params[:sort]) ? params[:sort] : default\n end",
"def order_by(column, order)\n return resource().order(column.to_s + \" \" + order)\n end",
"def sort_column\n Assign.column_names.include?(params[:sort]) ? params[:sort] : \"document_id\"\n end",
"def sort_sql_helper(param)\n return param.gsub('_reverse',\" DESC\")\n end",
"def sort_column\n Document.column_names.include?(params[:sort]) ? params[:sort] : \"id\"\n end",
"def sort_column\n Document.column_names.include?(params[:sort]) ? params[:sort] : \"id\"\n end",
"def order_by\n if params[:order_by]\n if params[:order_by] == 'created_at'\n # If created at, get newest first\n params[:order_by] + ' DESC'\n else\n # Otherwise, get closest to now\n params[:order_by] + ' ASC'\n end\n else\n # Default to start date, ascending\n 'starts_at ASC'\n end\n end",
"def sort_column\n TaskTemplate.column_names.include?(params[:sort]) ? params[:sort] : 'date'\n end",
"def order_by_statement(direction:)\n direction = direction.to_s.upcase\n raise \"Ording direction should be 'asc' or 'desc'\" unless %w[ASC DESC].include?(direction)\n return \"#{degenerate_fragment} #{direction}\" if type == Dimension::TYPES[:degenerate]\n \"#{label_fragment} #{direction}\"\n end",
"def sort_column\n Show.column_names.include?(params[:sort]) ? params[:sort] : \"imdb_rating\"\n end",
"def sorting\n sort_no = 0\n sorts = []\n\n loop do\n sorted = false\n name_col = \"iSortCol_#{sort_no}\"\n name_mode = \"sSortDir_#{sort_no}\"\n sort_col = @dts[name_col]\n break if !sort_col\n\n col_name = @columns[sort_col.to_i]\n next if !col_name\n\n if @dts[name_mode] == \"desc\"\n sort_mode = \"DESC\"\n else\n sort_mode = \"ASC\"\n end\n\n if match = col_name.to_s.match(/^(.+)_id$/)\n method_name = match[1]\n sub_model_name = StringCases.snake_to_camel(col_name.slice(0, col_name.length - 3))\n\n if Kernel.const_defined?(sub_model_name)\n sub_model_const = Kernel.const_get(sub_model_name)\n unless @joins.key?(method_name)\n @query = @query.includes(method_name)\n @joins[method_name] = true\n end\n\n @sort_columns.each do |sort_col_name|\n if sub_model_const.column_names.include?(sort_col_name.to_s)\n sorts << \"`#{sub_model_const.table_name}`.`#{escape_col(sort_col_name)}` #{sort_mode}\"\n sorted = true\n break\n end\n end\n end\n end\n\n if @model.column_names.include?(col_name.to_s)\n sorts << \"`#{@model.table_name}`.`#{escape_col(col_name)}` #{sort_mode}\"\n elsif @args[:sort]\n res = @args[:sort].call(:key => col_name, :sort_mode => sort_mode, :query => @query)\n @query = res if res\n else\n raise \"Unknown sort-column: '#{col_name}'.\"\n end\n\n sort_no += 1\n end\n\n @query = @query.order(sorts.join(\", \"))\n end",
"def sort_column(sort_table)\n if sort_table == \"Artist\"\n Artist.column_names.include?(params[:sort]) ? params[:sort] : \"name_stage\"\n end\n end",
"def sort_by(field_name, dir = 'desc')\n @query_hash[SORT_BY][field_name] = { field_name => dir }\n self\n end",
"def sort_column\n return @_sort_column if @_sort_column\n\n ['name', 'title', 'label', 'subject', 'full_name', 'first_name', 'email', 'number', 'description'].each do |name|\n return name if column_names.include?(name)\n end\n\n klass.primary_key\n end",
"def select_from_order_columns(columns)\n columns.compact.map do |column|\n if column.kind_of?(Arel::Nodes::Ordering)\n column.expr\n else\n column = column.to_sql if column.respond_to?(:to_sql)\n column.kind_of?(String) ? column.gsub(/ (DESC|ASC)/i, '') : column\n end\n end.reject do |column|\n column.kind_of?(Arel::Attributes::Attribute) ||\n column.kind_of?(Symbol) ||\n (column.kind_of?(String) && column =~ /^(\"?[a-z_0-9]+\"?[.])?\"?[a-z_0-9]+\"?$/i)\n end\n end",
"def sort_column\n Note.column_names.include?(params[:sort]) ? params[:sort] : \"updated_at\"\n end",
"def sort_column\n %w(name email role).include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def sort_column\n %w(name email role).include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def sort_column\n Recipe.column_names.include?(params[:sort]) ? params[:sort] : \"title\"\n end",
"def sort_column\n \n @sort_field = ''\n if params[:sort].to_s == MadConstants.donor_name\n @sort_field = 'concat(donours.first_name,donours.last_name)'\n elsif params[:sort].to_s == MadConstants.donation_amount\n @sort_field = 'donations.donation_amount'\n elsif params[:sort].to_s == MadConstants.donation_type\n @sort_field = 'donations.donation_type'\n elsif params[:sort].to_s == MadConstants.product\n @sort_field = 'cfr_products.name'\n elsif params[:sort].to_s == MadConstants.fundraiser_name\n @sort_field = 'users.first_name'\n elsif params[:sort].to_s == MadConstants.donation_status\n @sort_field = 'donations.donation_status'\n elsif params[:sort].to_s == MadConstants.eighty_g_required\n @sort_field = 'donations.eighty_g_required'\n else\n @sort_field = 'donations.id' \n end\n \n Donation.joins(:donour).joins('inner join cfr_products as cfr_products on cfr_products.id = donations.product_id').\n joins('inner join users as users on users.id = donations.fundraiser_id').\n cfr_txn_search(params[:search]).order(@sort_field + ' ' + sort_direction).\n paginate(:per_page => 10, :page => params[:page])\n end",
"def order_by_column\n target_class.clustering_columns.first.name if target_class.clustering_columns.any?\n end",
"def order_by_column\n target_class.clustering_columns.first.name if target_class.clustering_columns.any?\n end",
"def sort_column\n sortable_columns.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def sorting(order_column, options)\n sandbox = options[:sandbox]\n published(sandbox.nil?).interval(options[:interval], sandbox).order_by(order_column)\n end",
"def getSortingOrder #:doc:\n sorting = @default_sorting.dup\n ordering = [\"DESC\", \"ASC\", \"ASC\", \"ASC\"] # default ordering\n \n if @queryparams[:sort_by]\n # get given sort_by-values\n sorts = @queryparams[:sort_by].split(\" \")\n # get given order-values and make sure sorts.size == orders.size\n orders = Array.new(sorts.size, \"DESC\")\n if @queryparams[:order]\n orders = @queryparams[:order].split(\" \")\n if orders.size < sorts.size\n orders += Array.new(sorts.size - orders.size, \"DESC\")\n elsif orders.size > sorts.size\n orders = orders.slice(0, sorts.size)\n end\n orders.each do |o|\n if not (o.upcase == \"ASC\" or o.upcase == \"DESC\") then o = \"ASC\" end\n end \n end\n \n # first sort_by-value has to be processed last (so it gets first on the list)\n sorts = sorts.reverse\n orders = orders.reverse\n \n # check sort_by-values\n sorts.each_index do |i|\n if @sort_by.has_key?(sorts[i])\n # move the sort-attribute to first\n sort_value = @sort_by[sorts[i]]\n ind = sorting.index(\"LOWER(\" + @sort_by[sorts[i]] + \")\")\n if ind != nil\n sorting.delete_at(ind)\n ordering.delete_at(ind)\n sort_value = \"LOWER(\" + sort_value + \")\"\n end\n sorting.unshift(sort_value)\n ordering.unshift(orders[i].upcase)\n end\n end\n end\n \n #combine everything together\n returnable = sorting[0] + \" \" + ordering[0]\n sorting.each_index do |i|\n next if i == 0\n returnable += \", \" + sorting[i] + \" \" + ordering[i]\n end\n return returnable\n end",
"def sort_column_param\n params[:sort_column] || 'entry_date'\n end",
"def get_sort_order (get_param, column_name)\r\n\t\tif params[get_param] && !params[get_param].empty?\r\n\t\t\tif params[get_param].downcase == \"asc\"\r\n\t\t\t\tif column_name.kind_of?(Array)\r\n\t\t\t\t\t\"#{column_name.join(' ASC, ')} ASC\"\r\n\t\t\t\telse\r\n\t\t\t\t\t\"#{column_name} ASC\"\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\tif column_name.kind_of?(Array)\r\n\t\t\t\t\t\"#{column_name.join(' DESC, ')} DESC\"\r\n\t\t\t\telse\r\n\t\t\t\t\t\"#{column_name} DESC\"\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def add_order_by_for_association_limiting!(sql, options)\n return sql if options[:order].blank?\n\n order = options[:order].split(',').collect { |s| s.strip }.reject(&:blank?)\n order.map! {|s| $1 if s =~ / (.*)/}\n order = order.zip((0...order.size).to_a).map { |s,i| \"alias_#{i}__ #{s}\" }.join(', ')\n\n sql << \" ORDER BY #{order}\"\n end",
"def order_column_name\n timestamp_columns = [\"created_on\", \"updated_on\", \"commited_on\"]\n column_names.select {|column_name| timestamp_columns.include?(column_name) }.sort.last || \"id\"\n end",
"def get_ordering_string(params)\n if not params.key?(:sort)\n ordering_string = 'created_at ASC'\n elsif params[:sort] == 'created_at'\n ordering_string = 'created_at ASC'\n elsif params[:sort] == 'rating'\n ordering_string = 'rating DESC'\n end\n return ordering_string\n end",
"def get_group_by\n @group_by\n end",
"def agregate_order_by(params, options)\n case params[:order_by].to_s\n when \"direction\" then\n order_by = \"destinations.direction_code\"\n when \"destination\" then\n order_by = \"destinations.name\"\n when \"customer_orig\" then\n order_by = \"nice_user\"\n when \"customer_term\" then\n order_by = \"terminators.name\"\n when \"billed_orig\" then\n order_by = \"originating_billed\"\n when \"billed_term\" then\n order_by = \"terminating_billed\"\n when \"billsec_orig\" then\n order_by = \"originating_billsec\"\n when \"billsec_term\" then\n order_by = \"terminating_billsec\"\n when \"duration\" then\n order_by = \"duration\"\n when \"answered_calls\" then\n order_by = \"answered_calls\"\n when \"total_calls\" then\n order_by = \"total_calls\"\n when \"asr\" then\n order_by = \"asr\"\n when \"acd\" then\n order_by = \"acd\"\n else\n options[:order_by] ? order_by = options[:order_by] : order_by = \"\"\n end\n\n without = order_by\n order_by = \"users.first_name \" + (options[:order_desc] == 1 ? \"DESC\" : \"ASC\") + \", users.last_name\" if order_by.to_s == \"users.first_name\"\n order_by = \"ds.direction_code \" + (options[:order_desc] == 1 ? \"DESC\" : \"ASC\") + \", ds.name\" if order_by.to_s == \"destinations.name\"\n order_by = \"ds.direction_code \" + (options[:order_desc] == 1 ? \"DESC\" : \"ASC\") + \", ds.subcode\" if order_by.to_s == \"destinations.name\"\n order_by = \"t.name\" if order_by.to_s == \"terminators.name\"\n\n order_by += \" ASC\" if options[:order_desc] == 0 and order_by != \"\"\n order_by += \" DESC\" if options[:order_desc] == 1 and order_by != \"\"\n return without, order_by\n end",
"def sort_by(column)\n column = column.to_s\n\n direction = next_dir(column)\n column = direction && column\n\n { 'sort' => column, 'dir' => direction }\n end",
"def sort_column klass, default_column = \"title_sort\"\n klass.constantize.column_names.include?(params[:sort]) ? params[:sort] : default_column\n end",
"def sort_column klass, default_column = \"title_sort\"\n klass.constantize.column_names.include?(params[:sort]) ? params[:sort] : default_column\n end",
"def generate_sorted_by(request)\n\t\t# Sort the albums based on the \"order\" param from query string\n\t\torder = request.GET()[\"order\"]\n\t\tcase order\n\t\twhen \"rank\" then @albums.sort_by! { |album| album[@@COL_RANK] }\n\t\twhen \"name\" then @albums.sort_by! { |album| album[@@COL_NAME] }\n\t\twhen \"year\" then @albums.sort_by! { |album| album[@@COL_YEAR] }\n\t\telse @albums.sort_by! { |album| album[@@COL_RANK] }\n\t\tend\n\t\t# Return the HTML displaying the sort order\n\t\t\"<p>Sorted by #{order}</p>\"\n\tend",
"def get_sort_col\n unless params[:sortby].nil?\n @sortdir = if @sortcol == params[:sortby].to_i # if same column was selected\n flip_sort_direction(@sortdir)\n else\n \"ASC\"\n end\n @sortcol = params[:sortby].to_i\n end\n # in case sort column is not set, set the defaults\n if @sortcol.nil?\n @sortcol = 0\n @sortdir = \"ASC\"\n end\n params[:is_ascending] = @sortdir.to_s.downcase != \"desc\"\n @sortdir = params[:is_ascending] ? 'ASC' : 'DESC'\n @sortcol\n end",
"def prepared_columns(cols)\n RUBY_VERSION >= '1.9' ? cols.sort : cols.sort_by(&:to_s)\n end",
"def group_by?; @group_by; end",
"def group_by\n @group_by ||= (defaults[:group_by] || [])\n end",
"def distinct(columns, order_by) #:nodoc:\n return \"DISTINCT #{columns}\" if order_by.blank?\n\n # Construct a clean list of column names from the ORDER BY clause, removing\n # any ASC/DESC modifiers\n order_columns = order_by.split(',').collect { |s| s.split.first }\n order_columns.delete_if { |c| c.blank? }\n order_columns = order_columns.zip((0...order_columns.size).to_a).map { |s,i| \"#{s} AS alias_#{i}\" }\n\n # Return a DISTINCT ON() clause that's distinct on the columns we want but includes\n # all the required columns for the ORDER BY to work properly.\n sql = \"DISTINCT ON (#{columns}) #{columns}, \"\n sql << order_columns * ', '\n end",
"def sort_asc(column_name)\n results = CONNECTION.execute(\"SELECT * FROM #{table_name} ORDER BY #{column_name} ASC;\")\n results_as_objects(results)\n end",
"def query_sort(query)\n return query unless has_sort_params?\n\n apply_sort(query, @table, @sorting[:order_by], @valid_fields + @custom_fields2.keys, @sorting[:direction])\n end",
"def order_string\n \"#{params[:sort]} #{params[:direction]}\"\n end"
] | [
"0.7638743",
"0.72135925",
"0.7106896",
"0.69431645",
"0.68971735",
"0.6867724",
"0.67624557",
"0.65752786",
"0.6560675",
"0.6549717",
"0.64147556",
"0.6395926",
"0.63616353",
"0.63315666",
"0.6283763",
"0.6146684",
"0.6107245",
"0.60634905",
"0.6028775",
"0.6024536",
"0.6020289",
"0.60160446",
"0.6005409",
"0.59830886",
"0.59706277",
"0.5966061",
"0.59343517",
"0.5931204",
"0.5930416",
"0.59214276",
"0.5906011",
"0.58878845",
"0.58786154",
"0.5873526",
"0.58690244",
"0.5866922",
"0.5866859",
"0.5846956",
"0.58460593",
"0.58454293",
"0.58454293",
"0.5842639",
"0.58302695",
"0.5825676",
"0.58110154",
"0.58090866",
"0.58049285",
"0.5802963",
"0.57963526",
"0.5795259",
"0.57941777",
"0.57895666",
"0.5786343",
"0.57838064",
"0.5775781",
"0.57748306",
"0.577332",
"0.57722926",
"0.57689774",
"0.5762949",
"0.5751069",
"0.5751069",
"0.57503617",
"0.5748666",
"0.5746815",
"0.5737535",
"0.5735081",
"0.5733198",
"0.5721291",
"0.572128",
"0.5719987",
"0.57133573",
"0.5705094",
"0.5705094",
"0.5685656",
"0.5677466",
"0.56484836",
"0.56484836",
"0.5646083",
"0.56395245",
"0.56283903",
"0.56196445",
"0.560859",
"0.5603337",
"0.5598313",
"0.5583199",
"0.55811614",
"0.5571246",
"0.556123",
"0.5555805",
"0.5555805",
"0.5548954",
"0.554286",
"0.5538917",
"0.5535401",
"0.553372",
"0.55264956",
"0.5526014",
"0.5524188",
"0.5520491"
] | 0.8168596 | 0 |
Public: Returns a sort clause derived from the sort_criteria. The group_by column is always removed, since it will be handled separately. Returns a String SQL clause. | def sort_criteria_clause
return nil unless sort_criteria.present?
sort_criteria.map { |name, order| order_clause(name, order) if name != group_by }.reject(&:blank?).join(',')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_by_sort_clause\n return nil unless grouped?\n order_clause group_by, \n (default_order_for(group_by) || :asc), \n (sortable_for(group_by) || true)\n end",
"def group_by_sort_order\n if grouped? && (column = group_by_column)\n order = sort_criteria_order_for(column.name) || column.default_order\n column.sortable.is_a?(Array) ?\n column.sortable.collect {|s| \"#{s} #{order}\"}.join(',') :\n \"#{column.sortable} #{order}\"\n end\n end",
"def sort_clause\n sorter.to_sql\n end",
"def sort_expression\n col = sort_mappings[params[:sort].to_sym] || \n \"#{model_class.table_name}.#{params[:sort]}\"\n \"#{col} #{sort_dir}\"\n end",
"def order_clause\n col = case sort_params[:sort_col]\n when 'title'\n 'data_management_plans.title'\n when 'funder'\n 'affiliations_fundings.name'\n else\n 'data_management_plans.updated_at'\n end\n { \"#{col}\": :\"#{sort_params[:sort_dir]}\" }\n end",
"def group_by_sort_order\n if grouped? && (column = group_by_column)\n column.sortable.is_a?(Array) ?\n column.sortable.collect {|s| \"#{s} #{column.default_order}\"}.join(',') :\n \"#{column.sortable} #{column.default_order}\"\n end\n end",
"def get_sort_query\n c = get_cookie 'sort'\n if c.blank?\n if @default_sort.blank?\n c = @columns.first.id\n else\n c = @default_sort\n end\n end\n sp = c.split ' '\n ord = sp.second.blank? ? 'asc' : sp.second.downcase\n col = col_by_id sp.first\n @sort = @columns.first\n return nil if c.nil? or col.nil? or !col.sortable?\n @sort = col\n order = (ord == 'desc' ? 'DESC' : 'ASC')\n col.sort_order = order\n return col.db_fullname + \" \" + order\n end",
"def ordering_sql_string\n\t\tif order\n\t\t\torder.collect{|col,dir| absolute_column_name( col ) + ((dir.eql?(:asc))?(''):(' DESC')) if item_class.column_names.include?( col ) }.compact.join(',')\n\t\tend\n\tend",
"def sort_criteria\n @sort_criteria ||=\n sort_params.reduce('') do |sum, (key, value)|\n comparables = [\"a[:#{key}]\", \"b[:#{key}]\"]\n comparables.reverse! if value == :desc\n sum + \"comp = comp == 0 ? #{comparables.join(' <=> ')} : comp; \"\n end\n end",
"def to_cql\n \"ORDER BY #{@field} #{@dir.to_s.upcase}\"\n end",
"def ordered_expression_sql(oe)\n \"#{literal(oe.expression)} #{oe.descending ? 'DESC' : 'ASC'}\"\n end",
"def ordering_by\n order && order.to_s.gsub(/^(ascend|descend)_by_/, '')\n end",
"def sort_column\n Order.column_names.include?(params[:sort]) ? params[:sort] : \"updated_at\"\n end",
"def search_get_order_sql(sort_by, order_by, default)\n sql = []\n\n sort_by.each_with_index do |value, index|\n next if value.blank?\n next if order_by[index].blank?\n\n sql.push( \"#{ActiveRecord::Base.connection.quote_table_name(table_name)}.#{ActiveRecord::Base.connection.quote_column_name(value)} #{order_by[index]}\" )\n end\n\n if sql.blank?\n sql.push(\"#{ActiveRecord::Base.connection.quote_table_name(table_name)}.#{ActiveRecord::Base.connection.quote_column_name(default)}\")\n end\n\n sql.join(', ')\n end",
"def sort_and_order_sql\n {:sort => ATTACH_MAPPING[@sort], :order => @order}\n end",
"def sort_column\n Comment.column_names.include?(params[:sort]) ? params[:sort] : \"posted_on\"\n end",
"def get_ordering_string(params)\n if not params.key?(:sort)\n ordering_string = 'created_at ASC'\n elsif params[:sort] == 'created_at'\n ordering_string = 'created_at ASC'\n elsif params[:sort] == 'rating'\n ordering_string = 'rating DESC'\n end\n return ordering_string\n end",
"def sort_column\n \n @sort_field = ''\n if params[:sort].to_s == MadConstants.donor_name\n @sort_field = 'concat(donours.first_name,donours.last_name)'\n elsif params[:sort].to_s == MadConstants.donation_amount\n @sort_field = 'donations.donation_amount'\n elsif params[:sort].to_s == MadConstants.donation_type\n @sort_field = 'donations.donation_type'\n elsif params[:sort].to_s == MadConstants.product\n @sort_field = 'cfr_products.name'\n elsif params[:sort].to_s == MadConstants.fundraiser_name\n @sort_field = 'users.first_name'\n elsif params[:sort].to_s == MadConstants.donation_status\n @sort_field = 'donations.donation_status'\n elsif params[:sort].to_s == MadConstants.eighty_g_required\n @sort_field = 'donations.eighty_g_required'\n else\n @sort_field = 'donations.id' \n end\n \n Donation.joins(:donour).joins('inner join cfr_products as cfr_products on cfr_products.id = donations.product_id').\n joins('inner join users as users on users.id = donations.fundraiser_id').\n cfr_txn_search(params[:search]).order(@sort_field + ' ' + sort_direction).\n paginate(:per_page => 10, :page => params[:page])\n end",
"def search_get_order_select_sql(sort_by, order_by, default)\n sql = []\n\n sort_by.each_with_index do |value, index|\n next if value.blank?\n next if order_by[index].blank?\n\n sql.push( \"#{ActiveRecord::Base.connection.quote_table_name(table_name)}.#{ActiveRecord::Base.connection.quote_column_name(value)}\" )\n end\n\n if sql.blank?\n sql.push(\"#{ActiveRecord::Base.connection.quote_table_name(table_name)}.#{ActiveRecord::Base.connection.quote_column_name(default)}\")\n end\n\n sql.join(', ')\n end",
"def sort_sql_helper(param)\n return param.gsub('_reverse',\" DESC\")\n end",
"def sort_column\n # Schedule.column_names.include?(params[:sort]) ? params[:sort] : \"device_id\"\n %w[devices.name products.name test_plans.name start_time].include?(params[:sort]) ? params[:sort] : \"devices.name\"\n end",
"def order_string\n \"#{params[:sort]} #{params[:direction]}\"\n end",
"def sort_col\n params[:sort] || \"name\"\n end",
"def sort_column\n Transaction.column_names.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def sort_column\n Transaction.column_names.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def query_sort(query, table, *order_by_params)\n\tquery = \"select #{query} from #{table}\"\n\tif order_by_params != nil\n\t\tquery += \" order by\"\n\t\torder_by_params.each do |param|\n\t\t\tquery += \" #{param}\"\n\t\tend\n\tend\n\treturn query\nend",
"def sorting\n sort_no = 0\n sorts = []\n\n loop do\n sorted = false\n name_col = \"iSortCol_#{sort_no}\"\n name_mode = \"sSortDir_#{sort_no}\"\n sort_col = @dts[name_col]\n break if !sort_col\n\n col_name = @columns[sort_col.to_i]\n next if !col_name\n\n if @dts[name_mode] == \"desc\"\n sort_mode = \"DESC\"\n else\n sort_mode = \"ASC\"\n end\n\n if match = col_name.to_s.match(/^(.+)_id$/)\n method_name = match[1]\n sub_model_name = StringCases.snake_to_camel(col_name.slice(0, col_name.length - 3))\n\n if Kernel.const_defined?(sub_model_name)\n sub_model_const = Kernel.const_get(sub_model_name)\n unless @joins.key?(method_name)\n @query = @query.includes(method_name)\n @joins[method_name] = true\n end\n\n @sort_columns.each do |sort_col_name|\n if sub_model_const.column_names.include?(sort_col_name.to_s)\n sorts << \"`#{sub_model_const.table_name}`.`#{escape_col(sort_col_name)}` #{sort_mode}\"\n sorted = true\n break\n end\n end\n end\n end\n\n if @model.column_names.include?(col_name.to_s)\n sorts << \"`#{@model.table_name}`.`#{escape_col(col_name)}` #{sort_mode}\"\n elsif @args[:sort]\n res = @args[:sort].call(:key => col_name, :sort_mode => sort_mode, :query => @query)\n @query = res if res\n else\n raise \"Unknown sort-column: '#{col_name}'.\"\n end\n\n sort_no += 1\n end\n\n @query = @query.order(sorts.join(\", \"))\n end",
"def sort_column\n %w[priority due_at].include?(params[:sort_by]) ? params[:sort_by] : \"due_at\"\n end",
"def process_sort_by\n case public_plans_params.fetch(:sort_by, 'featured')\n when 'created_at'\n 'plans.created_at desc'\n when 'title'\n 'TRIM(plans.title) asc'\n else\n 'plans.featured desc, plans.created_at desc'\n end\n end",
"def sort_by\n unless params[:sort].blank?\n params[:sort] if params[:sort] == 'created_at' || 'vote_score' || 'replies'\n else\n 'created_at'\n end\n end",
"def calls_sort_option\n column = case params[:iSortCol_0].to_s\n when '1'\n 'number'\n when '2'\n 'caller_id'\n when '3'\n 'providers.name'\n when '4'\n 'answered'\n when '5'\n 'busy'\n when '6'\n 'audio_length'\n when '7'\n 'ring_length'\n end\n column + ' ' + (params[:sSortDir_0] =~ /^A/i ? 'asc' : 'desc') if column\n end",
"def sort_column\n Inquiry.column_names.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def getSortingOrder #:doc:\n sorting = @default_sorting.dup\n ordering = [\"DESC\", \"ASC\", \"ASC\", \"ASC\"] # default ordering\n \n if @queryparams[:sort_by]\n # get given sort_by-values\n sorts = @queryparams[:sort_by].split(\" \")\n # get given order-values and make sure sorts.size == orders.size\n orders = Array.new(sorts.size, \"DESC\")\n if @queryparams[:order]\n orders = @queryparams[:order].split(\" \")\n if orders.size < sorts.size\n orders += Array.new(sorts.size - orders.size, \"DESC\")\n elsif orders.size > sorts.size\n orders = orders.slice(0, sorts.size)\n end\n orders.each do |o|\n if not (o.upcase == \"ASC\" or o.upcase == \"DESC\") then o = \"ASC\" end\n end \n end\n \n # first sort_by-value has to be processed last (so it gets first on the list)\n sorts = sorts.reverse\n orders = orders.reverse\n \n # check sort_by-values\n sorts.each_index do |i|\n if @sort_by.has_key?(sorts[i])\n # move the sort-attribute to first\n sort_value = @sort_by[sorts[i]]\n ind = sorting.index(\"LOWER(\" + @sort_by[sorts[i]] + \")\")\n if ind != nil\n sorting.delete_at(ind)\n ordering.delete_at(ind)\n sort_value = \"LOWER(\" + sort_value + \")\"\n end\n sorting.unshift(sort_value)\n ordering.unshift(orders[i].upcase)\n end\n end\n end\n \n #combine everything together\n returnable = sorting[0] + \" \" + ordering[0]\n sorting.each_index do |i|\n next if i == 0\n returnable += \", \" + sorting[i] + \" \" + ordering[i]\n end\n return returnable\n end",
"def sort_column\n %w(name email role).include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def sort_column\n %w(name email role).include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def sort_column\n Battle.column_names.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def sort_column\n Category.column_names.include?(params[:sort]) ? params[:sort] : \"id\"\n end",
"def sort_column\n Race.column_names.include?(params[:sort]) ? params[:sort] : 'name'\n end",
"def sort_column\n EnemyTemplate.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def table_sort_string table_code\n sorting = table_preferences(table_code)[:sort]\n column = sorting.first \n key = column.keys.first \n order_string = (column[key] == :descending) ? \"DESC\" : \"ASC\"\n fallback_key = DEFAULT_TABLE_PREFERENCES[table_code.to_sym][:sort].first.keys[0]\n sort_column = SORT_COLUMN[table_code][key] || SORT_COLUMN[table_code][fallback_key]\n return \"#{sort_column} #{order_string}\"\n end",
"def sort_column\n Doctor.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n Doctor.column_names.include?(params[:sort]) ? params[:sort] : \"address\"\n Doctor.column_names.include?(params[:sort]) ? params[:sort] : \"phone\"\n Doctor.column_names.include?(params[:sort]) ? params[:sort] : \"doctor_type\"\n end",
"def query_sort(query)\n return query unless has_sort_params?\n\n apply_sort(query, @table, @sorting[:order_by], @valid_fields + @custom_fields2.keys, @sorting[:direction])\n end",
"def sort_column klass, default_column = \"sort_order\"\n klass.constantize.column_names.include?(params[:sort]) ? params[:sort] : default_column\n end",
"def sort_column\n Assign.column_names.include?(params[:sort]) ? params[:sort] : \"document_id\"\n end",
"def sort_column(sort_table)\n if sort_table == \"Artist\"\n Artist.column_names.include?(params[:sort]) ? params[:sort] : \"name_stage\"\n end\n end",
"def sort_column\n %w[fullname school].include?(params[:sort]) ? params[:sort]: \"created_at\"\n end",
"def sort_column\n Member.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def order_by(*props)\n @query[:order_by] = props.join(',')\n self\n end",
"def sort_column\n Note.column_names.include?(params[:sort]) ? params[:sort] : \"updated_at\"\n end",
"def sort_column\n TaskTemplate.column_names.include?(params[:sort]) ? params[:sort] : 'date'\n end",
"def typus_order_by\n\n order = []\n\n begin\n fields = self.send(\"admin_order_by\").map { |a| a.to_s }\n rescue\n config = Typus::Configuration.config[self.name]\n return \"`#{self.table_name}`.id ASC\" unless config && config['order_by']\n fields = config['order_by'].split(', ')\n end\n\n fields.each do |field|\n order_by = (field.include?(\"-\")) ? \"`#{self.table_name}`.#{field.delete('-')} DESC\" : \"`#{self.table_name}`.#{field} ASC\"\n order << order_by\n end\n\n return order.join(', ')\n\n end",
"def summary_order_by(params, options)\n case params[:order_by].to_s\n when \"orig_name\" then\n order_by = \"u.first_name\"\n when \"orig_calls\" then\n order_by = \"total_calls\"\n when \"orig_exec_billsec\" then\n order_by = \"exact_billsec\"\n when \"orig_billsec\" then\n order_by = \"originator_billsec\"\n when \"orig_price\" then\n order_by = \"originator_price\"\n\n when \"term_name\" then\n order_by = \"provider_name\"\n when \"term_calls\" then\n order_by = \"total_calls\"\n when \"term_exec_billsec\" then\n order_by = \"exact_billsec\"\n when \"term_billsec\" then\n order_by = \"provider_billsec\"\n when \"term_price\" then\n order_by = \"provider_price\"\n else\n options[:order_by] ? order_by = options[:order_by] : order_by = \"\"\n end\n without = order_by\n\n order_by = \"users.first_name \" + (options[:order_desc] == 1 ? \"DESC\" : \"ASC\") + \", users.last_name\" if order_by.to_s == \"users.first_name\"\n\n order_by += \" ASC\" if options[:order_desc] == 0 and order_by != \"\"\n order_by += \" DESC\" if options[:order_desc] == 1 and order_by != \"\"\n return without, order_by\n end",
"def sort_column\n sortable_columns.include?(params[:sort]) ? params[:sort] : \"created_at\"\n end",
"def sort_column\n Adjusthistory.column_names.include?(params[:sort]) ? params[:sort] : \"item_id\"\n end",
"def sort_column\n ItemTemplate.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def apply_sorting(relation)\n relation.order(@q.sorting.to_sql)\n end",
"def sort_param(log_param_name: 'time', mode: :desc)\n \"sort:!(#{escape(log_param_name)},#{mode})\"\n end",
"def sort_order # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n col = sort_column\n # do a case-insensitive sort if we are sort on last name\n col = \"lower(#{col})\" if col.include?('last_name')\n return Arel.sql(\"#{col} #{sort_direction}\") unless col.include?('enumerations')\n\n klass, method = col.split('.')\n values = klass.singularize.capitalize.constantize.send(method.intern)\n .order(Arel.sql(\"value #{sort_direction} \")).pluck('value')\n order_query = values.each_with_index.inject(+'CASE ') do |memo, (val, i)| # rubocop:disable Style/EachWithObject\n memo << \"WHEN( enumerations.value = '#{val}') THEN #{i} \"\n memo\n end\n Arel.sql(\"#{order_query} ELSE #{values.length} END\")\n end",
"def sort_column\n Recipe.column_names.include?(params[:sort]) ? params[:sort] : \"title\"\n end",
"def ordering_query\n \"#{sql_length}(#{slug_column}) ASC, #{slug_column} ASC\"\n end",
"def sort_column_param\n params[:sort_column] || 'entry_date'\n end",
"def apply_sort(query, table, column_name, allowed, direction)\n validate_query_table_column(query, table, column_name, allowed)\n validate_sorting(column_name, allowed, direction)\n\n # allow sorting by field mappings\n sort_field = @build.build_custom_calculated_field(column_name)&.fetch(:arel)\n sort_field = table[column_name] if sort_field.blank?\n\n if sort_field.is_a? String\n sort_field\n elsif direction == :desc\n Arel::Nodes::Descending.new(sort_field)\n else\n #direction == :asc\n Arel::Nodes::Ascending.new(sort_field)\n end => sort_field_by\n\n query.order(sort_field_by)\n end",
"def sort_column klass, default_column = \"title_sort\"\n klass.constantize.column_names.include?(params[:sort]) ? params[:sort] : default_column\n end",
"def sort_column klass, default_column = \"title_sort\"\n klass.constantize.column_names.include?(params[:sort]) ? params[:sort] : default_column\n end",
"def sort_column\n Task.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def sort_column\n Document.column_names.include?(params[:sort]) ? params[:sort] : \"id\"\n end",
"def sort_column\n Document.column_names.include?(params[:sort]) ? params[:sort] : \"id\"\n end",
"def sort_column\n RegionTemplate.column_names.include?(params[:sort]) ? params[:sort] : \"name\"\n end",
"def arel_order\n text_columns = if params[:order]\n params[:order].split(' ')\n elsif self.default_sort\n [self.default_sort].flatten\n else\n [model_class.primary_key].flatten\n end\n sort_columns = text_columns.map do |column|\n if column.to_s.include?('.')\n name,direction = column.to_s.split('.',2)\n raise \"Illegal sort direction: #{direction} in #{column}\" unless %w{asc desc}.include?(direction)\n table[name].send(direction)\n else\n table[column]\n end\n end\n sort_columns\n end",
"def sort(sort)\n self.query.sort = sort\n self.query.sort_descending = false\n self\n end",
"def sort_column\n Req.column_names.include?(params[:sort]) ? params[:sort] : \"req_total\"\n end",
"def build_sort_link(text, sort)\n link_to(text, :sort => sort, \n :order => params[:order] == 'desc' ? 'asc' : 'desc', \n :page => params[:page] ||= 1, \n :daysprune => params[:daysprune] ||= -1\n )\n end",
"def condition_sort(input)\n poke_name = input.poke_name\n product_db = SearchRecord::For.klass(Entity::Product)\n case input.sort\n when 'id'\n product_db.find_full_name(poke_name)\n when 'likes_DESC'\n product_db.order_by_desc_likes(poke_name)\n when 'likes_ASC'\n product_db.order_by_asc_likes(poke_name)\n when 'rating_DESC'\n product_db.order_by_desc_rating(poke_name)\n when 'rating_ASC'\n product_db.order_by_asc_rating(poke_name)\n when 'price_DESC'\n product_db.order_by_desc_price(poke_name)\n else\n # priceASC\n product_db.order_by_asc_price(poke_name)\n end\n end",
"def custom_sort(condition, sort, user_id)\n # param\n default_sort_master = SearchForm.sort_master\n is_default_sort = [*(-1 * default_sort_master.length...0)].map(&:to_s).include?(sort)\n # order by\n if is_default_sort\n default_sort(condition, default_sort_master, sort)\n else\n score_sort(condition, sort, user_id)\n end\n end",
"def sort_by\n if valid_column?(@sort_by)\n @sort_by\n else\n self.class.sortable_attributes.first\n end\n end",
"def sort_column\n session[:sort] = Stock.column_names.include?(params[:sort]) ? params[:sort] : session[:sort] || \"id\"\n end",
"def set_conditions_and_sort_order(query, sdb_type)\n conditions = [\"simpledb_type = '#{sdb_type}'\"]\n # look for query.order.first and insure in conditions\n # raise if order if greater than 1\n\n if query.order && query.order.length > 0\n query_object = query.order[0]\n #anything sorted on must be a condition for SDB\n conditions << \"#{query_object.property.name} IS NOT NULL\" \n order = \"order by #{query_object.property.name} #{query_object.direction}\"\n else\n order = \"\"\n end\n\n query.conditions.each do |operator, attribute, value|\n operator = case operator\n when :eql then '='\n when :not then '!='\n when :gt then '>'\n when :gte then '>='\n when :lt then '<'\n when :lte then '<='\n else raise \"Invalid query operator: #{operator.inspect}\" \n end\n conditions << \"#{attribute.name} #{operator} '#{value}'\"\n end\n [conditions,order]\n end",
"def basic_lab_tests_sort_filter(sort_order, sort_by)\n sort_filter = []\n # Default: sort by name ASC\n sort_by = 'name' if !sort_by || !%w(id, name).include?(sort_by.to_s)\n sort_order = 'asc' if !sort_order || !%w(asc, desc).include?(sort_order.to_s)\n\n case sort_by\n when 'id'\n sort_filter.push(id: { order: sort_order })\n when 'name'\n sort_filter.push(name: { order: sort_order })\n end\n sort_filter\n end",
"def sort_column\n nil\n end",
"def apply_sorting_to_relation(rel)\n return rel if !params[:sort]\n\n sorts = params[:sort].split(',')\n\n sorts.each do |sort|\n if sort =~ /^([-+]?)(.*)$/\n desc = ($1 && $1 == '-')\n attrname = $2\n\n (attr, path) = rel.nested_attribute(attrname)\n\n rel = rel.joins { path[1..-1].inject(self.__send__(path[0]).outer) { |a,x| a.__send__(x).outer } } if path.any?\n\n # Call .asc explicitly to overcome a bug in pgsql adapter leading to undefined method to_sql\n attr = desc ? attr.desc : attr.asc\n\n rel = rel.order(attr)\n end\n end\n\n rel\n end",
"def sort_column\n params[:sort] || \"last_name\"\n end",
"def sort_and_group\n @customer_sort_field = validate_sort_field( @customer_sort_field )\n @project_sort_field = validate_sort_field( @project_sort_field )\n @task_sort_field = validate_sort_field( @task_sort_field )\n\n @filtered_tasks.sort! do | task_a, task_b |\n complex_sort(\n task_a,\n task_b,\n {\n :group_by_billable => ( @task_grouping == 'billable' || @task_grouping == 'both' ),\n :group_by_active => ( @task_grouping == 'active' || @task_grouping == 'both' ),\n :customer_sort_field => @customer_sort_field,\n :project_sort_field => @project_sort_field,\n :task_sort_field => @task_sort_field\n }\n )\n end\n end",
"def clauses\n { sortby: sort_by_params, limit: limit_params }.compact\n end",
"def order_by_statement(direction:)\n direction = direction.to_s.upcase\n raise \"Ording direction should be 'asc' or 'desc'\" unless %w[ASC DESC].include?(direction)\n return \"#{degenerate_fragment} #{direction}\" if type == Dimension::TYPES[:degenerate]\n \"#{label_fragment} #{direction}\"\n end",
"def sort_column\n %w[title year].include?(params[:sort]) ? params[:sort] : \"year\"\n end",
"def to_group_sql\n case\n when is_many?, is_string?, ThinkingSphinx.use_group_by_shortcut?\n nil\n else\n @columns.collect { |column|\n column_with_prefix(column)\n }\n end\n end",
"def sort_by(field_name, dir = 'desc')\n @query_hash[SORT_BY][field_name] = { field_name => dir }\n self\n end",
"def sort_column\n #songs_count is a specific query, so it's not in the Song table\n default = (params[:sort] == \"songs_count\") ? \"songs_count\" : \"name\"\n Song.column_names.include?(params[:sort]) ? params[:sort] : default\n end",
"def get_order_by\n @order_by\n end",
"def get_list_order(sort, dir)\n\t\t\tif sort\n\t\t\t\tcolumn_order_mapping = get_sext_constant('SEXT_COLUMN_ORDER_MAPPING')\n\n\t\t\t\t# Lookup and use the designated ordering if defined in the model.\n\t\t \t\tif column_order_mapping && column_order_mapping.has_key?(sort.to_sym)\n\t\t \t\t\tsort = column_order_mapping[sort.to_sym]\n\n\t\t \t\t# Use the passed in value if it looks complete with table name.\n \t\t\t\telsif !sort.include?('.')\n\t\t\t\t\tsort = [self.table_name, sort].join('.')\n\t\t \t\tend\n\n\t\t\t\tdir ||= \"ASC\"\n\t\t \t\torder = sort + \" \" + dir\n\t\t \telse\n\t\t \t\torder = get_sext_constant('SEXT_DEFAULT_SORT')\n\t\t \tend\n\t\t \t\n\t\t\treturn order\t\n\t\tend",
"def sort_column\n Show.column_names.include?(params[:sort]) ? params[:sort] : \"imdb_rating\"\n end",
"def order_by\n if params[:order_by]\n if params[:order_by] == 'created_at'\n # If created at, get newest first\n params[:order_by] + ' DESC'\n else\n # Otherwise, get closest to now\n params[:order_by] + ' ASC'\n end\n else\n # Default to start date, ascending\n 'starts_at ASC'\n end\n end",
"def sort_order\n sort_string = params[:sort]\n if sort_string\n split = sort_string.split '_'\n sort_field = split[0]\n sort_dir = split[1]\n return {sort_field.to_sym => sort_dir}\n end\n return {text: :asc}\n end",
"def index_sort_order\n @query = {}\n @query['sort_key'] = params['sort_key'] unless params['sort_key'].blank?\n\n if @query['sort_key']&.starts_with?('-')\n \"#{@query['sort_key'].delete_prefix('-')} DESC\"\n elsif @query['sort_key'].present?\n \"#{@query['sort_key']} ASC\"\n else\n 'updated_at DESC'\n end\n end",
"def add_order_by_for_association_limiting!(sql, options)\n return sql if options[:order].blank?\n\n order = options[:order].split(',').collect { |s| s.strip }.reject(&:blank?)\n order.map! {|s| $1 if s =~ / (.*)/}\n order = order.zip((0...order.size).to_a).map { |s,i| \"alias_#{i}__ #{s}\" }.join(', ')\n\n sql << \" ORDER BY #{order}\"\n end",
"def apply_sorting(query, sort_params)\n (sort_params[:sort] || {}).each do |idx, order|\n order = (order.to_i % 2 == 0) ? :asc : :desc\n filter = ajax_filters.find { |f| f.position == idx.to_i }\n\n next if filter.blank?\n\n klass = filter.klass || query.klass\n column = filter.column\n\n if filter.sorter_query.present?\n query = filter.sorter_query.call(query, order)\n else\n query = query.reorder(\"#{klass.table_name}.#{column} #{order} NULLS LAST\")\n end\n end\n\n query\n end",
"def sort\n (@params[:sort] || :created_at).to_sym\n end",
"def sort_table column, human_name, date_param = nil\n\t\thtml = \"\"\n\t\t\n\t\t# if already sorting by this column then it reverses the sort\n\t\tif (request.url.include? column) && !(request.url.include? \"DESC\")\n\t\t\tif date_param\n\t\t\t\t# TODO: Return from this depth, makes for a simpler function\n\t\t\t\thtml << (link_to human_name, :sort => column + \" DESC\", :date => date_param).html_safe\n\t\t\telse\n\t\t\t\thtml << (link_to human_name, :sort => column + \" DESC\").html_safe\n\t\t\tend\n\t\telse\n\t\t\tif date_param\n\t\t\t\thtml << (link_to human_name, :sort => column, :date => date_param).html_safe\n\t\t\telse\n\t\t\t\thtml << (link_to human_name, :sort => column).html_safe\n\t\t\tend\n\t\tend\n\t\t\n\t\thtml.html_safe\n\tend",
"def sort_to_string(sort)\n parts = sort.split(' ')\n return I18n.t('search.index.sort_unknown') unless parts.count == 2\n \n method = parts[0] \n dir = I18n.t(\"search.index.sort_#{parts[1]}\")\n \n method_spec = case method\n when 'score'\n I18n.t('search.index.sort_score')\n when 'title_sort'\n \"#{Document.human_attribute_name('title')} #{dir}\"\n when 'authors_sort'\n \"#{Document.human_attribute_name('authors')} #{dir}\"\n when 'journal_sort'\n \"#{Document.human_attribute_name('journal')} #{dir}\"\n when 'year_sort'\n \"#{Document.human_attribute_name('year')} #{dir}\"\n end\n \n \"#{I18n.t('search.index.sort_prefix')} #{method_spec}\"\n end",
"def order\n \"#{sort} #{dir}\"\n end"
] | [
"0.8171751",
"0.75231844",
"0.75152755",
"0.72794294",
"0.712665",
"0.69320977",
"0.67540526",
"0.6722316",
"0.64181525",
"0.6412818",
"0.6266479",
"0.6257415",
"0.6170133",
"0.6163118",
"0.6131297",
"0.610832",
"0.6092351",
"0.6063083",
"0.6060084",
"0.60569334",
"0.60569286",
"0.6051177",
"0.60365456",
"0.60338736",
"0.60338736",
"0.60302526",
"0.6020707",
"0.6018168",
"0.60157305",
"0.6009043",
"0.60044056",
"0.5989894",
"0.5988495",
"0.59850466",
"0.59850466",
"0.5965103",
"0.5948063",
"0.59456104",
"0.59328073",
"0.5923524",
"0.5912442",
"0.5903891",
"0.58991516",
"0.58983105",
"0.5895859",
"0.58926964",
"0.5890041",
"0.5885187",
"0.58844155",
"0.5878441",
"0.5873453",
"0.5872353",
"0.58711845",
"0.58669955",
"0.585536",
"0.5849096",
"0.5848375",
"0.5845318",
"0.58342123",
"0.5821721",
"0.58200884",
"0.5818133",
"0.5812712",
"0.5812712",
"0.5812471",
"0.5811764",
"0.5811764",
"0.581031",
"0.5807383",
"0.5807359",
"0.580655",
"0.57901466",
"0.57865566",
"0.57775",
"0.5770587",
"0.5742723",
"0.57400537",
"0.57220685",
"0.57018983",
"0.570084",
"0.56938154",
"0.5688777",
"0.5687865",
"0.56855184",
"0.567621",
"0.56725365",
"0.5670849",
"0.56611776",
"0.5659824",
"0.5654265",
"0.565078",
"0.5647584",
"0.56467944",
"0.5640297",
"0.563846",
"0.561109",
"0.5600183",
"0.5591595",
"0.558692",
"0.55842185"
] | 0.76524013 | 1 |
Returns a SQL clause for a date or datetime field. | def date_clause(table, field, from, to)
s = []
s << ("#{table}.#{field} > '%s'" % [connection.quoted_date((from - 1).to_time.end_of_day)]) if from
s << ("#{table}.#{field} <= '%s'" % [connection.quoted_date(to.to_time.end_of_day)]) if to
s.join(' AND ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_clause(table, field, from, to)\n s = []\n if from\n from_yesterday = from - 1\n from_yesterday_time = Time.local(from_yesterday.year, from_yesterday.month, from_yesterday.day)\n if self.class.default_timezone == :utc\n from_yesterday_time = from_yesterday_time.utc\n end\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date(from_yesterday_time.end_of_day)])\n end\n if to\n to_time = Time.local(to.year, to.month, to.day)\n if self.class.default_timezone == :utc\n to_time = to_time.utc\n end\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date(to_time.end_of_day)])\n end\n s.join(' AND ')\n end",
"def date_clause_with_date_column(table, field, from, to, is_custom_filter)\n if (date?(from) || date?(to)) && DATE_TYPES.include?(ColumnType.for(table, field))\n s = []\n condition_pattern = \"#{table}.#{field} %s '%s'\"\n s << condition_pattern % ['>', end_day(from.yesterday)] if from\n s << condition_pattern % ['<=', end_day(to)] if to\n return s.join(' AND ')\n end\n date_clause_without_date_column(table, field, from, to, is_custom_filter)\n end",
"def sql(options = {})\n options = normalize_options(options)\n ret = \"\"\n\n if exact_date?(options)\n\tret += \"#{column} = '#{self.from_date(options)}' \"\n else\n\tret += \"#{column} >= '#{self.from_date(options)}' AND \"\t\n\tret += \"#{column} <= '#{self.to_date(options)}' \"\t\n end\n\n raise \"not time selection supported yet '#{range(options)}' please use beginning and end.\" if from_time or to_time\n\n return nil if ret == \"\"\n return ret\n end",
"def date_clause(table, field, from, to)\n s = []\n if from\n from_yesterday = from - 1\n from_yesterday_utc = Time.gm(from_yesterday.year, from_yesterday.month, from_yesterday.day)\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date(from_yesterday_utc.end_of_day)])\n end\n if to\n to_utc = Time.gm(to.year, to.month, to.day)\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date(to_utc.end_of_day)])\n end\n s.join(' AND ')\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \")\"\n when \"!\"\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \"))\"\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n when \"<=\"\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n when \"o\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}\" if field == \"status_id\"\n when \"c\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}\" if field == \"status_id\"\n when \">t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = date_range_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = date_range_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = date_range_clause(db_table, db_field, 0, 0)\n when \"w\"\n from = l(:general_first_day_of_week) == '7' ?\n # week starts on sunday\n ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) :\n # week starts on monday (Rails default)\n Time.now.at_beginning_of_week\n sql = \"#{db_table}.#{db_field} BETWEEN '%s' AND '%s'\" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"..\"\n from = nil\n to = nil\n sql = \"\"\n from = Date.parse(value[1])\n to = Date.parse(value[2])\n sql = value_in_date_range(db_table, db_field, from, to)\n end\n return sql\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \">t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \"><t-\"\n # between today - n days and today\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \">t-\"\n # >= today - n days\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil)\n when \"<t-\"\n # <= today - n days\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n # = n days in past\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \"><t+\"\n # between today and today + n days\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \">t+\"\n # >= today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n # <= today + n days\n sql = relative_date_clause(db_table, db_field, nil, value.first.to_i)\n when \"t+\"\n # = today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n # = today\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def sql\n selected_field_path = \"#{@selection.target_alias}.#{@selection.selected_field}\"\n operation = self.sql_operation.sub('?field', selected_field_path)\n \"#{operation} AS #{@field_name}\"\n end",
"def sql_for(name, operator=nil, values=nil, table=nil, field=nil, type=nil)\n values ||= values_for(name)\n # return if values_blank?(name, values)\n type ||= type_for(name)\n table ||= queryable_class.table_name\n operator ||= operator_for(name)\n field ||= name\n sql = nil\n\n case operator\n when \"=\"\n if [:date, :date_past].include?(type)\n sql = date_clause(table, field, (Date.parse(values.first) rescue nil), (Date.parse(values.first) rescue nil))\n elsif type == :boolean\n if values.first.to_i == 0\n sql = \"#{table}.#{field} = #{connection.quoted_false}\"\n else\n sql = \"#{table}.#{field} = #{connection.quoted_true}\"\n end\n else\n if values.present?\n sql = \"#{table}.#{field} IN (\" + values.map{ |val| \"'#{connection.quote_string(val)}'\" }.join(\",\") + \")\"\n else\n # IN an empty set\n sql = \"0=1\"\n end\n end\n when \"!\"\n if values.present?\n sql = \"(#{table}.#{field} IS NULL OR #{table}.#{field} NOT IN (\" + values.map{ |val| \"'#{connection.quote_string(val)}'\" }.join(\",\") + \"))\"\n else\n # empty set of forbidden values allows all results\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{table}.#{field} IS NULL\"\n when \"*\"\n sql = \"#{table}.#{field} IS NOT NULL\"\n when \">=\"\n if [:date, :date_past].include?(type)\n sql = date_clause(table, field, (Date.parse(values.first) rescue nil), nil)\n else\n sql = \"#{table}.#{field} >= #{values.first.to_i}\"\n end\n when \"<=\"\n if [:date, :date_past].include?(type)\n sql = date_clause(table, field, nil, (Date.parse(values.first) rescue nil))\n else\n sql = \"#{table}.#{field} <= #{values.first.to_i}\"\n end\n when \"><\"\n if [:date, :date_past].include?(type)\n sql = date_clause(table, field, (Date.parse(values[0]) rescue nil), (Date.parse(values[1]) rescue nil))\n else\n sql = \"#{table}.#{field} BETWEEN #{values[0].to_i} AND #{values[1].to_i}\"\n end\n when \">t-\"\n sql = relative_date_clause(table, field, - values.first.to_i, 0)\n when \"<t-\"\n sql = relative_date_clause(table, field, nil, - values.first.to_i)\n when \"t-\"\n sql = relative_date_clause(table, field, - values.first.to_i, - values.first.to_i)\n when \">t+\"\n sql = relative_date_clause(table, field, values.first.to_i, nil)\n when \"<t+\"\n sql = relative_date_clause(table, field, 0, values.first.to_i)\n when \"t+\"\n sql = relative_date_clause(table, field, values.first.to_i, values.first.to_i)\n when \"t\"\n sql = relative_date_clause(table, field, 0, 0)\n when \"w\"\n first_day_of_week = 7\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(table, field, - days_ago, - days_ago + 6)\n when \"~\"\n sql = \"LOWER(#{table}.#{field}) LIKE '%#{connection.quote_string(values.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{table}.#{field}) NOT LIKE '%#{connection.quote_string(values.first.to_s.downcase)}%'\"\n end\n\n sql.empty? ? nil : \"(#{sql})\"\n end",
"def type_literal_generic_date(column)\n :date\n end",
"def quoted_date(value)\n @logger.unknown(\"ODBCAdapter#quoted_date (MS SQL)>\") if @trace\n @logger.unknown(\"args=[#{value}]\") if @trace\n # MS SQL DBTIME and DBDATE environment variables should be set to:\n # DBTIME=%d.%m.%Y %H:%M:%S\n # DBDATE=%d.%m.%Y\n if value.acts_like?(:time) # Time, DateTime\n %Q!'#{value.strftime(\"%Y%m%d %H:%M:%S\")}'!\n else # Date\n %Q!'#{value.strftime(\"%Y%m%d\")}'!\n end\n end",
"def date_clause(table, field, from, to, is_custom_filter)\n s = []\n if from\n if from.is_a?(Date)\n from = date_for_user_time_zone(from.year, from.month, from.day).yesterday.end_of_day\n else\n from = from - 1 # second\n end\n if self.class.default_timezone == :utc\n from = from.utc\n end\n\n ### Patch Start\n if is_custom_filter && self.class.connection.adapter_name.downcase.to_sym == :postgresql && !Rails.env.test?\n s << (\"to_timestamp(#{table}.#{field},'DD/MM/YYYY HH24:MI') > to_timestamp('%s','DD/MM/YYYY HH24:MI')\" % [quoted_time(from, is_custom_filter)])\n else\n if Rails.env.test? || table.classify.constantize.columns_hash[field].type == :date || table.classify.constantize.columns_hash[field].type == :datetime\n s << (\"#{table}.#{field} > '%s'\" % [quoted_time(from, is_custom_filter)])\n else\n s << (\"STR_TO_DATE(#{table}.#{field},'%d/%m/%Y') > STR_TO_DATE('\" + quoted_time(from, is_custom_filter) + \"','%d/%m/%Y')\")\n end\n end\n ### Patch End\n\n end\n if to\n if to.is_a?(Date)\n to = date_for_user_time_zone(to.year, to.month, to.day).end_of_day\n end\n if self.class.default_timezone == :utc\n to = to.utc\n end\n\n ### Patch Start\n if is_custom_filter && self.class.connection.adapter_name.downcase.to_sym == :postgresql && !Rails.env.test?\n s << (\"to_timestamp(#{table}.#{field},'DD/MM/YYYY HH24:MI') <= to_timestamp('%s','DD/MM/YYYY HH24:MI')\" % [quoted_time(to, is_custom_filter)])\n else\n if Rails.env.test? || table.classify.constantize.columns_hash[field].type == :date || table.classify.constantize.columns_hash[field].type == :datetime\n s << (\"#{table}.#{field} <= '%s'\" % [quoted_time(to, is_custom_filter)])\n else\n s << (\"STR_TO_DATE(#{table}.#{field},'%d/%m/%Y') <= STR_TO_DATE('\" + quoted_time(to, is_custom_filter) + \"','%d/%m/%Y')\")\n end\n end\n ### Patch End\n\n end\n s.join(' AND ')\n end",
"def date_range_clause(table, field, from, to)\n s = []\n if from\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date((Date.yesterday + from).to_time.end_of_day)])\n end\n if to\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date((Date.today + to).to_time.end_of_day)])\n end\n s.join(' AND ')\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n\n #---------------\n # Smile specific : manage case where db_table param is not provided\n db_table_and_field = (db_table.present? ? \"#{db_table}.\" : '') + \"#{db_field}\"\n\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, parse_date(value.first), parse_date(value.first), is_custom_filter)\n when :integer\n int_values = value.first.to_s.scan(/[+-]?\\d+/).map(&:to_i).join(\",\")\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if int_values.present?\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) = #{int_values})\"\n else\n sql = \"#{db_table_and_field} IN (#{int_values})\"\n end\n else\n sql = \"1=0\"\n end\n when :float\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table_and_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = queried_class.send(:sanitize_sql_for_conditions, [\"#{db_table_and_field} IN (?)\", value])\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n # Smile specific : manage case where db_table param is not provided\n sql = queried_class.send(:sanitize_sql_for_conditions, [\"(#{db_table_and_field} IS NULL OR #{db_table_and_field} NOT IN (?))\", value])\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n #---------------\n # Smile specific : manage case where db_table param is not provided\n sql = \"#{db_table_and_field} IS NULL\"\n sql << \" OR #{db_table_and_field} = ''\" if (is_custom_filter || [:text, :string].include?(type_for(field)))\n when \"*\"\n #---------------\n # Smile specific : manage case where db_table param is not provided\n sql = \"#{db_table_and_field} IS NOT NULL\"\n sql << \" AND #{db_table_and_field} <> ''\" if is_custom_filter\n when \">=\"\n #---------------\n # Smile specific #147568 Filter on parent task\n # Smile specific : manage case where db_table param is not provided\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, parse_date(value.first), nil, is_custom_filter)\n else\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table_and_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, parse_date(value.first), is_custom_filter)\n else\n #---------------\n # Smile specific #147568 Filter on parent task\n # Smile specific, manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table_and_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, parse_date(value[0]), parse_date(value[1]), is_custom_filter)\n else\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table_and_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{self.class.connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{self.class.connection.quoted_true})\" if field == \"status_id\"\n when \"><t-\"\n # between today - n days and today\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0, is_custom_filter)\n when \">t-\"\n # >= today - n days\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil, is_custom_filter)\n when \"<t-\"\n # <= today - n days\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i, is_custom_filter)\n when \"t-\"\n # = n days in past\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i, is_custom_filter)\n when \"><t+\"\n # between today and today + n days\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i, is_custom_filter)\n when \">t+\"\n # >= today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil, is_custom_filter)\n when \"<t+\"\n # <= today + n days\n sql = relative_date_clause(db_table, db_field, nil, value.first.to_i, is_custom_filter)\n when \"t+\"\n # = today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i, is_custom_filter)\n when \"t\"\n # = today\n sql = relative_date_clause(db_table, db_field, 0, 0, is_custom_filter)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1, is_custom_filter)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = User.current.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6, is_custom_filter)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = User.current.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1, is_custom_filter)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = User.current.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1, is_custom_filter)\n when \"m\"\n # = this month\n date = User.current.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month, is_custom_filter)\n when \"lm\"\n # = last month\n date = User.current.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month, is_custom_filter)\n when \"y\"\n # = this year\n date = User.current.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year, is_custom_filter)\n when \"~\"\n sql = sql_contains(\"#{db_table_and_field}\", value.first)\n when \"!~\"\n sql = sql_contains(\"#{db_table_and_field}\", value.first, false)\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def to_sql\n self.to_datetime.to_sql\n \tend",
"def to_query(col, value, op = '=')\n return op == '=' ? \"(#{col} IS NULL)\" : \"(#{col} IS NOT NULL)\" if value.nil?\n\n case op.downcase\n when '=', '!='\n if value.is_a?(Array)\n rhs = 'IN (' + Array.new(value.length, '?').join(', ') + ')'\n rhs = 'NOT ' + rhs if op == '!='\n else\n rhs = op + ' ?'\n end\n when 'between'\n rhs = 'BETWEEN ? AND ?'\n when 'not between'\n rhs = 'NOT BETWEEN ? AND ?'\n when 'like'\n rhs = 'LIKE ?'\n when 'not like'\n rhs = 'NOT LIKE ?'\n else\n rhs = op + ' ?'\n end\n\n lhs = col.to_s\n lhs = \"LOWER(#{lhs})\" if @columns[col] == :string\n\n \"(#{lhs} #{rhs})\"\n end",
"def quote(fld)\n case fld\n when DateTime, Time\n %Q|'#{fld.to_s[0..-7]}'|\n when String, Symbol\n %Q|'#{escape fld.to_s}'|\n else\n super\n end\n\n end",
"def to_select_sql\n clause = @columns.collect { |column|\n column_with_prefix(column)\n }.join(', ')\n \n separator = all_ints? ? ',' : ' '\n \n clause = adapter.concatenate(clause, separator) if concat_ws?\n clause = adapter.group_concatenate(clause, separator) if is_many?\n clause = adapter.cast_to_datetime(clause) if type == :datetime\n clause = adapter.convert_nulls(clause) if type == :string\n \n \"#{clause} AS #{quote_column(unique_name)}\"\n end",
"def format_query_condition(condition)\n case condition\n when nil\n \"=\" # Search for empty field\n when Range\n format_range_condition(condition)\n when *FmRest::V1.datetime_classes\n FmRest::V1.convert_datetime_timezone(condition.to_datetime, klass.fmrest_config.timezone)\n .strftime(FmRest::V1::Dates::FM_DATETIME_FORMAT)\n when *FmRest::V1.date_classes\n condition.strftime(FmRest::V1::Dates::FM_DATE_FORMAT)\n else\n condition\n end\n end",
"def date_field(object_name, method, options = T.unsafe(nil)); end",
"def datetime_field(object_name, method, options = T.unsafe(nil)); end",
"def test_date_value\n row = SqlRow.new(SqlRowType.new('table', :id => :integer, :text => :date))\n row[:text] = Date.parse('2015-01-01')\n assert_equal \"'2015-01-01'\", row.sql_for(:text, :postgresql)\n end",
"def relative_date_clause(table, field, days_from, days_to)\n date_clause(table, field, (days_from ? Date.today + days_from : nil), (days_to ? Date.today + days_to : nil))\n end",
"def relative_date_clause(table, field, days_from, days_to)\n date_clause(table, field, (days_from ? Date.today + days_from : nil), (days_to ? Date.today + days_to : nil))\n end",
"def generate_date_query_argument(date = date_parsed)\n if created_at?\n \"created_at BETWEEN '#{date.midnight}' AND '#{date.end_of_day}'\"\n elsif updated_at?\n \"updated_at BETWEEN '#{date.midnight}' AND '#{date.end_of_day}'\"\n end\n end",
"def sql_of( expr, dataset)\n dataset.send :literal_expression_append, rv=String.new, expr\n rv\n end",
"def to_select_sql\n return nil unless include_as_association?\n \n separator = all_ints? || all_datetimes? || @crc ? ',' : ' '\n \n clause = @columns.collect { |column|\n part = column_with_prefix(column)\n case type\n when :string\n adapter.convert_nulls(part)\n when :datetime\n adapter.cast_to_datetime(part)\n when :multi\n part = adapter.cast_to_datetime(part) if is_many_datetimes?\n part = adapter.convert_nulls(part, '0') if is_many_ints?\n part\n else\n part\n end\n }.join(', ')\n \n clause = adapter.crc(clause) if @crc\n clause = adapter.concatenate(clause, separator) if concat_ws?\n clause = adapter.group_concatenate(clause, separator) if is_many?\n \n \"#{clause} AS #{quote_column(unique_name)}\"\n end",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def time_field(method, *args)\n db_type = type_from_database(method)\n\n # Note that if the database type is string or text, we still use a\n # time_select, as we're assuming it is then a serialized object.\n unless db_type.nil? or db_type =~ /^(?:string|text)$/\n self.send \"#{db_type}_select\", method, *args\n else\n self.time_select method, *args\n end\n end",
"def relative_date_clause(table, field, days_from, days_to)\n date_clause(table, field, (days_from ? Date.today + days_from : nil), (days_to ? Date.today + days_to : nil))\n end",
"def datetime_test(field, operator, value, &block) # :yields: finder_option_type, value\n\n # Parse the value as a date/time and ignore invalid timestamps\n timestamp = definition.parse_temporal(value)\n return [] unless timestamp\n\n timestamp = timestamp.to_date if field.date?\n # Check for the case that a date-only value is given as search keyword,\n # but the field is of datetime type. Change the comparison to return\n # more logical results.\n if field.datetime?\n span = 1.minute if(value =~ /\\A\\s*\\d+\\s+\\bminutes?\\b\\s+\\bago\\b\\s*\\z/i)\n span ||= (timestamp.day_fraction == 0) ? 1.day : 1.hour\n if [:eq, :ne].include?(operator)\n # Instead of looking for an exact (non-)match, look for dates that\n # fall inside/outside the range of timestamps of that day.\n negate = (operator == :ne) ? 'NOT ' : ''\n field_sql = field.to_sql(operator, &block)\n return [\"#{negate}(#{field_sql} >= ? AND #{field_sql} < ?)\", timestamp, timestamp + span]\n\n elsif operator == :gt\n # Make sure timestamps on the given date are not included in the results\n # by moving the date to the next day.\n timestamp += span\n operator = :gte\n\n elsif operator == :lte\n # Make sure the timestamps of the given date are included by moving the\n # date to the next date.\n timestamp += span\n operator = :lt\n end\n end\n\n # return the SQL test\n [\"#{field.to_sql(operator, &block)} #{sql_operator(operator, field)} ?\", timestamp]\n end",
"def sql_operator(operator, field)\n raise ScopedSearch::QueryNotSupported, \"the operator '#{operator}' is not supported for field type '#{field.type}'\" if !field.virtual? and [:like, :unlike].include?(operator) and !field.textual?\n SQL_OPERATORS[operator]\n end",
"def get_date_solr_query(p = {})\n times = get_times(p)\n registered_only?(p) ? '' : \"AND #{Last_Changed_Field}:[\\\"#{times[:first]}\\\" TO \\\"#{times[:last]}\\\"]\" # unless the user has asked for only registered items, apply the date range for published date\n end",
"def type_literal_generic_datetime(column)\n :datetime\n end",
"def sql(options = {})\n options = normalize_options(options)\n if value\t\n\t\"#{column(options)} #{operator} #{quoted_value(options)}\"\n else\n\t\"#{column(options)} #{operator}\"\n end\n end",
"def sql_query\n case @operator\n when :equals\n arel_field.eq(transmogrified_value)\n when :does_not_equal\n arel_field.not_eq(transmogrified_value)\n when :contains\n arel_field.matches(\"%#{transmogrified_value}%\")\n when :does_not_contain\n arel_field.does_not_match(\"%#{transmogrified_value}%\")\n when :starts_with\n arel_field.matches(\"#{transmogrified_value}%\")\n when :ends_with\n arel_field.matches(\"%#{transmogrified_value}\")\n when :greater_than\n arel_field.gt(transmogrified_value)\n when :greater_than_or_equal_to\n arel_field.gteq(transmogrified_value)\n when :less_than\n arel_field.lt(transmogrified_value)\n when :less_than_or_equal_to\n arel_field.lteq(transmogrified_value)\n when :in\n arel_field.in(transmogrified_value.split(/\\,\\s*/))\n when :not_in\n arel_field.not_in(transmogrified_value.split(/\\,\\s*/))\n when :blank\n arel_field.eq(nil)\n when :not_blank\n arel_field.not_eq(nil)\n end\n end",
"def where_clause\n \"\"\n end",
"def sql_expr\n @sql_expr ||= (meta[:sql_expr] || to_sql_name)\n end",
"def select_sql\n columns = wanted_active_record_columns.map do |column|\n clause = override_field_select_sql(column)\n quoted_column_name = Q.quote_column_name(column.name)\n if clause.nil?\n quoted_column_name\n else\n \"#{clause} AS #{quoted_column_name}\"\n end\n end\n\n \"SELECT #{columns.join(', ')} FROM #{Q.quote_table_name(pg_table_name)} #{where_clause}\"\n end",
"def select_date(month, day, year)\n select month, from: \"report_date_month\"\n select day, from: \"report_date_day\"\n select year, from: \"report_date_year\"\n end",
"def patrick_stewart_dates\n sql = <<-SQL\n SELECT show_date FROM guests WHERE guest_name = \"Patrick Stewart\";\n SQL\n DB[:conn].execute(sql)\nend",
"def type_cast_for_schema(value) # :nodoc:\n case value\n when 'toDate(now()', 'CAST(now() AS Date)'\n 'now()'.inspect\n else\n value.inspect\n end\n end",
"def clause(model, toggled)\n if toggled\n \"#{model.quoted_table_name}.#{model.connection.quote_column_name(@column.to_s)}\" +\n \" > #{adapter.time_difference(@threshold)}\"\n else\n nil\n end\n end",
"def type_literal_generic_datetime(column)\n :timestamp\n end",
"def override_field_select_sql(column)\n nil\n end",
"def build_condition_for_date(start_date, end_date, start_date_string=\"created_at\", end_date_string=\"created_at\")\n\t\t\" #{start_date_string} >= '#{start_date.to_time}' and #{end_date_string} <= '#{end_date.to_time + 1.day}' \" if validate_date?(start_date,end_date)\n\tend",
"def append_date_condition(search,r_name)\n if params[:date_selected]\n search += \" AND created_at Between :start_date AND :end_date \"\n r_name += \" created between #{params[:date_start]} - #{params[:date_end]}\"\n end\n [search,r_name]\n end",
"def quote(value, column = nil) #:nodoc:\n return super unless column\n\n case value\n when Float\n return super unless value.infinite? && column.type == :datetime\n \"'#{value.to_s.downcase}'\"\n when Numeric\n return super unless column.sql_type == 'money'\n # Not truly string input, so doesn't require (or allow) escape string syntax.\n \"'#{value}'\"\n when String\n case column.sql_type\n when 'bytea' then \"E'#{escape_bytea(value)}'::bytea\"\n when 'xml' then \"xml '#{quote_string(value)}'\"\n when /^bit/\n case value\n when /^[01]*$/ then \"B'#{value}'\" # Bit-string notation\n when /^[0-9A-F]*$/i then \"X'#{value}'\" # Hexadecimal notation\n end\n else\n super\n end\n else\n super\n end\n end",
"def function_sql(f)\n args = f.args\n \"#{f.f}#{args.empty? ? '()' : literal(args)}\"\n end",
"def to_sql\n sql = [\"select\"]\n select_values << \"*\" if select_values.empty?\n\n sql << select_values.uniq.join(\", \")\n\n sql << \"from #{build_series_name}\"\n\n sql << \"where #{where_values.join(\" and \")}\" unless where_values.empty?\n\n unless group_values.empty? && time_value.nil?\n group_fields = (time_value.nil? ? [] : [\"time(\" + @values[:time] + \")\"]) + group_values\n group_fields.uniq!\n sql << \"group by #{group_fields.join(\", \")}\"\n end\n\n sql << \"fill(#{fill_value})\" unless fill_value.nil?\n\n sql << \"order by #{order_values.uniq.join(\",\")}\" unless order_values.empty?\n\n sql << \"limit #{limit_value}\" unless limit_value.nil?\n sql << \"offset #{offset_value}\" unless offset_value.nil?\n sql << \"slimit #{slimit_value}\" unless slimit_value.nil?\n sql << \"soffset #{soffset_value}\" unless soffset_value.nil?\n sql << \"TZ('#{timezone_value}')\" unless timezone_value.blank?\n sql.join \" \"\n end",
"def to_sql\n \"timestamp '#{to_s}'\"\n end",
"def where_sql\n named.or(taxon_name_named).to_sql\n end",
"def column_sql\n column_sql_format.gsub(\"{table}\", quoted_table_name).gsub(\"{column}\", quoted_column_name)\n end",
"def sort_clause\n sorter.to_sql\n end",
"def quoted_date(value)\n if value.acts_like?(:time)\n if value.respond_to?(:getutc)\n value = value.getutc\n end\n end\n\n result = value.to_s(:db)\n end",
"def column_definition_sql(column)\n sql = String.new\n sql << \"#{quote_identifier(column[:name])} #{type_literal(column)}\"\n column_definition_order.each{|m| send(:\"column_definition_#{m}_sql\", sql, column)}\n sql\n end",
"def sql_literal(*)\n @dataset.sql\n end",
"def perform_date_param(date, relation = self)\n begin\n date = date.to_date\n rescue => e\n date = Date.today\n end\n relation = relation.where(created_at: date.beginning_of_day..date.end_of_day)\n relation\n end",
"def field_query(field, value)\n \"_query_:\\\"{!field f=#{field}}#{value}\\\"\"\n end",
"def searchable_date(attribute)\n searchable do\n time attribute\n string attribute\n end\n end",
"def select_statement\n \"select \" + selected_field_names.map { |field_name| zuora_field_name(field_name) }.join(', ')\n end",
"def sql_literal(ds)\n ds.literal(sql_expr)\n end",
"def sql_operator(operator, field)\n raise ScopedSearch::QueryNotSupported, \"the operator '#{operator}' is not supported for field type '#{field.type}'\" if !field.virtual? and [:like, :unlike].include?(operator) and !field.textual?\n return '@@' if [:like, :unlike].include?(operator) && field.full_text_search\n case operator\n when :like then 'ILIKE'\n when :unlike then 'NOT ILIKE'\n else super(operator, field)\n end\n end",
"def patrick_stewart_appearances\n sql = <<-SQL\n SELECT show_date\n FROM guest_appearances\n WHERE guest_name = \"Patrick Stewart\";\n SQL\n puts DB[:conn].execute(sql)\nend",
"def to_sql(options = {})\n \"#{field.to_sql(options)} = #{expression.to_sql(options)}\"\n end",
"def prepared_statement_arg(v)\n case v\n when Numeric\n v.to_s\n when Date, Time\n literal(v).gsub(\"'\", '')\n else\n v\n end\n end",
"def grab_rows(field, src_table_name = TABLE_NAME, num_rows = ROWS_PER_TRANSACTION)\n LOGGER.info \"Creating select statement based on field `#{field[:name]}` (#{field[:type]})\"\n \n if !(field[:type] =~ /int/).nil?\n LOGGER.info \"Using integer type for select.\"\n sql = \"SELECT * FROM `%s` WHERE `%s` >= '%s' AND `%s` < '%s' ORDER BY `%s` LIMIT %s;\" % [ Mysql::escape_string(src_table_name), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:min].to_i.to_s), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:max].to_i.to_s), \n Mysql::escape_string(field[:name]), \n num_rows]\n elsif !(field[:type] =~ /datetime/).nil?\n LOGGER.info \"Using datetime type for select.\" \n sql = \"SELECT * FROM `%s` WHERE `%s` >= '%s' AND `%s` < '%s' ORDER BY `%s` LIMIT %s;\" % [ Mysql::escape_string(src_table_name), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:min].strftime(MYSQL_DATETIME_FORMAT)), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:max].strftime(MYSQL_DATETIME_FORMAT)), \n Mysql::escape_string(field[:name]), \n num_rows]\n else\n LOGGER.info \"Using default type for select, this isn't expected.\"\n sql = \"SELECT * FROM `%s` WHERE `%s` >= '%s' AND `%s` < '%s' ORDER BY `%s` LIMIT %s;\" % [ Mysql::escape_string(src_table_name), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:min]), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:max]), \n Mysql::escape_string(field[:name]), \n num_rows] \n end\n \n LOGGER.debug \"SQL: #{sql}\"\n dbres = do_sql_command(sql)\n dbres\nend",
"def string\n @sql_string = \"SELECT #{@select} FROM #{@from}#{@join} WHERE #{@where};\"\n end",
"def sql_for_columns; @sql_for_columns end",
"def constraint_sql\n parameter_string = parameters.collect { |parameter_name| \"#{table.entity.attribute_by_name(parameter_name).sql.column_name}\" }.join(', ')\n function_call = \"#{self.qualified_function_name}(#{parameter_string}) = 1\"\n (self.or_conditions + [function_call]).join(' OR ')\n end",
"def quote_date_with_to_date(value)\n value = value.to_s(:db) if value.acts_like?(:date) || value.acts_like?(:time)\n \"TO_DATE('#{value}','YYYY-MM-DD HH24:MI:SS')\"\n end",
"def perform_field_query query, response, scope\n if Array === query\n case query.first\n when :method # a method call\n query.shift\n return eval(query.join('.'))\n when :literal # a literal value\n return query.last\n end\n end\n response.scalar_query(query, scope)\n end",
"def to_arel_sql(value)\n case value\n when Arel::Nodes::Node, Arel::Nodes::SqlLiteral, nil\n value\n when ActiveRecord::Relation\n Arel.sql(value.spawn.to_sql)\n else\n Arel.sql(value.respond_to?(:to_sql) ? value.to_sql : value.to_s)\n end\n end",
"def to_sql\n self.strftime(\"%Y-%m-%d %H:%M:%S\")\n \tend",
"def quoted_date(value)\n if value.acts_like?(:time)\n zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal\n\n if value.respond_to?(zone_conversion_method)\n value = value.send(zone_conversion_method)\n end\n value.strftime('%Y-%m-%d %H:%M:%S') # Time, DateTime\n else\n value.strftime('%Y-%m-%d') # Date\n end\n end",
"def attribute_condition(argument)\n case argument\n when nil then \"IS ?\"\n when Array, ActiveRecord::Associations::AssociationCollection then \"IN (?)\"\n when Range then \"BETWEEN ? AND ?\"\n else \"= ?\"\n end\n end",
"def appctrl_search_range_sql( model, field = nil )\n sql = range_start = range_end = nil\n\n field = model::USED_RANGE_COLUMN if ( field.nil? )\n\n unless ( params[ :search ].nil? )\n if ( ( params[ :search ].blank? and params[ :search_range_start ].blank? and params[ :search_range_end ].blank? ) or params[ :search_cancel ] )\n params.delete( :search )\n params.delete( :search_range_start )\n params.delete( :search_range_end )\n else\n range = model.used_range()\n range_start, range_end = appctrl_dates_from_search(\n Date.new( range.first ), # I.e. start year\n Date.new( range.last + 1 ) - 1 # I.e. start of year after end year, minus one day; that is, the last day of end year\n )\n\n # Since SQL date-only queries work on a 'start of the day' basis,\n # we do a \">=\" start and a \"<\" end comparison, setting the end to\n # the beginning of the *next* day.\n\n range_end += 1\n\n sql = \"#{ model.table_name }.#{ field } >= :range_start AND #{ model.table_name }.#{ field } < :range_end AND\"\n end\n end\n\n [ sql, range_start, range_end ]\n end",
"def booking_with_furthest_checkin_date\n ActiveRecord::Base.connection.exec_query(custom_sql).collect &:values\nend",
"def date \n \"date\" \n end",
"def sql(bindings, type = :find)\n statement, bind_values = build_statement(type)\n statement.gsub('?') { eval_bound_value(bind_values.shift, connection, bindings) }\n end",
"def sql(string)\n ::Arel::Nodes::SqlLiteral.new(string)\n end",
"def query_clause(type, key, value)\n \"_query_:\\\"{!#{type} f=#{key}}#{value.gsub('\"', '\\\"')}\\\"\"\n end",
"def arel_field\n case param.field.options[:transmogrification]\n when :timestamp_to_hours\n Arel::Nodes::NamedFunction.new('TIMESTAMPDIFF', [Arel::Nodes::SqlLiteral.new('HOUR'), arel_table[field], Arel::Nodes::SqlLiteral.new('UTC_TIMESTAMP()')])\n when :timestamp_to_days\n Arel::Nodes::NamedFunction.new('TIMESTAMPDIFF', [Arel::Nodes::SqlLiteral.new('DAY'), arel_table[field], Arel::Nodes::SqlLiteral.new('UTC_TIMESTAMP()')])\n when :sum\n Arel::Nodes::NamedFunction.new('SUM', [arel_table[field]])\n when :upper\n Arel::Nodes::NamedFunction.new('UPPER', [arel_table[field]])\n when :lower\n Arel::Nodes::NamedFunction.new('LOWER', [arel_table[field]])\n else\n arel_table[field]\n end\n end",
"def publication_date(field = nil)\n IsoDay.cast(find_record_items(field).first)&.to_s if field\n end",
"def datetime_field_tag(name, value = T.unsafe(nil), options = T.unsafe(nil)); end",
"def create_custom_function\n # puts \"Creating a custom function to make queries with timestamp as a string...\".cyan\n @session.execute('CREATE OR REPLACE FUNCTION timefstring(somearg text)\n RETURNS NULL ON NULL INPUT\n RETURNS timestamp\n LANGUAGE java\n AS $$\n java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss.SSS\");\n try {\n Date date = formatter.parse(somearg);\n return date;\n } catch(java.text.ParseException e) {\n return new Date();\n }\n $$')\n end",
"def query_clause(type, key, value)\n \"_query_:\\\"{!#{type} f=#{key}}#{value.gsub('\"', '\\\"')}\\\"\"\n end",
"def quote_column_name(name) #:nodoc:\r\n %Q(\"#{name}\")\r\n end",
"def date_field_tag(name, value = T.unsafe(nil), options = T.unsafe(nil)); end",
"def quoted_date(value)\n super.to_s\n end",
"def sql_for_bu_project_field(field, operator, value)\n sql_for_field(field, operator, value, 'bu_project_id', 'customized_id')\n end",
"def bound_datetime_field(method, attrs = {})\n update_bound_controls(method, attrs, 'datetime')\n attrs[:value] = @obj.send(method)\n attrs[:name] ||= control_name(method)\n unbound_datetime_field(attrs)\n end",
"def sql_quoted(value)\n Arel::Nodes.build_quoted(value)\n end",
"def compose\n case type\n when :integrated\n formated_query\n when :separated\n \"select #{target_column_names} from #{config[:object]} #{where_clause}\"\n end\n end",
"def to_select_sql\n clause = @columns.collect { |column|\n column_with_prefix(column)\n }.join(', ')\n \n clause = adapter.concatenate(clause) if concat_ws?\n clause = adapter.group_concatenate(clause) if is_many?\n \n \"#{adapter.cast_to_string clause } AS #{quote_column(unique_name)}\"\n end",
"def query_clause(type, key, value)\n \"_query_:\\\"{!#{type} f=#{key}}#{value.gsub('\"', '\\\"')}\\\"\"\n end",
"def sql_condition(negation, condition)\n negation == '0' ? NegationSQL[condition] : SQLConditions[condition]\n end",
"def query_type_to_clause_params()\n where_clause = nil\n sql_parameters = []\n qextra = false\n all_query = false\n\n type = self.type\n query = self.query\n if type == 'All'\n all_query = true\n elsif type == 'None'\n where_clause = '1=0'\n elsif type == 'Date'\n where_clause = \"(Begin_Date REGEXP ? OR EndDate REGEXP ?)\"\n sql_parameters << query\n sql_parameters << query\n elsif type == 'after'\n where_clause = \"Begin_Date > ?\"\n sql_parameters << query\n elsif type == 'before'\n where_clause = \"EndDate < ?\"\n sql_parameters << query\n elsif type == 'parameter'\n where_clause = \"`bottle_dbs`.`parameters` LIKE ?\"\n sql_parameters << \"%#{query}%\"\n qextra = 'params'\n elsif type == 'basin'\n where_clause = \"spatial_groups.`#{query}` = 1\"\n qextra = 'spatial_group'\n elsif type == 'Chief_Scientist'\n where_clause = \"contacts.LastName LIKE ?\"\n sql_parameters << \"%#{query}%\"\n qextra = 'contacts'\n else\n if @@cruise_columns.include?(type)\n where_clause = \"`cruises`.`#{type}` REGEXP ?\"\n sql_parameters << query\n else\n Rails.logger.debug(\"Search: unrecognized type #{type}\")\n where_clause = nil\n end\n end\n [where_clause, sql_parameters, qextra, all_query]\n end"
] | [
"0.6761678",
"0.67007613",
"0.6615816",
"0.65976596",
"0.64795",
"0.6290864",
"0.62821436",
"0.6151169",
"0.6080176",
"0.6070666",
"0.60588163",
"0.6050347",
"0.601616",
"0.59982234",
"0.58085644",
"0.57310665",
"0.57018715",
"0.5629879",
"0.5591728",
"0.552414",
"0.55058146",
"0.55010426",
"0.5498209",
"0.5498209",
"0.54851925",
"0.5458372",
"0.5436489",
"0.5436059",
"0.5436059",
"0.5436059",
"0.54229856",
"0.5418842",
"0.5409843",
"0.5404101",
"0.5388447",
"0.5363861",
"0.5352657",
"0.5347981",
"0.53422046",
"0.5274932",
"0.5245675",
"0.5244718",
"0.5239129",
"0.522811",
"0.5206185",
"0.5202264",
"0.51546",
"0.5138219",
"0.5133221",
"0.51149917",
"0.5111706",
"0.51115537",
"0.5085217",
"0.5067425",
"0.5063411",
"0.50501865",
"0.50346494",
"0.5034067",
"0.5032332",
"0.5031784",
"0.5030941",
"0.50268275",
"0.5022866",
"0.5022216",
"0.5019324",
"0.5013994",
"0.50071144",
"0.50064784",
"0.49923608",
"0.49794486",
"0.4977107",
"0.49673176",
"0.4958637",
"0.49550465",
"0.49527234",
"0.49521577",
"0.49330324",
"0.49177176",
"0.49108195",
"0.49081546",
"0.48966664",
"0.48923826",
"0.4885684",
"0.4879838",
"0.48756632",
"0.4858816",
"0.48587468",
"0.48561856",
"0.48534688",
"0.48513716",
"0.48468965",
"0.48451045",
"0.4844151",
"0.48387218",
"0.48276207",
"0.48209882",
"0.48193046",
"0.48134825",
"0.48088086",
"0.48018205"
] | 0.67144126 | 1 |
Returns a SQL clause for a date or datetime field using relative dates. | def relative_date_clause(table, field, days_from, days_to)
date_clause(table, field, (days_from ? Date.today + days_from : nil), (days_to ? Date.today + days_to : nil))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relative_date_clause(table, field, days_from, days_to)\n date_clause(table, field, (days_from ? Date.today + days_from : nil), (days_to ? Date.today + days_to : nil))\n end",
"def relative_date_clause(table, field, days_from, days_to)\n date_clause(table, field, (days_from ? Date.today + days_from : nil), (days_to ? Date.today + days_to : nil))\n end",
"def date_clause(table, field, from, to)\n s = []\n if from\n from_yesterday = from - 1\n from_yesterday_time = Time.local(from_yesterday.year, from_yesterday.month, from_yesterday.day)\n if self.class.default_timezone == :utc\n from_yesterday_time = from_yesterday_time.utc\n end\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date(from_yesterday_time.end_of_day)])\n end\n if to\n to_time = Time.local(to.year, to.month, to.day)\n if self.class.default_timezone == :utc\n to_time = to_time.utc\n end\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date(to_time.end_of_day)])\n end\n s.join(' AND ')\n end",
"def date_clause(table, field, from, to)\n s = []\n if from\n from_yesterday = from - 1\n from_yesterday_utc = Time.gm(from_yesterday.year, from_yesterday.month, from_yesterday.day)\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date(from_yesterday_utc.end_of_day)])\n end\n if to\n to_utc = Time.gm(to.year, to.month, to.day)\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date(to_utc.end_of_day)])\n end\n s.join(' AND ')\n end",
"def date_clause(table, field, from, to)\n s = []\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date((from - 1).to_time.end_of_day)]) if from\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date(to.to_time.end_of_day)]) if to\n s.join(' AND ')\n end",
"def date_clause_with_date_column(table, field, from, to, is_custom_filter)\n if (date?(from) || date?(to)) && DATE_TYPES.include?(ColumnType.for(table, field))\n s = []\n condition_pattern = \"#{table}.#{field} %s '%s'\"\n s << condition_pattern % ['>', end_day(from.yesterday)] if from\n s << condition_pattern % ['<=', end_day(to)] if to\n return s.join(' AND ')\n end\n date_clause_without_date_column(table, field, from, to, is_custom_filter)\n end",
"def date_range_clause(table, field, from, to)\n s = []\n if from\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date((Date.yesterday + from).to_time.end_of_day)])\n end\n if to\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date((Date.today + to).to_time.end_of_day)])\n end\n s.join(' AND ')\n end",
"def sql(options = {})\n options = normalize_options(options)\n ret = \"\"\n\n if exact_date?(options)\n\tret += \"#{column} = '#{self.from_date(options)}' \"\n else\n\tret += \"#{column} >= '#{self.from_date(options)}' AND \"\t\n\tret += \"#{column} <= '#{self.to_date(options)}' \"\t\n end\n\n raise \"not time selection supported yet '#{range(options)}' please use beginning and end.\" if from_time or to_time\n\n return nil if ret == \"\"\n return ret\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \")\"\n when \"!\"\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \"))\"\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n when \"<=\"\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n when \"o\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}\" if field == \"status_id\"\n when \"c\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}\" if field == \"status_id\"\n when \">t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = date_range_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = date_range_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = date_range_clause(db_table, db_field, 0, 0)\n when \"w\"\n from = l(:general_first_day_of_week) == '7' ?\n # week starts on sunday\n ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) :\n # week starts on monday (Rails default)\n Time.now.at_beginning_of_week\n sql = \"#{db_table}.#{db_field} BETWEEN '%s' AND '%s'\" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"..\"\n from = nil\n to = nil\n sql = \"\"\n from = Date.parse(value[1])\n to = Date.parse(value[2])\n sql = value_in_date_range(db_table, db_field, from, to)\n end\n return sql\n end",
"def perform_date_param(date, relation = self)\n begin\n date = date.to_date\n rescue => e\n date = Date.today\n end\n relation = relation.where(created_at: date.beginning_of_day..date.end_of_day)\n relation\n end",
"def perform_date_param(date, relation = self)\n date = date.to_date\n if date <= Date.today\n start_from = DateTime.now + MIN_TIME_BEFORE_MATCH_START\n else\n start_from = date.beginning_of_day\n end\n relation = relation.where(start_at: start_from..date.end_of_day)\n relation\n end",
"def date_clause(table, field, from, to, is_custom_filter)\n s = []\n if from\n if from.is_a?(Date)\n from = date_for_user_time_zone(from.year, from.month, from.day).yesterday.end_of_day\n else\n from = from - 1 # second\n end\n if self.class.default_timezone == :utc\n from = from.utc\n end\n\n ### Patch Start\n if is_custom_filter && self.class.connection.adapter_name.downcase.to_sym == :postgresql && !Rails.env.test?\n s << (\"to_timestamp(#{table}.#{field},'DD/MM/YYYY HH24:MI') > to_timestamp('%s','DD/MM/YYYY HH24:MI')\" % [quoted_time(from, is_custom_filter)])\n else\n if Rails.env.test? || table.classify.constantize.columns_hash[field].type == :date || table.classify.constantize.columns_hash[field].type == :datetime\n s << (\"#{table}.#{field} > '%s'\" % [quoted_time(from, is_custom_filter)])\n else\n s << (\"STR_TO_DATE(#{table}.#{field},'%d/%m/%Y') > STR_TO_DATE('\" + quoted_time(from, is_custom_filter) + \"','%d/%m/%Y')\")\n end\n end\n ### Patch End\n\n end\n if to\n if to.is_a?(Date)\n to = date_for_user_time_zone(to.year, to.month, to.day).end_of_day\n end\n if self.class.default_timezone == :utc\n to = to.utc\n end\n\n ### Patch Start\n if is_custom_filter && self.class.connection.adapter_name.downcase.to_sym == :postgresql && !Rails.env.test?\n s << (\"to_timestamp(#{table}.#{field},'DD/MM/YYYY HH24:MI') <= to_timestamp('%s','DD/MM/YYYY HH24:MI')\" % [quoted_time(to, is_custom_filter)])\n else\n if Rails.env.test? || table.classify.constantize.columns_hash[field].type == :date || table.classify.constantize.columns_hash[field].type == :datetime\n s << (\"#{table}.#{field} <= '%s'\" % [quoted_time(to, is_custom_filter)])\n else\n s << (\"STR_TO_DATE(#{table}.#{field},'%d/%m/%Y') <= STR_TO_DATE('\" + quoted_time(to, is_custom_filter) + \"','%d/%m/%Y')\")\n end\n end\n ### Patch End\n\n end\n s.join(' AND ')\n end",
"def generate_date_query_argument(date = date_parsed)\n if created_at?\n \"created_at BETWEEN '#{date.midnight}' AND '#{date.end_of_day}'\"\n elsif updated_at?\n \"updated_at BETWEEN '#{date.midnight}' AND '#{date.end_of_day}'\"\n end\n end",
"def search_in_date_range(by_direction, with_date)\n logger.debug \"Searched #{date_field} on #{self.class.name} with a scope\"\n where(\"#{table_name}.#{date_field} #{by_direction}= ?\", coalesce_date(with_date, by_direction))\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \">t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \"><t-\"\n # between today - n days and today\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \">t-\"\n # >= today - n days\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil)\n when \"<t-\"\n # <= today - n days\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n # = n days in past\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \"><t+\"\n # between today and today + n days\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \">t+\"\n # >= today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n # <= today + n days\n sql = relative_date_clause(db_table, db_field, nil, value.first.to_i)\n when \"t+\"\n # = today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n # = today\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def sql_for(name, operator=nil, values=nil, table=nil, field=nil, type=nil)\n values ||= values_for(name)\n # return if values_blank?(name, values)\n type ||= type_for(name)\n table ||= queryable_class.table_name\n operator ||= operator_for(name)\n field ||= name\n sql = nil\n\n case operator\n when \"=\"\n if [:date, :date_past].include?(type)\n sql = date_clause(table, field, (Date.parse(values.first) rescue nil), (Date.parse(values.first) rescue nil))\n elsif type == :boolean\n if values.first.to_i == 0\n sql = \"#{table}.#{field} = #{connection.quoted_false}\"\n else\n sql = \"#{table}.#{field} = #{connection.quoted_true}\"\n end\n else\n if values.present?\n sql = \"#{table}.#{field} IN (\" + values.map{ |val| \"'#{connection.quote_string(val)}'\" }.join(\",\") + \")\"\n else\n # IN an empty set\n sql = \"0=1\"\n end\n end\n when \"!\"\n if values.present?\n sql = \"(#{table}.#{field} IS NULL OR #{table}.#{field} NOT IN (\" + values.map{ |val| \"'#{connection.quote_string(val)}'\" }.join(\",\") + \"))\"\n else\n # empty set of forbidden values allows all results\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{table}.#{field} IS NULL\"\n when \"*\"\n sql = \"#{table}.#{field} IS NOT NULL\"\n when \">=\"\n if [:date, :date_past].include?(type)\n sql = date_clause(table, field, (Date.parse(values.first) rescue nil), nil)\n else\n sql = \"#{table}.#{field} >= #{values.first.to_i}\"\n end\n when \"<=\"\n if [:date, :date_past].include?(type)\n sql = date_clause(table, field, nil, (Date.parse(values.first) rescue nil))\n else\n sql = \"#{table}.#{field} <= #{values.first.to_i}\"\n end\n when \"><\"\n if [:date, :date_past].include?(type)\n sql = date_clause(table, field, (Date.parse(values[0]) rescue nil), (Date.parse(values[1]) rescue nil))\n else\n sql = \"#{table}.#{field} BETWEEN #{values[0].to_i} AND #{values[1].to_i}\"\n end\n when \">t-\"\n sql = relative_date_clause(table, field, - values.first.to_i, 0)\n when \"<t-\"\n sql = relative_date_clause(table, field, nil, - values.first.to_i)\n when \"t-\"\n sql = relative_date_clause(table, field, - values.first.to_i, - values.first.to_i)\n when \">t+\"\n sql = relative_date_clause(table, field, values.first.to_i, nil)\n when \"<t+\"\n sql = relative_date_clause(table, field, 0, values.first.to_i)\n when \"t+\"\n sql = relative_date_clause(table, field, values.first.to_i, values.first.to_i)\n when \"t\"\n sql = relative_date_clause(table, field, 0, 0)\n when \"w\"\n first_day_of_week = 7\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(table, field, - days_ago, - days_ago + 6)\n when \"~\"\n sql = \"LOWER(#{table}.#{field}) LIKE '%#{connection.quote_string(values.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{table}.#{field}) NOT LIKE '%#{connection.quote_string(values.first.to_s.downcase)}%'\"\n end\n\n sql.empty? ? nil : \"(#{sql})\"\n end",
"def build_condition_for_date(start_date, end_date, start_date_string=\"created_at\", end_date_string=\"created_at\")\n\t\t\" #{start_date_string} >= '#{start_date.to_time}' and #{end_date_string} <= '#{end_date.to_time + 1.day}' \" if validate_date?(start_date,end_date)\n\tend",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n\n #---------------\n # Smile specific : manage case where db_table param is not provided\n db_table_and_field = (db_table.present? ? \"#{db_table}.\" : '') + \"#{db_field}\"\n\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, parse_date(value.first), parse_date(value.first), is_custom_filter)\n when :integer\n int_values = value.first.to_s.scan(/[+-]?\\d+/).map(&:to_i).join(\",\")\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if int_values.present?\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) = #{int_values})\"\n else\n sql = \"#{db_table_and_field} IN (#{int_values})\"\n end\n else\n sql = \"1=0\"\n end\n when :float\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table_and_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = queried_class.send(:sanitize_sql_for_conditions, [\"#{db_table_and_field} IN (?)\", value])\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n # Smile specific : manage case where db_table param is not provided\n sql = queried_class.send(:sanitize_sql_for_conditions, [\"(#{db_table_and_field} IS NULL OR #{db_table_and_field} NOT IN (?))\", value])\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n #---------------\n # Smile specific : manage case where db_table param is not provided\n sql = \"#{db_table_and_field} IS NULL\"\n sql << \" OR #{db_table_and_field} = ''\" if (is_custom_filter || [:text, :string].include?(type_for(field)))\n when \"*\"\n #---------------\n # Smile specific : manage case where db_table param is not provided\n sql = \"#{db_table_and_field} IS NOT NULL\"\n sql << \" AND #{db_table_and_field} <> ''\" if is_custom_filter\n when \">=\"\n #---------------\n # Smile specific #147568 Filter on parent task\n # Smile specific : manage case where db_table param is not provided\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, parse_date(value.first), nil, is_custom_filter)\n else\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table_and_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, parse_date(value.first), is_custom_filter)\n else\n #---------------\n # Smile specific #147568 Filter on parent task\n # Smile specific, manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table_and_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, parse_date(value[0]), parse_date(value[1]), is_custom_filter)\n else\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table_and_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{self.class.connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{self.class.connection.quoted_true})\" if field == \"status_id\"\n when \"><t-\"\n # between today - n days and today\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0, is_custom_filter)\n when \">t-\"\n # >= today - n days\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil, is_custom_filter)\n when \"<t-\"\n # <= today - n days\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i, is_custom_filter)\n when \"t-\"\n # = n days in past\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i, is_custom_filter)\n when \"><t+\"\n # between today and today + n days\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i, is_custom_filter)\n when \">t+\"\n # >= today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil, is_custom_filter)\n when \"<t+\"\n # <= today + n days\n sql = relative_date_clause(db_table, db_field, nil, value.first.to_i, is_custom_filter)\n when \"t+\"\n # = today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i, is_custom_filter)\n when \"t\"\n # = today\n sql = relative_date_clause(db_table, db_field, 0, 0, is_custom_filter)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1, is_custom_filter)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = User.current.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6, is_custom_filter)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = User.current.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1, is_custom_filter)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = User.current.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1, is_custom_filter)\n when \"m\"\n # = this month\n date = User.current.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month, is_custom_filter)\n when \"lm\"\n # = last month\n date = User.current.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month, is_custom_filter)\n when \"y\"\n # = this year\n date = User.current.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year, is_custom_filter)\n when \"~\"\n sql = sql_contains(\"#{db_table_and_field}\", value.first)\n when \"!~\"\n sql = sql_contains(\"#{db_table_and_field}\", value.first, false)\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def get_date_solr_query(p = {})\n times = get_times(p)\n registered_only?(p) ? '' : \"AND #{Last_Changed_Field}:[\\\"#{times[:first]}\\\" TO \\\"#{times[:last]}\\\"]\" # unless the user has asked for only registered items, apply the date range for published date\n end",
"def interpret_relative_date date\n \t\tall_durations = EXISTING_PATTERNS[:weekdays] + EXISTING_PATTERNS[:months] + EXISTING_PATTERNS[:durations]\n\t \trelative_date = /(?<tense>#{EXISTING_PATTERNS[:relative_tense]}) (?<type>#{all_durations})(\\s at)*/.match(date)\n\n \t\t# Check if the user is referring to a weekday\n\t \tif weekday?(relative_date[:type])\n \t \t\tif (relative_date[:tense] == 'next')\n\t\t\t\tdate_of_next(relative_date[:type])\n\t \t\telse\n\t \t\t\tdate_of_previous(relative_date[:type])\n\t \t\tend\n\t \telse\n \t\t\ttense = (relative_date[:tense] == 'next') ? 'from_now' : 'ago'\n\t \t\tcalculate_datetime(relative_date[:type], 1, tense)\n\t \tend\n \tend",
"def appctrl_search_range_sql( model, field = nil )\n sql = range_start = range_end = nil\n\n field = model::USED_RANGE_COLUMN if ( field.nil? )\n\n unless ( params[ :search ].nil? )\n if ( ( params[ :search ].blank? and params[ :search_range_start ].blank? and params[ :search_range_end ].blank? ) or params[ :search_cancel ] )\n params.delete( :search )\n params.delete( :search_range_start )\n params.delete( :search_range_end )\n else\n range = model.used_range()\n range_start, range_end = appctrl_dates_from_search(\n Date.new( range.first ), # I.e. start year\n Date.new( range.last + 1 ) - 1 # I.e. start of year after end year, minus one day; that is, the last day of end year\n )\n\n # Since SQL date-only queries work on a 'start of the day' basis,\n # we do a \">=\" start and a \"<\" end comparison, setting the end to\n # the beginning of the *next* day.\n\n range_end += 1\n\n sql = \"#{ model.table_name }.#{ field } >= :range_start AND #{ model.table_name }.#{ field } < :range_end AND\"\n end\n end\n\n [ sql, range_start, range_end ]\n end",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def test_date_value\n row = SqlRow.new(SqlRowType.new('table', :id => :integer, :text => :date))\n row[:text] = Date.parse('2015-01-01')\n assert_equal \"'2015-01-01'\", row.sql_for(:text, :postgresql)\n end",
"def chain_with_datetime_query(collection, query)\n case query.method.to_s\n when 'between'\n method = if query.field == 'user_created_at'\n :user_signed_up_betw\n elsif query.field == 'interacted_at'\n :interacted_at_betw\n elsif query.field =~ /\\Adashboard:[0-9a-f]+\\Z/\n :dashboard_betw\n end\n\n collection.send(method,\n query,\n query.min_value.in_time_zone(query_set.time_zone),\n query.max_value.in_time_zone(query_set.time_zone)\n )\n when 'lesser_than', 'greater_than'\n beginning_of_that_days_ago = (\n Time.current.in_time_zone(query_set.time_zone) - (query.value.to_i).days\n ).beginning_of_day\n\n method = if query.field == 'user_created_at'\n query.method == 'greater_than' ? :user_signed_up_gt : :user_signed_up_lt\n elsif query.field == 'interacted_at'\n query.method == 'greater_than' ? :interacted_at_gt : :interacted_at_lt\n elsif query.field =~ /\\Adashboard:[0-9a-f]+\\Z/\n query.method == 'greater_than' ? :dashboard_gt : :dashboard_lt\n end\n\n collection.send(method, query, beginning_of_that_days_ago)\n end\n end",
"def datetime_test(field, operator, value, &block) # :yields: finder_option_type, value\n\n # Parse the value as a date/time and ignore invalid timestamps\n timestamp = definition.parse_temporal(value)\n return [] unless timestamp\n\n timestamp = timestamp.to_date if field.date?\n # Check for the case that a date-only value is given as search keyword,\n # but the field is of datetime type. Change the comparison to return\n # more logical results.\n if field.datetime?\n span = 1.minute if(value =~ /\\A\\s*\\d+\\s+\\bminutes?\\b\\s+\\bago\\b\\s*\\z/i)\n span ||= (timestamp.day_fraction == 0) ? 1.day : 1.hour\n if [:eq, :ne].include?(operator)\n # Instead of looking for an exact (non-)match, look for dates that\n # fall inside/outside the range of timestamps of that day.\n negate = (operator == :ne) ? 'NOT ' : ''\n field_sql = field.to_sql(operator, &block)\n return [\"#{negate}(#{field_sql} >= ? AND #{field_sql} < ?)\", timestamp, timestamp + span]\n\n elsif operator == :gt\n # Make sure timestamps on the given date are not included in the results\n # by moving the date to the next day.\n timestamp += span\n operator = :gte\n\n elsif operator == :lte\n # Make sure the timestamps of the given date are included by moving the\n # date to the next date.\n timestamp += span\n operator = :lt\n end\n end\n\n # return the SQL test\n [\"#{field.to_sql(operator, &block)} #{sql_operator(operator, field)} ?\", timestamp]\n end",
"def append_date_condition(search,r_name)\n if params[:date_selected]\n search += \" AND created_at Between :start_date AND :end_date \"\n r_name += \" created between #{params[:date_start]} - #{params[:date_end]}\"\n end\n [search,r_name]\n end",
"def quoted_date(value)\n @logger.unknown(\"ODBCAdapter#quoted_date (MS SQL)>\") if @trace\n @logger.unknown(\"args=[#{value}]\") if @trace\n # MS SQL DBTIME and DBDATE environment variables should be set to:\n # DBTIME=%d.%m.%Y %H:%M:%S\n # DBDATE=%d.%m.%Y\n if value.acts_like?(:time) # Time, DateTime\n %Q!'#{value.strftime(\"%Y%m%d %H:%M:%S\")}'!\n else # Date\n %Q!'#{value.strftime(\"%Y%m%d\")}'!\n end\n end",
"def future(query_date = Date.current)\n klass.where(\n future_condition(query_date: query_date, table: arel_table),\n )\n end",
"def where_clause\n '(DATE(checkin_at) >= :init_date AND DATE(checkout_at) >= :init_date)\n AND (DATE(checkin_at) <= :end_date AND DATE(checkout_at) <= :end_date)'\n end",
"def lifts_by_date(db, date)\n db.execute(\"SELECT * FROM lifts WHERE date = '#{date}'\")\nend",
"def add_date_time_scopes(col)\n if self.column_names.include?(col.to_s)\n politely_add_named_scope :\"#{col}_older_than\", lambda {|*args| where( \"#{col} < ?\", args.first || 7.days.ago ) }\n politely_add_named_scope :\"#{col}_newer_than\", lambda {|*args| where( \"#{col} > ?\", args.first || 7.days.ago ) }\n politely_add_named_scope :\"#{col}_in_past\", lambda { where( \"#{col} < ?\", Time.now ) }\n politely_add_named_scope :\"#{col}_in_future\", lambda { where( \"#{col} > ?\", Time.now ) }\n add_order_scopes(col)\n end\n end",
"def date_field(object_name, method, options = T.unsafe(nil)); end",
"def to_sql\n self.to_datetime.to_sql\n \tend",
"def to_query(col, value, op = '=')\n return op == '=' ? \"(#{col} IS NULL)\" : \"(#{col} IS NOT NULL)\" if value.nil?\n\n case op.downcase\n when '=', '!='\n if value.is_a?(Array)\n rhs = 'IN (' + Array.new(value.length, '?').join(', ') + ')'\n rhs = 'NOT ' + rhs if op == '!='\n else\n rhs = op + ' ?'\n end\n when 'between'\n rhs = 'BETWEEN ? AND ?'\n when 'not between'\n rhs = 'NOT BETWEEN ? AND ?'\n when 'like'\n rhs = 'LIKE ?'\n when 'not like'\n rhs = 'NOT LIKE ?'\n else\n rhs = op + ' ?'\n end\n\n lhs = col.to_s\n lhs = \"LOWER(#{lhs})\" if @columns[col] == :string\n\n \"(#{lhs} #{rhs})\"\n end",
"def sql\n selected_field_path = \"#{@selection.target_alias}.#{@selection.selected_field}\"\n operation = self.sql_operation.sub('?field', selected_field_path)\n \"#{operation} AS #{@field_name}\"\n end",
"def add_date_time_scopes(col)\n if self.column_names.include?(col.to_s)\n politely_add_named_scope :\"#{col}_older_than\", lambda {|*args| { :conditions => [\"#{col} < ?\", args.first || 7.days.ago] } }\n politely_add_named_scope :\"#{col}_newer_than\", lambda {|*args| { :conditions => [\"#{col} > ?\", args.first || 7.days.ago] } }\n politely_add_named_scope :\"#{col}_in_past\", { :conditions => [\"#{col} < ?\", Time.now] }\n politely_add_named_scope :\"#{col}_in_future\", { :conditions => [\"#{col} > ?\", Time.now] }\n add_order_scopes(col)\n end\n end",
"def patrick_stewart_dates\n sql = <<-SQL\n SELECT show_date FROM guests WHERE guest_name = \"Patrick Stewart\";\n SQL\n DB[:conn].execute(sql)\nend",
"def sql_query\n case @operator\n when :equals\n arel_field.eq(transmogrified_value)\n when :does_not_equal\n arel_field.not_eq(transmogrified_value)\n when :contains\n arel_field.matches(\"%#{transmogrified_value}%\")\n when :does_not_contain\n arel_field.does_not_match(\"%#{transmogrified_value}%\")\n when :starts_with\n arel_field.matches(\"#{transmogrified_value}%\")\n when :ends_with\n arel_field.matches(\"%#{transmogrified_value}\")\n when :greater_than\n arel_field.gt(transmogrified_value)\n when :greater_than_or_equal_to\n arel_field.gteq(transmogrified_value)\n when :less_than\n arel_field.lt(transmogrified_value)\n when :less_than_or_equal_to\n arel_field.lteq(transmogrified_value)\n when :in\n arel_field.in(transmogrified_value.split(/\\,\\s*/))\n when :not_in\n arel_field.not_in(transmogrified_value.split(/\\,\\s*/))\n when :blank\n arel_field.eq(nil)\n when :not_blank\n arel_field.not_eq(nil)\n end\n end",
"def bound_date_field(method, attrs = {})\n update_bound_controls(method, attrs, 'date')\n attrs[:value] = @obj.send(method)\n attrs[:name] ||= control_name(method)\n unbound_date_field(attrs)\n end",
"def date_add_sql_append(sql, da)\n if defined?(super)\n return super\n end\n h = da.interval\n expr = da.expr\n cast = case db_type = db.database_type\n when :postgres\n interval = String.new\n each_valid_interval_unit(h, DEF_DURATION_UNITS) do |value, sql_unit|\n interval << \"#{value} #{sql_unit} \"\n end\n if interval.empty?\n return literal_append(sql, Sequel.cast(expr, Time))\n else\n return complex_expression_sql_append(sql, :+, [Sequel.cast(expr, Time), Sequel.cast(interval, :interval)])\n end\n when :sqlite\n args = [expr]\n each_valid_interval_unit(h, DEF_DURATION_UNITS) do |value, sql_unit|\n args << \"#{value} #{sql_unit}\"\n end\n return function_sql_append(sql, Sequel.function(:datetime, *args))\n # SEQUEL5: Remove cubrid\n when :mysql, :hsqldb, :cubrid\n if db_type == :hsqldb\n # HSQLDB requires 2.2.9+ for the DATE_ADD function\n expr = Sequel.cast(expr, Time)\n end\n each_valid_interval_unit(h, MYSQL_DURATION_UNITS) do |value, sql_unit|\n expr = Sequel.function(:DATE_ADD, expr, Sequel.lit([\"INTERVAL \", \" \"], value, sql_unit))\n end\n when :mssql, :h2, :access, :sqlanywhere\n units = case db_type\n when :mssql, :sqlanywhere\n MSSQL_DURATION_UNITS\n when :h2\n H2_DURATION_UNITS\n when :access\n ACCESS_DURATION_UNITS\n end\n each_valid_interval_unit(h, units) do |value, sql_unit|\n expr = Sequel.function(:DATEADD, sql_unit, value, expr)\n end\n when :derby\n if expr.is_a?(Date) && !expr.is_a?(DateTime)\n # Work around for https://issues.apache.org/jira/browse/DERBY-896\n expr = Sequel.cast_string(expr) + ' 00:00:00'\n end\n each_valid_interval_unit(h, DERBY_DURATION_UNITS) do |value, sql_unit|\n expr = Sequel.lit([\"{fn timestampadd(#{sql_unit}, \", \", timestamp(\", \"))}\"], value, expr)\n end\n when :oracle\n each_valid_interval_unit(h, MYSQL_DURATION_UNITS) do |value, sql_unit|\n expr = Sequel.+(expr, Sequel.lit([\"INTERVAL \", \" \"], value.to_s, sql_unit))\n end\n when :db2\n expr = Sequel.cast(expr, Time)\n each_valid_interval_unit(h, DB2_DURATION_UNITS) do |value, sql_unit|\n expr = Sequel.+(expr, Sequel.lit([\"\", \" \"], value, sql_unit))\n end\n false\n else\n raise Error, \"date arithmetic is not implemented on #{db.database_type}\"\n end\n\n if cast\n expr = Sequel.cast(expr, Time)\n end\n\n literal_append(sql, expr)\n end",
"def relative_date(date)\n content_tag :time, date.xmlschema, data: { relative: true }\n end",
"def current_or_future_on(query_date = Date.current)\n current_cond =\n current_condition(query_date: query_date, table: arel_table)\n future_cond =\n future_condition(query_date: query_date, table: arel_table)\n\n klass.where(current_cond.or(future_cond))\n end",
"def to_sql_query_range(options={})\n min_statement = \"MIN(#{quote_column(@model.primary_key)})\"\n max_statement = \"MAX(#{quote_column(@model.primary_key)})\"\n \n # Fix to handle Sphinx PostgreSQL bug (it doesn't like NULLs or 0's)\n if adapter == :postgres\n min_statement = \"COALESCE(#{min_statement}, 1)\"\n max_statement = \"COALESCE(#{max_statement}, 1)\"\n end\n \n sql = \"SELECT #{min_statement}, #{max_statement} \" +\n \"FROM #{@model.quoted_table_name} \"\n if self.delta? && !@delta_object.clause(@model, options[:delta]).blank?\n sql << \"WHERE #{@delta_object.clause(@model, options[:delta])}\"\n end\n \n sql\n end",
"def sqlify_date(raw_date)\n m, d, y = raw_date.split('/')\n \"%04d-%02d-%02d\" % [y, m, d]\nend",
"def quote(fld)\n case fld\n when DateTime, Time\n %Q|'#{fld.to_s[0..-7]}'|\n when String, Symbol\n %Q|'#{escape fld.to_s}'|\n else\n super\n end\n\n end",
"def booking_with_furthest_checkin_date\n ActiveRecord::Base.connection.exec_query(custom_sql).collect &:values\nend",
"def grab_rows(field, src_table_name = TABLE_NAME, num_rows = ROWS_PER_TRANSACTION)\n LOGGER.info \"Creating select statement based on field `#{field[:name]}` (#{field[:type]})\"\n \n if !(field[:type] =~ /int/).nil?\n LOGGER.info \"Using integer type for select.\"\n sql = \"SELECT * FROM `%s` WHERE `%s` >= '%s' AND `%s` < '%s' ORDER BY `%s` LIMIT %s;\" % [ Mysql::escape_string(src_table_name), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:min].to_i.to_s), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:max].to_i.to_s), \n Mysql::escape_string(field[:name]), \n num_rows]\n elsif !(field[:type] =~ /datetime/).nil?\n LOGGER.info \"Using datetime type for select.\" \n sql = \"SELECT * FROM `%s` WHERE `%s` >= '%s' AND `%s` < '%s' ORDER BY `%s` LIMIT %s;\" % [ Mysql::escape_string(src_table_name), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:min].strftime(MYSQL_DATETIME_FORMAT)), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:max].strftime(MYSQL_DATETIME_FORMAT)), \n Mysql::escape_string(field[:name]), \n num_rows]\n else\n LOGGER.info \"Using default type for select, this isn't expected.\"\n sql = \"SELECT * FROM `%s` WHERE `%s` >= '%s' AND `%s` < '%s' ORDER BY `%s` LIMIT %s;\" % [ Mysql::escape_string(src_table_name), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:min]), \n Mysql::escape_string(field[:name]), \n Mysql::escape_string(field[:max]), \n Mysql::escape_string(field[:name]), \n num_rows] \n end\n \n LOGGER.debug \"SQL: #{sql}\"\n dbres = do_sql_command(sql)\n dbres\nend",
"def type_literal_generic_date(column)\n :date\n end",
"def arel_field\n case param.field.options[:transmogrification]\n when :timestamp_to_hours\n Arel::Nodes::NamedFunction.new('TIMESTAMPDIFF', [Arel::Nodes::SqlLiteral.new('HOUR'), arel_table[field], Arel::Nodes::SqlLiteral.new('UTC_TIMESTAMP()')])\n when :timestamp_to_days\n Arel::Nodes::NamedFunction.new('TIMESTAMPDIFF', [Arel::Nodes::SqlLiteral.new('DAY'), arel_table[field], Arel::Nodes::SqlLiteral.new('UTC_TIMESTAMP()')])\n when :sum\n Arel::Nodes::NamedFunction.new('SUM', [arel_table[field]])\n when :upper\n Arel::Nodes::NamedFunction.new('UPPER', [arel_table[field]])\n when :lower\n Arel::Nodes::NamedFunction.new('LOWER', [arel_table[field]])\n else\n arel_table[field]\n end\n end",
"def select_date(month, day, year)\n select month, from: \"report_date_month\"\n select day, from: \"report_date_day\"\n select year, from: \"report_date_year\"\n end",
"def buil_must_query_filter\n query_filter = [{ 'range' => date_range_filter }]\n query_filter | @raw_query\n end",
"def relative_date? date\n \t\tall_durations = EXISTING_PATTERNS[:weekdays] + EXISTING_PATTERNS[:months] + EXISTING_PATTERNS[:durations]\n \t\t!(/(#{EXISTING_PATTERNS[:relative_tense]}) (#{all_durations})/.match(date)).nil? \n \tend",
"def append_matter_date_cond(search,conditions_hash)\n\n \n search += \" AND created_at Between :start_date AND :end_date \" if params[:get_records] == \"My\"\n \n time = nil\n case params[:report][:duration]\n when \"1\" #1 months\n time = Time.zone.now.last_month\n when \"2\" #3 months\n 3.times do |i|\n unless time\n time = Time.zone.now.last_month\n else\n time = time.last_month\n end\n end\n when \"3\" #6 months\n 6.times do |i|\n unless time\n time = Time.zone.now.last_month\n else\n time = time.last_month\n end\n end\n else #date range given\n conditions_hash[:start_date] = params[:date_start].to_time\n conditions_hash[:end_date] = params[:date_end].to_time + (23.9*60*60)\n end\n if params[:report][:duration] != \"range\"\n conditions_hash[:start_date] = time\n conditions_hash[:end_date] = Time.zone.now\n end\n search\n end",
"def datetime_field(object_name, method, options = T.unsafe(nil)); end",
"def query(date_string)\n { created_at: date_string.to_date.beginning_of_day..date_string.to_date.end_of_day }\n end",
"def add_range_to_jql str\n str << \" and created >= '#{@sprint_start_date}' and created <= '#{@sprint_end_date}'\"\n end",
"def to_arel_sql(value)\n case value\n when Arel::Nodes::Node, Arel::Nodes::SqlLiteral, nil\n value\n when ActiveRecord::Relation\n Arel.sql(value.spawn.to_sql)\n else\n Arel.sql(value.respond_to?(:to_sql) ? value.to_sql : value.to_s)\n end\n end",
"def get_reminders(date)\r\n d = date_checker(date)\r\n new_date = normalize_date(d)\r\n get = <<-SQL\r\n SELECT * FROM reminders WHERE date = ?\r\n SQL\r\n $DB.execute(get, [new_date])\r\n #puts selected_reminders\r\nend",
"def perform_field_query query, response, scope\n if Array === query\n case query.first\n when :method # a method call\n query.shift\n return eval(query.join('.'))\n when :literal # a literal value\n return query.last\n end\n end\n response.scalar_query(query, scope)\n end",
"def sql_operator(operator, field)\n raise ScopedSearch::QueryNotSupported, \"the operator '#{operator}' is not supported for field type '#{field.type}'\" if !field.virtual? and [:like, :unlike].include?(operator) and !field.textual?\n SQL_OPERATORS[operator]\n end",
"def filterable_by_date_range(with_name = :created_at)\n @_filterable_by_date_range_field = with_name.to_s\n end",
"def quote_date_with_to_date(value)\n value = value.to_s(:db) if value.acts_like?(:date) || value.acts_like?(:time)\n \"TO_DATE('#{value}','YYYY-MM-DD HH24:MI:SS')\"\n end",
"def current(query_date = Date.current)\n klass.where(\n current_condition(query_date: query_date, table: arel_table),\n )\n end",
"def sql_expr\n @sql_expr ||= (meta[:sql_expr] || to_sql_name)\n end",
"def convert_expr(expr, values = [], entry = nil)\n if expr_conjunction?(expr)\n return convert_conjunction(expr, values, entry)\n end\n\n column = qualified_db_column(expr, entry)\n op = expr.op\n arg = case expr.op\n when 'in', 'not in' then '(?)'\n when 'between', 'not between' then '? AND ?'\n else\n '?'\n end\n\n values << expr.value\n [\"#{column} #{op} #{arg}\", values]\n end",
"def format_query_condition(condition)\n case condition\n when nil\n \"=\" # Search for empty field\n when Range\n format_range_condition(condition)\n when *FmRest::V1.datetime_classes\n FmRest::V1.convert_datetime_timezone(condition.to_datetime, klass.fmrest_config.timezone)\n .strftime(FmRest::V1::Dates::FM_DATETIME_FORMAT)\n when *FmRest::V1.date_classes\n condition.strftime(FmRest::V1::Dates::FM_DATE_FORMAT)\n else\n condition\n end\n end",
"def searchable(*attr_names)\r\n attr_names.each do |attr_name|\r\n scope \"search_#{attr_name}\", -> attr_value do\r\n where(attr_name => (attr_name =~ /_on$/ ? parse_date_string(attr_value) : attr_value))\r\n end\r\n end\r\n end",
"def append_time_expense_date_cond(search,r_name,conditions_hash)\r\n \r\n search += \"AND time_entry_date Between :start_date AND :end_date \"\r\n \r\n time = nil\r\n case params[:report][:duration]\r\n when \"1\" #1 week\r\n time = 7.days.ago\r\n when \"2\" #2 weeks\r\n time = 14.days.ago\r\n when \"3\" #1month\r\n time = Time.zone.now.last_month\r\n when \"4\" #3months\r\n 3.times do |i|\r\n unless time\r\n time = Time.zone.now.last_month\r\n else\r\n time = time.last_month\r\n end\r\n end\r\n when \"range\" #Date Range\r\n r_name += \" entered between #{params[:date_start]} - #{params[:date_end]}\"\r\n conditions_hash[:start_date] = params[:date_start].to_time\r\n conditions_hash[:end_date] = params[:date_end].to_time + (23.9*60*60)\r\n end\r\n if params[:report][:duration] != \"range\"\r\n conditions_hash[:start_date] = time\r\n conditions_hash[:end_date] = Time.zone.now\r\n end\r\n [search,r_name]\r\n end",
"def field_query(field, value)\n \"_query_:\\\"{!field f=#{field}}#{value}\\\"\"\n end",
"def relative_date datetime\n return '' if datetime.nil?\n\n # Now we'll calculate a short, human-friendly\n # version of the full date (like '2 days, 5 hours')\n added_secs = datetime.strftime('%s').to_i\n now_secs = DateTime.now.strftime('%s').to_i\n\n ChronicDuration.output(now_secs - added_secs)\n end",
"def attendance_between_dates_condition\n\t\t\"attendances.attendance_on BETWEEN '#{start_on}' AND '#{end_on}'\"\n\tend",
"def sql_of( expr, dataset)\n dataset.send :literal_expression_append, rv=String.new, expr\n rv\n end",
"def filter_by_date(term)\n search_data = term.split(DATE_SEARCH_SEPARATOR)\n comparison_date = ActiveSupport::TimeZone.new('UTC').parse(search_data.last)\n return \"[#{comparison_date.xmlschema} TO *]\" if search_data.first == 'after'\n return \"[* TO #{comparison_date.xmlschema}]\" if search_data.first == 'before'\n \"[#{comparison_date.xmlschema.to_s} TO #{(comparison_date + 1.days).xmlschema}]\"\n end",
"def where_operator(field, operator, *args, **options)\n if field.is_a?(Arel::Nodes::Node)\n node = field\n elsif has_attribute?(field)\n node = arel_table[field]\n else\n node = Arel.sql(field.to_s)\n end\n\n arel = node.send(operator, *args, **options)\n where(arel)\n end",
"def filter_by_date(term)\n search_data = term.split(DATE_SEARCH_SEPARATOR)\n comparison_date = load_comparison_date(search_data.last)\n return \"[#{comparison_date.xmlschema} TO *]\" if search_data.first == DATE_SEARCH_TERMS.last\n return \"[* TO #{comparison_date.xmlschema}]\" if search_data.first == DATE_SEARCH_TERMS.first\n \"[#{comparison_date.xmlschema.to_s} TO #{(comparison_date + 1.days).xmlschema}]\"\n end",
"def for(date)\n where(actual_date: date)\n end",
"def transaction_query(query, start_date, end_date)\n raise NoMethodError, \"transaction_query method will come soon\"\n end",
"def datetime_local_field(object_name, method, options = T.unsafe(nil)); end",
"def datetime_range_column(new_column, options = {})\n\t\t\t\t\t\t\n\t\t\t\t\t\t# Set method\n\t\t\t\t\t\tdefine_method((new_column.to_s + \"=\").to_sym) do |value|\n\t\t\t\t\t\t\tcolumn = new_column\n\n\t\t\t\t\t\t\t# Check type\n\t\t\t\t\t\t\tif !value.nil? && !value.is_a?(Hash)\n\t\t\t\t\t\t\t\traise \"Wrong value format, expecting Hash or nil.\"\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t# Filter\n\t\t\t\t\t\t\tvalue = value.symbolize_keys.select { |key, value| [:date, :from, :to].include?(key) } if !value.nil?\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif value.nil? || value[:date].blank? || value[:from].blank? || value[:to].blank?\n\t\t\t\t\t\t\t\tself.send(\"#{column.to_s}_from=\", nil)\n\t\t\t\t\t\t\t\tself.send(\"#{column.to_s}_to=\", nil)\n\t\t\t\t\t\t\telse\n\n\t\t\t\t\t\t\t\t# Parse date\n\t\t\t\t\t\t\t\tif value[:date].is_a?(::String)\n\t\t\t\t\t\t\t\t\tdate = Date.parse(value[:date])\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tdate = value[:date]\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t# Parse from\n\t\t\t\t\t\t\t\tif value[:from].is_a?(::String)\n\t\t\t\t\t\t\t\t\tfrom = DateTime.parse(value[:from])\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tfrom = value[:from]\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t# Parse to\n\t\t\t\t\t\t\t\tif value[:to].is_a?(::String)\n\t\t\t\t\t\t\t\t\tto = DateTime.parse(value[:to])\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tto = value[:to]\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t# Compose\n\t\t\t\t\t\t\t\tif !date.nil?\n\t\t\t\t\t\t\t\t\tself.send(\"#{column.to_s}_from=\", DateTime.compose(date, from)) if !from.nil?\n\t\t\t\t\t\t\t\t\tself.send(\"#{column.to_s}_to=\", DateTime.compose(date, to)) if !to.nil?\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tself.send(\"#{column.to_s}_from=\", nil)\n\t\t\t\t\t\t\t\t\tself.send(\"#{column.to_s}_to=\", nil)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# Get method\n\t\t\t\t\t\tdefine_method(new_column.to_sym) do\n\t\t\t\t\t\t\tcolumn = new_column\n\t\t\t\t\t\t\tvalue_from = self.send(\"#{column.to_s}_from\")\n\t\t\t\t\t\t\tvalue_to = self.send(\"#{column.to_s}_to\")\n\t\t\t\t\t\t\tif value_from.blank? && value_to.blank?\n\t\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\treturn { date: value_from.to_date, from: value_from, to: value_to }\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend",
"def find_patient_earliest_start_date(patient, date_enrolled = nil)\n date_enrolled ||= find_patient_date_enrolled(patient)\n\n patient_id = ActiveRecord::Base.connection.quote(patient.patient_id)\n date_enrolled = ActiveRecord::Base.connection.quote(date_enrolled)\n\n result = ActiveRecord::Base.connection.select_one(\n \"SELECT date_antiretrovirals_started(#{patient_id}, #{date_enrolled}) AS date\"\n )\n\n result['date']&.to_date\n end",
"def dates\n dates_query.all\n end",
"def test_dates_in_query_params_treated_as_strings\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/hello\", log_http_options.deep_merge({\n :params => {\n :date_field => \"2010-05-01\",\n },\n }))\n assert_response_code(200, response)\n record = wait_for_log(response)[:hit_source]\n assert_equal(\"2010-05-01\", record[\"request_query\"][\"date_field\"])\n\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/hello\", log_http_options.deep_merge({\n :params => {\n :date_field => \"2010-05-0\",\n },\n }))\n assert_response_code(200, response)\n record = wait_for_log(response)[:hit_source]\n assert_equal(\"2010-05-0\", record[\"request_query\"][\"date_field\"])\n\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/hello\", log_http_options.deep_merge({\n :params => {\n :date_field => \"foo\",\n },\n }))\n assert_response_code(200, response)\n record = wait_for_log(response)[:hit_source]\n assert_equal(\"foo\", record[\"request_query\"][\"date_field\"])\n end",
"def patrick_stewart_appearances\n sql = <<-SQL\n SELECT show_date\n FROM guest_appearances\n WHERE guest_name = \"Patrick Stewart\";\n SQL\n puts DB[:conn].execute(sql)\nend",
"def clause(model, toggled)\n if toggled\n \"#{model.quoted_table_name}.#{model.connection.quote_column_name(@column.to_s)}\" +\n \" > #{adapter.time_difference(@threshold)}\"\n else\n nil\n end\n end",
"def sql(options = {})\n options = normalize_options(options)\n if value\t\n\t\"#{column(options)} #{operator} #{quoted_value(options)}\"\n else\n\t\"#{column(options)} #{operator}\"\n end\n end",
"def to_sparql(**options)\n \"TZ(\" + operands.to_sparql(**options) + \")\"\n end",
"def solr_date(date)\n return Time.utc(date.year, date.mon, date.mday).iso8601()\nend",
"def solr_date(date)\n return Time.utc(date.year, date.mon, date.mday).iso8601()\nend",
"def build_query(base)\n # Expose columns and get the list of the ones for select\n columns = expose_columns(base, @query.try(:arel_table))\n sub_columns = columns.dup\n type = @union_all.present? ? 'all' : ''\n\n # Build any extra columns that are dynamic and from the recursion\n extra_columns(base, columns, sub_columns)\n\n # Prepare the query depending on its type\n if @query.is_a?(String) && @sub_query.is_a?(String)\n args = @args.each_with_object({}) { |h, (k, v)| h[k] = base.connection.quote(v) }\n ::Arel.sql(\"(#{@query} UNION #{type.upcase} #{@sub_query})\" % args)\n elsif relation_query?(@query)\n @query = @query.where(@where) if @where.present?\n @bound_attributes.concat(@query.send(:bound_attributes))\n\n if relation_query?(@sub_query)\n @bound_attributes.concat(@sub_query.send(:bound_attributes))\n\n sub_query = @sub_query.select(*sub_columns).arel\n sub_query.from([@sub_query.arel_table, table])\n else\n sub_query = ::Arel.sql(@sub_query)\n end\n\n @query.select(*columns).arel.union(type, sub_query)\n else\n raise ArgumentError, <<-MSG.squish\n Only String and ActiveRecord::Base objects are accepted as query and sub query\n objects, #{@query.class.name} given for #{self.class.name}.\n MSG\n end\n end",
"def sql_test(field, operator, value, lhs, &block) # :yields: finder_option_type, value\n return field.to_ext_method_sql(lhs, sql_operator(operator, field), value, &block) if field.virtual?\n\n yield(:keyparameter, lhs.sub(/^.*\\./,'')) if field.key_field\n\n condition, *values = if field.temporal?\n datetime_test(field, operator, value, &block)\n elsif field.set?\n set_test(field, operator, value, &block)\n else\n [\"#{field.to_sql(operator, &block)} #{self.sql_operator(operator, field)} #{value_placeholders(operator, value)}\", value]\n end\n values.each { |value| preprocess_parameters(field, operator, value, &block) }\n\n if field.relation && definition.reflection_by_name(field.definition.klass, field.relation).macro == :has_many\n connection = field.definition.klass.connection\n reflection = definition.reflection_by_name(field.definition.klass, field.relation)\n primary_key_col = reflection.options[:primary_key] || field.definition.klass.primary_key\n primary_key = \"#{connection.quote_table_name(field.definition.klass.table_name)}.#{connection.quote_column_name(primary_key_col)}\"\n key, join_table = if reflection.options.has_key?(:through)\n [primary_key, has_many_through_join(field)]\n else\n [connection.quote_column_name(field.reflection_keys(reflection)[1]),\n connection.quote_table_name(field.klass.table_name)]\n end\n\n condition = \"#{primary_key} IN (SELECT #{key} FROM #{join_table} WHERE #{condition} )\"\n end\n condition\n end",
"def bound_datetime_field(method, attrs = {})\n update_bound_controls(method, attrs, 'datetime')\n attrs[:value] = @obj.send(method)\n attrs[:name] ||= control_name(method)\n unbound_datetime_field(attrs)\n end",
"def select_date(date = Date.today, options = {})\r\n if !options[:order]\r\n options[:order] = [:year, :month, :day]\r\n else # don't allow time, just dates\r\n options[:order] = options[:order] - [:hour, :minute, :second, :ampm]\r\n end\r\n select_datetime(date, options)\r\n end",
"def test_quoted_datetime_local\n with_active_record_default_timezone :local do\n t = DateTime.now\n assert_equal t.to_s(:db), @quoter.quoted_date(t)\n end\n end",
"def searchable_date(attribute)\n searchable do\n time attribute\n string attribute\n end\n end",
"def rewrite_query # :nodoc:\n if timestamp = compute_mtime\n append_query(timestamp.to_i.to_s)\n end\n end",
"def calc_query(query, table, aggregate = {}, as=nil)\n\tquery = \"select #{query}\"\n\n\tif !aggregate.empty?\n\t\taggregate.each do |operation, column|\n\t\t\tquery += \"#{operation}(#{column}) \"\n\t\t\tquery += as \" #{as}\"\n\t\tend\n\tend\n\n\tquery += \" from #{table}\"\n\n\treturn query\nend",
"def sql_for_bu_project_field(field, operator, value)\n sql_for_field(field, operator, value, 'bu_project_id', 'customized_id')\n end"
] | [
"0.7916117",
"0.7916117",
"0.71775657",
"0.7087279",
"0.7069307",
"0.67671645",
"0.6665684",
"0.6291998",
"0.62455803",
"0.613135",
"0.6094927",
"0.6094068",
"0.5842428",
"0.5817658",
"0.57967645",
"0.57849914",
"0.5680531",
"0.5475651",
"0.544504",
"0.53898245",
"0.5313643",
"0.52308065",
"0.5214827",
"0.5214827",
"0.5214827",
"0.5209957",
"0.519665",
"0.5191343",
"0.5171707",
"0.5143653",
"0.51234955",
"0.5049863",
"0.50278807",
"0.50119627",
"0.4986986",
"0.49759057",
"0.49686304",
"0.49512613",
"0.4945696",
"0.48976666",
"0.4888004",
"0.48729286",
"0.4866978",
"0.4830575",
"0.48262918",
"0.4819799",
"0.4803633",
"0.4802712",
"0.47949734",
"0.47902963",
"0.47788173",
"0.47754523",
"0.4731584",
"0.47179964",
"0.47153828",
"0.47147515",
"0.47131035",
"0.47040418",
"0.46577203",
"0.4631154",
"0.46173614",
"0.46004233",
"0.45960245",
"0.45947132",
"0.45653492",
"0.45652583",
"0.4555389",
"0.45526114",
"0.45457208",
"0.45370662",
"0.45324513",
"0.45308995",
"0.45196515",
"0.45158613",
"0.45089296",
"0.45059937",
"0.45039868",
"0.45036128",
"0.4503356",
"0.45004472",
"0.44980413",
"0.44875526",
"0.44684127",
"0.44683024",
"0.4461779",
"0.4460036",
"0.44543836",
"0.4452507",
"0.44524834",
"0.44516364",
"0.44516364",
"0.44513625",
"0.44500634",
"0.44496998",
"0.44385085",
"0.44373542",
"0.44286814",
"0.44279787",
"0.44253787",
"0.44239122"
] | 0.78421736 | 2 |
Helper method to generate the WHERE sql for a +field+, +operator+ and a +value+ | def sql_for(name, operator=nil, values=nil, table=nil, field=nil, type=nil)
values ||= values_for(name)
# return if values_blank?(name, values)
type ||= type_for(name)
table ||= queryable_class.table_name
operator ||= operator_for(name)
field ||= name
sql = nil
case operator
when "="
if [:date, :date_past].include?(type)
sql = date_clause(table, field, (Date.parse(values.first) rescue nil), (Date.parse(values.first) rescue nil))
elsif type == :boolean
if values.first.to_i == 0
sql = "#{table}.#{field} = #{connection.quoted_false}"
else
sql = "#{table}.#{field} = #{connection.quoted_true}"
end
else
if values.present?
sql = "#{table}.#{field} IN (" + values.map{ |val| "'#{connection.quote_string(val)}'" }.join(",") + ")"
else
# IN an empty set
sql = "0=1"
end
end
when "!"
if values.present?
sql = "(#{table}.#{field} IS NULL OR #{table}.#{field} NOT IN (" + values.map{ |val| "'#{connection.quote_string(val)}'" }.join(",") + "))"
else
# empty set of forbidden values allows all results
sql = "1=1"
end
when "!*"
sql = "#{table}.#{field} IS NULL"
when "*"
sql = "#{table}.#{field} IS NOT NULL"
when ">="
if [:date, :date_past].include?(type)
sql = date_clause(table, field, (Date.parse(values.first) rescue nil), nil)
else
sql = "#{table}.#{field} >= #{values.first.to_i}"
end
when "<="
if [:date, :date_past].include?(type)
sql = date_clause(table, field, nil, (Date.parse(values.first) rescue nil))
else
sql = "#{table}.#{field} <= #{values.first.to_i}"
end
when "><"
if [:date, :date_past].include?(type)
sql = date_clause(table, field, (Date.parse(values[0]) rescue nil), (Date.parse(values[1]) rescue nil))
else
sql = "#{table}.#{field} BETWEEN #{values[0].to_i} AND #{values[1].to_i}"
end
when ">t-"
sql = relative_date_clause(table, field, - values.first.to_i, 0)
when "<t-"
sql = relative_date_clause(table, field, nil, - values.first.to_i)
when "t-"
sql = relative_date_clause(table, field, - values.first.to_i, - values.first.to_i)
when ">t+"
sql = relative_date_clause(table, field, values.first.to_i, nil)
when "<t+"
sql = relative_date_clause(table, field, 0, values.first.to_i)
when "t+"
sql = relative_date_clause(table, field, values.first.to_i, values.first.to_i)
when "t"
sql = relative_date_clause(table, field, 0, 0)
when "w"
first_day_of_week = 7
day_of_week = Date.today.cwday
days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)
sql = relative_date_clause(table, field, - days_ago, - days_ago + 6)
when "~"
sql = "LOWER(#{table}.#{field}) LIKE '%#{connection.quote_string(values.first.to_s.downcase)}%'"
when "!~"
sql = "LOWER(#{table}.#{field}) NOT LIKE '%#{connection.quote_string(values.first.to_s.downcase)}%'"
end
sql.empty? ? nil : "(#{sql})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(#{db_table}.#{db_field} AS decimal(60,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \">t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), (Date.parse(value.first) rescue nil))\n when :integer\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) = #{value.first.to_i})\"\n else\n sql = \"#{db_table}.#{db_field} = #{value.first.to_i}\"\n end\n when :float\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")\"\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \"))\"\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value.first) rescue nil), nil)\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, (Date.parse(value.first) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, (Date.parse(value[0]) rescue nil), (Date.parse(value[1]) rescue nil))\n else\n if is_custom_filter\n sql = \"(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table}.#{db_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})\" if field == \"status_id\"\n when \"><t-\"\n # between today - n days and today\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)\n when \">t-\"\n # >= today - n days\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil)\n when \"<t-\"\n # <= today - n days\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n # = n days in past\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \"><t+\"\n # between today and today + n days\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i)\n when \">t+\"\n # >= today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n # <= today + n days\n sql = relative_date_clause(db_table, db_field, nil, value.first.to_i)\n when \"t+\"\n # = today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n # = today\n sql = relative_date_clause(db_table, db_field, 0, 0)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = Date.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1)\n when \"m\"\n # = this month\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"lm\"\n # = last month\n date = Date.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month)\n when \"y\"\n # = this year\n date = Date.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'\"\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n case operator\n when \"=\"\n sql = \"#{db_table}.#{db_field} IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \")\"\n when \"!\"\n sql = \"(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (\" + value.collect{|val| \"'#{connection.quoted_string(val)}'\"}.join(\",\") + \"))\"\n when \"!*\"\n sql = \"#{db_table}.#{db_field} IS NULL\"\n sql << \" OR #{db_table}.#{db_field} = ''\" if is_custom_filter\n when \"*\"\n sql = \"#{db_table}.#{db_field} IS NOT NULL\"\n sql << \" AND #{db_table}.#{db_field} <> ''\" if is_custom_filter\n when \">=\"\n sql = \"#{db_table}.#{db_field} >= #{value.first.to_f}\"\n when \"<=\"\n sql = \"#{db_table}.#{db_field} <= #{value.first.to_f}\"\n when \"o\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}\" if field == \"status_id\"\n when \"c\"\n sql = \"#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}\" if field == \"status_id\"\n when \">t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, 0)\n when \"<t-\"\n sql = date_range_clause(db_table, db_field, nil, - value.first.to_i)\n when \"t-\"\n sql = date_range_clause(db_table, db_field, - value.first.to_i, - value.first.to_i)\n when \">t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, nil)\n when \"<t+\"\n sql = date_range_clause(db_table, db_field, 0, value.first.to_i)\n when \"t+\"\n sql = date_range_clause(db_table, db_field, value.first.to_i, value.first.to_i)\n when \"t\"\n sql = date_range_clause(db_table, db_field, 0, 0)\n when \"w\"\n from = l(:general_first_day_of_week) == '7' ?\n # week starts on sunday\n ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) :\n # week starts on monday (Rails default)\n Time.now.at_beginning_of_week\n sql = \"#{db_table}.#{db_field} BETWEEN '%s' AND '%s'\" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]\n when \"~\"\n sql = \"LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"!~\"\n sql = \"LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quoted_string(value.first.to_s.downcase)}%'\"\n when \"..\"\n from = nil\n to = nil\n sql = \"\"\n from = Date.parse(value[1])\n to = Date.parse(value[2])\n sql = value_in_date_range(db_table, db_field, from, to)\n end\n return sql\n end",
"def sql_query\n case @operator\n when :equals\n arel_field.eq(transmogrified_value)\n when :does_not_equal\n arel_field.not_eq(transmogrified_value)\n when :contains\n arel_field.matches(\"%#{transmogrified_value}%\")\n when :does_not_contain\n arel_field.does_not_match(\"%#{transmogrified_value}%\")\n when :starts_with\n arel_field.matches(\"#{transmogrified_value}%\")\n when :ends_with\n arel_field.matches(\"%#{transmogrified_value}\")\n when :greater_than\n arel_field.gt(transmogrified_value)\n when :greater_than_or_equal_to\n arel_field.gteq(transmogrified_value)\n when :less_than\n arel_field.lt(transmogrified_value)\n when :less_than_or_equal_to\n arel_field.lteq(transmogrified_value)\n when :in\n arel_field.in(transmogrified_value.split(/\\,\\s*/))\n when :not_in\n arel_field.not_in(transmogrified_value.split(/\\,\\s*/))\n when :blank\n arel_field.eq(nil)\n when :not_blank\n arel_field.not_eq(nil)\n end\n end",
"def conditions_for(fields=[])\n predicate = []\n values = []\n fields.each do |field|\n predicate << \"lower(#{field.to_s}) like ?\"\n values << \"'%' + @search_key.downcase + '%'\"\n end\n eval(\"[\\\"#{predicate.join(' OR ')}\\\", #{values.join(',')}]\")\n end",
"def sql_for_field(field, operator, value, db_table, db_field, is_custom_filter=false)\n sql = ''\n\n #---------------\n # Smile specific : manage case where db_table param is not provided\n db_table_and_field = (db_table.present? ? \"#{db_table}.\" : '') + \"#{db_field}\"\n\n case operator\n when \"=\"\n if value.any?\n case type_for(field)\n when :date, :date_past\n sql = date_clause(db_table, db_field, parse_date(value.first), parse_date(value.first), is_custom_filter)\n when :integer\n int_values = value.first.to_s.scan(/[+-]?\\d+/).map(&:to_i).join(\",\")\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if int_values.present?\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) = #{int_values})\"\n else\n sql = \"#{db_table_and_field} IN (#{int_values})\"\n end\n else\n sql = \"1=0\"\n end\n when :float\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})\"\n else\n sql = \"#{db_table_and_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}\"\n end\n else\n sql = queried_class.send(:sanitize_sql_for_conditions, [\"#{db_table_and_field} IN (?)\", value])\n end\n else\n # IN an empty set\n sql = \"1=0\"\n end\n when \"!\"\n if value.any?\n # Smile specific : manage case where db_table param is not provided\n sql = queried_class.send(:sanitize_sql_for_conditions, [\"(#{db_table_and_field} IS NULL OR #{db_table_and_field} NOT IN (?))\", value])\n else\n # NOT IN an empty set\n sql = \"1=1\"\n end\n when \"!*\"\n #---------------\n # Smile specific : manage case where db_table param is not provided\n sql = \"#{db_table_and_field} IS NULL\"\n sql << \" OR #{db_table_and_field} = ''\" if (is_custom_filter || [:text, :string].include?(type_for(field)))\n when \"*\"\n #---------------\n # Smile specific : manage case where db_table param is not provided\n sql = \"#{db_table_and_field} IS NOT NULL\"\n sql << \" AND #{db_table_and_field} <> ''\" if is_custom_filter\n when \">=\"\n #---------------\n # Smile specific #147568 Filter on parent task\n # Smile specific : manage case where db_table param is not provided\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, parse_date(value.first), nil, is_custom_filter)\n else\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) >= #{value.first.to_f})\"\n else\n sql = \"#{db_table_and_field} >= #{value.first.to_f}\"\n end\n end\n when \"<=\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, nil, parse_date(value.first), is_custom_filter)\n else\n #---------------\n # Smile specific #147568 Filter on parent task\n # Smile specific, manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) <= #{value.first.to_f})\"\n else\n sql = \"#{db_table_and_field} <= #{value.first.to_f}\"\n end\n end\n when \"><\"\n if [:date, :date_past].include?(type_for(field))\n sql = date_clause(db_table, db_field, parse_date(value[0]), parse_date(value[1]), is_custom_filter)\n else\n #---------------\n # Smile specific : manage case where db_table param is not provided\n if is_custom_filter\n sql = \"(#{db_table_and_field} <> '' AND CAST(CASE #{db_table_and_field} WHEN '' THEN '0' ELSE #{db_table_and_field} END AS decimal(30,3)) BETWEEN #{value[0].to_f} AND #{value[1].to_f})\"\n else\n sql = \"#{db_table_and_field} BETWEEN #{value[0].to_f} AND #{value[1].to_f}\"\n end\n end\n when \"o\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{self.class.connection.quoted_false})\" if field == \"status_id\"\n when \"c\"\n sql = \"#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{self.class.connection.quoted_true})\" if field == \"status_id\"\n when \"><t-\"\n # between today - n days and today\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0, is_custom_filter)\n when \">t-\"\n # >= today - n days\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, nil, is_custom_filter)\n when \"<t-\"\n # <= today - n days\n sql = relative_date_clause(db_table, db_field, nil, - value.first.to_i, is_custom_filter)\n when \"t-\"\n # = n days in past\n sql = relative_date_clause(db_table, db_field, - value.first.to_i, - value.first.to_i, is_custom_filter)\n when \"><t+\"\n # between today and today + n days\n sql = relative_date_clause(db_table, db_field, 0, value.first.to_i, is_custom_filter)\n when \">t+\"\n # >= today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, nil, is_custom_filter)\n when \"<t+\"\n # <= today + n days\n sql = relative_date_clause(db_table, db_field, nil, value.first.to_i, is_custom_filter)\n when \"t+\"\n # = today + n days\n sql = relative_date_clause(db_table, db_field, value.first.to_i, value.first.to_i, is_custom_filter)\n when \"t\"\n # = today\n sql = relative_date_clause(db_table, db_field, 0, 0, is_custom_filter)\n when \"ld\"\n # = yesterday\n sql = relative_date_clause(db_table, db_field, -1, -1, is_custom_filter)\n when \"w\"\n # = this week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = User.current.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago, - days_ago + 6, is_custom_filter)\n when \"lw\"\n # = last week\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = User.current.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 7, - days_ago - 1, is_custom_filter)\n when \"l2w\"\n # = last 2 weeks\n first_day_of_week = l(:general_first_day_of_week).to_i\n day_of_week = User.current.today.cwday\n days_ago = (day_of_week >= first_day_of_week ? day_of_week - first_day_of_week : day_of_week + 7 - first_day_of_week)\n sql = relative_date_clause(db_table, db_field, - days_ago - 14, - days_ago - 1, is_custom_filter)\n when \"m\"\n # = this month\n date = User.current.today\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month, is_custom_filter)\n when \"lm\"\n # = last month\n date = User.current.today.prev_month\n sql = date_clause(db_table, db_field, date.beginning_of_month, date.end_of_month, is_custom_filter)\n when \"y\"\n # = this year\n date = User.current.today\n sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year, is_custom_filter)\n when \"~\"\n sql = sql_contains(\"#{db_table_and_field}\", value.first)\n when \"!~\"\n sql = sql_contains(\"#{db_table_and_field}\", value.first, false)\n else\n raise \"Unknown query operator #{operator}\"\n end\n\n return sql\n end",
"def build_where(query)\n where = \"\"\n query.each_pair do |k, v| \n if (k!='include' and k!='exclude')\n where += \"(`#{escape_str_field(k)}` #{build_equal_condition(v)}) AND \"\n end\n end\n where.chomp(' AND ')\n end",
"def sql(options = {})\n options = normalize_options(options)\n if value\t\n\t\"#{column(options)} #{operator} #{quoted_value(options)}\"\n else\n\t\"#{column(options)} #{operator}\"\n end\n end",
"def where(search, operator)\n\t\twhere_clause=[]\n\t\tfor i in 0..search.count-1\n\t\t\tif search.values[i].is_a? String\n\t\t\t\twhere_clause.push(\"#{search.keys[i]}#{operator}'#{search.values[i]}'\")\n\t\t\telse\n\t\t\t\twhere_clause.push(\"#{search.keys[i]}#{operator}#{search.values[i]}\")\n\t\t\tend\n\t\tend\n\t\twhere_clause = where_clause.join(\" AND \")\n\t\tresults = DATA.execute(\"SELECT * FROM #{@table} WHERE #{where_clause}\")\n\t\treturn results\n\tend",
"def where_operator(field, operator, *args, **options)\n if field.is_a?(Arel::Nodes::Node)\n node = field\n elsif has_attribute?(field)\n node = arel_table[field]\n else\n node = Arel.sql(field.to_s)\n end\n\n arel = node.send(operator, *args, **options)\n where(arel)\n end",
"def where_operator(field, operator, *args, **options)\n arel = arel_node(field).send(operator, *args, **options)\n where(arel)\n end",
"def generate_where_phrase\n opt_where = @opt[:where]\n\n return '' if opt_where.nil? or opt_where.empty?\n\n where = []\n opt_where.each_pair { |k, v|\n a = @entity.attr(k)\n r = @entity.rel(k)\n if a\n raise \"Field #{k.inspect} is not indexed\" unless a.indexed?\n wh = where_entry_single_column(k, v)\n elsif r\n if r.multi?\n @tables << \" LEFT JOIN `#{r.sql_table}` ON `#{@entity.name}`.`_id`=`#{r.sql_table}`.`#{r.sql_column1}`\"\n wh = where_entry_join_id(r, v)\n else\n wh = where_entry_single_column(k, v)\n end\n elsif k == '_id'\n # ID column is not an attribute, so it requires special case\n wh = where_entry_single_column(k, v)\n else\n raise \"Invalid field name: #{k.inspect}\" unless a\n end\n\n where << wh if wh\n }\n\n @where_phrase = where.empty? ? '' : \"WHERE #{where.join(' AND ')}\"\n end",
"def to_query(col, value, op = '=')\n return op == '=' ? \"(#{col} IS NULL)\" : \"(#{col} IS NOT NULL)\" if value.nil?\n\n case op.downcase\n when '=', '!='\n if value.is_a?(Array)\n rhs = 'IN (' + Array.new(value.length, '?').join(', ') + ')'\n rhs = 'NOT ' + rhs if op == '!='\n else\n rhs = op + ' ?'\n end\n when 'between'\n rhs = 'BETWEEN ? AND ?'\n when 'not between'\n rhs = 'NOT BETWEEN ? AND ?'\n when 'like'\n rhs = 'LIKE ?'\n when 'not like'\n rhs = 'NOT LIKE ?'\n else\n rhs = op + ' ?'\n end\n\n lhs = col.to_s\n lhs = \"LOWER(#{lhs})\" if @columns[col] == :string\n\n \"(#{lhs} #{rhs})\"\n end",
"def generate_query_condition_values(val, table_name, field_name, _join_table_name)\n if val.is_a?(Hash)\n\n condition_type = val[:condition]\n\n # If we have a non-equals condition specified, generate the extra conditions\n if condition_type.in?(ValidExtraConditions)\n # A simple unary or binary condition\n\n # Setup the query conditions array [\"sql\", cond1, cond2, ...]\n if @extra_conditions[0].blank?\n @extra_conditions[0] = ''\n else\n @extra_conditions[0] += \" #{BoolTypeString} \"\n end\n\n if condition_type.in? UnaryConditions\n # It is a unary condition, extend the SQL\n @extra_conditions[0] += \"#{table_name}.#{field_name} #{condition_type}\"\n else\n # It is a binary condition, extend the SQL and conditions\n vc = ValidExtraConditions.find { |c| c == condition_type }\n vv = dynamic_value(val[:value])\n @extra_conditions[0] += \"#{table_name}.#{field_name} #{vc} (?)\"\n @extra_conditions << vv\n end\n\n elsif condition_type.in?(ValidExtraConditionsArrays)\n # It is an array condition\n\n veca_extra_args = ''\n\n # Setup the query conditions array [\"sql\", cond1, cond2, ...]\n if @extra_conditions[0].blank?\n @extra_conditions[0] = ''\n else\n @extra_conditions[0] += \" #{BoolTypeString} \"\n end\n\n # Extend the SQL and conditions\n vc = ValidExtraConditionsArrays.find { |c| c == condition_type }\n\n raise FphsException, 'Use a value: key with a condition:' unless val.key?(:value)\n\n vv = dynamic_value(val[:value])\n\n negate = (val[:not] ? 'NOT' : '')\n\n leftop = '?'\n\n if vc == '&&' || vc.end_with?(' REV') || vv.is_a?(Array)\n leftop = 'ARRAY[?]'\n leftop += '::varchar[]' if vv.first.is_a? String\n end\n\n veca_extra_args = ', 1' if vc.include?('ARRAY_LENGTH')\n\n rightop = \"#{table_name}.#{field_name}#{veca_extra_args}\"\n if vc.end_with?(' REV')\n ro = rightop\n rightop = leftop\n leftop = ro\n vc = vc.sub(' REV', '')\n end\n\n @extra_conditions[0] += \"#{negate} (#{leftop} #{vc} (#{rightop}))\"\n @extra_conditions << vv\n elsif condition_type\n raise FphsException, \"calc_action condition '#{condition_type}' for #{table_name} and #{field_name} is not recognized\"\n end\n\n end\n\n return unless !condition_type && !val.in?(ReturnTypes)\n\n @condition_values[table_name] ||= {}\n val = val.reject { |r| r.in?(ReturnTypes) } if val.is_a?(Array)\n @condition_values[table_name][field_name] = dynamic_value(val)\n end",
"def parse_params(field, oper, value)\n case oper\n when \"eq\"\n condiciones = [field +\" = ?\", value]\n when \"lt\"\n condiciones = [field +\" < ?\", value]\n when \"le\"\n condiciones = [field +\" <= ?\", value]\n when \"gt\"\n condiciones = [field +\" > ?\", value]\n when \"ge\"\n condiciones = [field +\" >= ?\", value]\n when \"ne\"\n condiciones = [field +\" <> ?\", value]\n when \"bn\"\n condiciones = [\"not \" + field +\" like ?\", \"#{value}%\"]\n when \"bw\"\n condiciones = [field +\" like ?\", \"#{value}%\"]\n when \"ew\"\n condiciones = [field +\" like ?\", \"%#{value}\"]\n when \"cn\"\n condiciones = [field +\" like ?\", \"%#{value}%\"]\n else\n condiciones = []\n end\n return condiciones\n end",
"def sql_test(field, operator, value, lhs, &block) # :yields: finder_option_type, value\n return field.to_ext_method_sql(lhs, sql_operator(operator, field), value, &block) if field.virtual?\n\n yield(:keyparameter, lhs.sub(/^.*\\./,'')) if field.key_field\n\n condition, *values = if field.temporal?\n datetime_test(field, operator, value, &block)\n elsif field.set?\n set_test(field, operator, value, &block)\n else\n [\"#{field.to_sql(operator, &block)} #{self.sql_operator(operator, field)} #{value_placeholders(operator, value)}\", value]\n end\n values.each { |value| preprocess_parameters(field, operator, value, &block) }\n\n if field.relation && definition.reflection_by_name(field.definition.klass, field.relation).macro == :has_many\n connection = field.definition.klass.connection\n reflection = definition.reflection_by_name(field.definition.klass, field.relation)\n primary_key_col = reflection.options[:primary_key] || field.definition.klass.primary_key\n primary_key = \"#{connection.quote_table_name(field.definition.klass.table_name)}.#{connection.quote_column_name(primary_key_col)}\"\n key, join_table = if reflection.options.has_key?(:through)\n [primary_key, has_many_through_join(field)]\n else\n [connection.quote_column_name(field.reflection_keys(reflection)[1]),\n connection.quote_table_name(field.klass.table_name)]\n end\n\n condition = \"#{primary_key} IN (SELECT #{key} FROM #{join_table} WHERE #{condition} )\"\n end\n condition\n end",
"def where_clause(where, and_or = \"and\", equals_like = \"=\")\n clause = where.keys.collect { |k| \"#{k} #{equals_like} #{Formatter.format(where[k])}\" }\n clause.empty? ? \"\" : \"where #{clause.join(\" #{and_or} \")}\"\n end",
"def sql_where_w_optional_conditions(where_prefix, cond1, cond2=nil, cond3=nil)\n return '' unless cond1.present? || cond2.present? || cond3.present?\n\n if where_prefix\n sql_where = ' WHERE '\n else\n sql_where = ' AND '\n end\n\n sql_where += cond1 if cond1.present?\n\n if cond2.present?\n sql_where += ' AND ' if cond1.present?\n sql_where += cond2\n end\n\n if cond3.present?\n sql_where += ' AND ' if cond1.present? || cond2.present?\n sql_where += cond3\n end\n\n sql_where\n end",
"def where(key, operator = nil, *values)\n if operator\n @conditions.add(operator, key, *values)\n self\n else\n OperatorBuilder.new(self, key)\n end\n end",
"def calc_where_clause(our_where = where)\n ands = our_where.uniq.map do |x|\n # Make half-assed attempt to cut down on proliferating parens...\n if x.match(/^\\(.*\\)$/) || !x.match(/ or /i)\n x\n else\n \"(#{x})\"\n end\n end\n ands.join(\" AND \")\n end",
"def filter(field, operator, value, value2=nil)\n operator = operator.to_s.upcase\n raise ArgumentError, \"invalid operator\" unless Operators.include?(operator)\n \n chain { |x|\n filter = { 'field' => field, 'operator' => operator, 'value1' => value.to_s }\n filter['value2'] = value2.to_s if operator == 'BETWEEN'\n x.filters << filter\n }\n end",
"def complex_expression_sql_append(sql, op, args)\n case op\n when :^\n j = ' # '\n c = false\n args.each do |a|\n sql << j if c\n literal_append(sql, a)\n c ||= true\n end\n when :ILIKE, :'NOT ILIKE'\n sql << '('\n literal_append(sql, args[0])\n sql << ' ' << op.to_s << ' '\n literal_append(sql, args[1])\n sql << ')'\n else\n super\n end\n end",
"def complex_expression_sql(op, args)\n case op\n when *TWO_ARITY_OPERATORS\n \"(#{literal(args.at(0))} #{op} #{literal(args.at(1))})\"\n when *N_ARITY_OPERATORS\n \"(#{args.collect{|a| literal(a)}.join(\" #{op} \")})\"\n when :NOT\n \"NOT #{literal(args.at(0))}\"\n when :NOOP\n literal(args.at(0))\n else\n raise(Sequel::Error, \"invalid operator #{op}\")\n end\n end",
"def sql_operator(operator, field)\n raise ScopedSearch::QueryNotSupported, \"the operator '#{operator}' is not supported for field type '#{field.type}'\" if !field.virtual? and [:like, :unlike].include?(operator) and !field.textual?\n SQL_OPERATORS[operator]\n end",
"def condition_string(starts_at_attr, ends_at_attr)\n except_option = Array(options[:exclude_edges]).map(&:to_s)\n starts_at_sign = except_option.include?(starts_at_attr.to_s.split(\".\").last) ? \"<\" : \"<=\"\n ends_at_sign = except_option.include?(ends_at_attr.to_s.split(\".\").last) ? \">\" : \">=\"\n query = []\n query << \"(#{ends_at_attr} IS NULL OR #{ends_at_attr} #{ends_at_sign} :starts_at_value)\"\n query << \"(#{starts_at_attr} IS NULL OR #{starts_at_attr} #{starts_at_sign} :ends_at_value)\"\n query.join(\" AND \")\n end",
"def TokenSearchSql(searchValues, columnToSearch, operator, parameterValues, exactValueOnly)\n\tsqlBuilder = \"\"\n\t\n\tif (searchValues == nil || searchValues.length == 0 || columnToSearch == nil || columnToSearch.length == 0)\n\t\tsqlBuilder = \"(1 = 1)\"\n\telse\n\t\tsqlBuilder += \"(\"\n\t\n\t\tsearchValues.each do |searchValue|\t\t\n\t\t\tsqlBuilder += \"(\" + columnToSearch + \" like ?) \" + operator\n\t\t\t\n\t\t\tif (exactValueOnly)\n\t\t\t\tparameterValues.push(searchValue.to_s)\n\t\t\telse\n\t\t\t\tparameterValues.push(\"%\" + searchValue.to_s + \"%\")\n\t\t\tend\n\t\tend\n\t\t\n\t\tsqlBuilder = sqlBuilder.chomp(operator)\n\t\tsqlBuilder += \")\"\n\tend\n\t\n\treturn sqlBuilder\nend",
"def default_where(klass)\n sql = ''\n arel_nodes = klass.scoped.with_default_scope.where_values.grep(Arel::Nodes::Equality)\n string_nodes = klass.scoped.with_default_scope.where_values.grep(String)\n\n unless arel_nodes.empty?\n sql += arel_nodes.inject(arel_nodes[0]) do |arel, equality|\n arel = arel.and(equality); arel\n end.to_sql\n end\n\n unless string_nodes.empty?\n sql += ' AND ' + string_nodes.map { |node| \"(#{node})\"}.join(' AND ')\n end\n\n sql\n end",
"def to_find_conditions(join_association = {})\n return nil if operator.nil?\n \n op, arg_format, values = operator, \"?\", [operand]\n op, arg_format, values = case operator\n when :<=> then [ \"BETWEEN\", \"? AND ?\", [ operand.first, operand.last ] ]\n when :=~ then\n case operand\n when String then [ \"LIKE\", arg_format, values ]\n when Regexp then [ \"REGEXP\", arg_format, values.map(&:source) ]\n end\n when :==, :=== then\n case operand\n when Array then [ \"IN\", \"(?)\", values ]\n when Range then [ \"IN\", \"(?)\", values ]\n when Condition then [ \"=\", operand.full_name, [] ]\n when nil then [ \"IS\", \"NULL\", [] ]\n else [ \"=\", arg_format, values ]\n end\n when :contains then [ \"LIKE\", arg_format, values.map{|v| \"%#{v}%\" } ]\n else\n case operand\n when Condition then [ op, oprand.full_name, [] ]\n else [ op, arg_format, values ]\n end\n end\n sql = \"#{full_name} #{op} #{arg_format}\"\n sql = \"NOT (#{sql})\" if @negative\n [ sql, *values ]\n end",
"def add_or_filters(fields, operators, values)\n if fields.present? && operators.present?\n fields.each do |field|\n # Smile specific #340206 Filtre additifs\n add_or_filter(field, operators[field], values && values[field])\n end\n end\n end",
"def build_where_ns(query,ns)\n where = \"\"\n query.each_pair do |k, v| \n if (k!='include' and k!='exclude')\n where += \"(`#{ns}`.`#{escape_str_field(k)}` #{build_equal_condition(v)}) AND \"\n end\n end\n where.chomp(' AND ')\n end",
"def to_sql\n return nil unless filters.present? and valid?\n filters.map { |n, f| sql_for(n) }.reject(&:blank?).join(' AND ')\n end",
"def where_clause_for(cols)\n cols.map{|c| c.to_s.upcase}.map{|c|\n if @column_values[c] == nil\n \"#{c} is null\"\n else\n \"#{c} = #{quote_value(c) }\"\n end\n }.join \" and \"\n end",
"def _init_sql_where_condition\n last_association_model = @association_chain.target_model\n actual_field = Babik::Table::Field.new(last_association_model, @selected_field).real_field\n @sql_where_condition = Babik::Selection::Operation::Base.factory(\n \"#{target_alias}.#{actual_field}\", @operator, @value\n )\n end",
"def build_equal_condition(v) \n if v.nil?\n # Nulls (nil)\n return \"IS NULL\"\n elsif v.kind_of? Integer or v.kind_of? Float\n # Integers / Floats\n return \"= \"+v.to_s\n else\n # Everything Else\n return \"= '#{@mysql.escape(v.to_s)}'\" \n end\n end",
"def build_condition_string\n @criteria.each do |k, criteria_fields|\n next if criteria_fields['value'].blank? # If there is no value to compare against don't add to the where clause\n\n # \"(display_field_values.display_field_id = ? AND display_field_values.value #{condition})\"\n condition_sql = \"\"\n condition_params = []\n\n if %w(survey_response_id survey_responses.page_url survey_responses.created_at survey_responses.device).include?(criteria_fields['display_field_id'])\n\n # The display_field_id is actually the full column name we want to use in the where clause\n operator = sql_condition(criteria_fields['include_exclude'], criteria_fields['condition'])\n\n condition_sql = \"#{criteria_fields['display_field_id']} #{operator} ?\"\n\n if criteria_fields['display_field_id'] == 'survey_responses.created_at'\n # When the display_field_id == 'survey_responses.created_at' then we need to convert the value to a datetime object\n begin\n # chomp the value\n criteria_fields['value'].chomp!\n\n # Set the time format string based on the datetime input by the user\n if /\\d{1,2}\\/\\d{1,2}\\/\\d{4}\\s\\d{2}:\\d{2}:\\d{2}/.match(criteria_fields['value'])\n time_string = \"%m/%d/%Y %H:%M:%S\"\n elsif /\\d{1,2}\\/\\d{1,2}\\/\\d{4}\\s\\d{2}:\\d{2}/.match(criteria_fields['value'])\n time_string = \"%m/%d/%Y %H:%M\"\n elsif /\\d{1,2}\\/\\d{1,2}\\/\\d{4}/.match(criteria_fields['value'])\n time_string = '%m/%d/%Y'\n else\n next # The time submitted date does not fit any of the formats so skip the condition\n end\n\n search_time = Time.strptime(criteria_fields['value'] + \" #{Time.zone.now.formatted_offset}\", time_string.chomp + \" %:z\")\n search_time += 1.day if time_string == \"%m/%d/%Y\" && operator == \">\"\n search_time = search_time + 1.day - 1.second if time_string == \"%m/%d/%Y\" && operator == \"<=\"\n\n condition_params << search_time\n\n rescue\n next # An error was raised when processing Time.strptime() meaning we have an invalid date\n end\n else\n # When the display_field_id == 'survey_resposnes.page_url' just add the condition directly on\n condition_params << value_bind(criteria_fields['value'], criteria_fields['condition'])\n end\n\n else\n # Add the field to search\n field_to_search = \"display_field_values.display_field_id = ?\"\n condition_params << criteria_fields['display_field_id']\n\n # add the condition check\n condition = \"display_field_values.value #{sql_condition(criteria_fields['include_exclude'], criteria_fields['condition'])} ?\"\n\n # add the condition parameter\n condition_params << value_bind(criteria_fields['value'], criteria_fields['condition'])\n\n condition_sql = \"(#{field_to_search} AND #{condition})\"\n end\n\n @conditions << condition_sql\n @parameters.concat(condition_params)\n\n @clause_joins << (criteria_fields['clause_join'] || 'AND') unless @conditions.size == 1\n end\n end",
"def sql_for_circuit_group_id_field(field, operator, value)\n op = operator == \"!\" ? 'NOT' : ''\n \"(#{Issue.table_name}.cinema_id #{op} IN (SELECT DISTINCT cinemas_circuit_groups.cinema_id FROM cinemas_circuit_groups \" +\n \"WHERE cinemas_circuit_groups.circuit_group_id IN (\" + value.collect{|val| \"'#{connection.quote_string(val)}'\"}.join(\",\") + \")))\"\n end",
"def build_filter filter, fields\n where = [fields.map { |f| \"#{f} like ?\" }.join(\" || \")]\n fields.count.times { |n| where << \"%#{filter}%\" }\n where\n end",
"def sql_operator(operator, field)\n raise ScopedSearch::QueryNotSupported, \"the operator '#{operator}' is not supported for field type '#{field.type}'\" if !field.virtual? and [:like, :unlike].include?(operator) and !field.textual?\n return '@@' if [:like, :unlike].include?(operator) && field.full_text_search\n case operator\n when :like then 'ILIKE'\n when :unlike then 'NOT ILIKE'\n else super(operator, field)\n end\n end",
"def set_test(field, operator,value, &block)\n set_value = translate_value(field, value)\n raise ScopedSearch::QueryNotSupported, \"Operator '#{operator}' not supported for '#{field.field}'\" unless [:eq,:ne].include?(operator)\n negate = ''\n if [true,false].include?(set_value)\n negate = 'NOT ' if operator == :ne\n if field.numerical?\n operator = (set_value == true) ? :gt : :eq\n set_value = 0\n else\n operator = (set_value == true) ? :ne : :eq\n set_value = false\n end\n end\n [\"#{negate}(#{field.to_sql(operator, &block)} #{self.sql_operator(operator, field)} ?)\", set_value]\n end",
"def filters_sql\n if filters.blank?\n ''\n else\n conditions = JSON.parse filters\n sql_array = []\n conditions.each do |condition|\n if condition['values']\n values = condition['values'].map { |x| \"'#{x}'\" }.join(',')\n sql_array << \" #{condition['name']} in (#{values})\"\n else\n sql_array << \" #{condition['name']} between #{condition['from']} and #{condition['to']}\"\n end\n end\n sql_array.join(' AND ')\n end\n end",
"def field_query(field, value)\n \"_query_:\\\"{!field f=#{field}}#{value}\\\"\"\n end",
"def next_condition_as_sql\n case @next_condition\n when CONDITION::NONE\n return \"\"\n when CONDITION::AND\n return \"AND\"\n when CONDITION::OR\n return \"OR\"\n end\n end",
"def get_filters_sql\n if self.filters.blank?\n return ''\n else\n conditions = JSON.parse self.filters\n sql_array = []\n conditions.each do |condition|\n if condition['values']\n values = condition['values'].map{|x| \"'#{x}'\"}.join(',')\n sql_array << \" #{condition['name']} in (#{values})\"\n else\n sql_array << \" #{condition['name']} between #{condition['from']} and #{condition['to']}\"\n end\n end\n sql_array.join(' AND ')\n end\n end",
"def build_query(params)\n query = UserInteraction.includes(:user, :interaction, :answer)\n fields = get_fields()\n params.each do |filter|\n field_id = filter['field'].to_sym\n operator = filter['operand']\n operand = filter['value']\n if operator == FILTER_OPERATOR_CONTAINS\n query = query.where( get_active_record_expression(fields[field_id]['column_name'], operator, fields[field_id]['model']), \"%\"+operand.to_s+\"%\" )\n else\n query = query.where( get_active_record_expression(fields[field_id]['column_name'], operator, fields[field_id]['model']), operand )\n end\n end\n return query \n end",
"def query_filter(query, table, parameters = {})\n\tquery = \"select #{query} from #{table}\"\n\tif !parameters.empty?\n\t\tquery += \"where\"\n\t\t#if arguments are given, we append them to the query. This method may\n\t\t#not work as is, but the general idea is solid\n\t\tparameters.each do |key, value|\n\t\t\tquery += key\n\t\t\tquery += \" \"\n\t\t\tquery += value\n\t\tend \n\tend\n\treturn query\nend",
"def field_concatinator(field, values)\n if values.size > 0\n list = [([\"#{field} ~* ?\"]*values.size).join(\" AND \")] + values\n list[0] = \"(#{list[0]})\"\n list\n else\n []\n end\n end",
"def query_clause(type, key, value)\n \"_query_:\\\"{!#{type} f=#{key}}#{value.gsub('\"', '\\\"')}\\\"\"\n end",
"def query_clause(type, key, value)\n \"_query_:\\\"{!#{type} f=#{key}}#{value.gsub('\"', '\\\"')}\\\"\"\n end",
"def query_clause(type, key, value)\n \"_query_:\\\"{!#{type} f=#{key}}#{value.gsub('\"', '\\\"')}\\\"\"\n end",
"def grouping_query(field, phrase, op = 'AND')\n raise 'op must be AND or OR' unless ['AND', 'OR'].include? op\n\n \"_query_:\\\"{!lucene q.op=#{op}}#{field}:(#{phrase})\\\"\"\n end",
"def where_clause\n \"\"\n end",
"def filter_expr(expr)\n case expr\n when Hash\n SQL::BooleanExpression.from_value_pairs(expr)\n when Array\n if String === expr[0]\n filter_expr(expr.shift.gsub(QUESTION_MARK){literal(expr.shift)}.lit)\n else\n SQL::BooleanExpression.from_value_pairs(expr)\n end\n when Proc\n expr.to_sql(self).lit\n when SQL::NumericExpression, SQL::StringExpression\n raise(Error, \"Invalid SQL Expression type: #{expr.inspect}\") \n when Symbol, SQL::Expression\n expr\n when String\n \"(#{expr})\".lit\n else\n raise(Error, 'Invalid filter argument')\n end\n end",
"def add_filters(fields, operators, values)\n fields.each do |field|\n add_filter(field, operators[field], values[field])\n end\n end",
"def get_condition_string(table, real = false, withoutrule = -1,options = {}) \n ret = conditions.select{|c| c.valid?(table) }.map {|c| c.sql(table) }\n ret[withoutrule] = nil if withoutrule != -1\n# if not options[:without_date]\n#\tdc = DateCondition.new(\"date\", from_date, to_date, time_description)\n#\tret << [dc.sql]\t \n# end\n ret = ret.compact\n ret = ret.join(\" AND \")\n return nil if ret == \"\"\n return ret\n \n# if not real then\n#\tif options[:negative_set] then\n#\t ret = \"1=1\" if ret == nil\n#\t ret = \"NOT (#{ret})\"\n#\tend\n#\tif options[:global_rule_number] then\n#\t if options[:banished_set] then\n#\t c = get_condition_string(true,options[:global_rule_number])\n#\t c = \"1=1\" if c == nil\n#\t ret += \" AND #{c}\"\n#\t else\n#\t ret += \" AND #{get_condition(options[:global_rule_number])}\"\n#\t end\n#\tend\n# end \n end",
"def where_exp(input, variable, expression); end",
"def filter_wql\n wql = super\n wql[:right_plus] = [wql[:right_plus], right_plus_val].compact\n wql\nend",
"def where(table, column, value, and_or=\"and\", ignore_case=false)\n if ignore_case\n return where_ignore_case(table, column, value, and_or)\n end\n if and_or == \"and\"\n and_exp(@builder.equal(@alias[table].get(column),value))\n else # or\n or_exp(@builder.equal(@alias[table].get(column),value))\n end\n self\n end",
"def add_filters(fields, operators, values)\n if fields.is_a?(Array) && operators.is_a?(Hash) && (values.nil? || values.is_a?(Hash))\n fields.each do |field|\n add_filter(field, operators[field], values && values[field])\n end\n end\n end",
"def add_filters(fields, operators, values)\n if fields.is_a?(Array) && operators.is_a?(Hash) && (values.nil? || values.is_a?(Hash))\n fields.each do |field|\n add_filter(field, operators[field], values && values[field])\n end\n end\n end",
"def get_filter_sql\n filter_sql = \"( \"\n self.foreach_filter do |filter|\n filter_sql += \"#{filter.get_filter_sql} #{filter.next_condition_as_sql} \"\n end\n filter_sql += \")\"\n return filter_sql\n end",
"def date_clause(table, field, from, to)\n s = []\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date((from - 1).to_time.end_of_day)]) if from\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date(to.to_time.end_of_day)]) if to\n s.join(' AND ')\n end",
"def conditions_clause\n cc = conditions.dup\n cc << filter_clause\n cc.compact.map{|c| @resource.send(:sanitize_sql_for_conditions, c)} * ' AND '\n end",
"def append_where(where, operator = :AND)\n raise \"Parameter is not Array\" if !where.is_a?(String)\n raise \"Invalid operator: #{operator}\" if operator != :AND && operator != :OR\n\n \t @where = \n if @where.nil? || @where.empty?\n where \n else\n \"#{@where} #{operator} #{where}\"\n end\n end",
"def search_conditions(query, fields=nil)\n return nil if query.blank?\n fields ||= @search_columns\n\n # split the query by commas as well as spaces, just in case\n words = query.split(\",\").map(&:split).flatten\n\n binds = {} # bind symbols\n or_frags = [] # OR fragments\n count = 1 # to keep count on the symbols and OR fragments\n\n words.each do |word|\n like_frags = [fields].flatten.map { |f| \"LOWER(#{f}) LIKE :word#{count}\" }\n or_frags << \"(#{like_frags.join(\" OR \")})\"\n binds[\"word#{count}\".to_sym] = \"%#{word.to_s.downcase}%\"\n count += 1\n end\n [or_frags.join(\" AND \"), binds]\n end",
"def value_conditions(field_name, val)\n val.blank? ? nil : \"CAST(#{field_name} as CHAR(50)) LIKE '#{val.gsub(\"'\",\"''\")}%'\".tr_s('%*', '%')\n end",
"def conditions\n [conditions_clauses.join(' AND '), *conditions_options]\nend",
"def sql_for_bu_project_field(field, operator, value)\n sql_for_field(field, operator, value, 'bu_project_id', 'customized_id')\n end",
"def date_clause(table, field, from, to)\n s = []\n if from\n from_yesterday = from - 1\n from_yesterday_utc = Time.gm(from_yesterday.year, from_yesterday.month, from_yesterday.day)\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date(from_yesterday_utc.end_of_day)])\n end\n if to\n to_utc = Time.gm(to.year, to.month, to.day)\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date(to_utc.end_of_day)])\n end\n s.join(' AND ')\n end",
"def scaffold_search_add_condition(conditions, record, field) # :doc:\n return unless column = record.column_for_attribute(field)\n if column.klass == String\n if record.send(field).length > 0\n conditions[0] << \"#{record.class.table_name}.#{field} #{record.class.scaffold_auto_complete_search_operator} ?\"\n conditions << \"%#{record.send(field)}%\"\n end\n elsif column.klass == Object\n conditions[0] << \"#{record.class.table_name}.#{field} IS #{record.send(field) ? 'TRUE' : 'FALSE'}\"\n else\n conditions[0] << \"#{record.class.table_name}.#{field} = ?\"\n conditions << record.send(field)\n end\n end",
"def date_clause_with_date_column(table, field, from, to, is_custom_filter)\n if (date?(from) || date?(to)) && DATE_TYPES.include?(ColumnType.for(table, field))\n s = []\n condition_pattern = \"#{table}.#{field} %s '%s'\"\n s << condition_pattern % ['>', end_day(from.yesterday)] if from\n s << condition_pattern % ['<=', end_day(to)] if to\n return s.join(' AND ')\n end\n date_clause_without_date_column(table, field, from, to, is_custom_filter)\n end",
"def field_search(field_queries, query)\n return query unless field_check? field_queries\n\n field_queries.each do |exps|\n sub_queries = build_sub_queries_with exps\n query = query.try(:and, sub_queries) || sub_queries\n end\n query\n end",
"def and(*exps)\n joined_exps = exps.join(' and ')\n @query[:filters] += \" and #{joined_exps}\"\n self\n end",
"def construct_all_tags_search(table, field)\n sql_array = [subjects, media_types, durations].map { |a| a if a.any? }.compact\n sql_strings = sql_array.map do |values|\n \"(#{construct_tag_search(table, field, values)})\"\n end\n \"AND \" + sql_strings.join(\" AND \") unless sql_strings.empty?\n end",
"def to_sql(builder, definition, &block)\n if operator == :not && children.length == 1\n builder.to_not_sql(rhs, definition, &block)\n elsif [:null, :notnull].include?(operator)\n to_null_sql(builder, definition, &block)\n elsif children.length == 1\n to_default_fields_sql(builder, definition, &block)\n elsif children.length == 2\n to_single_field_sql(builder, definition, &block)\n else\n raise ScopedSearch::QueryNotSupported, \"Don't know how to handle this operator node: #{operator.inspect} with #{children.inspect}!\"\n end\n end",
"def where(*exps)\n joined_exps = exps.join(' and ')\n return self if joined_exps.empty?\n\n if @query[:filters].nil?\n @query[:filters] = joined_exps\n else\n @query[:filters] += \" and #{joined_exps}\"\n end\n\n self\n end",
"def to_single_field_sql(builder, definition, &block)\n raise ScopedSearch::QueryNotSupported, \"Field name not a leaf node\" unless lhs.kind_of?(ScopedSearch::QueryLanguage::AST::LeafNode)\n raise ScopedSearch::QueryNotSupported, \"Value not a leaf node\" unless rhs.kind_of?(ScopedSearch::QueryLanguage::AST::LeafNode)\n\n # Search only on the given field.\n field = definition.field_by_name(lhs.value)\n raise ScopedSearch::QueryNotSupported, \"Field '#{lhs.value}' not recognized for searching!\" unless field\n\n # see if the value passes user defined validation\n if operator == :in\n rhs.value.split(',').each { |v| validate_value(field, v) }\n else\n validate_value(field, rhs.value)\n end\n\n builder.sql_test(field, operator, rhs.value,lhs.value, &block)\n end",
"def complex_expression_sql_append(sql, op, args)\n r = args[1]\n if (((op == :'=' || op == :'!=') and r.is_a?(Sequel::Model)) ||\n (multiple = ((op == :IN || op == :'NOT IN') and ((is_ds = r.is_a?(Sequel::Dataset)) or r.all?{|x| x.is_a?(Sequel::Model)}))))\n l = args[0]\n if ar = model.association_reflections[l]\n if multiple\n klass = ar.associated_class\n if is_ds\n if r.respond_to?(:model)\n unless r.model <= klass\n # A dataset for a different model class, could be a valid regular query\n return super\n end\n else\n # Not a model dataset, could be a valid regular query\n return super\n end\n else\n unless r.all?{|x| x.is_a?(klass)}\n raise Sequel::Error, \"invalid association class for one object for association #{l.inspect} used in dataset filter for model #{model.inspect}, expected class #{klass.inspect}\"\n end\n end\n elsif !r.is_a?(ar.associated_class)\n raise Sequel::Error, \"invalid association class #{r.class.inspect} for association #{l.inspect} used in dataset filter for model #{model.inspect}, expected class #{ar.associated_class.inspect}\"\n end\n\n if exp = association_filter_expression(op, ar, r)\n literal_append(sql, exp)\n else\n raise Sequel::Error, \"invalid association type #{ar[:type].inspect} for association #{l.inspect} used in dataset filter for model #{model.inspect}\"\n end\n elsif multiple && (is_ds || r.empty?)\n # Not a query designed for this support, could be a valid regular query\n super\n else\n raise Sequel::Error, \"invalid association #{l.inspect} used in dataset filter for model #{model.inspect}\"\n end\n else\n super\n end\n end",
"def conditions(fow_entries, prefix=\"location_\")\n return \"1=0\" if fow_entries.blank?\n\n \"(\" + conditions_for_coordinates(fow_entries, prefix) +\n \") AND (#{sanitize_sql_for_conditions(\n [\"#{prefix}galaxy_id=?\", fow_entries[0].galaxy_id]\n )})\"\n end",
"def append_replaceable_where(where, operator = :AND)\n raise \"Parameter is not string\" if !where.is_a?(String)\n raise \"Invalid operator: #{operator}\" if operator != :AND && operator != :OR\n \n @tmp_where = where \n @tmp_operator = operator \n end",
"def conditions\n return ['1=0'] if !valid?\n\n conds = []\n values = []\n for col in klass.columns do\n col_str = col_name(col)\n val = @attrs[encode_name(col)]\n if !val.blank?\n case col.type\n when :string, :text\n if val =~ /\\*$/\n conds << col_str + ' like ?'\n values << val.gsub(/\\*$/, '%')\n else\n conds << col_str + '=?'\n values << val\n end\n when :datetime\n case is_dbms?\n when Dbms::MYSQL\n# conds << col_str + @_operator.exp(encode_name(col))\n conds << sprintf(\"date(%s)\",\n col_str) +\n @_operator.exp(encode_name(col))\n else\n conds << sprintf(\"date(timezone('%s',%s))\",\n DEFAULT_TIMEZONE_FOR_TIMESTAMP_DATE_COMPARISON,\n col_str) +\n @_operator.exp(encode_name(col))\n end\n values << val.to_s\n when :boolean\n case is_dbms?\n when Dbms::MYSQL\n conds << col_str + @_operator.exp(encode_name(col))\n values << (val=='true')\n else\n conds << col_str + @_operator.exp(encode_name(col))\n values << val\n end\n else\n conds << col_str + @_operator.exp(encode_name(col))\n values << val\n end\n end\n end\n return [conds.join(' and ')] + values\n end",
"def to_query\n \"(#{(@values.uniq.map { |value| \"#{name_as_search_key}:\\\"#{value}\\\"#{boost_as_string}\" }).join(operation_as_join)})\"\n end",
"def query(*conditions)\n filters = (conditions + @mapping.conditions).compact.join(\" and \")\n filters = \" where #{filters}\" unless filters.empty?\n\n \"select #{lookups} from #{@record_type}#{filters}\"\n end",
"def conditions\n\t\t[conditions_clauses.join(' AND '), *conditions_options]\n\tend",
"def conditions\n\t\t[conditions_clauses.join(' AND '), *conditions_options]\n\tend",
"def query\n ([query_for_one_keyword] * split_query_string.size).join(' AND ')\n end",
"def add_conditions!(sql, conditions)\n sql << \"WHERE #{sanitize_conditions(conditions)} \" unless conditions.nil?\n sql << (conditions.nil? ? \"WHERE \" : \" AND \") + type_condition unless descends_from_active_record?\n end",
"def params_field_ops(params)\n begin\n fields = params.to_unsafe_h.compact.select { |k| k.match(/(^q$|^q_)/) }\n ops = params.to_unsafe_h.fetch(\"op_row\", [\"default\"])\n ops.zip(fields)\n rescue\n []\n end\n end",
"def valid_find_operator\n\t\toperator = ' OR '\n\t\tif params[:operator] and !params[:operator].blank? and \n\t\t\t\t['AND','OR'].include?(params[:operator])\n\t\t\toperator = \" #{params[:operator]} \"\n\t\tend\n\t\toperator\n\tend",
"def handle_AND(clause)\n \"#{clause.gsub!(' AND ', ' ').strip!}\"\n clause.gsub!('( ', '(')\n clause.gsub!(' )', ')')\n clause\n end",
"def where(*params, &block)\n @where << ComparisonExpression.new(*params, &block)\n self\n end",
"def statement\n # filters clauses\n filters_clauses = []\n filters.each_key do |field|\n next if field == \"subproject_id\"\n v = values_for(field).clone\n next unless v and !v.empty?\n operator = operator_for(field)\n\n # \"me\" value substitution\n if %w(assigned_to_id author_id user_id watcher_id updated_by last_updated_by).include?(field)\n if v.delete(\"me\")\n if User.current.logged?\n v.push(User.current.id.to_s)\n v += User.current.group_ids.map(&:to_s) if field == 'assigned_to_id'\n else\n v.push(\"0\")\n end\n end\n end\n\n if field == 'project_id'\n if v.delete('mine')\n v += User.current.memberships.map(&:project_id).map(&:to_s)\n end\n end\n\n if field =~ /^cf_(\\d+)\\.cf_(\\d+)$/\n filters_clauses << sql_for_chained_custom_field(field, operator, v, $1, $2)\n elsif field =~ /cf_(\\d+)$/\n # custom field\n filters_clauses << sql_for_custom_field(field, operator, v, $1)\n elsif field =~ /^cf_(\\d+)\\.(.+)$/\n filters_clauses << sql_for_custom_field_attribute(field, operator, v, $1, $2)\n elsif respond_to?(method = \"sql_for_#{field.tr('.','_')}_field\")\n # specific statement\n filters_clauses << send(method, field, operator, v)\n else\n # regular field\n filters_clauses << '(' + sql_for_field(field, operator, v, queried_table_name, field) + ')'\n end\n end if filters and valid?\n\n if (c = group_by_column) && c.is_a?(QueryCustomFieldColumn)\n # Excludes results for which the grouped custom field is not visible\n filters_clauses << c.custom_field.visibility_by_project_condition\n end\n\n ################\n # Smile specific #340206 Filtre additifs\n # Or filters clauses\n or_filters_clauses = []\n # Namespace to avoid a confusion with Class:ActiveRecord::AttributeMethods::Query\n if ::Query.respond_to?(:or_filters_provided?)\n or_filters.each_key do |field|\n next if field == \"subproject_id\"\n v = or_values_for(field).clone\n next unless v and !v.empty?\n operator = or_operator_for(field)\n\n # \"me\" value substitution\n ################\n # Smile specific : +old_value fields for Indicators\n # TODO move redmine_smile_indicators old_value_* to hook\n # * old_value_assigned_to_id\n # * old_value_author_id\n # * old_value_user_id\n # * old_value_watcher_id\n if %w(assigned_to_id old_value_assigned_to_id author_id old_value_author_id user_id old_value_user_id watcher_id old_value_watcher_id).include?(field)\n if v.delete(\"me\")\n if User.current.logged?\n v.push(User.current.id.to_s)\n v += User.current.group_ids.map(&:to_s) if field == 'assigned_to_id'\n else\n v.push(\"0\")\n end\n end\n end\n\n if field == 'project_id'\n if v.delete('mine')\n v += User.current.memberships.map(&:project_id).map(&:to_s)\n end\n end\n\n if field =~ /^cf_(\\d+)\\.cf_(\\d+)$/\n or_filters_clauses << sql_for_chained_custom_field(field, operator, v, $1, $2)\n elsif field =~ /cf_(\\d+)$/\n # custom field\n or_filters_clauses << sql_for_custom_field(field, operator, v, $1)\n elsif field =~ /^cf_(\\d+)\\.(.+)$/\n filters_clauses << sql_for_custom_field_attribute(field, operator, v, $1, $2)\n elsif respond_to?(method = \"sql_for_#{field.tr('.','_')}_field\")\n # specific statement\n or_filters_clauses << send(method, field, operator, v)\n else\n # regular field\n or_filters_clauses << '(' + sql_for_field(field, operator, v, queried_table_name, field) + ')'\n end\n end if or_filters and valid?\n\n if (c = group_by_column) && c.is_a?(QueryCustomFieldColumn)\n # Excludes results for which the grouped custom field is not visible\n or_filters_clauses << c.custom_field.visibility_by_project_condition\n end\n or_filters_clauses.reject!(&:blank?)\n end\n # END -- Smile specific #340206 Filtre additifs\n #######################\n\n filters_clauses << project_statement\n filters_clauses.reject!(&:blank?)\n\n result_statement = filters_clauses.any? ? filters_clauses.join(' AND ') : nil\n\n ################\n # Smile specific #340206 Filtre additifs\n if or_filters_clauses.any?\n if filters_clauses.any?\n result_statement += ' AND (' + or_filters_clauses.join(' OR ') + ')'\n else\n result_statement = or_filters_clauses.join(' OR ')\n end\n end\n # END -- Smile specific #340206 Filtre additifs\n #######################\n\n result_statement\n end",
"def parse_expr_tree(expr_tree, opts = {})\n instruction = {\n selects: {},\n joins: [],\n where: \"\"\n }\n\n # If expr_tree is blank\n if expr_tree.blank?\n instruction[:where] = TRUE_WHERE_QUERY\n return instruction\n end\n\n # If expr_tree is not blank\n tree_operator = nil\n where_stack = []\n\n expr_tree.each_with_index do |expr, idx|\n if (idx == 0) && (%w(AND OR).include? expr)\n tree_operator = expr\n else\n if expr.is_a? Array\n result = parse_expr_tree(expr, opts)\n instruction[:joins] |= result[:joins].flatten\n instruction[:selects].merge! result[:selects]\n where = \"(#{result[:where]})\"\n else\n\n # =====================================================================================\n # TODO: @giosakti simplify this algorithm\n # =====================================================================================\n\n expr_stack = expr.scan(/(?:\"(?:\\\\.|[^\"])*\"|[^\" ])+/)\n if (expr_stack.size != 3) && (!%w(= IN).include? expr_stack[1])\n raise \"Syntax error #{expr}\"\n else\n operator = expr_stack[1]\n\n #\n # Evaluate lhs\n #\n lhs_expr = expr_stack.first\n if lhs_expr.start_with?(\"object\")\n result = parse_lhs(lhs_expr, opts[:object], operator)\n lhs_join = result[:join]\n lhs_select = result[:select]\n lhs_where = result[:where]\n else\n raise \"Syntax error: #{lhs_expr} at left-hand side\"\n end\n\n #\n # Evaluate rhs\n #\n rhs_expr = expr_stack.last\n if rhs_expr.start_with?(\"subject\")\n rhs_where = parse_rhs(rhs_expr, opts[:subject], operator)\n else\n rhs_where = rhs_expr\n end\n\n #\n # Formulaize instructions\n #\n instruction[:joins] |= [lhs_join] if lhs_join.present?\n instruction[:selects].merge! lhs_select if lhs_select.present?\n if rhs_where.present?\n where = \"#{lhs_where} #{operator} #{rhs_where}\"\n else\n where = FALSE_WHERE_QUERY\n end\n end\n\n # =====================================================================================\n # END TODO: @giosakti simplify this algorithm\n # =====================================================================================\n\n end\n\n where_stack.push where\n end\n end\n\n if tree_operator\n instruction[:where] = where_stack.join(\" #{tree_operator} \")\n else\n instruction[:where] = where_stack.shift\n end\n\n return instruction\n end",
"def str_sql_search(str, fields)\n str.gsub!(\"'\", '')\n str.gsub!('\"', '')\n str.gsub!(\"\\\\\", '')\n str.gsub!(\"%\", '')\n \n arr = string_to_arr(str)\n rows = []\n cells = []\n \n for field in fields\n cells = []\n \n for a in arr\n cells.push(\"(#{field} LIKE \\\"%#{a}%\\\")\")\n end\n \n rows.push(\"(\" + cells.join(\" AND \") + \")\")\n end\n \n return rows.join(\" OR \")\n end",
"def build_where(opts, other = [])\n case opts\n when String, Array\n #TODO: Remove duplication with: /activerecord/lib/active_record/sanitization.rb:113\n values = Hash === other.first ? other.first.values : other\n\n values.grep(ActiveRecord::Relation) do |rel|\n self.bind_values += rel.bind_values\n end\n\n [@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))]\n when Hash\n attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)\n\n attributes.values.grep(ActiveRecord::Relation) do |rel|\n self.bind_values += rel.bind_values\n end\n\n PredicateBuilder.build_from_hash(klass, attributes, table)\n else\n [opts]\n end\n end",
"def build_where_query(options)\n query_keys = {}\n options.each do |k,v|\n # as expected by DynamoDB\n typed_key = k.to_s\n query_keys[typed_key] = dyno_typed_key(key: typed_key, val: v)\n end\n {\n table_name: self.table_name,\n attributes_to_get: attribute_names,\n key: query_keys\n }\n end",
"def complex_expression_sql_append(sql, op, args)\n case op\n when :&, :|, :^, :<<, :>>, :'B~'\n complex_expression_emulate_append(sql, op, args)\n # REGEXP_OPERATORS = [:~, :'!~', :'~*', :'!~*']\n when :'~'\n function_sql_append(sql, SQL::Function.new(:REGEX, args.at(0), args.at(1)))\n when :'!~'\n sql << Sequel::Dataset::NOT_SPACE\n function_sql_append(sql, SQL::Function.new(:REGEX, args.at(0), args.at(1)))\n when :'~*'\n function_sql_append(sql, SQL::Function.new(:IREGEX, args.at(0), args.at(1)))\n when :'!~*'\n sql << Sequel::Dataset::NOT_SPACE\n function_sql_append(sql, SQL::Function.new(:IREGEX, args.at(0), args.at(1)))\n else\n super\n end\n end",
"def initialize(column, operator, value, options = {})\n return super(column) if column.instance_of?(Hash)\n throw \"No column given.\" unless column\n throw \"No operator given.\" unless operator\n\n @column = column\n @operator = operator\n @value = value \n if @value == nil\n\t@operator = \"IS NULL\" if @operator == \"=\"\n\t@operator = \"IS NOT NULL\" if @operator == \"!=\"\n end\n @value = nil if @operator == \"IS NULL\" || @operator == \"IS NOT NULL\"\n @options = options\n # value = @conditions[i][2]\n # value = [value] if value.class.name == \"String\"\n # value = [] if value == nil\n # ret = \"\"\n # for val in value \n # ret += \" OR \" if ret != \"\"\n # ret += \"#{@conditions[i][0]} #{@conditions[i][1]} #{val}\"\n # end\n # return \"(#{ret})\"\n end",
"def conditions\n sqlwhere = \"1 = 1 \"\n sqlwhere = sqlwhere + \"and orders.namel like ? \" if is_string_here?(namel)\n sqlwhere = sqlwhere + \"and orders.email like ? \" if is_string_here?(email)\n sqlwhere = sqlwhere + \"and addresses.street_address1 like ? \" if is_string_here?(street_address1)\n sqlwhere = sqlwhere + \"and addresses.street_address2 like ? \" if is_string_here?(street_address2)\n sqlwhere = sqlwhere + \"and orders.user_id = ? \" if is_object_here?(user_id)\n sqlwhere = sqlwhere + \"and orders.order_state_id = ? \" if is_object_here?(order_state_id)\n sqlwhere = sqlwhere + \"and orders.checkout_state_id = ? \" if is_object_here?(checkout_state_id)\n sqlwhere = sqlwhere + \"and orders.created_at > ? \" if is_object_here?(created_at_since)\n sqlwhere = sqlwhere + \"and orders.created_at < ? \" if is_object_here?(created_at_till)\n\n result = [sqlwhere]\n result << UnicodeUtils.downcase(namel) if is_string_here?(namel)\n result << UnicodeUtils.downcase(email) if is_string_here?(email)\n result << UnicodeUtils.downcase(street_address1) if is_string_here?(street_address1)\n result << UnicodeUtils.downcase(street_address2) if is_string_here?(street_address2)\n result << user_id if is_object_here?(user_id)\n result << order_state_id if is_object_here?(order_state_id)\n result << checkout_state_id if is_object_here?(checkout_state_id)\n result << created_at_since if is_object_here?(created_at_since)\n result << created_at_till if is_object_here?(created_at_till)\n result\n end",
"def initialize field, operator, value\n @field = field\n @operator = operator\n if @operator == :eq && value.class == String\n value = /^#{value}$/\n else\n value = value\n end\n @value = value\n\n method_string = 'def compare(inval);'\n if value.class == Regexp\n if operator == :eq\n method_string += \" inval.match(@value);\"\n else\n raise ArgumentError, \"operation #{operator} does not work with a regexp\"\n end\n else\n if operator == :eq\n method_string += \" inval == @value;\"\n elsif operator == :lt\n method_string += \" inval < @value;\"\n elsif operator == :gt\n method_string += \" inval > @value;\"\n end\n end\n method_string += 'end;'\n self.instance_eval method_string\n end",
"def date_clause(table, field, from, to)\n s = []\n if from\n from_yesterday = from - 1\n from_yesterday_time = Time.local(from_yesterday.year, from_yesterday.month, from_yesterday.day)\n if self.class.default_timezone == :utc\n from_yesterday_time = from_yesterday_time.utc\n end\n s << (\"#{table}.#{field} > '%s'\" % [connection.quoted_date(from_yesterday_time.end_of_day)])\n end\n if to\n to_time = Time.local(to.year, to.month, to.day)\n if self.class.default_timezone == :utc\n to_time = to_time.utc\n end\n s << (\"#{table}.#{field} <= '%s'\" % [connection.quoted_date(to_time.end_of_day)])\n end\n s.join(' AND ')\n end"
] | [
"0.7423291",
"0.7368303",
"0.72244465",
"0.7081502",
"0.7064582",
"0.700777",
"0.6853337",
"0.68013805",
"0.67052764",
"0.6692466",
"0.66903245",
"0.6663531",
"0.66351473",
"0.65600836",
"0.6530368",
"0.648571",
"0.64322424",
"0.6410216",
"0.6329698",
"0.63262427",
"0.63238883",
"0.63124603",
"0.6287788",
"0.6280991",
"0.62708294",
"0.6212155",
"0.62039846",
"0.6190689",
"0.61447495",
"0.61256707",
"0.61152565",
"0.6105017",
"0.6099541",
"0.6095464",
"0.60920227",
"0.6083332",
"0.60824585",
"0.604498",
"0.60416895",
"0.6034336",
"0.6025789",
"0.6021499",
"0.6002209",
"0.6000488",
"0.59845835",
"0.59830153",
"0.5982188",
"0.59642005",
"0.59631944",
"0.59462106",
"0.5945776",
"0.592205",
"0.5921558",
"0.59034187",
"0.5893301",
"0.5891486",
"0.58790874",
"0.58731276",
"0.58731276",
"0.5872052",
"0.5838891",
"0.58358693",
"0.58347076",
"0.58335465",
"0.58327585",
"0.5828983",
"0.58265704",
"0.5824851",
"0.58185995",
"0.58155817",
"0.5810765",
"0.58076704",
"0.58049554",
"0.57984567",
"0.57863754",
"0.5773808",
"0.5772782",
"0.57672864",
"0.5764709",
"0.575199",
"0.5751378",
"0.57473063",
"0.5737613",
"0.5737613",
"0.5727261",
"0.572723",
"0.5720269",
"0.5719968",
"0.57196903",
"0.57142955",
"0.5708937",
"0.5706677",
"0.5704508",
"0.5704144",
"0.5699375",
"0.5688211",
"0.5685547",
"0.56751955",
"0.56642586",
"0.56618124"
] | 0.6486339 | 15 |
PLACE 0,0,NORTH MOVE REPORT Output: 0,1,NORTH | def test_scenario1
r = robot
r.move(table)
assert_equal('0,1,NORTH', r.report)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def place\n next_move = {x: command.arguments[:x], y: command.arguments[:y]}\n if inside_table?(next_move_x_y(next_move, false))\n update_position!(next_move_x_y(next_move, false))\n update_direction!\n else\n almost_die\n end\n end",
"def move\n @coordinates[1] += 1 if @rover_facing == 'N'\n @coordinates[0] += 1 if @rover_facing == 'E'\n @coordinates[1] -= 1 if @rover_facing == 'S'\n @coordinates[0] -= 1 if @rover_facing == 'W'\nend",
"def drive_north(direction)\n if direction == 'N'\n @new_vertical_position = take_input[3].to_i\n @new_vertical_position += 1\n @current_position = \"#{take_input[2].to_i},#{@new_vertical_position}\"\n end\n end",
"def move\n check_placement\n\n new_position = make_move(current_position, direction)\n position(new_position[0], new_position[1], @table.size)\n end",
"def move\n\t\treturn \"INVALID COMMANDS, YOU CAN NOT MAKE THE ROBOT FALL OFF THE TABLE\" unless is_valid_move?\n\t\tcase @direction\n\t\twhen \"east\"\n\t\t\t@x_coordinate += 1\n\t\twhen \"west\"\n\t\t\t@x_coordinate -= 1\n\t\twhen \"south\"\n\t\t\t@y_coordinate -= 1\n\t\twhen \"north\"\n\t\t\t@y_coordinate += 1\n\t\telse\n\t\tend\n\t\ttrue\n\tend",
"def move\n case @toy_direction\n when \"NORTH\"\n new_place = [@toy_place[0], @toy_place[1] + 1]\n when \"EAST\"\n new_place = [@toy_place[0] + 1, @toy_place[1]]\n when \"SOUTH\"\n new_place = [@toy_place[0], @toy_place[1] - 1]\n when \"WEST\"\n new_place = [@toy_place[0] - 1, @toy_place[1]]\n end\n place_robot(new_place, @toy_direction)\n end",
"def projected_move\n\t\t\t\traise NotYetPlaced if been_placed.nil?\n\n\t\t\t\t_x = x\n\t\t\t\t_y = y\n\t\t\t\tcase face\n\t\t\t\twhen 'NORTH'\n\t\t\t\t\t_y += 1\n\t\t\t\twhen 'EAST'\n\t\t\t\t\t_x += 1\t\t\t\t\t\n\t\t\t\twhen 'SOUTH'\n\t\t\t\t\t_y -= 1\n\t\t\t\twhen 'WEST'\n\t\t\t\t\t_x -= 1\t\t\t\t\t\n\t\t\t\tend\n\t\t\t\t[_x, _y]\n\t\t\tend",
"def execute\n return unless @robot.placed?\n\n original_position = @robot.position\n new_position = original_position.dup\n new_position.move\n\n @robot.position = new_position if @table.position_valid?(new_position)\n end",
"def move\n case @direction\n when \"N\" then @y += 1 unless @y + 1 > @plateau.y || @@rover_locations.values.include?([@x, @y + 1])\n when \"E\" then @x += 1 unless @x + 1 > @plateau.x || @@rover_locations.values.include?([@x + 1, @y])\n when \"S\" then @y -= 1 unless @y - 1 < 0 || @@rover_locations.values.include?([@x, @y -1])\n when \"W\" then @x -= 1 unless @x - 1 < 0 || @@rover_locations.values.include?([@x -1, @x])\n end\n @@rover_locations[@id.to_sym] = [@x, @y]\n end",
"def move\n\n if @position != []\n if @position[2] == \"EAST\"\n @position[0] += 1\n elsif @position[2] == \"WEST\"\n @position[0] -= 1\n elsif @position[2] == \"NORTH\"\n @position[1] += 1\n elsif @position[2] == \"SOUTH\"\n @position[1] -= 1\n end\n check_position()\n else\n puts \"Invalid Command!!.\\nPlease execute command (place) to place the robot on the table.\"\n end\n @position\nend",
"def move\n return unless placed?\n # We know place() will already ignore invalid placements, so just advance\n # the robot and let it fail silently if those positions are not on the board\n place(*next_position, direction)\n end",
"def move\n case @facing\n when \"north\"\n @posY += 1 if @posY+1 < @table.width\n when \"east\"\n @posX += 1 if @posX+1 < @table.height\n when \"south\"\n @posY -= 1 if @posY-1 >= 0\n when \"west\"\n @posX -= 1 if @posX-1 >= 0\n end\n end",
"def moves\n # All pieces can stay in place\n [[0,0]]\n end",
"def move\n case @rover_facing\n when 'N'\n @coordinates[1] += 1\n when 'E'\n @coordinates[0] += 1\n when 'S'\n @coordinates[1] -= 1\n when 'W'\n @coordinates[0] -= 1\n end\n end",
"def place_at(x, y, direction)\n @position = [x.to_i, y.to_i]\n @front = case direction.downcase \n when \"north\" then :north\n when \"south\" then :east\n when \"east\" then :south\n when \"west\" then :west\n end\n puts \"position is: #{@position} direction is #{@front}\"\n end",
"def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end",
"def move; end",
"def move; end",
"def move\n check_placed\n new_position = case facing\n when :north then @position.inc_y\n when :south then @position.dec_y\n when :east then @position.inc_x\n when :west then @position.dec_y\n end\n check_position(new_position)\n @position = new_position\n end",
"def place args\n \n @is_robot_availabe = true\n \n @pos_x,@pos_y,@direction = args\n\n if not (0..TABLE_X).include?(@pos_x) or not (0..TABLE_Y).include?(@pos_y)\n puts \"Warning: The position of Robot at (#{@pos_x}, #{@pos_y}) is outside the table (5,5).\"\n @is_robot_availabe = false\n return\n end\n\n if not DIRECTIONS.include?(@direction)\n puts \"Warning: #{@direction} is invaid. Robot can only move towards the four directions: \\n\"\\\n \"#{DIRECTIONS.inspect}.\"\n @is_robot_availabe = false\n return\n end\n\n # return \"PLACE\" #for test\n end",
"def place x, y, f\n if @board.can_place?(x, y) and valid_direction?(f)\n @x = x\n @y = y\n @f = DIRECTIONS.index(f.to_s.downcase)\n end\n report\n end",
"def move\n case self.direction\n when 'NORTH'\n self.y += 1 unless self.y == @table.y\n when 'EAST'\n self.x += 1 unless self.x == @table.x\n when 'SOUTH'\n self.y -= 1 unless self.y == 0\n when 'WEST'\n self.x -= 1 unless self.x == 0\n end\n end",
"def forward_move\n case @facing\n when 'NORTH'\n @y += 1\n when 'SOUTH'\n @y -= 1\n when 'EAST'\n @x += 1\n when 'WEST'\n @x -= 1\n end\n self\n end",
"def move\n if @placed\n position = @face.move(@x, @y)\n x = position[0]\n y = position[1]\n if @table.validate(x, y)\n @x = x\n @y = y\n end\n end\n end",
"def move_rover()\n puts \"DEBUG: moving: #{@orientation}\" if DEBUG\n case @orientation\n when DIRECTION_EAST\n @position[:x] += 1 if @position[:x] < @map.width\n when DIRECTION_WEST\n @position[:x] -= 1 if @position[:x] > 0\n when DIRECTION_NORTH\n @position[:y] += 1 if @position[:y] < @map.height\n when DIRECTION_SOUTH\n @position[:y] -= 1 if @position[:y] > 0\n end\n puts \"DEBUG: position after move: #{@position}\" if DEBUG\n end",
"def move(forward)\n moves = [0, forward ? 1 : -1]\n moves.reverse! if @hor\n new_coord = @coord.add(moves + moves)\n set!(new_coord[0], new_coord[1], @hor)\n end",
"def update_position!(next_move)\n table.x = next_move[:x]\n table.y = next_move[:y]\n end",
"def move!\n if placed?\n case orientation.to_sym\n when :NORTH then @y += 1 if valid_coordinates?(x, y + 1)\n when :EAST then @x += 1 if valid_coordinates?(x + 1, y)\n when :SOUTH then @y -= 1 if valid_coordinates?(x, y - 1)\n when :WEST then @x -= 1 if valid_coordinates?(x - 1, y)\n end\n nil\n else\n raise RobotSimulation::NotPlacedError, \"Robot has not been placed yet.\"\n end\n end",
"def move\n move_by a, m\n end",
"def move(direction)\n \n end",
"def move!\n case @facing\n when Direction::NORTH\n @loc[:y] += 1 unless out_of_bounds? @loc[:x], @loc[:y] + 1\n when Direction::EAST\n @loc[:x] += 1 unless out_of_bounds? @loc[:x] + 1, @loc[:y]\n when Direction::SOUTH\n @loc[:y] -= 1 unless out_of_bounds? @loc[:x], @loc[:y] - 1\n when Direction::WEST\n @loc[:x] -= 1 unless out_of_bounds? @loc[:x] - 1, @loc[:y]\n else\n raise %q{Don't know which direction to move}\n end\n end",
"def next_move(_n, bot_pos_x, bot_pos_y, princess_position, _grid)\n case\n when princess_position[0] - bot_pos_x < 0 then move = 'UP'\n when princess_position[0] - bot_pos_x > 0 then move = 'DOWN'\n when princess_position[1] - bot_pos_y < 0 then move = 'LEFT'\n when princess_position[1] - bot_pos_y > 0 then move = 'RIGHT'\n end\n move\n end",
"def move\n return unless placed?\n # no need to use a loop since the length is only 2\n new_x = @pos_x + @direction[:x]\n new_y = @pos_y + @direction[:y]\n\n return unless valid_position?(new_x, new_y)\n set_position(new_x, new_y)\n end",
"def move_forward\r\r\n @move_poll+= [[@direction, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n end",
"def place(args)\n return if (args.empty?) ||\n (args.length != 3) ||\n (args[0].to_i < 0 || args[0].to_i >= @table.height) ||\n (args[1].to_i < 0 || args[1].to_i >= @table.width) ||\n !DIRECTIONS.include?(args[2])\n\n @posX = args[0].to_i\n @posY = args[1].to_i\n @facing = args[2]\n @placed = true\n end",
"def place_object\n @board.place_object *next_position\n end",
"def execute\n if @robot.placed?\n new_position = @robot.current_position.go_to(@robot.current_position.direction)\n\n @robot.current_position = new_position if @table.position_is_valid?(new_position)\n end\n end",
"def test_can_move_north\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :TEST)\n\n assert_equal(:NORTH, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(0, 0))\n\n @robot.move\n assert_equal(0, @robot.x, \"X position should be 0 (not changed)\")\n assert_equal(1, @robot.y, \"Y position should be 1 (moved 1 north)\")\n assert_equal(:NORTH, @robot.direction, \"Direction should be :NORTH (not changed)\")\n assert_equal(\"M\", @robot.get_path_value(0, 1))\n end",
"def nextMove(n,r,c,grid)\n # place m on grid at r,c\n actions = generate_path(grid, 'm','p')\n puts actions[0]\n grid[r][c] = '-'\n if actions[0] == 'LEFT'\n grid[r][c-1]='m'\n elsif actions[0] == 'RIGHT'\n grid[r][c+1]='m'\n elsif actions[0] == 'UP'\n grid[r-1][c]='m'\n elsif actions[0] == 'DOWN'\n grid[r+1][c]='m'\n end\n actions[0]\n end",
"def move\n\n end",
"def test_can_not_move_north\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :TEST, 1, 5)\n\n assert_equal(:NORTH, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(1, 5))\n\n @robot.move\n assert_equal(1, @robot.x, \"X position should be 1 (not changed)\")\n assert_equal(5, @robot.y, \"Y position should be 5 (not changed)\")\n assert_equal(:NORTH, @robot.direction, \"Direction should be :NORTH (not changed)\")\n assert_equal(\"P\", @robot.get_path_value(1, 5))\n end",
"def move\n placed?\n if @direction == \"NORTH\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?(@x, (@y+1))\n @y+=1\n elsif @direction == \"SOUTH\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?(@x, (@y-1))\n @y-=1\n elsif @direction == \"WEST\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?((@x-1), @y)\n @x-=1\n elsif @direction == \"EAST\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?((@x+1), @y)\n @x+=1\n end\n end",
"def second_move() \n\t\tif first_move == false && board[4].class = Fixnum\n\t\t\tboard[4] = marker\n\t\telse\n\t\t\tcorner\n\t\tend\n\tend",
"def move\n\t\tif @direction == \"N\"\n\t\t\t@y += 1\n\t\telsif @direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif @direction == \"E\"\n\t\t\t@x += 1\n\t\telsif @direction == \"S\"\n\t\t\t@y -= 1\n\t\tend\n\tend",
"def moves\n end",
"def second_move() \r\n\t\tif first_move == false && board[4].class = Fixnum\r\n\t\t\tboard[4] = marker\r\n\t\telse\r\n\t\t\tcorner\r\n\t\tend\r\n\tend",
"def moves\n\n end",
"def move\n \n end",
"def move\n \n end",
"def move(location, token=\"X\") # move( 0 , O ) \n @board[location] = token\n #binding.pry\n end",
"def move\n case @direction\n when \"NORTH\" then move_north\n when \"SOUTH\" then move_south\n when \"EAST\" then move_east\n when \"WEST\" then move_west\n end\n end",
"def next_move(bot_pos_x, bot_pos_y, princess_position)\n case\n when princess_position[0] - bot_pos_x < 0 then move = 'UP'\n when princess_position[0] - bot_pos_x > 0 then move = 'DOWN'\n when princess_position[1] - bot_pos_y < 0 then move = 'LEFT'\n when princess_position[1] - bot_pos_y > 0 then move = 'RIGHT'\n end\n move\nend",
"def place_robot(new_place, direction)\n if @table_top.move_robot(new_place)\n @toy_place = new_place\n @toy_direction = direction\n end\n end",
"def interpret_move(command)\n ensure_placed\n @robot.move_forward\n end",
"def move()\n case @mov_dir\n when :right\n if @coord_x == @max_x\n @max_x += 1 # Moving out of bounds. No need to do anything because Ruby rocks! :P\n end\n @coord_x += 1\n \n when :up\n if @coord_y == 0\n @map.unshift [] # Moving out of bounds. Adds a new line to the top\n @max_y += 1\n else\n @coord_y -= 1\n end\n \n when :down\n if @coord_y == @max_y\n @max_y += 1\n @map.push [] # Moving out of bounds. Adds a new line to the bottom\n end\n @coord_y += 1\n \n when :left\n if @coord_x == 0\n @map.each do |a| # Moving out of bounds. Adds a new line to the left\n a.unshift ' ' \n end\n @max_x += 1\n else\n @coord_x -= 1\n end\n end\n end",
"def move\n # Check that we have been placed\n if self.placed?\n # Create a new version to hold our new position for validation later\n new_position = @current_position.dup\n \n # Get our direction constant to establish whether we want to operate on the X or Y co-ordinate and whether to subtract or add based on direction\n direction_constant = self.get_direction_constant\n\n # Calculate our new position operating on the correct coordinate with the correct operation using the constants we have on the class\n new_position[direction_constant[:coordinate]] = new_position[direction_constant[:coordinate]] + direction_constant[:operation_value] \n # Check if the new position is valid move to this position\n if @table.valid_destination new_position[:x], new_position[:y]\n # Set our new valid position\n @current_position = new_position \n puts \"The Toy Robot has moved to (#{@current_position[:x]}, #{@current_position[:y]}) facing #{@current_position[:direction]}...\"\n else\n puts \"The Toy Robot cannot move any further, position unchanged, skipping command...\"\n return false\n end\n else\n puts \"The Toy Robot has not been placed, skipping command...\"\n return false\n end\n end",
"def move\n origin = @table.find(self)\n\n # Check if the robot can move without falling off the table\n case @direction\n when Direction::NORTH\n movement = Coordinate.new(0, 1)\n when Direction::EAST\n movement = Coordinate.new(1, 0)\n when Direction::SOUTH\n movement = Coordinate.new(0, -1)\n when Direction::WEST\n movement = Coordinate.new(-1, 0)\n end\n destination = origin + movement\n return unless @table.contain? destination\n\n # Safe to move\n @table.place origin, nil\n @table.place destination, self\n end",
"def setup_move\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n mx = @map_char.real_x + @acts[1]\n my = @map_char.real_y + @acts[2]\n goto(mx, my, @acts[3], @acts[4], @acts[5] || 0)\n end",
"def next_move_x_y(next_move, place=true)\n origin_x = place ? table.x : 0\n origin_y = place ? table.y : 0\n next_move[:x] = origin_x + next_move[:x]\n next_move[:y] = origin_y + next_move[:y]\n next_move\n end",
"def move\n ##incrementing or decrementing eg. current_direction W,\n ##position_x decrementing by 1 (-=1)\n if @current_direction == \"N\"\n @position_y += 1\n puts \"#{@position_y}\"\n elsif @current_direction == \"E\"\n @position_x += 1\n elsif @current_direction == \"W\"\n @position_x -= 1\n elsif @current_direction == \"S\"\n @position_y -= 1\n end\n\n end",
"def move(forward)\n if @direction == \"N\"\n if @y + 1 < @@ymax\n @y += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"S\"\n if @y - 1 > @@ymin\n @y -= 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction ==\"E\"\n if @x + 1 < @@xmax\n @x += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"W\"\n if @x - 1 > @@xmin\n @x -= 1\n else\n puts \"Nice try sucker\"\n end\n else\n puts \"Where in the world are you?\"\n end\nend",
"def commit_move!(start_pos, end_pos, count = true)\n self.turn_count = 1 + turn_count.to_i if count\n current_piece = self[start_pos]\n self[end_pos].move_to([10,10]) if self[end_pos].is_a?(Piece)\n swap_positions(start_pos, end_pos, current_piece, EmptySquare.new, true)\n promote_last_lines\n end",
"def move\n @leading_x = coordinate_array[0]\n @leading_y = coordinate_array[1]\n end",
"def move_by_one(order)\n case co_ordinates[2]\n when \"N\"\n co_ordinates[1] += order[1]\n when \"S\"\n co_ordinates[1] -= order[1]\n when \"E\"\n co_ordinates[0] += order[1]\n when \"W\"\n co_ordinates[0] -= order[1]\n end\n puts \"move_by_one: co_ordinates = #{co_ordinates}\"\n end",
"def move (direction)\n\n [email protected]_valid_move @xpos, @ypos\n\n if direction == 'north'\n @ypos += 1\n elsif direction == 'east'\n @xpos += 1\n elsif direction == 'south'\n @ypos -= 1\n elsif direction == 'west'\n @xpos -= 1\n end\n\n else\n puts \"that's not a valid move\"\n end\n\n def report\n \"My co-ordinates are #{@xpos}, #{@ypos}\"\n end\nend",
"def interpret_place(command)\n matches = command.upcase.match(/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(NORTH|SOUTH|EAST|WEST)/)\n raise CommandError, \"Invalid place command.\" if matches.nil?\n \n xpos = matches[1].to_i\n ypos = matches[2].to_i\n direction = matches[3]\n \n coords = Coordinate.new(xpos, ypos)\n direction = Direction[direction]\n \n if @robot.nil?\n @robot = Robot.new(coords, direction, @table)\n else\n @robot.place(coords, direction, @table)\n end\n end",
"def place(pos)\n @board[pos.i][pos.j] = Stone.new(current, pos, move)\n UpdateGroups.call(game: self, pos: pos)\n ko_clear\n opponent = current == :black ? :white : :black\n capture(opponent, pos)\n capture(current)\n next_player\n self\n end",
"def move_forward\n case @orientation\n when :north\n @position.y_coordinate += 1\n when :east\n @position.x_coordinate += 1\n when :south\n @position.y_coordinate -= 1\n when :west\n @position.x_coordinate -= 1\n end\n end",
"def move\n position_after_move = @position.new_coordinates_for_step_size(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n #ignore the command if robot is being out off tabletop\n if(@table_top.has_within_bounds?(position_after_move))\n @position = @position.new_coordinates_for(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n end\n end",
"def place(x, y, direction_to_face)\n # Check if we're working with a valid destination\n if @table.valid_destination x, y \n # Set our new position instance variable values\n @current_position[:x] = x\n @current_position[:y] = y\n @current_position[:direction] = direction_to_face\n\n puts \"Toy Robot placed at (#{@current_position[:x]}, #{@current_position[:y]}) facing #{@current_position[:direction]}\"\n\n return true\n else\n puts \"Invalid placement given, please specify a valid place within the range of the table in the format X, Y e.g. PLACE 1, 2\" \n return false\n end\n end",
"def move\n case @direction\n when \"N\"\n @coord_y += 1\n when \"S\"\n @coord_y -= 1\n when \"E\"\n @coord_x += 1\n else\n @coord_x -= 1\n end #end of case\nend",
"def move_onto(a, b)\n reveal(a)\n reveal(b)\n move_single(a, b)\n end",
"def test_can_not_move_south\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :SOUTH, 1, 0)\n\n assert_equal(:SOUTH, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(1, 0))\n\n @robot.move\n assert_equal(1, @robot.x, \"X position should be 1 (not changed)\")\n assert_equal(0, @robot.y, \"Y position should be 0 (not changed)\")\n assert_equal(:SOUTH, @robot.direction, \"Direction should be :SOUTH (not changed)\")\n assert_equal(\"P\", @robot.get_path_value(1, 0))\n end",
"def place_command_proceed\n @robot.place(@x_position.to_i, @y_position.to_i, @vector.to_s.strip)\n end",
"def move\n case @direction\n when \"N\"\n @y_coord += 1\n when \"S\"\n @y_coord -= 1\n when \"W\"\n @x_coord += 1\n when \"E\"\n @x_coord -= 1\n end\n end",
"def move(direction)\n action = true\n m = @pusher[:pos_m]\n n = @pusher[:pos_n]\n\n direction = direction.downcase\n\n # Following of the direction, test 2 cells\n if direction == 'u' && can_move?('u')\n m_1 = m-1\n m_2 = m-2\n n_1 = n_2 = n\n @pusher[:pos_m] -= 1\n elsif direction == 'd' && can_move?('d')\n m_1 = m+1\n m_2 = m+2\n n_1 = n_2 = n\n @pusher[:pos_m] += 1\n elsif direction == 'l' && can_move?('l')\n n_1 = n-1\n n_2 = n-2\n m_1 = m_2 = m\n @pusher[:pos_n] -= 1\n elsif direction == 'r' && can_move?('r')\n n_1 = n+1\n n_2 = n+2\n m_1 = m_2 = m\n @pusher[:pos_n] += 1\n else\n action = false\n state = NO_MOVE\n end\n\n # Move accepted\n if action\n state = NORMAL_MOVE\n\n # Test on cell (m,n)\n if read_pos(m, n) == '+'\n write_pos(m, n, '.')\n else\n write_pos(m, n, 's')\n end\n\n # Test on cell (m_2,n_2)\n if ['$', '*'].include? read_pos(m_1, n_1)\n if read_pos(m_2, n_2) == '.'\n write_pos(m_2, n_2, '*')\n else\n write_pos(m_2, n_2, '$')\n end\n\n state = BOX_MOVE\n end\n\n # Test on cell (m_1, n_1)\n if ['.', '*'].include? read_pos(m_1, n_1)\n write_pos(m_1, n_1, '+')\n else\n write_pos(m_1, n_1, '@')\n end\n end\n\n state\n end",
"def place(command)\n\t\tcommand.sub!(\"PLACE\", \"\")\n\t\tif (command =~ /\\s*\\d,\\d,\\w+/).nil?\n\t\t\tputs \"\"\n puts \"You forgot to tell the robot where to be placed or ..\"\n else\n \t\t@x, @y, @robot_direction = command.split(\",\")\n \t\t@x = number_or_nil(@x)\n \t\t@y = number_or_nil(@y)\n end\n\t\t#validates the location of the placement\n\t\tif valid_placement?\n\t\t\[email protected](@x, @y, @robot_direction)\n\t\t\tputs \"\"\n\t\t\tputs \"The robot has been placed at #{@x} #{@y} facing #{@robot_direction}. Let\\'s go on a rampage!\"\n\t\telse\n\t\t\tputs \"..the place command is incorrectly formatted or outside the table bounds. \"\n\t\t\tputs \"The boundries of this world reach from #{@min},#{@min} up to #{@width - 1},#{@height - 1}\"\n\t\t\tputs \"A place command looks like \\'PLACE 0,0,North \\' \"\n\t\tend\n\tend",
"def hop!\n\t\t@direction = @dice.throw #throw dice and read direction into a variable\n\n\t\t#if the direction is illegal (due to skippy's location at a boundary), roll the dice again \n\t\t#until a legal direction is returned\n\t\twhile !movable_direction? do\n\t\t\t@direction = @dice.throw\n\t\tend\n\t\t\n\t\t#using @north, @south....etc variables defined previously, move skippy as per dice direction\n\t\tif @direction == :NORTH\n\t\t\tthen @location = @location + @north\n\t\telsif @direction == :SOUTH\n\t\t\tthen @location = @location + @south\n\t\telsif @direction == :EAST\n\t\t\tthen @location = @location + @east\n\t\telse\n\t\t\t@location = @location + @west\n\t\tend\n\t\t\t\t\t\n\tend",
"def move\n @glade['add_point'].sensitive = false\n @locate_thread = @planning.locate(@start, @finish) {move_finished}\n end",
"def perform_move(move)\n @board[*move] = self\n @board[*@location] = nil\n @location = move\n @king = true if in_end_row?\n move\n end",
"def move(*_)\n dir = direction_compass.to_direction(direction)\n new_value = direction_compass.direction[dir.to_sym]\n\n place(x + new_value[:x], y + new_value[:y])\n end",
"def prospect_move(total_turns)\n @turns += 1\n if @turns == total_turns\n end_search\n else\n neighbor_index = rand(@curr_location.neighbor_list.length)\n puts \"Heading from #{@curr_location.loc} to #{@curr_location.neighbor_list[neighbor_index]}.\"\n change_curr_location(@map.get_by_name(@curr_location.neighbor_list[neighbor_index]))\n end\n end",
"def move_left\n left_tile = Couple.new(@location.first, @location.second - 1)\n move_to(left_tile)\n end",
"def moveto(x, y)\r\r\n @x = x % $game_map.width\r\r\n @y = y % $game_map.height\r\r\n @real_x = @x\r\r\n @real_y = @y\r\r\n @prelock_direction = 0\r\r\n straighten\r\r\n update_bush_depth\r\r\n end",
"def test_scenario3\n r = Robot.new(1, 2, 'EAST')\n r.move(table)\n r.move(table)\n r.turn_left\n r.move(table)\n assert_equal('3,3,NORTH', r.report)\n end",
"def test_can_not_move_west\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :WEST, 0, 4)\n\n assert_equal(:WEST, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(0, 4))\n\n @robot.move\n assert_equal(0, @robot.x, \"X position should be 0 (not changed)\")\n assert_equal(4, @robot.y, \"Y position should be 4 (not changed)\")\n assert_equal(:WEST, @robot.direction, \"Direction should be :WEST (not changed)\")\n assert_equal(\"P\", @robot.get_path_value(0, 4))\n end",
"def lmove(source, destination, where_source, where_destination); end",
"def lmove(source, destination, where_source, where_destination); end",
"def move\n @position += MOVMENT_ALTERATIONS[rand(0..1)]\n end",
"def move (x,y,direction)\n if direction ==\"EAST\"\n if validate(x+1) then return x+1,y end\n elsif direction ==\"WEST\"\n if validate(x-1) then return x-1,y end\n elsif direction ==\"NORTH\"\n if validate(y+1) then return x,y+1 end\n elsif direction ==\"SOUTH\"\n if validate(y-1) then return x,y-1 end\n end\n return x,y\n end",
"def place?(robot, direction_sym)\n true\n end",
"def move(direction, map)\n x = @x_location\n y = @y_location\n \n case direction\n when :north then y -= 1\n when :south then y += 1 \n when :west then x -= 1\n when :east then x += 1 \n end\n \n unless map[y][x].is_a_wall?\n @x_location = x\n @y_location = y\n end \n end",
"def move_piece(start_pos,end_pos)\n begin \n raise \"No piece here to move\" if grid[start_pos[0]][start_pos[1]].nil?\n raise \"Can't move to this spot\" if end_pos[0] > 7 || end_pos[0] < 0 || end_pos[1] > 7 || end_pos[1] < 0 \n self[start_pos], self[end_pos] = self[end_pos],self[start_pos]\n end\n end",
"def test_can_move_south\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :SOUTH, 1, 2)\n\n assert_equal(:SOUTH, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(1, 2))\n\n @robot.move\n assert_equal(1, @robot.x, \"X position should be 1 (not changed)\")\n assert_equal(1, @robot.y, \"Y position should be 1 (moved 1 south)\")\n assert_equal(:SOUTH, @robot.direction, \"Direction should be :SOUTH (not changed)\")\n assert_equal(\"M\", @robot.get_path_value(1, 1))\n end",
"def place(x, y, orientation)\n position(x, y, @table.size)\n self.direction = orientation.to_sym\n end",
"def grid_move(new_grid_pos)\n @grid_pos = new_grid_pos\n @ori_x = original_x\n @ori_y = original_y\n self.battle_phase = :move\n end",
"def move\n\t\tunless @y >= 0 then\n\t\t\t@y += 1\n\t\tend\n\t\tif @x_total <= 150 and @y_total <= 150 then\n\t\t\t@x += 1\n\t\t\t@y += 1\n\t\t\t@x_total +=1\n\t\t\t@y_total += 1\n\t\tend\n\t\tif @x_total > 150 and @y_total > 150 and @x_total < 300 and @y_total < 300 then\n\t\t\t@y -= 1\n\t\t\t@x_total += 1\n\t\t\t@y_total += 1\n\t\tend\n\t\tif @x_total > 298 and @y_total > 298 and @x_total < 450 and @y_total < 450 then\n\t\t\t@y +=1\n\t\t\t@x -= 1\n\t\t\t@x_total += 1\n\t\t\t@y_total += 1\n\t\tend\n\t\tif @x_total > 448 and @y_total > 448 and @x_total < 600 and @y_total < 600 then\n\t\t\t@y -= 1\n\t\t\t@x_total += 1\n\t\t\t@y_total += 1\n\t\tend\n\t\tif @x_total == 599 and @y_total == 599 then\n\t\t\t@x_total = @y_total = 0\n\t\tend\n\tend",
"def hanoi(pin0, pin1, pin2, disks)\n if disks == 1\n puts \"Move from #{pin0} to #{pin2}\"\n else\n hanoi(pin0, pin1, pin2, disks - 1)\n hanoi(pin0, pin2, pin1, 1)\n hanoi(pin2, pin1, pin0, disks - 1)\n end\nend",
"def input_move(column, player)\n placed = false\n return false unless (1..width).include?(column)\n\n grid.reverse_each do |row|\n if row[column - 1] == empty_cell && placed == false\n row[column - 1] = player\n placed = true\n end\n end\n placed\n end",
"def move_by_input\r\r\n return if !movable? || $game_map.interpreter.running?\r\r\n if CXJ::FREE_MOVEMENT::ENABLE_DIAGONAL && Input.dir8 > 0 && Input.dir8 % 2 != 0\r\r\n d = Input.dir8\r\r\n horz = (d == 1 || d == 7 ? 4 : 6)\r\r\n vert = (d == 1 || d == 3 ? 2 : 8)\r\r\n move_diagonal(horz, vert)\r\r\n elsif Input.dir4 > 0\r\r\n move_straight(Input.dir4)\r\r\n end\r\r\n end"
] | [
"0.6726027",
"0.6560745",
"0.6539834",
"0.6535293",
"0.6527546",
"0.6520768",
"0.65065175",
"0.64961916",
"0.64522535",
"0.6411783",
"0.63982135",
"0.6396631",
"0.63836455",
"0.6357319",
"0.63566446",
"0.6338761",
"0.6325651",
"0.6325651",
"0.63244396",
"0.6310757",
"0.6290769",
"0.62685627",
"0.62503594",
"0.6211191",
"0.6171925",
"0.6142312",
"0.6140472",
"0.6131663",
"0.6122576",
"0.61186296",
"0.6112675",
"0.6110488",
"0.6107144",
"0.6105626",
"0.6097225",
"0.6092869",
"0.6092361",
"0.60906786",
"0.6083538",
"0.60812986",
"0.6076571",
"0.6074864",
"0.60707414",
"0.60496956",
"0.6044577",
"0.6031862",
"0.6029251",
"0.60291123",
"0.60291123",
"0.6023317",
"0.6021904",
"0.60197794",
"0.60105336",
"0.6006265",
"0.599005",
"0.59868014",
"0.59794146",
"0.59603137",
"0.59491235",
"0.59451276",
"0.59440655",
"0.5933894",
"0.59216434",
"0.59206253",
"0.5919402",
"0.5911324",
"0.5910392",
"0.59096324",
"0.5908214",
"0.5906568",
"0.5906111",
"0.58910894",
"0.5890103",
"0.58782",
"0.5877094",
"0.58722126",
"0.58691716",
"0.5868126",
"0.58654815",
"0.585805",
"0.5855593",
"0.58492047",
"0.58414704",
"0.5833345",
"0.58310825",
"0.58271694",
"0.5809405",
"0.5809405",
"0.58029467",
"0.5801513",
"0.57955074",
"0.5795339",
"0.5795278",
"0.57904476",
"0.57857245",
"0.57851285",
"0.5775311",
"0.5774966",
"0.5771765",
"0.5769886"
] | 0.63011116 | 20 |
PLACE 0,0,NORTH LEFT REPORT Output: 0,0,WEST | def test_scenario2
r = robot
r.turn_left
assert_equal('0,0,WEST', r.report)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drive_west(direction)\n if direction == 'W'\n @new_horizontal_position = take_input[2].to_i\n @new_horizontal_position -= 1\n @current_position = \"#{@new_horizontal_position},#{take_input[3].to_i}\"\n end\n end",
"def west\n @west ||= id.div(ROWS) * SIZE + SOUTH_WEST.lng\n end",
"def rotate_left\n placed?\n @direction = case @direction\n when \"NORTH\" then \"WEST\"\n when \"EAST\" then \"NORTH\"\n when \"SOUTH\" then \"EAST\"\n when \"WEST\" then \"SOUTH\"\n end\n end",
"def left\n check_placed\n @facing = next_facing(-1)\n end",
"def left\n if @position != []\n if @position[2] == \"EAST\"\n @position[2] = \"NORTH\"\n elsif @position[2] == \"WEST\"\n @position[2] = \"SOUTH\"\n elsif @position[2] == \"NORTH\"\n @position[2] = \"WEST\"\n elsif @position[2] == \"SOUTH\"\n @position[2] = \"EAST\"\n end\n else\n puts \"Invalid Command!!.\\nPlease execute command (place) to place the robot on the table.\"\n end\n return @position\nend",
"def west \n \"west\" \n end",
"def test_can_move_west\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :WEST, 5, 5)\n\n assert_equal(:WEST, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(5, 5))\n\n @robot.move\n assert_equal(4, @robot.x, \"X position should be 4 (moved 1 east)\")\n assert_equal(5, @robot.y, \"Y position should be 5 (not changed)\")\n assert_equal(:WEST, @robot.direction, \"Direction should be :WEST (not changed)\")\n assert_equal(\"M\", @robot.get_path_value(4, 5))\n end",
"def west\n @state.west(self)\n end",
"def turnLeft\n case @currentDir\n when :north\n @currentDir = :west\n when :south\n @currentDir = :east\n when :east\n @currentDir = :north\n when :west\n @currentDir = :south\n end\n end",
"def west\n Textcell.new(@x-1, @y,@parent)\n end",
"def move_west\n @x -= 1\n end",
"def left(seat)\n if seat == :south \n return :west \n elsif seat == :east\n return :south\n else\n return :east \n end \n end",
"def move_left\n left_tile = C[@location.first, @location.second - 1]\n move_to(left_tile)\n end",
"def right position\n # if currently facing north\n if position[2] == \"north\"\n # right will make it face east\n position[2] = \"east\"\n # if currently facing south\n elsif position[2] == \"south\"\n # right will make it face west\n position[2] = \"west\"\n # if currently facing east\n elsif position[2] == \"east\"\n # right will make it face south\n position[2] = \"south\"\n # if currently facing west\n elsif position[2] == \"west\"\n # right will make it face north\n position[2] = \"north\"\n end\n position\nend",
"def move_left\n left_tile = Couple.new(@location.first, @location.second - 1)\n move_to(left_tile)\n end",
"def test_can_not_move_west\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :WEST, 0, 4)\n\n assert_equal(:WEST, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(0, 4))\n\n @robot.move\n assert_equal(0, @robot.x, \"X position should be 0 (not changed)\")\n assert_equal(4, @robot.y, \"Y position should be 4 (not changed)\")\n assert_equal(:WEST, @robot.direction, \"Direction should be :WEST (not changed)\")\n assert_equal(\"P\", @robot.get_path_value(0, 4))\n end",
"def left\n West.new\n end",
"def move_left\n\t\tmove([-1,0])\n\tend",
"def west (game)\n @state.west(self, game)\n end",
"def north(i=@cursor) i-width end",
"def steer(where)\n case where\n when :left\n @right_pin.set(0)\n @left_pin.set(1)\n when :right\n @left_pin.set(0)\n @right_pin.set(1)\n else\n @left_pin.set(0)\n @right_pin.set(0)\n end\n end",
"def north\n @north ||= south + SIZE\n end",
"def turn_left\n # a kind of matrix multiplication\n new_row_diff = 0 - @col_diff\n new_col_diff = @row_diff + 0\n @row_diff = new_row_diff\n @col_diff = new_col_diff\n end",
"def place_at(x, y, direction)\n @position = [x.to_i, y.to_i]\n @front = case direction.downcase \n when \"north\" then :north\n when \"south\" then :east\n when \"east\" then :south\n when \"west\" then :west\n end\n puts \"position is: #{@position} direction is #{@front}\"\n end",
"def west (room , game)\n if @left.nil?\n \"No puedes ir al Oeste\"\n else\n @left.call(room, game)\n end\n end",
"def south_west\n Textcell.new(@x-1, @y+1,@parent)\n end",
"def south_west\n @south_west ||= Point.new(south, west)\n end",
"def relative_left_cell\n return left_cell if @facing == 'up'\n return up_cell if @facing == 'right'\n return right_cell if @facing == 'down'\n return down_cell if @facing == 'left'\n end",
"def right\n if @position != []\n if @position[2] == \"EAST\"\n @position[2] = \"SOUTH\"\n elsif @position[2] == \"WEST\"\n @position[2] = \"NORTH\"\n elsif @position[2] == \"NORTH\"\n @position[2] = \"EAST\"\n elsif @position[2] == \"SOUTH\"\n @position[2] = \"WEST\"\n end\n else\n puts \"Invalid Command!!.\\nPlease execute command (place) to place the robot on the table.\"\n end\n return @position\nend",
"def move_left\n\t\t# if the horse isn;t yet at the left of of the screne move it left 20\n\t\tif @x > 0\n\t\t\t\t@x = @x -20\n\t\tend\n\tend",
"def forward_move\n case @facing\n when 'NORTH'\n @y += 1\n when 'SOUTH'\n @y -= 1\n when 'EAST'\n @x += 1\n when 'WEST'\n @x -= 1\n end\n self\n end",
"def racquetLeft(racquet)\n if racquet - 2 != 1 #If the leftermost part of the racket isn't in the left wall\n return racquet - 1 #return the current position but 1 to the left \n else\n return racquet\n end\nend",
"def move_left(array)\r\n set_current_row_col(array)\r\n new_col = (@current_col == 0) ? array.first.length - 1 : @current_col - 1 # This logic will decide the new co-ordinated of space\r\n current_ele = array[@current_row][new_col]\r\n array[@current_row][new_col] = ' '\r\n replace_existing_element(array,current_ele, @current_row, @current_col)\r\n array\r\n end",
"def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end",
"def north_west\n Textcell.new(@x-1, @y-1,@parent)\n end",
"def turn_left\n case @heading\n when 'W' then @heading = 'S'\n when 'E' then @heading = 'N'\n when 'N' then @heading = 'W'\n when 'S' then @heading = 'E'\n end\n end",
"def left_directions\n {\n ToyEnums::NORTH => ToyEnums::WEST,\n ToyEnums::WEST => ToyEnums::SOUTH,\n ToyEnums::SOUTH => ToyEnums::EAST,\n ToyEnums::EAST => ToyEnums::NORTH\n }\n end",
"def left(j)\n\t\tnew_loc = @location.dup\n\t\tnew_loc[:x] -= j\n\t\tGridPoint3D.new(x: new_loc[:x], y: new_loc[:y], z: new_loc[:z])\n\tend",
"def hop!\n\t\t#loop throws die until a direction that will not bring skippy outside the boundary is found\n\t\tbegin\n\t\t\tnewpoint = @location.clone\n\t\t\tdirection = @die.throw_die\n\t\t\tcase direction\n\t\t\t\twhen :NORTH\n\t\t\t\t\tnewpoint.y = newpoint.y + 1\n\t\t\t\twhen :SOUTH\n\t\t\t\t\tnewpoint.y = newpoint.y - 1\n\t\t\t\twhen :EAST\n\t\t\t\t\tnewpoint.x = newpoint.x + 1\n\t\t\t\twhen :WEST\n\t\t\t\t\tnewpoint.x = newpoint.x - 1\n\t\t\tend\t\n\t\tend while newpoint.y > @dimension-1 || newpoint.y < 0 || newpoint.x > @dimension-1 || newpoint.x < 0\n\t\t@location = newpoint.clone\n\tend",
"def move\n case self.direction\n when 'NORTH'\n self.y += 1 unless self.y == @table.y\n when 'EAST'\n self.x += 1 unless self.x == @table.x\n when 'SOUTH'\n self.y -= 1 unless self.y == 0\n when 'WEST'\n self.x -= 1 unless self.x == 0\n end\n end",
"def left(degrees)\n right(-degrees)\n end",
"def place dw\n (@w*@h).times{|startpt|\n return if test_place(dw, startpt)\n }\n end",
"def lower_left\n @lower_left ||= world.point(x_min, y_min)\n end",
"def draw_left_rests\n if @left_rests > 0\n big_rests = @left_rests / 2\n small_rests = @left_rests % 2\n if (@index % 2) == 1\n big_rests.times{@left_hand << \"r4 \"}\n @left_hand << \"r#{(8.0/small_rests).to_i} \" if small_rests > 0\n else\n @left_hand << \"r#{(8.0/small_rests).to_i} \" if small_rests > 0\n big_rests.times{@left_hand << \"r4 \"}\n end\n @left_rests = 0\n end\n end",
"def left!\n # TODO: Refactor. Can be less explicit\n case @facing\n when Direction::NORTH\n @facing = Direction::WEST\n when Direction::EAST\n @facing = Direction::NORTH\n when Direction::SOUTH\n @facing = Direction::EAST\n when Direction::WEST\n @facing = Direction::SOUTH\n else\n raise %q{Cannot rotate left}\n end\n end",
"def stair_move_left\n # unless @through\n if front_system_tag == StairsL\n return true unless $game_map.system_tag(@x - 1, @y - 1) == StairsL\n move_upper_left\n return true\n elsif system_tag == StairsR\n move_lower_left\n return true\n end\n # end\n return false\n end",
"def set_left_start_point\n @leading_x = 0\n @leading_y = find_left_entry\n end",
"def diagonal_left\n end",
"def left!(position_of_empty_tile)\n @state_array[position_of_empty_tile]=@state_array[position_of_empty_tile - 1]\n @state_array[position_of_empty_tile - 1] = @@empty\n @path += \"R\"\n self\n end",
"def move_left\n # @dx = -8\n @x -= 8\n end",
"def half_wind; end",
"def write_stand\n write_bits(0, 2) # we write 0 because we're standing\n end",
"def move_lower\n movement { self.position += 1 }\n end",
"def drive_east(direction)\n if direction == 'E'\n @new_horizontal_position = take_input[2].to_i\n @new_horizontal_position += 1\n @current_position = \"#{@new_horizontal_position},#{take_input[3].to_i}\"\n end\n end",
"def turn_left\n case @direction\n when \"n\"\n then \"w\"\n when \"w\"\n then \"s\"\n when \"s\"\n then \"e\"\n when \"e\"\n then \"n\"\n end\n end",
"def drive_north(direction)\n if direction == 'N'\n @new_vertical_position = take_input[3].to_i\n @new_vertical_position += 1\n @current_position = \"#{take_input[2].to_i},#{@new_vertical_position}\"\n end\n end",
"def go_left(the_maze, floor, position, steps)\r\n if can_go_left?(the_maze, floor, position)\r\n the_maze = the_maze.set(floor, the_maze[floor].set(position, \"m\"))\r\n walk_maze(the_maze, floor, position - 1, steps.push([floor, position]))\r\n else\r\n return Hamster.vector\r\n end\r\nend",
"def left\n check_placement\n\n super\n end",
"def turn_left\n\t\tif @direction == \"N\"\n\t\t\t@direction = \"W\"\n\t\telsif @direction == \"W\"\n\t\t\t@direction = \"S\"\n\t\telsif @direction == \"S\"\n\t\t\t@direction = \"E\"\n\t\telsif @direction == \"E\"\n\t\t\t@direction = \"N\"\n\t\tend\n\tend",
"def turn_left\n @shape.body.t -= 300.0\n end",
"def move\n placed?\n if @direction == \"NORTH\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?(@x, (@y+1))\n @y+=1\n elsif @direction == \"SOUTH\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?(@x, (@y-1))\n @y-=1\n elsif @direction == \"WEST\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?((@x-1), @y)\n @x-=1\n elsif @direction == \"EAST\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?((@x+1), @y)\n @x+=1\n end\n end",
"def turn_left\n index = DIRECTIONS.index(@facing)-1\n @facing = DIRECTIONS[index]\n end",
"def wind\r\n\tcoldest = 1000\r\n\tci = 0\r\n\twarmest = -1000\r\n\twi = 0\r\n\t## find the coldest and the hottest positions indexes\r\n\[email protected]_with_index do |p,index|\r\n\t if p.temperature < coldest\r\n\t coldest = p.temperature\r\n\t\tci = index\r\n\t end\r\n\t if p.temperature >= warmest\r\n\t warmest = p.temperature\r\n\t\twi = index\r\n\t end\r\n\tend\r\n\t## puts \"#{coldest} : #{ci}\"\r\n\t## puts \"#{warmest} : #{wi}\"\r\n\t\r\n\t@positions[ci].temperature += 10\r\n\t\r\n\t\r\n\t##################################\r\n\t# left_over = @positions[ci].water_bank % 9\r\n\t# amount_for_each = @positions[ci].water_bank / 9\r\n\tn = check_neighbours(ci)\r\n\tn.each_with_index do |ni,index|\r\n\t ni.temperature += 2\r\n\t # ni.water_bank += amount_for_each \r\n\t # @positions[ci].water_bank -= amount_for_each \r\n\tend\r\n\t\r\n\t@positions[wi].temperature -= 10\r\n\t# left_over = @positions[wi].water_bank % 9\r\n\t# amount_for_each = @positions[wi].water_bank / 9\r\n n = check_neighbours(wi)\r\n\tn.each_with_index do |ni,index|\r\n\t ni.temperature -= 2\r\n\t # ni.water_bank += amount_for_each \r\n\t # @positions[wi].water_bank -= amount_for_each \r\n\tend\r\n\t####################################\r\n\t\r\n\t# gets the water banks, starting from the coldest\r\n\tstart = ci\r\n\ts = []\r\n\t#from coldest position to last position\r\n\t[*start...(@width*@height)].each do |i|\r\n\t s << @positions[i].water_bank\r\n\tend\r\n\t# from 0 (or first position) to the coldest position\r\n\tif start > 0\r\n\t [*0..(start-1)].each do |i|\r\n\t s << @positions[i].water_bank\r\n\t end\r\n\tend\r\n\t\r\n\t# then starting fromt he warmest replacing the water banks with the previously collected\r\n\tstart = wi\r\n\t#from warmest position to last position\r\n\t[*start...(@width*@height)].each do |i|\r\n\t @positions[i].water_bank = s[i]\r\n\tend\r\n\t# from first position to warmest position\r\n\tif start > 0\r\n\t [*0..(start-1)].each do |i|\r\n\t @positions[i].water_bank = s[i]\r\n\t end\r\n\tend\r\n\t\r\n\tif @log == true\r\n\t @logger.write \"wind\"\r\n\tend\r\n end",
"def left(robot)\n extend Placed\n\n return robot unless placed? robot\n robot.f = Navigation::ALL[\n Navigation::ALL.index(robot.f) - 1\n ]\n robot\n end",
"def right\n check_placed\n @facing = next_facing(+1)\n end",
"def left; end",
"def left; end",
"def left; end",
"def move\n case @facing\n when \"north\"\n @posY += 1 if @posY+1 < @table.width\n when \"east\"\n @posX += 1 if @posX+1 < @table.height\n when \"south\"\n @posY -= 1 if @posY-1 >= 0\n when \"west\"\n @posX -= 1 if @posX-1 >= 0\n end\n end",
"def puzzleSwitch(w, num)\n if ( ($ypos[num] >= ($ypos['space'] - 0.01)) \\\n && ($ypos[num] <= ($ypos['space'] + 0.01)) \\\n && ($xpos[num] >= ($xpos['space'] - 0.26)) \\\n && ($xpos[num] <= ($xpos['space'] + 0.26))) \\\n || (($xpos[num] >= ($xpos['space'] - 0.01)) \\\n && ($xpos[num] <= ($xpos['space'] + 0.01)) \\\n && ($ypos[num] >= ($ypos['space'] - 0.26)) \\\n && ($ypos[num] <= ($ypos['space'] + 0.26)))\n tmp = $xpos['space']\n $xpos['space'] = $xpos[num]\n $xpos[num] = tmp\n tmp = $ypos['space']\n $ypos['space'] = $ypos[num]\n $ypos[num] = tmp\n w.place('relx'=>$xpos[num], 'rely'=>$ypos[num])\n end\nend",
"def direction_left\n DIRECTIONS[(DIRECTIONS.index(direction) - 1) % 4]\n end",
"def direction_left\n DIRECTIONS[(DIRECTIONS.index(direction) - 1) % 4]\n end",
"def piece_left\n return unless @falling_piece\n\n @falling_piece.x -= @block_size\n @falling_piece.grid_position.x -= 1\n\n piece_right if collides?\n end",
"def move_lower_left\n unless @direction_fix\n @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)\n end\n if (passable?(@x, @y, 2) && passable?(@x, @y + 1, 4)) ||\n (passable?(@x, @y, 4) && passable?(@x - 1, @y, 2)) # 8 a la place de 2 sur les deux lignes\n move_follower_to_character\n @x -= 1\n @y += 1\n if @follower && $game_variables[Yuki::Var::FM_Sel_Foll] == 0\n @memorized_move = :move_lower_left\n @follower.direction = @direction\n end\n movement_process_end(true)\n increase_steps\n end\n end",
"def interpret_left(command)\n ensure_placed\n @robot.rotate_left\n end",
"def open_up(row,col)\n return if @grid[row][col] == nil\n return if @known_empty.include? (row.to_s + col.to_s)\n numera = [1,2,3,4,5,6,7,8,9]\n if numera.include? @grid[row][col]\n @known_empty << (row.to_s + col.to_s)\n return \n end\n \n @known_empty << (row.to_s + col.to_s)\n # North\n open_up(row-1,col) if row-1 > -1\n # NE\n open_up(row - 1,col + 1) if (row > -1) && (col + 1 < 9) \n # East\n open_up(row,col+1) if (col+1 < 9)\n # SE\n open_up(row+1,col+1) if (row+1 < 9) && (col + 1 < 9) \n # South\n open_up(row + 1,col) if row + 1 < 9 \n # SW\n open_up(row + 1,col - 1) if (row + 1 < 9) && (col - 1 > -1)\n # West\n open_up(row,col - 1) if col - 1 > -1 \n # NW\n open_up(row - 1,col - 1) if (row -1 > -1) && (col - 1 > -1) \n\n return\n\n end",
"def turn_left\n @orientation = CompassPoints::LEFT_TURNS[@orientation] if placed?\n end",
"def move\n @coordinates[1] += 1 if @rover_facing == 'N'\n @coordinates[0] += 1 if @rover_facing == 'E'\n @coordinates[1] -= 1 if @rover_facing == 'S'\n @coordinates[0] -= 1 if @rover_facing == 'W'\nend",
"def calculate_location_left\n self.location_left = {}\n if location_right.key? :east\n location_left[:west] = location_right[:east]\n else\n location_left[:east] = location_right[:west]\n end\n\n if location_right.key? :north\n location_left[:south] = location_right[:north]\n else\n location_left[:north] = location_right[:south]\n end\n end",
"def move_up_left\n i = 1\n until false\n x, y = @pos\n x -= i\n y -= i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def to_s_v1\n output = \"+\" + \"---+\" * columns + \"\\n\"\n\n each_row do |row|\n top = \"|\"\n bottom = \"+\"\n\n row.each do |cell|\n cell = Cell.new(-1, -1) unless cell\n\n body = \" \" # <-- that's THREE (3) spaces!\n east_boundary = (cell.linked?(cell.east) ? \" \" : \"|\")\n top << body << east_boundary\n\n # three spaces below, too >>-------------->> >...<\n south_boundary = (cell.linked?(cell.south) ? \" \" : \"---\")\n corner = \"+\"\n bottom << south_boundary << corner\n end\n\n output << top << \"\\n\"\n output << bottom << \"\\n\"\n end\n\n output\n end",
"def left(args) \n return if !@is_robot_availabe\n #find its left elem\n @direction = DIRECTIONS[DIRECTIONS.index(@direction) - 1]\n # return \"LEFT\" #for test\n end",
"def left(degrees)\n right(-degrees)\n end",
"def oposit(direction)\n if direction == \"top\"\n return \"bottom\"\n elsif direction == \"bottom\"\n return \"top\"\n elsif direction == \"right\"\n return \"left\"\n elsif direction == \"left\"\n return \"right\"\n end\n return nil\n end",
"def left\n Point.new(@x - 1, @y)\n end",
"def left\n Point.new(@x - 1, @y)\n end",
"def turnLeft\n return WEST\n end",
"def left\n index = FACES.find_index(@face)\n if index > MIN_LEFT\n @face = FACES[index-1]\n else\n @face = FACES[3]\n end\n end",
"def move_rover()\n puts \"DEBUG: moving: #{@orientation}\" if DEBUG\n case @orientation\n when DIRECTION_EAST\n @position[:x] += 1 if @position[:x] < @map.width\n when DIRECTION_WEST\n @position[:x] -= 1 if @position[:x] > 0\n when DIRECTION_NORTH\n @position[:y] += 1 if @position[:y] < @map.height\n when DIRECTION_SOUTH\n @position[:y] -= 1 if @position[:y] > 0\n end\n puts \"DEBUG: position after move: #{@position}\" if DEBUG\n end",
"def move_east\n # Each time we move_east we move the Robot 1 space to the left\n @east += 1\n end",
"def top_left\n x_shift = 0\n y_shift = 0\n\n corner = Point.new(@offset.x + @width / 2, @offset.y + @height / 2)\n\n # move left on the map until we have the starting coordinate and offset\n while corner.x.positive?\n corner.x -= tile_width\n x_shift += 1\n end\n\n # move up on the map until we have the starting coordinate and offset\n while corner.y.positive?\n corner.y -= tile_height\n y_shift += 1\n end\n\n coordinate = Coordinate.new(@reference.row - y_shift, @reference.column - x_shift, @reference.zoom)\n\n [coordinate, corner]\n end",
"def left(degrees)\n turn(degrees)\n end",
"def left\n @x_min\n end",
"def left\n @ole.Left\n end",
"def left\n @ole.Left\n end",
"def move (x,y,direction)\n if direction ==\"EAST\"\n if validate(x+1) then return x+1,y end\n elsif direction ==\"WEST\"\n if validate(x-1) then return x-1,y end\n elsif direction ==\"NORTH\"\n if validate(y+1) then return x,y+1 end\n elsif direction ==\"SOUTH\"\n if validate(y-1) then return x,y-1 end\n end\n return x,y\n end",
"def hop!\n\t\t@direction = @dice.throw #throw dice and read direction into a variable\n\n\t\t#if the direction is illegal (due to skippy's location at a boundary), roll the dice again \n\t\t#until a legal direction is returned\n\t\twhile !movable_direction? do\n\t\t\t@direction = @dice.throw\n\t\tend\n\t\t\n\t\t#using @north, @south....etc variables defined previously, move skippy as per dice direction\n\t\tif @direction == :NORTH\n\t\t\tthen @location = @location + @north\n\t\telsif @direction == :SOUTH\n\t\t\tthen @location = @location + @south\n\t\telsif @direction == :EAST\n\t\t\tthen @location = @location + @east\n\t\telse\n\t\t\t@location = @location + @west\n\t\tend\n\t\t\t\t\t\n\tend",
"def left\n direction.move_left!\n end",
"def test_left_backward\n rover = MarsRover.new\n rover.command('LB')\n assert_equal([1,0,'W'], rover.position)\n end",
"def test_scenario3\n r = Robot.new(1, 2, 'EAST')\n r.move(table)\n r.move(table)\n r.turn_left\n r.move(table)\n assert_equal('3,3,NORTH', r.report)\n end"
] | [
"0.71620125",
"0.6751498",
"0.63663757",
"0.6259096",
"0.62498456",
"0.60428506",
"0.6041264",
"0.60330224",
"0.59826523",
"0.59790814",
"0.59680974",
"0.59331715",
"0.5905262",
"0.58589476",
"0.58507276",
"0.58234036",
"0.58156127",
"0.5779869",
"0.5773733",
"0.5767857",
"0.5743068",
"0.573984",
"0.5731756",
"0.57277197",
"0.5719715",
"0.5692729",
"0.5691469",
"0.56897306",
"0.56553215",
"0.5652475",
"0.5650593",
"0.5648632",
"0.5620783",
"0.56086355",
"0.55798405",
"0.5564138",
"0.5561534",
"0.5546597",
"0.5524105",
"0.55175257",
"0.5506676",
"0.54912174",
"0.54906005",
"0.5490404",
"0.54880327",
"0.54879284",
"0.54816455",
"0.54799646",
"0.5473452",
"0.54631805",
"0.54629266",
"0.54505706",
"0.5439696",
"0.54385644",
"0.54354745",
"0.54344803",
"0.5429334",
"0.54176444",
"0.54169387",
"0.5409291",
"0.54081154",
"0.54037577",
"0.5400376",
"0.53865314",
"0.5381884",
"0.53725874",
"0.53725874",
"0.53725874",
"0.5365047",
"0.53425133",
"0.53403956",
"0.53403956",
"0.533433",
"0.5319146",
"0.53186923",
"0.5313162",
"0.5312346",
"0.53121245",
"0.5302676",
"0.5301954",
"0.53006124",
"0.5298733",
"0.52864546",
"0.52651185",
"0.5264972",
"0.5264972",
"0.5262539",
"0.5254719",
"0.52446663",
"0.52421767",
"0.5236964",
"0.52333254",
"0.5232331",
"0.5223207",
"0.5223207",
"0.5221706",
"0.5213674",
"0.52078015",
"0.52056974",
"0.52038485"
] | 0.5653994 | 29 |
PLACE 1,2,EAST MOVE MOVE LEFT MOVE REPORT Output: 3,3,NORTH | def test_scenario3
r = Robot.new(1, 2, 'EAST')
r.move(table)
r.move(table)
r.turn_left
r.move(table)
assert_equal('3,3,NORTH', r.report)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left\n if @position != []\n if @position[2] == \"EAST\"\n @position[2] = \"NORTH\"\n elsif @position[2] == \"WEST\"\n @position[2] = \"SOUTH\"\n elsif @position[2] == \"NORTH\"\n @position[2] = \"WEST\"\n elsif @position[2] == \"SOUTH\"\n @position[2] = \"EAST\"\n end\n else\n puts \"Invalid Command!!.\\nPlease execute command (place) to place the robot on the table.\"\n end\n return @position\nend",
"def move (x,y,direction)\n if direction ==\"EAST\"\n if validate(x+1) then return x+1,y end\n elsif direction ==\"WEST\"\n if validate(x-1) then return x-1,y end\n elsif direction ==\"NORTH\"\n if validate(y+1) then return x,y+1 end\n elsif direction ==\"SOUTH\"\n if validate(y-1) then return x,y-1 end\n end\n return x,y\n end",
"def move\n\n if @position != []\n if @position[2] == \"EAST\"\n @position[0] += 1\n elsif @position[2] == \"WEST\"\n @position[0] -= 1\n elsif @position[2] == \"NORTH\"\n @position[1] += 1\n elsif @position[2] == \"SOUTH\"\n @position[1] -= 1\n end\n check_position()\n else\n puts \"Invalid Command!!.\\nPlease execute command (place) to place the robot on the table.\"\n end\n @position\nend",
"def move\n @coordinates[1] += 1 if @rover_facing == 'N'\n @coordinates[0] += 1 if @rover_facing == 'E'\n @coordinates[1] -= 1 if @rover_facing == 'S'\n @coordinates[0] -= 1 if @rover_facing == 'W'\nend",
"def move\n case @rover_facing\n when 'N'\n @coordinates[1] += 1\n when 'E'\n @coordinates[0] += 1\n when 'S'\n @coordinates[1] -= 1\n when 'W'\n @coordinates[0] -= 1\n end\n end",
"def drive_west(direction)\n if direction == 'W'\n @new_horizontal_position = take_input[2].to_i\n @new_horizontal_position -= 1\n @current_position = \"#{@new_horizontal_position},#{take_input[3].to_i}\"\n end\n end",
"def right\n if @position != []\n if @position[2] == \"EAST\"\n @position[2] = \"SOUTH\"\n elsif @position[2] == \"WEST\"\n @position[2] = \"NORTH\"\n elsif @position[2] == \"NORTH\"\n @position[2] = \"EAST\"\n elsif @position[2] == \"SOUTH\"\n @position[2] = \"WEST\"\n end\n else\n puts \"Invalid Command!!.\\nPlease execute command (place) to place the robot on the table.\"\n end\n return @position\nend",
"def move\n case @direction\n when \"NORTH\" then move_north\n when \"SOUTH\" then move_south\n when \"EAST\" then move_east\n when \"WEST\" then move_west\n end\n end",
"def move\n case @direction\n when \"N\" then @y += 1 unless @y + 1 > @plateau.y || @@rover_locations.values.include?([@x, @y + 1])\n when \"E\" then @x += 1 unless @x + 1 > @plateau.x || @@rover_locations.values.include?([@x + 1, @y])\n when \"S\" then @y -= 1 unless @y - 1 < 0 || @@rover_locations.values.include?([@x, @y -1])\n when \"W\" then @x -= 1 unless @x - 1 < 0 || @@rover_locations.values.include?([@x -1, @x])\n end\n @@rover_locations[@id.to_sym] = [@x, @y]\n end",
"def drive_north(direction)\n if direction == 'N'\n @new_vertical_position = take_input[3].to_i\n @new_vertical_position += 1\n @current_position = \"#{take_input[2].to_i},#{@new_vertical_position}\"\n end\n end",
"def move\n\t\treturn \"INVALID COMMANDS, YOU CAN NOT MAKE THE ROBOT FALL OFF THE TABLE\" unless is_valid_move?\n\t\tcase @direction\n\t\twhen \"east\"\n\t\t\t@x_coordinate += 1\n\t\twhen \"west\"\n\t\t\t@x_coordinate -= 1\n\t\twhen \"south\"\n\t\t\t@y_coordinate -= 1\n\t\twhen \"north\"\n\t\t\t@y_coordinate += 1\n\t\telse\n\t\tend\n\t\ttrue\n\tend",
"def left_or_right(move_index)\n case move_index\n when 2, 58\n castling_check_squares(3)\n when 6, 62\n castling_check_squares(2)\n end\n end",
"def right position\n # if currently facing north\n if position[2] == \"north\"\n # right will make it face east\n position[2] = \"east\"\n # if currently facing south\n elsif position[2] == \"south\"\n # right will make it face west\n position[2] = \"west\"\n # if currently facing east\n elsif position[2] == \"east\"\n # right will make it face south\n position[2] = \"south\"\n # if currently facing west\n elsif position[2] == \"west\"\n # right will make it face north\n position[2] = \"north\"\n end\n position\nend",
"def projected_move\n\t\t\t\traise NotYetPlaced if been_placed.nil?\n\n\t\t\t\t_x = x\n\t\t\t\t_y = y\n\t\t\t\tcase face\n\t\t\t\twhen 'NORTH'\n\t\t\t\t\t_y += 1\n\t\t\t\twhen 'EAST'\n\t\t\t\t\t_x += 1\t\t\t\t\t\n\t\t\t\twhen 'SOUTH'\n\t\t\t\t\t_y -= 1\n\t\t\t\twhen 'WEST'\n\t\t\t\t\t_x -= 1\t\t\t\t\t\n\t\t\t\tend\n\t\t\t\t[_x, _y]\n\t\t\tend",
"def move_left\n left_tile = C[@location.first, @location.second - 1]\n move_to(left_tile)\n end",
"def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end",
"def move\n case @toy_direction\n when \"NORTH\"\n new_place = [@toy_place[0], @toy_place[1] + 1]\n when \"EAST\"\n new_place = [@toy_place[0] + 1, @toy_place[1]]\n when \"SOUTH\"\n new_place = [@toy_place[0], @toy_place[1] - 1]\n when \"WEST\"\n new_place = [@toy_place[0] - 1, @toy_place[1]]\n end\n place_robot(new_place, @toy_direction)\n end",
"def turnLeft\n case @currentDir\n when :north\n @currentDir = :west\n when :south\n @currentDir = :east\n when :east\n @currentDir = :north\n when :west\n @currentDir = :south\n end\n end",
"def move_left\n left_tile = Couple.new(@location.first, @location.second - 1)\n move_to(left_tile)\n end",
"def move_left\n\t\tmove([-1,0])\n\tend",
"def moves\n # All pieces can stay in place\n [[0,0]]\n end",
"def drive_east(direction)\n if direction == 'E'\n @new_horizontal_position = take_input[2].to_i\n @new_horizontal_position += 1\n @current_position = \"#{@new_horizontal_position},#{take_input[3].to_i}\"\n end\n end",
"def move_rover()\n puts \"DEBUG: moving: #{@orientation}\" if DEBUG\n case @orientation\n when DIRECTION_EAST\n @position[:x] += 1 if @position[:x] < @map.width\n when DIRECTION_WEST\n @position[:x] -= 1 if @position[:x] > 0\n when DIRECTION_NORTH\n @position[:y] += 1 if @position[:y] < @map.height\n when DIRECTION_SOUTH\n @position[:y] -= 1 if @position[:y] > 0\n end\n puts \"DEBUG: position after move: #{@position}\" if DEBUG\n end",
"def movements\n @movements ||= {\n \"s\" => -> (x, y, z) { [x, y - 1, z + 1] },\n \"n\" => -> (x, y, z) { [x, y + 1, z - 1] },\n \"ne\" => -> (x, y, z) { [x + 1, y, z - 1] },\n \"se\" => -> (x, y, z) { [x + 1, y - 1, z] },\n \"nw\" => -> (x, y, z) { [x - 1, y + 1, z] },\n \"sw\" => -> (x, y, z) { [x - 1, y, z + 1] },\n }\n end",
"def next_move(bot_pos_x, bot_pos_y, princess_position)\n case\n when princess_position[0] - bot_pos_x < 0 then move = 'UP'\n when princess_position[0] - bot_pos_x > 0 then move = 'DOWN'\n when princess_position[1] - bot_pos_y < 0 then move = 'LEFT'\n when princess_position[1] - bot_pos_y > 0 then move = 'RIGHT'\n end\n move\nend",
"def forward_move\n case @facing\n when 'NORTH'\n @y += 1\n when 'SOUTH'\n @y -= 1\n when 'EAST'\n @x += 1\n when 'WEST'\n @x -= 1\n end\n self\n end",
"def place_at(x, y, direction)\n @position = [x.to_i, y.to_i]\n @front = case direction.downcase \n when \"north\" then :north\n when \"south\" then :east\n when \"east\" then :south\n when \"west\" then :west\n end\n puts \"position is: #{@position} direction is #{@front}\"\n end",
"def rotate_left\n placed?\n @direction = case @direction\n when \"NORTH\" then \"WEST\"\n when \"EAST\" then \"NORTH\"\n when \"SOUTH\" then \"EAST\"\n when \"WEST\" then \"SOUTH\"\n end\n end",
"def next_move(_n, bot_pos_x, bot_pos_y, princess_position, _grid)\n case\n when princess_position[0] - bot_pos_x < 0 then move = 'UP'\n when princess_position[0] - bot_pos_x > 0 then move = 'DOWN'\n when princess_position[1] - bot_pos_y < 0 then move = 'LEFT'\n when princess_position[1] - bot_pos_y > 0 then move = 'RIGHT'\n end\n move\n end",
"def walk\n if @headed_left\n move_left\n else\n move_right\n end\n end",
"def moves\n end",
"def nextMove(n,r,c,grid)\n # place m on grid at r,c\n actions = generate_path(grid, 'm','p')\n puts actions[0]\n grid[r][c] = '-'\n if actions[0] == 'LEFT'\n grid[r][c-1]='m'\n elsif actions[0] == 'RIGHT'\n grid[r][c+1]='m'\n elsif actions[0] == 'UP'\n grid[r-1][c]='m'\n elsif actions[0] == 'DOWN'\n grid[r+1][c]='m'\n end\n actions[0]\n end",
"def next_move\n case Direction::DIRECTIONS[direction.current]\n when Direction::DIRECTIONS[0] # NORTH\n {x: 0, y: 1}\n when Direction::DIRECTIONS[1] # EAST\n {x: 1, y: 0}\n when Direction::DIRECTIONS[2] # SOUTH\n {x: 0, y: -1}\n when Direction::DIRECTIONS[3] # WEST\n {x: -1, y: 0}\n end\n end",
"def move(forward)\n if @direction == \"N\"\n if @y + 1 < @@ymax\n @y += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"S\"\n if @y - 1 > @@ymin\n @y -= 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction ==\"E\"\n if @x + 1 < @@xmax\n @x += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"W\"\n if @x - 1 > @@xmin\n @x -= 1\n else\n puts \"Nice try sucker\"\n end\n else\n puts \"Where in the world are you?\"\n end\nend",
"def move_east\n # Each time we move_east we move the Robot 1 space to the left\n @east += 1\n end",
"def move_right\n\t\tmove([1,0])\n\tend",
"def move\n case @direction\n when \"N\"\n @coord_y += 1\n when \"S\"\n @coord_y -= 1\n when \"E\"\n @coord_x += 1\n else\n @coord_x -= 1\n end #end of case\nend",
"def moves\n sliding_moves + jumping_moves\n end",
"def move\n ##incrementing or decrementing eg. current_direction W,\n ##position_x decrementing by 1 (-=1)\n if @current_direction == \"N\"\n @position_y += 1\n puts \"#{@position_y}\"\n elsif @current_direction == \"E\"\n @position_x += 1\n elsif @current_direction == \"W\"\n @position_x -= 1\n elsif @current_direction == \"S\"\n @position_y -= 1\n end\n\n end",
"def interpret_left(command)\n ensure_placed\n @robot.rotate_left\n end",
"def go_left(the_maze, floor, position, steps)\r\n if can_go_left?(the_maze, floor, position)\r\n the_maze = the_maze.set(floor, the_maze[floor].set(position, \"m\"))\r\n walk_maze(the_maze, floor, position - 1, steps.push([floor, position]))\r\n else\r\n return Hamster.vector\r\n end\r\nend",
"def test_can_move_west\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :WEST, 5, 5)\n\n assert_equal(:WEST, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(5, 5))\n\n @robot.move\n assert_equal(4, @robot.x, \"X position should be 4 (moved 1 east)\")\n assert_equal(5, @robot.y, \"Y position should be 5 (not changed)\")\n assert_equal(:WEST, @robot.direction, \"Direction should be :WEST (not changed)\")\n assert_equal(\"M\", @robot.get_path_value(4, 5))\n end",
"def moves\n\n end",
"def move\n case @facing\n when \"north\"\n @posY += 1 if @posY+1 < @table.width\n when \"east\"\n @posX += 1 if @posX+1 < @table.height\n when \"south\"\n @posY -= 1 if @posY-1 >= 0\n when \"west\"\n @posX -= 1 if @posX-1 >= 0\n end\n end",
"def move\n case self.direction\n when 'NORTH'\n self.y += 1 unless self.y == @table.y\n when 'EAST'\n self.x += 1 unless self.x == @table.x\n when 'SOUTH'\n self.y -= 1 unless self.y == 0\n when 'WEST'\n self.x -= 1 unless self.x == 0\n end\n end",
"def move\n\t\tif @direction == \"N\"\n\t\t\t@y += 1\n\t\telsif @direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif @direction == \"E\"\n\t\t\t@x += 1\n\t\telsif @direction == \"S\"\n\t\t\t@y -= 1\n\t\tend\n\tend",
"def move_left\n # @dx = -8\n @x -= 8\n end",
"def move (direction)\n\n [email protected]_valid_move @xpos, @ypos\n\n if direction == 'north'\n @ypos += 1\n elsif direction == 'east'\n @xpos += 1\n elsif direction == 'south'\n @ypos -= 1\n elsif direction == 'west'\n @xpos -= 1\n end\n\n else\n puts \"that's not a valid move\"\n end\n\n def report\n \"My co-ordinates are #{@xpos}, #{@ypos}\"\n end\nend",
"def place args\n \n @is_robot_availabe = true\n \n @pos_x,@pos_y,@direction = args\n\n if not (0..TABLE_X).include?(@pos_x) or not (0..TABLE_Y).include?(@pos_y)\n puts \"Warning: The position of Robot at (#{@pos_x}, #{@pos_y}) is outside the table (5,5).\"\n @is_robot_availabe = false\n return\n end\n\n if not DIRECTIONS.include?(@direction)\n puts \"Warning: #{@direction} is invaid. Robot can only move towards the four directions: \\n\"\\\n \"#{DIRECTIONS.inspect}.\"\n @is_robot_availabe = false\n return\n end\n\n # return \"PLACE\" #for test\n end",
"def direction_left\n DIRECTIONS[(DIRECTIONS.index(direction) - 1) % 4]\n end",
"def direction_left\n DIRECTIONS[(DIRECTIONS.index(direction) - 1) % 4]\n end",
"def move!\n case @facing\n when Direction::NORTH\n @loc[:y] += 1 unless out_of_bounds? @loc[:x], @loc[:y] + 1\n when Direction::EAST\n @loc[:x] += 1 unless out_of_bounds? @loc[:x] + 1, @loc[:y]\n when Direction::SOUTH\n @loc[:y] -= 1 unless out_of_bounds? @loc[:x], @loc[:y] - 1\n when Direction::WEST\n @loc[:x] -= 1 unless out_of_bounds? @loc[:x] - 1, @loc[:y]\n else\n raise %q{Don't know which direction to move}\n end\n end",
"def left\n check_placed\n @facing = next_facing(-1)\n end",
"def left_directions\n {\n ToyEnums::NORTH => ToyEnums::WEST,\n ToyEnums::WEST => ToyEnums::SOUTH,\n ToyEnums::SOUTH => ToyEnums::EAST,\n ToyEnums::EAST => ToyEnums::NORTH\n }\n end",
"def move\n placed?\n if @direction == \"NORTH\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?(@x, (@y+1))\n @y+=1\n elsif @direction == \"SOUTH\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?(@x, (@y-1))\n @y-=1\n elsif @direction == \"WEST\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?((@x-1), @y)\n @x-=1\n elsif @direction == \"EAST\"\n raise \"Out of bounds\" unless @tabletop.table_boundary?((@x+1), @y)\n @x+=1\n end\n end",
"def explore\n rover_bay.each do |r|\n if pass_path_check?(r)\n move(r)\n else\n raise \"There is a collision\\nin placement #{r.coordinate.inspect}, please revise instruction set #{r.command.inspect}\"\n end\n end\n end",
"def move!\n if placed?\n case orientation.to_sym\n when :NORTH then @y += 1 if valid_coordinates?(x, y + 1)\n when :EAST then @x += 1 if valid_coordinates?(x + 1, y)\n when :SOUTH then @y -= 1 if valid_coordinates?(x, y - 1)\n when :WEST then @x -= 1 if valid_coordinates?(x - 1, y)\n end\n nil\n else\n raise RobotSimulation::NotPlacedError, \"Robot has not been placed yet.\"\n end\n end",
"def move # takes (x, y, direction) from Rover\n\t\tif direction == \"N\"\n\t\t\t@y += 1\n\t\telsif direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif direction == \"S\"\n\t\t\t@y -= 1\n\t\telsif direction == \"E\"\n\t\t\t@x += 1\n\t\telse \n\t\t\treturn \"The input direction enterned is wrong\"\n\t\tend\n\tend",
"def move\n if @direction.north? then @y += 1\n elsif @direction.south? then @y -= 1\n elsif @direction.east? then @x += 1\n elsif @direction.west? then @x -= 1\n end\n return self\n end",
"def move(args)\n return if !@is_robot_availabe\n case @direction\n when \"NORTH\"\n if @pos_y + STEP <= TABLE_Y\n @pos_y += STEP\n return\n end\n \n when \"EAST\"\n if @pos_x + STEP <= TABLE_X\n @pos_x += STEP\n return\n end\n \n when \"SOUTH\"\n if @pos_y - STEP >= 0\n @pos_y -= STEP\n return\n end\n \n when \"WEST\"\n if @pos_x - STEP >= 0\n @pos_x -= STEP\n return\n end\n \n end\n puts \"Warning: Robot cannot move towards #{@direction} anymore. \"\n # return \"MOVE\" #for test\n end",
"def move_east\n @x += 1\n end",
"def move(direction)\n action = true\n m = @pusher[:pos_m]\n n = @pusher[:pos_n]\n\n direction = direction.downcase\n\n # Following of the direction, test 2 cells\n if direction == 'u' && can_move?('u')\n m_1 = m-1\n m_2 = m-2\n n_1 = n_2 = n\n @pusher[:pos_m] -= 1\n elsif direction == 'd' && can_move?('d')\n m_1 = m+1\n m_2 = m+2\n n_1 = n_2 = n\n @pusher[:pos_m] += 1\n elsif direction == 'l' && can_move?('l')\n n_1 = n-1\n n_2 = n-2\n m_1 = m_2 = m\n @pusher[:pos_n] -= 1\n elsif direction == 'r' && can_move?('r')\n n_1 = n+1\n n_2 = n+2\n m_1 = m_2 = m\n @pusher[:pos_n] += 1\n else\n action = false\n state = NO_MOVE\n end\n\n # Move accepted\n if action\n state = NORMAL_MOVE\n\n # Test on cell (m,n)\n if read_pos(m, n) == '+'\n write_pos(m, n, '.')\n else\n write_pos(m, n, 's')\n end\n\n # Test on cell (m_2,n_2)\n if ['$', '*'].include? read_pos(m_1, n_1)\n if read_pos(m_2, n_2) == '.'\n write_pos(m_2, n_2, '*')\n else\n write_pos(m_2, n_2, '$')\n end\n\n state = BOX_MOVE\n end\n\n # Test on cell (m_1, n_1)\n if ['.', '*'].include? read_pos(m_1, n_1)\n write_pos(m_1, n_1, '+')\n else\n write_pos(m_1, n_1, '@')\n end\n end\n\n state\n end",
"def move to_move\r\n\t\tif to_move == 0\r\n\t\t\tvia_road = driver.location.west_road\r\n\t\t\tdriver.location = driver.location.west_location\r\n\t\t\treturn via_road\r\n\t\telsif to_move == 1\r\n\t\t\tvia_road = driver.location.north_road\r\n\t\t\tdriver.location = driver.location.north_location\r\n\t\t\treturn via_road\r\n\t\telsif to_move == 2\r\n\t\t\tvia_road = driver.location.east_road\r\n\t\t\tdriver.location = driver.location.east_location\r\n\t\t\treturn via_road\r\n\t\telsif to_move == 3\r\n\t\t\tvia_road = driver.location.south_road\r\n\t\t\tdriver.location = driver.location.south_location\r\n\t\t\treturn via_road\r\n\t\tend\r\n\t\t\r\n\tend",
"def moves\n diagonal_dirs\n end",
"def analyze_moves(tiles)\n horis = analyze_horis(tiles)\n vert = analyze_vert(tiles)\n if horis > vert\n puts \"1 --> #{horis}, #{vert}\"\n [:arrow_right, :left].sample\n elsif horis < vert\n puts \"2 --> #{horis}, #{vert}\"\n [:arrow_down, :arrow_up].sample\n elsif (horis == vert) && (vert != 0)\n puts \"3 --> #{horis}, #{vert}\"\n [:arrow_down, :arrow_up].sample\n else\n sample = [:arrow_left, :arrow_up, :arrow_right, :arrow_down].sample\n puts \"sample --> #{sample}\"\n sample\n end\n end",
"def moves\r\n # pos = [0,0]\r\n # row, col = pos\r\n all_h = []\r\n all_d = []\r\n HORIZONTAL_DIRS.each do |h_pos|\r\n h_row, h_col = h_pos\r\n all_h += grow_unblocked_moves_in_dir(h_row, h_col) #returns all moves in h_pos\r\n end\r\n DIAGONAL_DIRS.each do |d_pos|\r\n h_row, h_col = d_pos\r\n all_d += grow_unblocked_moves_in_dir(h_row, h_col) #returns all moves in d_pos\r\n end\r\n if self.class == Queen\r\n return all_h + all_d\r\n elsif self.class == Bishop\r\n return all_d\r\n elsif self.class == Rook\r\n return all_h\r\n end\r\n end",
"def move(direction)\n \n end",
"def legal_moves(index)\n legal_moves = []\n legal_moves << index - 1 if index % 3 != 0 #left\n legal_moves << index + 1 if index % 3 != 2 #right\n legal_moves << index + 3 if index + 3 < 9 #up\n legal_moves << index - 3 if index - 3 > -1 #down\n return legal_moves\n end",
"def moves\n forward_steps + side_attacks\n end",
"def test_can_move_north\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :TEST)\n\n assert_equal(:NORTH, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(0, 0))\n\n @robot.move\n assert_equal(0, @robot.x, \"X position should be 0 (not changed)\")\n assert_equal(1, @robot.y, \"Y position should be 1 (moved 1 north)\")\n assert_equal(:NORTH, @robot.direction, \"Direction should be :NORTH (not changed)\")\n assert_equal(\"M\", @robot.get_path_value(0, 1))\n end",
"def left(args) \n return if !@is_robot_availabe\n #find its left elem\n @direction = DIRECTIONS[DIRECTIONS.index(@direction) - 1]\n # return \"LEFT\" #for test\n end",
"def move()\n case @mov_dir\n when :right\n if @coord_x == @max_x\n @max_x += 1 # Moving out of bounds. No need to do anything because Ruby rocks! :P\n end\n @coord_x += 1\n \n when :up\n if @coord_y == 0\n @map.unshift [] # Moving out of bounds. Adds a new line to the top\n @max_y += 1\n else\n @coord_y -= 1\n end\n \n when :down\n if @coord_y == @max_y\n @max_y += 1\n @map.push [] # Moving out of bounds. Adds a new line to the bottom\n end\n @coord_y += 1\n \n when :left\n if @coord_x == 0\n @map.each do |a| # Moving out of bounds. Adds a new line to the left\n a.unshift ' ' \n end\n @max_x += 1\n else\n @coord_x -= 1\n end\n end\n end",
"def test_can_not_move_west\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :WEST, 0, 4)\n\n assert_equal(:WEST, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(0, 4))\n\n @robot.move\n assert_equal(0, @robot.x, \"X position should be 0 (not changed)\")\n assert_equal(4, @robot.y, \"Y position should be 4 (not changed)\")\n assert_equal(:WEST, @robot.direction, \"Direction should be :WEST (not changed)\")\n assert_equal(\"P\", @robot.get_path_value(0, 4))\n end",
"def move(robot_name,robot_direction)\n case robot_direction\n when \"NORTH\"\n self.robot_position[robot_name][1] +=1 if robot_position[robot_name][1] < max_height\n when \"SOUTH\"\n self.robot_position[robot_name][1] -=1 if robot_position[robot_name][1] > 0\n when \"WEST\"\n self.robot_position[robot_name][0] -=1 if robot_position[robot_name][0] > 0\n when \"EAST\"\n self.robot_position[robot_name][0] +=1 if robot_position[robot_name][0] < max_length\n else\n nil\n end\n end",
"def interpret_move(command)\n ensure_placed\n @robot.move_forward\n end",
"def move_by_one(order)\n case co_ordinates[2]\n when \"N\"\n co_ordinates[1] += order[1]\n when \"S\"\n co_ordinates[1] -= order[1]\n when \"E\"\n co_ordinates[0] += order[1]\n when \"W\"\n co_ordinates[0] -= order[1]\n end\n puts \"move_by_one: co_ordinates = #{co_ordinates}\"\n end",
"def test_scenario1 \n r = robot\n r.move(table)\n assert_equal('0,1,NORTH', r.report)\n end",
"def check_left(move)\n\t\tnxt_spc= move-1\n\t\tarray=[]\n\t\tuntil passed_left_edge?(nxt_spc) || empty_space?(nxt_spc) || cp_piece?(nxt_spc) do\n\t\t\tarray.push(nxt_spc)\n\t\t\tnxt_spc-=1\n\t\tend\n\t\tprint array\n\t\treturn array\n\tend",
"def moves(direction = :all)\n case direction\n when :all\n ([left] + [top_left] + [top] + [top_right] +\n [right] + [bottom_right] + [bottom] + [bottom_left]).delete_if(&:empty?)\n when :left then [left]\n when :top_left then [top_left]\n when :top then [top]\n when :top_right then [top_right]\n when :right then [right]\n when :bottom_right then [bottom_right]\n when :bottom then [bottom]\n when :bottom_left then [bottom_left]\n end\n end",
"def move(starting, goal)\n # your code here\n intermediate = (1..3).find { |n| n != starting && n != goal }\n \"#{starting}->#{intermediate} #{starting}->#{goal} #{intermediate}->#{goal}\"\nend",
"def moves\n forward_steps + side_attacks\n end",
"def turn_left\n case @direction\n when \"n\"\n then \"w\"\n when \"w\"\n then \"s\"\n when \"s\"\n then \"e\"\n when \"e\"\n then \"n\"\n end\n end",
"def move\n return unless placed?\n # We know place() will already ignore invalid placements, so just advance\n # the robot and let it fail silently if those positions are not on the board\n place(*next_position, direction)\n end",
"def moves; [] end",
"def test_can_move_east\n table_top = TableTop.new(5, 5)\n @robot.place(table_top, :EAST, 1, 2)\n\n assert_equal(:EAST, @robot.direction)\n assert_equal(\"P\", @robot.get_path_value(1, 2))\n\n @robot.move\n assert_equal(2, @robot.x, \"X position should be 2 (moved 1 east)\")\n assert_equal(2, @robot.y, \"Y position should be 2 (not changed)\")\n assert_equal(:EAST, @robot.direction, \"Direction should be :EAST (not changed)\")\n assert_equal(\"M\", @robot.get_path_value(2, 2))\n end",
"def calculate_route\n\t\t@cl = init_loc\n\t\t@steps << cl\n\n\t\twhile not at_rightmost_side?\n\t\t\t@cl = next_step\n\t\t\t@steps << cl\n\t\tend \t\t\n\tend",
"def move\r\n case direction\r\n when DIRECTIONS[:north]\r\n self.longitude += 1\r\n when DIRECTIONS[:south]\r\n self.longitude -= 1\r\n when DIRECTIONS[:east]\r\n self.latitude += 1\r\n when DIRECTIONS[:west]\r\n self.latitude -= 1\r\n end\r\n\r\n return [latitude, longitude]\r\n end",
"def left(robot)\n extend Placed\n\n return robot unless placed? robot\n robot.f = Navigation::ALL[\n Navigation::ALL.index(robot.f) - 1\n ]\n robot\n end",
"def move_west\n @x -= 1\n end",
"def move\n case @direction\n when \"N\"\n @y_coord += 1\n when \"S\"\n @y_coord -= 1\n when \"W\"\n @x_coord += 1\n when \"E\"\n @x_coord -= 1\n end\n end",
"def move_up_left\n i = 1\n until false\n x, y = @pos\n x -= i\n y -= i\n pos = [x, y]\n break if x > 7 || x < 0 || y > 7 || y < 0 || @board[pos].color == @color\n @moves << pos\n break if @board[pos].color != @color\n i += 1\n end\n end",
"def move(direction)\n\t\tcase direction\n\t\twhen \"North\"\n\t\t\tmove_north\n\t\twhen \"East\"\n\t\t\tmove_east\n\t\twhen \"South\"\n\t\t\tmove_south\n\t\twhen \"West\"\n\t\t\tmove_west\n\t\tend\n\tend",
"def walk\n case @direction\n when 'N'\n @y += 1\n when 'W'\n @x += 1\n when 'S'\n @y -= 1\n when 'E'\n @x -= 1\n end\n end",
"def turn_left\n\t\tif @direction == \"N\"\n\t\t\t@direction = \"W\"\n\t\telsif @direction == \"W\"\n\t\t\t@direction = \"S\"\n\t\telsif @direction == \"S\"\n\t\t\t@direction = \"E\"\n\t\telsif @direction == \"E\"\n\t\t\t@direction = \"N\"\n\t\tend\n\tend",
"def move\n\t\tif valid_move?\n\t\t\tputs \"\"\n\t\t\tif OS.mac?\n\t\t\t\tcmd = ('say \"roger-roger\"')\n\t\t\t\tsystem cmd\n\t\t\tend\n\t\t\tputs \"Roger, roger I\\'m moving forward one field!\"\n\t\t\tcase @robot_direction\n\t\t\twhen \"EAST\" then @x += 1\n\t\t\twhen \"WEST\" then @x -= 1\n\t\t\twhen \"NORTH\" then @y += 1\n\t\t\twhen \"SOUTH\" then @y -= 1\n\t\t\tend\n\t\telse\n puts \"This is the end of this world and I can't go further in this direction, please change direction\"\n\t\tend\n\tend",
"def relative_left_cell\n return left_cell if @facing == 'up'\n return up_cell if @facing == 'right'\n return right_cell if @facing == 'down'\n return down_cell if @facing == 'left'\n end",
"def move(forward)\n moves = [0, forward ? 1 : -1]\n moves.reverse! if @hor\n new_coord = @coord.add(moves + moves)\n set!(new_coord[0], new_coord[1], @hor)\n end",
"def test_left_wrap\n rover = MarsRover.new(0,0,'N', world=World.new(5,5))\n rover.command('LF')\n assert_equal([4,0,'W'], rover.position)\n end",
"def test_left_backward\n rover = MarsRover.new\n rover.command('LB')\n assert_equal([1,0,'W'], rover.position)\n end",
"def move_ears(left, right)\n message.posleft = left if left\n message.posright = right if right\n nil\n end"
] | [
"0.6981736",
"0.6721071",
"0.66007376",
"0.65701956",
"0.6481079",
"0.64718866",
"0.64606196",
"0.6455801",
"0.6443049",
"0.64305604",
"0.64285034",
"0.6404821",
"0.63822407",
"0.636183",
"0.63358563",
"0.6310428",
"0.62961847",
"0.6269694",
"0.62652886",
"0.62573844",
"0.6234744",
"0.62125874",
"0.6212434",
"0.6176565",
"0.61747307",
"0.61730397",
"0.61712563",
"0.6170661",
"0.6142133",
"0.61030215",
"0.60609925",
"0.60599023",
"0.6057661",
"0.60517734",
"0.6044917",
"0.6036903",
"0.60197645",
"0.60170716",
"0.6014431",
"0.60005146",
"0.60002005",
"0.5999418",
"0.5992117",
"0.59801275",
"0.5971998",
"0.5955028",
"0.5954889",
"0.59515864",
"0.5949814",
"0.5949147",
"0.5949147",
"0.5943846",
"0.59408873",
"0.5936638",
"0.5935718",
"0.59137154",
"0.59121835",
"0.5909971",
"0.58948714",
"0.5887285",
"0.5885793",
"0.5874578",
"0.5873445",
"0.5868951",
"0.58514136",
"0.5849411",
"0.58474976",
"0.584552",
"0.5842578",
"0.5841647",
"0.5840222",
"0.5835382",
"0.58323324",
"0.58306235",
"0.5818956",
"0.58094484",
"0.58073723",
"0.5804428",
"0.58008075",
"0.5791057",
"0.5790968",
"0.57867503",
"0.5782113",
"0.5778334",
"0.57732147",
"0.57703996",
"0.5756303",
"0.5747617",
"0.57399654",
"0.5739731",
"0.57379776",
"0.5735699",
"0.5732891",
"0.573024",
"0.5722914",
"0.57225645",
"0.5718497",
"0.5716012",
"0.5711981",
"0.5707689"
] | 0.634947 | 14 |
GET /movers GET /movers.json | def index
@movers = Mover.all
render json: @movers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @vers = Ver.all\n end",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def index\n @verbs = Verb.all\n\n render json: @verbs\n end",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def show\n @jm_verse = JmVerse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jm_verse }\n end\n end",
"def index\n @vdms = Vdm.all\n\n render json: @vdms\n end",
"def index\n #@verses = Verse.all\n @verses = Verse.paginate(page: params[:page]) \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @verses }\n end\n end",
"def index\n @mirrors = Mirror.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mirrors }\n end\n end",
"def index\n @admin_versions = Admin::Version.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_versions }\n end\n end",
"def index\n @servers = Server.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers }\n end\n end",
"def show\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbo }\n end\n end",
"def index\n @game_servers = Game::Server.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @game_servers }\n end\n end",
"def index\n @releases = @environment.releases.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases }\n end\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def index\n @moments = Moment.page(params[:page])\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend",
"def index\n response = VersionResponse.new( BUILD_VERSION )\n render json: response, :status => 200\n end",
"def index\n @vdm_changes = VdmChange.all\n\n render json: @vdm_changes\n end",
"def index\n @serves = Serve.all\n end",
"def index\n @client_releases = ClientRelease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @client_releases }\n end\n end",
"def fetch_versions\n http_get(\"#{host}/#{Configuration.versions_file}\").body\n end",
"def servers\n response = get \"server\"\n data = JSON.parse response.body\n data[\"servers\"][\"server\"]\n end",
"def servers\n response = get \"server\"\n data = JSON.parse response.body\n data[\"servers\"][\"server\"]\n end",
"def index\n @file_versions = FileVersion.all\n\n render json: @file_versions\n end",
"def index\n @servings = Serving.all\n end",
"def show\n @revision = Revision.find(params[:id])\n\n render json: @revision\n end",
"def index\n @matches = Match.all\n @recent = Match.recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @matches }\n end\n end",
"def index\n @videos = Video.all\n render json: @videos\n end",
"def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def index\n @api_versions = ApiVersion.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end",
"def index\n @verbindungs = Verbindung.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @verbindungs }\n end\n end",
"def show\n render json: @verb\n end",
"def index\n @servers = getmydata(\"Server\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers }\n end\n end",
"def index\n @majors = majors\n respond_to do |format|\n format.json{\n return render json: ret\n }\n end\n end",
"def index\n @api_versions = ApiVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end",
"def get_all_actors_for_movie(movie)\n url = \"http://movies.api.mks.io/actors\"\n response = RestClient.get(url, accept: 'application/json')\n\nend",
"def index\n @api_v1_mentorings = Api::V1::Mentoring.all\n end",
"def index\n @torrents = Torrents.new(:url => \"http://newt.local:9091/transmission/rpc\").load\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @torrents }\n end\n end",
"def get_all_movies_for_actor(actor)\n url = \"http://movies.api.mks.io/movies\"\n response = RestClient.get(url, accept: 'application/json')\n\nend",
"def show\n # base url of the remote data\n # append the 'id' to this to generate the remote url\n baseUrl = 'https://api.gojimo.net/api/v4/'\n\n # request the meta data from the remote server and\n # extract the time its data was last updated\n meta = open(\"#{baseUrl}#{params[:id]}\").meta\n update_at = meta[\"last-modified\"].to_date\n\n # request new data when the local data timestamp pre dates the remote data\n requires_refresh = params[:update_at].blank? || update_at > params[:update_at].to_date\n\n # request the remote data if it is newer than the local copy\n data = open(\"#{baseUrl}#{params[:id]}\").read if requires_refresh\n # parse any data since we are going to add the data to an object which is then converted to json\n data = JSON.parse(data) unless data.blank?\n\n # return any data together with timestamps and a flag to show whetjer new data was retrieved\n render json: {new_data: requires_refresh, data: data, update_at: update_at.strftime('%a %d %b %Y'), check_at: Time.now.strftime('%H:%M %a %d %b %Y')}\n\n end",
"def index\n @mrvs = Mrv.all\n end",
"def index\n @cmms = Cmm.all\n render json: @cmms\n end",
"def index\n @servers = Server.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers.to_json(:include => { :websites => {:include => :plugins } }) }\n end\n end",
"def show\n @monit = Monit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monit }\n end\n end",
"def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend",
"def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end",
"def list\n movies = Movie.order(release_date: :desc)\n render :json => movies.to_json\n\tend",
"def index\n respond_with releases\n end",
"def index\n @poms = Pom.all\n\n respond_to do |format|\n # just poms\n format.json { render json: @poms, :except => [:created_at, :updated_at]}\n end\n end",
"def index\n render json: @links\n end",
"def upgrade\n respond_to do |wants|\n wants.json {\n ver = params[:ver]\n soft = SoftVersion.find_new_version_by_ver(ver)\n hash = {}\n if soft and soft.is_a?SoftVersion\n hash[:newversion] = true\n hash[:url] = \"http://#{request.host_with_port}/welcome/download?soft=#{soft.soft_name}&version=#{soft.version}\"\n else\n hash[\"newversion\"] = false\n hash[\"url\"] = \"No new version\"\n end\n render :json => hash.to_json, :layout => false\n }\n end\n\n end",
"def index\n @nvs_mig_statuses = NvsMigStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nvs_mig_statuses }\n end\n end",
"def index\n @routes = Route.where(:verified => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @routes }\n end\n end",
"def get_monster_info\n monster_string = RestClient.get('http://www.dnd5eapi.co/api/monsters/')\n monster_hash = JSON.parse(monster_string)\n monster_info = monster_hash[\"results\"]\n monster_info\nend",
"def show\n @mote = Mote.find(params[:id])\n @mote.ports.sort! { |a,b| a.portNumber <=> b.portNumber }\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mote }\n end\n end",
"def index\n Rails.logger.info('👻 Disraptor: Showing available routes.')\n\n routes = Disraptor::Route.find_all()\n\n render json: { 'disraptor/routes': routes }\n end",
"def index\n @heroes = Hero.all\n\n render json: @heroes\n end",
"def index\n @machines = Machine.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @machines }\n end\n end",
"def index\n @lights = Light.all\n\n render json: @lights\n end",
"def index\n @versions = Version.all\n end",
"def info\n result = []\n Server.all.each do |server|\n result << server.short_result\n end\n\n status_key = makeStatusKey(result)\n render :json => {servers:result}.merge(status_key)\n\n end",
"def index\n @memos = @book.memos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @memos }\n end\n end",
"def recent_matches\n @matches = Match.where(status: nil);\n render json: { matches: @matches }, status: :ok\n end",
"def show\n @moretinymobtrail = Moretinymobtrail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moretinymobtrail }\n end\n end",
"def index\n @builds = Build.all\n render json: @builds\n end",
"def index\n @api_v1_menus = Menu.all\n render json: @api_v1_menus\n end",
"def show\n @serv = Serv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @serv }\n end\n end",
"def index\r\n @locations = Location.all\r\n @mv = MapsVersion.first\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end",
"def movies\n get('Movies')\n end",
"def index\r\n @machines = Machine.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @machines }\r\n end\r\n end",
"def list\n get('/')\n end",
"def show\n render json: @vdm\n end",
"def index\n @mercado_meta = MercadoMetum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mercado_meta }\n end\n end",
"def new\n @jm_verse = JmVerse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jm_verse }\n end\n end",
"def index\n @verbs = Verb.active.to_a \n @lines = @lines.where(:verb_id => params[:verb_id]) unless params[:verb_id].nil? \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lines }\n end\n end",
"def index\n @carbon_monoxides = CarbonMonoxide.all\n render json: @carbon_monoxides\n end",
"def get_versions\r\n versions_nodes = BankNodestructure.version_gather(params[:subject], params[:grade])\r\n render json: versions_nodes.to_json\r\n end",
"def index\n @mugshots = Mugshot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mugshots }\n end\n end",
"def index\n @page = Page.find(params[:page_id])\n @revisions = @page.revisions\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @revisions }\n end\n end",
"def get_from_mashable\n route = 'http://mashable.com/stories.json'\n raw_response = RestClient.get route\n response = JSON.load raw_response\n response[\"hot\"].map do |story|\n story_hash = {\n title: story[\"title\"],\n score: story[\"shares\"][\"total\"],\n category: story[\"channel\"],\n author: story[\"author\"]\n }\n end\nend",
"def index\n @harvests = Harvest.all\n @upcoming_harvests = Harvest.upcoming\n @past_harvests = Harvest.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @harvests }\n end\n end",
"def index\n @mock_servers = MockServer.all\n end",
"def index\n\t\tvendas = Venda.all\n\t\trender json: vendas, status: :ok\n\tend",
"def index\n @zabbix_servers = ZabbixServer.all\n\n respond_to do |format|\n format.json\n format.html\n end\n end",
"def index \n misses = Miss.all.order(created_at: :desc)\n render json: misses \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 @monel = Monel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monel }\n end\n end",
"def index\n @players = Player.all\n render json: @players, status: 200\n end",
"def show\n render json: @mover\n end",
"def index\n @vampires = Vampire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vampires }\n end\n end",
"def index\n @mobs_nanos = MobsNano.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @mobs_nanos.to_xml }\n end\n end",
"def show\n @admin_version = Admin::Version.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_version }\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 get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend",
"def index\n player = Player.all\n render json: players, status: 200\n end",
"def live\r\n channels = Channel.live\r\n render json: channels\r\n end"
] | [
"0.6280001",
"0.62173295",
"0.620463",
"0.61603177",
"0.59509516",
"0.5942563",
"0.5891583",
"0.5883662",
"0.58809155",
"0.5865459",
"0.5785898",
"0.57800215",
"0.5767855",
"0.57437533",
"0.5723428",
"0.57047355",
"0.57047355",
"0.57047355",
"0.5694611",
"0.5693582",
"0.5681222",
"0.5652389",
"0.56504935",
"0.564227",
"0.5620122",
"0.5620122",
"0.56120485",
"0.5606261",
"0.56049",
"0.558093",
"0.55760914",
"0.55732363",
"0.5570869",
"0.55655456",
"0.5565234",
"0.55557114",
"0.55547464",
"0.555147",
"0.55503404",
"0.55420095",
"0.55412364",
"0.5537022",
"0.552808",
"0.5527626",
"0.5524318",
"0.551919",
"0.5506379",
"0.5505778",
"0.5496107",
"0.5490486",
"0.5484775",
"0.54787517",
"0.5476136",
"0.5466727",
"0.54526174",
"0.54476845",
"0.5447023",
"0.54280615",
"0.54259276",
"0.541842",
"0.5414232",
"0.54108286",
"0.5406662",
"0.5397593",
"0.53953433",
"0.5392053",
"0.5391862",
"0.5388687",
"0.5387139",
"0.53863513",
"0.53862566",
"0.53849393",
"0.5384287",
"0.5375027",
"0.53741175",
"0.5373184",
"0.53688",
"0.5363795",
"0.5359531",
"0.5356866",
"0.5356002",
"0.5354631",
"0.53525215",
"0.5351785",
"0.53455055",
"0.53417975",
"0.53382343",
"0.53286535",
"0.5326773",
"0.53244424",
"0.5320607",
"0.5318149",
"0.53110665",
"0.5304092",
"0.5299396",
"0.5299263",
"0.5299263",
"0.5297717",
"0.52951616",
"0.5292745"
] | 0.69801074 | 0 |
GET /movers/1 GET /movers/1.json | def show
render json: @mover
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @movers = Mover.all\n\n render json: @movers\n end",
"def show\n @jm_verse = JmVerse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jm_verse }\n end\n end",
"def show\n @monit = Monit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monit }\n end\n end",
"def show\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbo }\n end\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def show\n @revision = Revision.find(params[:id])\n\n render json: @revision\n end",
"def index\n @verbs = Verb.all\n\n render json: @verbs\n end",
"def new\n @jm_verse = JmVerse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jm_verse }\n end\n end",
"def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def index\n @vers = Ver.all\n end",
"def show\n @moretinymobtrail = Moretinymobtrail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moretinymobtrail }\n end\n end",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def show\n @monel = Monel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monel }\n end\n end",
"def index\n @moments = Moment.page(params[:page])\n end",
"def index\n @vdms = Vdm.all\n\n render json: @vdms\n end",
"def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def show\n @version = Version.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @version }\n end\n end",
"def show\n # base url of the remote data\n # append the 'id' to this to generate the remote url\n baseUrl = 'https://api.gojimo.net/api/v4/'\n\n # request the meta data from the remote server and\n # extract the time its data was last updated\n meta = open(\"#{baseUrl}#{params[:id]}\").meta\n update_at = meta[\"last-modified\"].to_date\n\n # request new data when the local data timestamp pre dates the remote data\n requires_refresh = params[:update_at].blank? || update_at > params[:update_at].to_date\n\n # request the remote data if it is newer than the local copy\n data = open(\"#{baseUrl}#{params[:id]}\").read if requires_refresh\n # parse any data since we are going to add the data to an object which is then converted to json\n data = JSON.parse(data) unless data.blank?\n\n # return any data together with timestamps and a flag to show whetjer new data was retrieved\n render json: {new_data: requires_refresh, data: data, update_at: update_at.strftime('%a %d %b %Y'), check_at: Time.now.strftime('%H:%M %a %d %b %Y')}\n\n end",
"def show\n @mouvement_recurrent = MouvementRecurrent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mouvement_recurrent }\n end\n end",
"def show\n @admin_version = Admin::Version.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_version }\n end\n end",
"def index\n @majors = majors\n respond_to do |format|\n format.json{\n return render json: ret\n }\n end\n end",
"def index\n response = VersionResponse.new( BUILD_VERSION )\n render json: response, :status => 200\n end",
"def show\n @monnaie = Monnaie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monnaie }\n end\n end",
"def index\n #@verses = Verse.all\n @verses = Verse.paginate(page: params[:page]) \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @verses }\n end\n end",
"def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end",
"def index\n @admin_versions = Admin::Version.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_versions }\n end\n end",
"def show\n @metum = Metum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metum }\n end\n end",
"def show\n @momsg = Momsg.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @momsg }\n end\n end",
"def show\n @mill = Mill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mill }\n end\n end",
"def show\n @vano = Vano.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vano }\n end\n end",
"def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend",
"def show\n @mercado_metum = MercadoMetum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mercado_metum }\n end\n end",
"def index\n @mercado_meta = MercadoMetum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mercado_meta }\n end\n end",
"def show\n render json: @verb\n end",
"def get\n\t\t\t result = Status.find_by(windmillid: params[:windmillid]) \n \t\t\trender json: [result.as_json(only: [:status,:power,:gen,:frequency,:rotor,:wind,:pitch])]\n\tend",
"def new\n @monit = Monit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monit }\n end\n end",
"def index\n @cmms = Cmm.all\n render json: @cmms\n end",
"def get_modelos\n marca = Marca.find(params[:marca_id])\n @modelos = Modelo.of_marca(marca.id)\n\n render json: @modelos\n\n end",
"def show\n @verbindung = Verbindung.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbindung }\n end\n end",
"def index\n @api_v1_mentorings = Api::V1::Mentoring.all\n end",
"def show\n @nvs_mig_status = NvsMigStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nvs_mig_status }\n end\n end",
"def show\n @vet = Vet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vet }\n end\n end",
"def index\n @mirrors = Mirror.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mirrors }\n end\n end",
"def show\n @moresmalltrial = Moresmalltrial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmalltrial }\n end\n end",
"def new\n @verbo = Verbo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verbo }\n end\n end",
"def show\n @v1_message = V1::Message.find(params[:id])\n\n render json: @v1_message\n end",
"def show\n @mi = Mi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mi }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def index\n @verbindungs = Verbindung.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @verbindungs }\n end\n end",
"def show\n @serv = Serv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @serv }\n end\n end",
"def show\n @moment = Moment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moment }\n end\n end",
"def index\n @poms = Pom.all\n\n respond_to do |format|\n # just poms\n format.json { render json: @poms, :except => [:created_at, :updated_at]}\n end\n end",
"def show\n render json: @vdm\n end",
"def new\n @serving = Serving.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serving }\n end\n end",
"def show\n @voc = Voc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voc }\n end\n end",
"def show\n @motivobaja = MotivoBaja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @motivobaja }\n end\n end",
"def show\n @po = Po.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @po }\n end\n end",
"def index\n @file_versions = FileVersion.all\n\n render json: @file_versions\n end",
"def show\n @mib = Mib.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mib }\n end\n end",
"def new\n @admin_version = Admin::Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_version }\n end\n end",
"def index\n @carbon_monoxides = CarbonMonoxide.all\n render json: @carbon_monoxides\n end",
"def index\n @api_versions = ApiVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end",
"def show\n @v1_order = V1::Order.find(params[:id])\n\n if @v1_order.nil?\n render json: @v1_order, message: 'Resource not found', status: 404\n else\n render json: @v1_order, message: 'OK', status: 200\n end\n end",
"def index\n @mugshots = Mugshot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mugshots }\n end\n end",
"def show\n @micorpost = Micorpost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @micorpost }\n end\n end",
"def show\n @mosttinymobtrail = Mosttinymobtrail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mosttinymobtrail }\n end\n end",
"def show\n @vocalium = Vocalium.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @vocalium }\n end\n end",
"def index\n @api_v1_todos = Todo.all\n render json: @api_v1_todos\n end",
"def show\n @mattress = Mattress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mattress }\n end\n end",
"def index\n @vdm_changes = VdmChange.all\n\n render json: @vdm_changes\n end",
"def show\n @missionmaker = Missionmaker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @missionmaker }\n end\n end",
"def index\n @vampires = Vampire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vampires }\n end\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def index\n @moons = Moon.all\n end",
"def index\n @api_v1_menus = Menu.all\n render json: @api_v1_menus\n end",
"def index\n @memos = @book.memos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @memos }\n end\n end",
"def show\n @pinglun = Pinglun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pinglun }\n end\n end",
"def index\n @testmonials = Testmonial.all\n\n render json: @testmonials\n end",
"def show\n @mision = Mision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mision }\n end\n end",
"def show\n @server1 = Server1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @server1 }\n end\n end",
"def index\r\n @locations = Location.all\r\n @mv = MapsVersion.first\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end",
"def show\n @motion = Motion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @motion }\n end\n end",
"def index\n @nvs_mig_statuses = NvsMigStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nvs_mig_statuses }\n end\n end",
"def show\n @api_version = ApiVersion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_version }\n end\n end",
"def show\n @mote = Mote.find(params[:id])\n @mote.ports.sort! { |a,b| a.portNumber <=> b.portNumber }\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mote }\n end\n end",
"def get_all_actors_for_movie(movie)\n url = \"http://movies.api.mks.io/actors\"\n response = RestClient.get(url, accept: 'application/json')\n\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 render json: Server.where(name: params[:name]).first\n end",
"def get_monster_info\n monster_string = RestClient.get('http://www.dnd5eapi.co/api/monsters/')\n monster_hash = JSON.parse(monster_string)\n monster_info = monster_hash[\"results\"]\n monster_info\nend",
"def show\n @mission = Mission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mission }\n end\n end",
"def show\n @rpm = Rpm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rpm }\n end\n end",
"def show\n @mencion = Mencion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mencion }\n end\n end",
"def index\n @mohrs = Mohr.all\n end",
"def new\n @version = Version.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @version }\n end\n end",
"def show\n @volume_metadatum = VolumeMetadatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volume_metadatum }\n end\n end",
"def new\n @vocalium = Vocalium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @vocalium }\n end\n end"
] | [
"0.6883134",
"0.6593592",
"0.62272745",
"0.6108805",
"0.61077464",
"0.61077464",
"0.61077464",
"0.6051739",
"0.60380703",
"0.6022514",
"0.5998722",
"0.599316",
"0.5991184",
"0.5976257",
"0.5953912",
"0.59391624",
"0.59266895",
"0.59152865",
"0.5910201",
"0.58913296",
"0.58911455",
"0.5875616",
"0.585557",
"0.5847111",
"0.5842113",
"0.5839937",
"0.58325446",
"0.5828167",
"0.5826698",
"0.5822252",
"0.58159536",
"0.5811119",
"0.5810167",
"0.5799828",
"0.5798129",
"0.5790811",
"0.5778045",
"0.57765347",
"0.5774719",
"0.5763625",
"0.5759338",
"0.57526654",
"0.5752256",
"0.57520205",
"0.5740665",
"0.57403415",
"0.5738526",
"0.57329464",
"0.5728472",
"0.5721798",
"0.57170683",
"0.57170683",
"0.57170683",
"0.57110894",
"0.57029784",
"0.5698366",
"0.5695584",
"0.5686588",
"0.56712586",
"0.56541187",
"0.56515104",
"0.5648246",
"0.56467825",
"0.5643546",
"0.5638074",
"0.563154",
"0.5626847",
"0.56192553",
"0.56143063",
"0.56132543",
"0.5612202",
"0.56113225",
"0.5610592",
"0.56059957",
"0.56034195",
"0.56033826",
"0.5600365",
"0.5596269",
"0.55961704",
"0.5595057",
"0.55943394",
"0.559343",
"0.5592863",
"0.55744326",
"0.55741125",
"0.5570664",
"0.5563553",
"0.5562032",
"0.55572975",
"0.55541575",
"0.555399",
"0.55511665",
"0.5545681",
"0.5543602",
"0.55404586",
"0.55390227",
"0.55324847",
"0.5525276",
"0.5524858",
"0.5522106",
"0.55192745"
] | 0.0 | -1 |
POST /movers POST /movers.json | def create
@mover = Mover.new(mover_params)
if @mover.save
render json: @mover, status: :created, location: @mover
else
render json: @mover.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def create\n @verb = Verb.new(verb_params)\n\n if @verb.save\n render json: @verb, status: :created, location: @verb\n else\n render json: @verb.errors, status: :unprocessable_entity\n end\n end",
"def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend",
"def create\n @mrv = Mrv.new(mrv_params)\n\n respond_to do |format|\n if @mrv.save\n format.html { redirect_to @mrv, notice: 'Mrv was successfully created.' }\n format.json { render :show, status: :created, location: @mrv }\n else\n format.html { render :new }\n format.json { render json: @mrv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jm_verse = JmVerse.new(params[:jm_verse])\n\n respond_to do |format|\n if @jm_verse.save\n format.html { redirect_to @jm_verse, notice: 'Jm verse was successfully created.' }\n format.json { render json: @jm_verse, status: :created, location: @jm_verse }\n else\n format.html { render action: \"new\" }\n format.json { render json: @jm_verse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ver = Ver.new(ver_params)\n\n respond_to do |format|\n if @ver.save\n format.html { redirect_to @ver, notice: 'Ver was successfully created.' }\n format.json { render :show, status: :created, location: @ver }\n else\n format.html { render :new }\n format.json { render json: @ver.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @movers = Mover.all\n\n render json: @movers\n end",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def create\n @verse = Verse.new(params[:verse])\n\n respond_to do |format|\n if @verse.save\n format.html { redirect_to @verse, notice: 'Verse was successfully created.' }\n format.json { render json: @verse, status: :created, location: @verse }\n else\n format.html { render action: \"new\" }\n format.json { render json: @verse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @verse = Verse.new(params[:verse])\n\n respond_to do |format|\n if @verse.save\n format.html { redirect_to @verse, notice: 'Verse was successfully created.' }\n format.json { render json: @verse, status: :created, location: @verse }\n else\n format.html { render action: \"new\" }\n format.json { render json: @verse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @verbo = Verbo.new(params[:verbo])\n\n respond_to do |format|\n if @verbo.save\n format.html { redirect_to @verbo, notice: 'Verbo was successfully created.' }\n format.json { render json: @verbo, status: :created, location: @verbo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @verbo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @verma = Verma.new(verma_params)\n\n respond_to do |format|\n if @verma.save\n format.html { redirect_to @verma, notice: 'Verma was successfully created.' }\n format.json { render :show, status: :created, location: @verma }\n else\n format.html { render :new }\n format.json { render json: @verma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mot_m = MotM.new(mot_m_params)\n\n respond_to do |format|\n if @mot_m.save\n format.html { redirect_to matches_path, notice: 'Your vote was successfully cast.' }\n format.json { render action: 'show', status: :created, location: @mot_m }\n else\n format.html { render action: 'new' }\n format.json { render json: @mot_m.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @server = Server.find(params[:server_id])\n @vm = @server.vms.build(vm_params)\n respond_to do |format|\n if @vm.save\n format.html { redirect_to @vm, notice: 'Vm was successfully created.' }\n format.json { render :show, status: :created, location: @vm }\n else\n format.html { render :new }\n format.json { render json: @vm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save\n return if @vserver_hash.nil?\n put_rest \"vservers/#{@name}\", @vserver_hash.to_json, :content_type => \"application/json\"\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n @revision = Revision.new(params[:revision])\n\n if @revision.save\n render json: @revision, status: :created, location: @revision\n else\n render json: @revision.errors, status: :unprocessable_entity\n end\n end",
"def create\n @micorpost = Micorpost.new(params[:micorpost])\n\n respond_to do |format|\n if @micorpost.save\n format.html { redirect_to @micorpost, notice: 'Micorpost was successfully created.' }\n format.json { render json: @micorpost, status: :created, location: @micorpost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @micorpost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def POST; end",
"def create\n megam_rest.post_appdefn(to_hash)\n end",
"def create_ping\n post 'ping'\n end",
"def create\n # Read the Matches from the JSON Object\n data = params[:matches]\n matches = data.to_a\n\n MatchCreatorJob.perform_later(matches: matches)\n\n render json: {}, status: :ok\n\n end",
"def create\n @serving = Serving.new(params[:serving])\n\n respond_to do |format|\n if @serving.save\n format.html { redirect_to @serving, notice: 'Serving was successfully created.' }\n format.json { render json: @serving, status: :created, location: @serving }\n else\n format.html { render action: \"new\" }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mock_server = MockServer.new(mock_server_params)\n\n respond_to do |format|\n if @mock_server.save\n format.json { render :show, status: :created, location: @mock_server }\n else\n format.json { render json: @mock_server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mote = Mote.new(params[:mote])\n\n respond_to do |format|\n if @mote.save\n format.html { redirect_to @mote, notice: 'Mote was successfully created.' }\n format.json { render json: @mote, status: :created, location: @mote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_aos_version_box(args = {}) \n post(\"/aosversions.json/aosversionbox\", args)\nend",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end",
"def index\n @verbs = Verb.all\n\n render json: @verbs\n end",
"def makes\n make_request :get, '/makes'\n end",
"def create\n megam_rest.post_event(to_hash)\n end",
"def create\n megam_rest.post_appreq(to_hash)\n end",
"def moip_post\n @nasp_rail = NaspRail.new(params[:nasp_rail])\n\n format.html { redirect_to @nasp_rail, :notice => 'Nova entrada criada com sucesso.' }\n format.json { render :json => @nasp_rail, :status => :created, :location => @nasp_rail }\n end",
"def post; end",
"def reply(data)\n res.json(Satz.serializer.dump(data))\n end",
"def create_post(params)\n mock_request = Rack::MockRequest.new(APP)\n mock_request.post(new_post_endpoint, { 'router.params' => params, format: :json })\n end",
"def new\n @jm_verse = JmVerse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jm_verse }\n end\n end",
"def create\n @moretinymobtrail = Moretinymobtrail.new(params[:moretinymobtrail])\n\n respond_to do |format|\n if @moretinymobtrail.save\n format.html { redirect_to @moretinymobtrail, notice: 'Moretinymobtrail was successfully created.' }\n format.json { render json: @moretinymobtrail, status: :created, location: @moretinymobtrail }\n else\n format.html { render action: \"new\" }\n format.json { render json: @moretinymobtrail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n model = params[:model]\n #NOTE: Pay attention how the data is passed as a hash. This is how locomotive expects it. Not obvious.\n # req.set_form_data('content_entry[name]' => data['name'], 'content_entry[summary]' => data['summary'], 'model' => model)\n form_data = {}\n params[:content_entry].each do |key,val|\n form_data[\"content_entry[#{key}]\"] = val\n end\n #data = params[:content_entry]\n\n uri = URI(\"#{@cms_url}/locomotive/api/content_types/#{model}/entries.json?auth_token=#{APP_CONFIG['locomotive']['auth_token']}\")\n\n req = Net::HTTP::Post.new(uri)\n req.set_form_data(form_data)\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(req)\n end\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n render :json => res.body\n else\n # examine response code and generate appropriate error message\n render :json => res.value\n end\n\n end",
"def medieval_composers\n response = RestClient.get 'https://api.openopus.org/composer/list/epoch/Medieval.json'\n json = JSON.parse response\n puts json\n\n if !json.nil?\n json[\"composers\"].map do |composer|\n Composer.create(name: \"#{composer[\"complete_name\"]}\", birth: \"#{composer[\"birth\"]}\", death: \"#{composer[\"death\"]}\", portrait: \"#{composer[\"portrait\"]}\", period_id: 1)\n end\n else\n puts \"Error seeding composers\"\n end\nend",
"def new\n @serving = Serving.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serving }\n end\n end",
"def create\n @verdict = Verdict.new(verdict_params)\n\n respond_to do |format|\n if @verdict.save\n format.html { redirect_to admin_verdicts_path(v: @verdict.slug), notice: t('shared.msgs.success_created',\n obj: t('activerecord.models.verdict', count: 1)) }\n else\n set_date\n format.html { render :new }\n end\n end\n end",
"def create\n @serving = Serving.new(serving_params)\n\n respond_to do |format|\n if @serving.save\n format.html { redirect_to @serving, notice: 'Serving was successfully created.' }\n format.json { render :show, status: :created, location: @serving }\n else\n format.html { render :new }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @motoristum = Motoristum.new(motoristum_params)\n\n respond_to do |format|\n if @motoristum.save\n format.html { redirect_to @motoristum, notice: 'Motoristum was successfully created.' }\n format.json { render :show, status: :created, location: @motoristum }\n else\n format.html { render :new }\n format.json { render json: @motoristum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_route(route, message)\n raise TypeError unless route.is_a? Route\n @changeset = @api.create_changeset(message, tags={'created_by'=>'ITCR'})\n ways_list = []\n nodes_list = create_node_list(route.path)\n\n until nodes_list.empty? # For node's maximum limit of a way\n way_nodes = nodes_list.take(MAX_NODES)\n nodes_list = nodes_list.drop(MAX_NODES)\n way_id = create_way(way_nodes)\n ways_list << way_id\n end\n\n relation = create_relation(ways_list) # Link ways to relation\n relation = add_stops(relation, route.stops) # Add bus stops to relation\n\n @api.save(relation, @changeset) # Save relation using the API\n puts 'Relation created succesfuly.'\n @api.close_changeset(@changeset)\n @changeset.id\n end",
"def post\n resource.post(request, response)\n end",
"def post\n if phase.has_key?('post')\n execute(\"post\", phase['post'])\n end\n end",
"def post(path, **args); end",
"def create\n @verb = Verb.new(:infinitive => verb_params[:infinitive], :translation => verb_params[:translation], :group => verb_params[:group])\n if @verb.save\n @tenses.each_with_index do |tense, index|\n @forms.each_with_index do |form, index2|\n if(verb_params[tense][form].strip != '')\n @form = Form.new(:content => verb_params[tense][form], :temp => index.to_i, :person => index2.to_i,:verb => @verb)\n @form.save\n end\n end\n end\n end\n\n respond_to do |format|\n if @verb.save\n format.html { redirect_to @verb, notice: 'Verb was successfully created.' }\n format.json { render action: 'show', status: :created, location: @verb }\n else\n format.html { render action: 'new' }\n format.json { render json: @verb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @server = Server.new(server_params)\n @neo = Neography::Rest.new\n\n respond_to do |format|\n if @server.save && n = Neography::Node.create(\"name\" => server_params[:name])\n n.add_to_index('servers', 'name', server_params[:name])\n n.id = n.neo_id # this construct should be improved..\n format.html { redirect_to @server, notice: 'Server was successfully created.' }\n format.json { render :show, status: :created, location: @server }\n else\n format.html { render :new }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mircopost = Mircopost.new(mircopost_params)\n\n respond_to do |format|\n if @mircopost.save\n format.html { redirect_to @mircopost, notice: 'Mircopost was successfully created.' }\n format.json { render :show, status: :created, location: @mircopost }\n else\n format.html { render :new }\n format.json { render json: @mircopost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @monit = Monit.new(params[:monit])\n\n respond_to do |format|\n if @monit.save\n format.html { redirect_to @monit, notice: 'Monit was successfully created.' }\n format.json { render json: @monit, status: :created, location: @monit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @monit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @midsurvey = Midsurvey.new(midsurvey_params)\n\n respond_to do |format|\n if @midsurvey.save\n format.html { redirect_to final_path, notice: 'Midsurvey was successfully created.' }\n format.json { render :show, status: :created, location: @midsurvey }\n else\n format.html { render :new }\n format.json { render json: @midsurvey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_create_link_via_API_JSON\r\n get \"/logout\"\r\n post \"/links.json\", :api_key => 'testapikey',\r\n :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response :created\r\n link = JSON.parse(response.body)\r\n check_new_link(link) \r\n end",
"def post()\n # construct arguments to fetch\n args = {\n method: 'post',\n credentials: 'include',\n headers: {'Content-Type' => 'application/json'},\n body: {\n project: @ppmc.id,\n ids: @ppmc.mentors.join(','),\n action: 'add',\n targets: ['ldap', 'ppmc', 'committer']\n }.inspect\n }\n\n @disabled = true\n Polyfill.require(%w(Promise fetch)) do\n @create_disabled = true\n fetch(\"actions/ppmc\", args).then {|response|\n content_type = response.headers.get('content-type') || ''\n if response.status == 200 and content_type.include? 'json'\n response.json().then do |json|\n self.update(json)\n end\n else\n alert \"#{response.status} #{response.statusText}\"\n end\n @create_disabled = false\n }.catch {|error|\n alert error\n @create_disabled = false\n }\n end\n end",
"def test_create_palindrome_message\n body = {\n \tdata: {\n \t\ttype: 'messages',\n \t\tattributes: {\n \t\t\tcontent: 'racecar'\n \t\t}\n \t}\n }\n\n post '/messages', body.to_json, 'CONTENT_TYPE' => AppConstants::CONTENT_TYPE\n assert last_response.created?\n assert_equal 'application/vnd.api+json', last_response.headers['Content-Type']\n\n response_body = JSON.parse last_response.body\n data = response_body['data']\n\n assert_equal 'messages', data['type']\n assert_equal body[:data][:attributes][:content], data['attributes']['content']\n assert data['attributes']['is_palindrome']\n assert_equal \"localhost:4567/messages/#{data['id']}\", last_response.headers['Location']\n end",
"def create\n @tarot_bot = TarotBot.new(tarot_bot_params)\n\n if @tarot_bot.save\n render json: { status: :ok }\n else\n render json: { status: :internal_server_error }\n end\n end",
"def handle_post\n make_response(201, {message: 'New resource created'})\nend",
"def create\n # @route = Route.new(params[:route])\n \n waypoints = params[:waypoints]\n creator = params[:creator]\n updated_at = params[:updated_at]\n name = params[:name]\n\n @route = Route.new(waypoints: waypoints, creator: creator, updated_at: updated_at, name: name)\n \n @route.save\n\n render json: @route\n\n # @vote_creator = VoteCreator.new(vote_params)\n # @vote = @vote_creator.vote\n # if @vote_creator.save\n # render json: @vote, status: :created, location: @vote\n # else\n # render json: @vote.errors, status: :unprocessable_entity\n # end\n end",
"def post(*args)\n request(:post, *args)\n end",
"def create\n @observ = Observ.new(observ_params)\n\n respond_to do |format|\n if @observ.save\n format.html { redirect_to @observ, notice: 'Observ was successfully created.' }\n format.json { render action: 'show', status: :created, location: @observ }\n else\n format.html { render action: 'new' }\n format.json { render json: @observ.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\r\n end",
"def post\n end",
"def new\n @verbo = Verbo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verbo }\n end\n end",
"def create\n @server = @site.servers.new(server_params.merge({used_at: (Time.now - 1.day)}))\n\n respond_to do |format|\n if @server.save\n format.html { redirect_to [:admin, @site], notice: 'Server was successfully created.' }\n format.json { render action: 'show', status: :created, location: [:admin, @site] }\n else\n format.html { render action: 'new' }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n if @promotion.save\n render json: @promotion, status: :created, location: @promotion\n else\n render json: @promotion.errors, status: :unprocessable_entity\n end\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def new\n @micorpost = Micorpost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @micorpost }\n end\n end",
"def create\n @mobs_nano = MobsNano.new(params[:mobs_nano])\n\n respond_to do |format|\n if @mobs_nano.save\n flash[:notice] = 'MobsNano was successfully created.'\n format.html { redirect_to mobs_nano_url(@mobs_nano) }\n format.xml { head :created, :location => mobs_nano_url(@mobs_nano) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mobs_nano.errors.to_xml }\n end\n end\n end",
"def download\n page = params[:page].to_i\n\n a = download_conjugation(page)\n @verbs_conj.each do |verb|\n v = Verb.new(:infinitive => verb[:infinitive], :translation => verb[:translation], :group => verb[:group])\n if v.save\n @tenses.each_with_index do |tense, index|\n @forms.each_with_index do |form, index2|\n if(verb[tense][form].strip != '')\n @form = Form.new(:content => verb[tense][form], :temp => index.to_i, :person => index2.to_i,:verb => v)\n @form.save\n end\n end\n end\n end\n end\n File.open(\"public/temp_#{page}.json\",\"w\") do |f|\n f.write(JSON.pretty_generate(@verbs_conj))\n end\n\n @verbs = Verb.all\n respond_to do |format|\n format.html{ render action: 'index'}\n format.json { head :no_content }\n end\n\n end",
"def create\n @monel = Monel.new(params[:monel])\n\n respond_to do |format|\n if @monel.save\n format.html { redirect_to @monel, notice: 'Monel was successfully created.' }\n format.json { render json: @monel, status: :created, location: @monel }\n else\n format.html { render action: \"new\" }\n format.json { render json: @monel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @moon = Moon.new(moon_params)\n\n respond_to do |format|\n if @moon.save\n format.html { redirect_to @moon, notice: 'Moon was successfully created.' }\n format.json { render :show, status: :created, location: @moon }\n else\n format.html { render :new }\n format.json { render json: @moon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n venture = Venture.new(venture_params)\n\n if venture.save \n render json: {venture: venture}, status: :created\n else\n render json: {status: 'Error', message: 'Venture not saved', data: venture.errors}, status: :unprocessable_entity\n end\n end",
"def create\n @motto = Motto.new(motto_params)\n\n respond_to do |format|\n if @motto.save\n format.html { redirect_to @motto, notice: 'Motto was successfully created.' }\n format.json { render :show, status: :created, location: @motto }\n else\n format.html { render :new }\n format.json { render json: @motto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def handle_post()\n make_response(201, \"New resource created\")\nend",
"def create\n @hero = Hero.new(hero_params)\n\n if @hero.save\n render json: @hero, status: :created, location: @hero\n else\n render json: @hero.errors, status: :unprocessable_entity\n end\n end",
"def create\n post = Post.new(comment: post_params[:comment], user: current_user, pokemon: retrieve_pokemon)\n return render_model_errors(post.errors, :unprocessable_entity) unless post.save\n broadcast(post, 'create')\n head :ok\n end",
"def new_releases\n api_call(\"https://api.spotify.com/\",\"/v1/browse/new-releases\")\n end",
"def post(*args)\n request :post, *args\n end",
"def post(action, **args); end",
"def create\n @server = Server.new(params[:server])\n\n respond_to do |format|\n if @server.save\n format.html { redirect_to @server, notice: 'Server was successfully created.' }\n format.json { render json: @server, status: :created, location: @server }\n else\n format.html { render action: \"new\" }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @verbindung = Verbindung.new(params[:verbindung])\n\n respond_to do |format|\n if @verbindung.save\n format.html { redirect_to @verbindung, notice: 'Verbindung was successfully created.' }\n format.json { render json: @verbindung, status: :created, location: @verbindung }\n else\n format.html { render action: \"new\" }\n format.json { render json: @verbindung.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @machine = Machine.new(params[:machine])\n\n respond_to do |format|\n if @machine.save\n format.html { redirect_to @machine, notice: t('controller.successfully_created', :model => t('activerecord.models.machine')) }\n format.json { render json: @machine, status: :created, location: @machine }\n else\n format.html { render action: \"new\" }\n format.json { render json: @machine.errors, status: :unprocessable_entity }\n end\n end\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 @bot_server = BotServer.new(bot_server_params)\n\n respond_to do |format|\n if @bot_server.save\n format.html { redirect_to bot_servers_path, notice: 'Bot server was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bot_server }\n else\n format.html { render action: 'new' }\n format.json { render json: @bot_server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @convo = Convo.new(params[:convo])\n @convo.user_id = current_user.id\n upmerituser(current_user, 10)\n respond_to do |format|\n if @convo.save\n format.html { redirect_to convo_posts_url(:convo_id => @convo.id), notice: 'New conversation created.' }\n format.json { render json: convo_posts_url(:convo_id => @convo.id), status: :created, location: @convo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @convo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @monster = Monster.new(params[:monster])\n\n respond_to do |format|\n if @monster.save\n format.html { redirect_to @monster, notice: 'Monster was successfully created.' }\n format.json { render json: @monster, status: :created, location: @monster }\n else\n format.html { render action: \"new\" }\n format.json { render json: @monster.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 TargetsForm.new(target_params).save\n\n respond_to do |format|\n format.html { redirect_to after_write_path, notice: 'Targets were successfully created.' }\n format.json { render :show, status: :created, location: @target }\n end\n end",
"def create\n response.headers['Content-Type'] = 'text/javascript'\n\n attributes = params.require(:board).permit(:name)\n @board = Board.create!(attributes)\n $redis.publish('boards:create', @board.to_json)\n render nothing: true\n end",
"def create\n \n # Dynamically add last_updated and health\n @mirror = Mirror.new(mirror_params)\n @mirror.health = true\n\n respond_to do |format|\n if @mirror.save\n format.html { redirect_to @mirror, notice: 'Mirror was successfully created.' }\n format.json { render :show, status: :created, location: @mirror }\n else\n format.html { render :new }\n format.json { render json: @mirror.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @monument = Monument.new(monument_params)\n\n respond_to do |format|\n if @monument.save\n format.html { redirect_to @monument, notice: 'Monument was successfully created.' }\n format.json { render :show, status: :created, location: @monument }\n else\n format.html { render :new }\n format.json { render json: @monument.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n version_attributes = params.require(:version).permit(:id, :file, :file_file_name, :version, :uploaded_by, :reason)\n @document = Document.find(params[:document_id])\n @document.versions << Version.create(version_attributes)\n render :json => @document, :include => [:versions]\n end",
"def create\n @mens_team = MensTeam.new(mens_team_params)\n\n respond_to do |format|\n if @mens_team.save\n format.html { redirect_to @mens_team, notice: 'Mens team was successfully created.' }\n format.json { render :show, status: :created, location: @mens_team }\n else\n format.html { render :new }\n format.json { render json: @mens_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(revision, key, options)\n post_path(\n path_to_post(revision),\n options.merge(key: key),\n get_parser(:object, Tinybucket::Model::BuildStatus)\n )\n end",
"def new\n @moretinymobtrail = Moretinymobtrail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @moretinymobtrail }\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 upgrade\n respond_to do |wants|\n wants.json {\n ver = params[:ver]\n soft = SoftVersion.find_new_version_by_ver(ver)\n hash = {}\n if soft and soft.is_a?SoftVersion\n hash[:newversion] = true\n hash[:url] = \"http://#{request.host_with_port}/welcome/download?soft=#{soft.soft_name}&version=#{soft.version}\"\n else\n hash[\"newversion\"] = false\n hash[\"url\"] = \"No new version\"\n end\n render :json => hash.to_json, :layout => false\n }\n end\n\n end",
"def create\n @homeroom = Homeroom.new(homeroom_params)\n\n respond_to do |format|\n if @homeroom.save\n format.html { redirect_to @homeroom, notice: 'Homeroom was successfully created.' }\n format.json { render :show, status: :created, location: @homeroom }\n else\n format.html { render :new }\n format.json { render json: @homeroom.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.618034",
"0.6041709",
"0.5827564",
"0.5759862",
"0.5752757",
"0.57189643",
"0.561509",
"0.5601669",
"0.5597951",
"0.5597951",
"0.5513864",
"0.55125785",
"0.549787",
"0.5477987",
"0.5390466",
"0.5381035",
"0.5328123",
"0.5285386",
"0.5277775",
"0.5256013",
"0.5230142",
"0.5208415",
"0.52054584",
"0.5199694",
"0.5199484",
"0.5192913",
"0.5177138",
"0.5177138",
"0.5177138",
"0.5153624",
"0.5150601",
"0.51467",
"0.5144668",
"0.51441354",
"0.5143517",
"0.51378864",
"0.5131819",
"0.5117707",
"0.51134276",
"0.51051444",
"0.5102796",
"0.50993407",
"0.5097042",
"0.50897676",
"0.5079579",
"0.50786006",
"0.50750345",
"0.5073397",
"0.50731516",
"0.5069537",
"0.50655204",
"0.50607747",
"0.50536686",
"0.5049335",
"0.50485134",
"0.5045575",
"0.5036555",
"0.5035479",
"0.503387",
"0.5019416",
"0.5016713",
"0.50145465",
"0.50106657",
"0.50074583",
"0.5007335",
"0.49925438",
"0.4990757",
"0.49807695",
"0.49780035",
"0.49729222",
"0.4972047",
"0.49719924",
"0.4968548",
"0.4964079",
"0.4962409",
"0.4956782",
"0.49543586",
"0.49531853",
"0.49471205",
"0.49469024",
"0.4946401",
"0.49440932",
"0.49360716",
"0.4932202",
"0.49302685",
"0.4929409",
"0.49263254",
"0.49243557",
"0.49239323",
"0.49204358",
"0.49199265",
"0.4913378",
"0.49120092",
"0.49039048",
"0.49036098",
"0.49016237",
"0.48949248",
"0.4890221",
"0.48890767",
"0.4882803"
] | 0.5224448 | 21 |
PATCH/PUT /movers/1 PATCH/PUT /movers/1.json | def update
@mover = Mover.find(params[:id])
if @mover.update(mover_params)
head :no_content
else
render json: @mover.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def patch!\n request! :patch\n end",
"def update\n @verb = Verb.find(params[:id])\n\n if @verb.update(verb_params)\n head :no_content\n else\n render json: @verb.errors, status: :unprocessable_entity\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 patch(path, **args); end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end",
"def update!(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 put!\n request! :put\n end",
"def update\n respond_to do |format|\n if @verb.update(verb_params)\n format.html { redirect_to @verb, notice: 'Verb was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @verb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def update\n @moose = Moose.find(params[:id])\n\n respond_to do |format|\n if @moose.update_attributes(params[:moose])\n format.html { redirect_to @moose, notice: 'Moose was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @moose.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n head :ok\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @mrv.update(mrv_params)\n format.html { redirect_to @mrv, notice: 'Mrv was successfully updated.' }\n format.json { render :show, status: :ok, location: @mrv }\n else\n format.html { render :edit }\n format.json { render json: @mrv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ver.update(ver_params)\n format.html { redirect_to @ver, notice: 'Ver was successfully updated.' }\n format.json { render :show, status: :ok, location: @ver }\n else\n format.html { render :edit }\n format.json { render json: @ver.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 @api_version = ApiVersion.find(params[:id])\n\n respond_to do |format|\n if @api_version.update_attributes(params[:api_version])\n format.html { redirect_to admin_api_versions_path, flash: {success: t('app.msgs.success_updated', :obj => t('mongoid.models.api_version.one'))} }\n format.json { head :no_content }\n else\n set_tabbed_translation_form_settings('advanced')\n format.html { render action: \"edit\" }\n format.json { render json: @api_version.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def update\n @jm_verse = JmVerse.find(params[:id])\n\n respond_to do |format|\n if @jm_verse.update_attributes(params[:jm_verse])\n format.html { redirect_to @jm_verse, notice: 'Jm verse was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jm_verse.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 options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n if @verbo.update_attributes(params[:verbo])\n format.html { redirect_to @verbo, notice: 'Verbo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @verbo.errors, status: :unprocessable_entity }\n end\n end\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 update\n @momsg = Momsg.find(params[:id])\n\n respond_to do |format|\n if @momsg.update_attributes(params[:momsg])\n format.html { redirect_to @momsg, notice: 'Momsg was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @momsg.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update\n respond_to do |format|\n if @observ.update(observ_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @observ.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @serving = Serving.find(params[:id])\n\n respond_to do |format|\n if @serving.update_attributes(params[:serving])\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n if @metodo.update_attributes(params[:metodo])\n format.html { redirect_to metodos_url }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @metodo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch; end",
"def patch; end",
"def update\n respond_to do |format|\n if @mot_m.update(mot_m_params)\n format.html { redirect_to matches_path, notice: 'Your vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mot_m.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch_kubernetes_version_with_http_info(moid, kubernetes_version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.patch_kubernetes_version ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.patch_kubernetes_version\"\n end\n # verify the required parameter 'kubernetes_version' is set\n if @api_client.config.client_side_validation && kubernetes_version.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_version' when calling KubernetesApi.patch_kubernetes_version\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/Versions/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.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 content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\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(kubernetes_version)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesVersion'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.patch_kubernetes_version\",\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(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#patch_kubernetes_version\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n respond_to_update({thing: @author})\n end",
"def patch(action, **args); end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update\n respond_to do |format|\n if @m1.update(m1_params)\n format.html { redirect_to @m1, notice: 'M1 was successfully updated.' }\n format.json { render :show, status: :ok, location: @m1 }\n else\n format.html { render :edit }\n format.json { render json: @m1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @verma.update(verma_params)\n format.html { redirect_to @verma, notice: 'Verma was successfully updated.' }\n format.json { render :show, status: :ok, location: @verma }\n else\n format.html { render :edit }\n format.json { render json: @verma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n req.patch?\n end",
"def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end",
"def update\n respond_with []\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 UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @server1 = Server1.find(params[:id])\n\n respond_to do |format|\n if @server1.update_attributes(params[:server1])\n format.html { redirect_to @server1, notice: 'Server was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @server1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @vet = Vet.find(params[:id])\n\n respond_to do |format|\n if @vet.update_attributes(params[:vet])\n format.html { redirect_to @vet, notice: 'Vet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mou.update(mou_params)\n format.html { redirect_to @mou, notice: 'Mou was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mou.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @computer.versionless do |doc|\n if doc.update(computer_params)\n format.html { redirect_to computers_path, notice: t('computer.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @computer.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end",
"def cmd_modify argv\n setup argv\n json = @hash['json']\n e = @hash['element']\n response = @api.modify(json, e)\n msg response\n return response\n end",
"def update\n @po = Po.find(params[:id])\n\n respond_to do |format|\n if @po.update_attributes(params[:po])\n format.html { redirect_to @po, notice: 'Po was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @po.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end",
"def update\n respond_to do |format|\n if @version.update(version_params)\n format.html { redirect_to @version, notice: 'Version was successfully updated.' }\n format.json { render :show, status: :ok, location: @version }\n else\n format.html { render :edit }\n format.json { render json: @version.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mote = Mote.find(params[:id])\n respond_to do |format|\n if @mote.update_attributes(params[:mote])\n format.html { redirect_to @mote, notice: 'Mote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @revision = Revision.find(params[:id])\n\n if @revision.update(params[:revision])\n head :no_content\n else\n render json: @revision.errors, status: :unprocessable_entity\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\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 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 http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n respond_to do |format|\n if @server.update_attributes(params[:server])\n @server.send_update\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @requested_cancellation = args[:requested_cancellation] if args.key?(:requested_cancellation)\n @status_message = args[:status_message] if args.key?(:status_message)\n @target = args[:target] if args.key?(:target)\n @validation_result = args[:validation_result] if args.key?(:validation_result)\n @verb = args[:verb] if args.key?(:verb)\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\n respond_to do |format|\n if @test_metum.update(test_metum_params)\n format.html { redirect_to @test_metum, notice: 'Test metum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_metum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_mod\n if params[:title] != nil && params[:content] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully updated\"\n redirect_to questions_path\n end\n end",
"def update(data = :object || :json)\n end",
"def update\n @api_v1_post_vote = PostVote.find(params[:id])\n\n respond_to do |format|\n if @api_v1_post_vote.update_attributes(params[:api_v1_post_vote])\n format.html { redirect_to @api_v1_post_vote, notice: 'Post vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_v1_post_vote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end",
"def update\n @vano = Vano.find(params[:id])\n\n respond_to do |format|\n if @vano.update_attributes(params[:vano])\n format.html { redirect_to @vano, notice: 'Vano was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vano.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @metum.update(metum_params)\n format.html { redirect_to @metum, notice: 'Metum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @metum.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(path)\n output { patch(path, params) }\n end"
] | [
"0.6559324",
"0.6404041",
"0.6288759",
"0.62777406",
"0.615597",
"0.6143237",
"0.60717356",
"0.6019002",
"0.599752",
"0.599752",
"0.5994568",
"0.59854394",
"0.59622806",
"0.5945145",
"0.5945145",
"0.59058744",
"0.58820784",
"0.58739406",
"0.5863574",
"0.5855251",
"0.5854169",
"0.58427083",
"0.58374745",
"0.5830321",
"0.5824327",
"0.5814133",
"0.5814133",
"0.58113486",
"0.5809281",
"0.58005494",
"0.5785842",
"0.57808167",
"0.57726806",
"0.577107",
"0.576494",
"0.5761846",
"0.5754369",
"0.57460284",
"0.57346874",
"0.57346874",
"0.57322884",
"0.572729",
"0.5723722",
"0.5718625",
"0.5712673",
"0.5712673",
"0.5712673",
"0.5712673",
"0.5712673",
"0.5712673",
"0.569146",
"0.5670489",
"0.5669657",
"0.56595874",
"0.56401116",
"0.5630426",
"0.56084263",
"0.5602831",
"0.5601264",
"0.55967057",
"0.55899316",
"0.55857253",
"0.5585202",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.5579434",
"0.55756366",
"0.5574602",
"0.5562798",
"0.55625916",
"0.55572456",
"0.5552423",
"0.5551937",
"0.5551274",
"0.5544019",
"0.5543062",
"0.55296445",
"0.552727",
"0.5520305",
"0.551605",
"0.5510682",
"0.55091715",
"0.5504388",
"0.5504231",
"0.55027384",
"0.55022603",
"0.5502225",
"0.5494069"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.